* [PATCH net-next] net_sched: sch_sfq: annotate data-races around q->perturb_period
@ 2024-04-30 18:00 Eric Dumazet
2024-05-01 19:47 ` Simon Horman
2024-05-03 2:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-04-30 18:00 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Jamal Hadi Salim, Simon Horman, Cong Wang, Jiri Pirko, netdev,
eric.dumazet, Eric Dumazet
sfq_perturbation() reads q->perturb_period locklessly.
Add annotations to fix potential issues.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/sched/sch_sfq.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index e66f4afb920d28b2fcca1e15634b61ca41ee1bcc..3b9245a3c767a6feed5e06f90459ae896b217c23 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -608,6 +608,7 @@ static void sfq_perturbation(struct timer_list *t)
struct Qdisc *sch = q->sch;
spinlock_t *root_lock;
siphash_key_t nkey;
+ int period;
get_random_bytes(&nkey, sizeof(nkey));
rcu_read_lock();
@@ -618,8 +619,12 @@ static void sfq_perturbation(struct timer_list *t)
sfq_rehash(sch);
spin_unlock(root_lock);
- if (q->perturb_period)
- mod_timer(&q->perturb_timer, jiffies + q->perturb_period);
+ /* q->perturb_period can change under us from
+ * sfq_change() and sfq_destroy().
+ */
+ period = READ_ONCE(q->perturb_period);
+ if (period)
+ mod_timer(&q->perturb_timer, jiffies + period);
rcu_read_unlock();
}
@@ -662,7 +667,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
q->quantum = ctl->quantum;
q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum);
}
- q->perturb_period = ctl->perturb_period * HZ;
+ WRITE_ONCE(q->perturb_period, ctl->perturb_period * HZ);
if (ctl->flows)
q->maxflows = min_t(u32, ctl->flows, SFQ_MAX_FLOWS);
if (ctl->divisor) {
@@ -724,7 +729,7 @@ static void sfq_destroy(struct Qdisc *sch)
struct sfq_sched_data *q = qdisc_priv(sch);
tcf_block_put(q->block);
- q->perturb_period = 0;
+ WRITE_ONCE(q->perturb_period, 0);
del_timer_sync(&q->perturb_timer);
sfq_free(q->ht);
sfq_free(q->slots);
--
2.45.0.rc0.197.gbae5840b3b-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] net_sched: sch_sfq: annotate data-races around q->perturb_period
2024-04-30 18:00 [PATCH net-next] net_sched: sch_sfq: annotate data-races around q->perturb_period Eric Dumazet
@ 2024-05-01 19:47 ` Simon Horman
2024-05-03 2:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-05-01 19:47 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Jamal Hadi Salim,
Cong Wang, Jiri Pirko, netdev, eric.dumazet
On Tue, Apr 30, 2024 at 06:00:15PM +0000, Eric Dumazet wrote:
> sfq_perturbation() reads q->perturb_period locklessly.
> Add annotations to fix potential issues.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net_sched: sch_sfq: annotate data-races around q->perturb_period
2024-04-30 18:00 [PATCH net-next] net_sched: sch_sfq: annotate data-races around q->perturb_period Eric Dumazet
2024-05-01 19:47 ` Simon Horman
@ 2024-05-03 2:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-03 2:10 UTC (permalink / raw)
To: Eric Dumazet
Cc: davem, kuba, pabeni, jhs, horms, xiyou.wangcong, jiri, netdev,
eric.dumazet
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 30 Apr 2024 18:00:15 +0000 you wrote:
> sfq_perturbation() reads q->perturb_period locklessly.
> Add annotations to fix potential issues.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/sched/sch_sfq.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
Here is the summary with links:
- [net-next] net_sched: sch_sfq: annotate data-races around q->perturb_period
https://git.kernel.org/netdev/net-next/c/a17ef9e6c2c1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-03 2:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 18:00 [PATCH net-next] net_sched: sch_sfq: annotate data-races around q->perturb_period Eric Dumazet
2024-05-01 19:47 ` Simon Horman
2024-05-03 2:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).