Skip to content

Commit 18cdd2f

Browse files
vladimirolteankuba-moo
authored andcommitted
net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex
Since the writer-side lock is taken here, we do not need to open an RCU read-side critical section, instead we can use rtnl_dereference() to tell lockdep we are serialized with concurrent writes. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent c8cbe12 commit 18cdd2f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

net/sched/sch_taprio.c

+4-10
Original file line numberDiff line numberDiff line change
@@ -1484,10 +1484,8 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
14841484
}
14851485
INIT_LIST_HEAD(&new_admin->entries);
14861486

1487-
rcu_read_lock();
1488-
oper = rcu_dereference(q->oper_sched);
1489-
admin = rcu_dereference(q->admin_sched);
1490-
rcu_read_unlock();
1487+
oper = rtnl_dereference(q->oper_sched);
1488+
admin = rtnl_dereference(q->admin_sched);
14911489

14921490
/* no changes - no new mqprio settings */
14931491
if (!taprio_mqprio_cmp(dev, mqprio))
@@ -1878,9 +1876,8 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
18781876
struct nlattr *nest, *sched_nest;
18791877
unsigned int i;
18801878

1881-
rcu_read_lock();
1882-
oper = rcu_dereference(q->oper_sched);
1883-
admin = rcu_dereference(q->admin_sched);
1879+
oper = rtnl_dereference(q->oper_sched);
1880+
admin = rtnl_dereference(q->admin_sched);
18841881

18851882
opt.num_tc = netdev_get_num_tc(dev);
18861883
memcpy(opt.prio_tc_map, dev->prio_tc_map, sizeof(opt.prio_tc_map));
@@ -1924,8 +1921,6 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
19241921
nla_nest_end(skb, sched_nest);
19251922

19261923
done:
1927-
rcu_read_unlock();
1928-
19291924
return nla_nest_end(skb, nest);
19301925

19311926
admin_error:
@@ -1935,7 +1930,6 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
19351930
nla_nest_cancel(skb, nest);
19361931

19371932
start_error:
1938-
rcu_read_unlock();
19391933
return -ENOSPC;
19401934
}
19411935

0 commit comments

Comments
 (0)