Skip to content

Commit 293c7e2

Browse files
edumazetdavem330
authored andcommitted
net_sched: sch_hhf: implement lockless hhf_dump()
Instead of relying on RTNL, hhf_dump() can use READ_ONCE() annotations, paired with WRITE_ONCE() ones in hhf_change(). Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 49e8ae5 commit 293c7e2

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

net/sched/sch_hhf.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -534,27 +534,31 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt,
534534
sch_tree_lock(sch);
535535

536536
if (tb[TCA_HHF_BACKLOG_LIMIT])
537-
sch->limit = nla_get_u32(tb[TCA_HHF_BACKLOG_LIMIT]);
537+
WRITE_ONCE(sch->limit, nla_get_u32(tb[TCA_HHF_BACKLOG_LIMIT]));
538538

539-
q->quantum = new_quantum;
540-
q->hhf_non_hh_weight = new_hhf_non_hh_weight;
539+
WRITE_ONCE(q->quantum, new_quantum);
540+
WRITE_ONCE(q->hhf_non_hh_weight, new_hhf_non_hh_weight);
541541

542542
if (tb[TCA_HHF_HH_FLOWS_LIMIT])
543-
q->hh_flows_limit = nla_get_u32(tb[TCA_HHF_HH_FLOWS_LIMIT]);
543+
WRITE_ONCE(q->hh_flows_limit,
544+
nla_get_u32(tb[TCA_HHF_HH_FLOWS_LIMIT]));
544545

545546
if (tb[TCA_HHF_RESET_TIMEOUT]) {
546547
u32 us = nla_get_u32(tb[TCA_HHF_RESET_TIMEOUT]);
547548

548-
q->hhf_reset_timeout = usecs_to_jiffies(us);
549+
WRITE_ONCE(q->hhf_reset_timeout,
550+
usecs_to_jiffies(us));
549551
}
550552

551553
if (tb[TCA_HHF_ADMIT_BYTES])
552-
q->hhf_admit_bytes = nla_get_u32(tb[TCA_HHF_ADMIT_BYTES]);
554+
WRITE_ONCE(q->hhf_admit_bytes,
555+
nla_get_u32(tb[TCA_HHF_ADMIT_BYTES]));
553556

554557
if (tb[TCA_HHF_EVICT_TIMEOUT]) {
555558
u32 us = nla_get_u32(tb[TCA_HHF_EVICT_TIMEOUT]);
556559

557-
q->hhf_evict_timeout = usecs_to_jiffies(us);
560+
WRITE_ONCE(q->hhf_evict_timeout,
561+
usecs_to_jiffies(us));
558562
}
559563

560564
qlen = sch->q.qlen;
@@ -657,15 +661,18 @@ static int hhf_dump(struct Qdisc *sch, struct sk_buff *skb)
657661
if (opts == NULL)
658662
goto nla_put_failure;
659663

660-
if (nla_put_u32(skb, TCA_HHF_BACKLOG_LIMIT, sch->limit) ||
661-
nla_put_u32(skb, TCA_HHF_QUANTUM, q->quantum) ||
662-
nla_put_u32(skb, TCA_HHF_HH_FLOWS_LIMIT, q->hh_flows_limit) ||
664+
if (nla_put_u32(skb, TCA_HHF_BACKLOG_LIMIT, READ_ONCE(sch->limit)) ||
665+
nla_put_u32(skb, TCA_HHF_QUANTUM, READ_ONCE(q->quantum)) ||
666+
nla_put_u32(skb, TCA_HHF_HH_FLOWS_LIMIT,
667+
READ_ONCE(q->hh_flows_limit)) ||
663668
nla_put_u32(skb, TCA_HHF_RESET_TIMEOUT,
664-
jiffies_to_usecs(q->hhf_reset_timeout)) ||
665-
nla_put_u32(skb, TCA_HHF_ADMIT_BYTES, q->hhf_admit_bytes) ||
669+
jiffies_to_usecs(READ_ONCE(q->hhf_reset_timeout))) ||
670+
nla_put_u32(skb, TCA_HHF_ADMIT_BYTES,
671+
READ_ONCE(q->hhf_admit_bytes)) ||
666672
nla_put_u32(skb, TCA_HHF_EVICT_TIMEOUT,
667-
jiffies_to_usecs(q->hhf_evict_timeout)) ||
668-
nla_put_u32(skb, TCA_HHF_NON_HH_WEIGHT, q->hhf_non_hh_weight))
673+
jiffies_to_usecs(READ_ONCE(q->hhf_evict_timeout))) ||
674+
nla_put_u32(skb, TCA_HHF_NON_HH_WEIGHT,
675+
READ_ONCE(q->hhf_non_hh_weight)))
669676
goto nla_put_failure;
670677

671678
return nla_nest_end(skb, opts);

0 commit comments

Comments
 (0)