Skip to content

Commit c85cedb

Browse files
edumazetdavem330
authored andcommitted
net_sched: sch_skbprio: implement lockless skbprio_dump()
Instead of relying on RTNL, skbprio_dump() can use READ_ONCE() annotation, paired with WRITE_ONCE() one in skbprio_change(). Also add a READ_ONCE(sch->limit) in skbprio_enqueue(). 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 6c00dc4 commit c85cedb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/sched/sch_skbprio.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ static int skbprio_enqueue(struct sk_buff *skb, struct Qdisc *sch,
7979
prio = min(skb->priority, max_priority);
8080

8181
qdisc = &q->qdiscs[prio];
82-
if (sch->q.qlen < sch->limit) {
82+
83+
/* sch->limit can change under us from skbprio_change() */
84+
if (sch->q.qlen < READ_ONCE(sch->limit)) {
8385
__skb_queue_tail(qdisc, skb);
8486
qdisc_qstats_backlog_inc(sch, skb);
8587
q->qstats[prio].backlog += qdisc_pkt_len(skb);
@@ -172,7 +174,7 @@ static int skbprio_change(struct Qdisc *sch, struct nlattr *opt,
172174
if (opt->nla_len != nla_attr_size(sizeof(*ctl)))
173175
return -EINVAL;
174176

175-
sch->limit = ctl->limit;
177+
WRITE_ONCE(sch->limit, ctl->limit);
176178
return 0;
177179
}
178180

@@ -200,7 +202,7 @@ static int skbprio_dump(struct Qdisc *sch, struct sk_buff *skb)
200202
{
201203
struct tc_skbprio_qopt opt;
202204

203-
opt.limit = sch->limit;
205+
opt.limit = READ_ONCE(sch->limit);
204206

205207
if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
206208
return -1;

0 commit comments

Comments
 (0)