net/sched: Replace rcu_swap_protected() with rcu_replace_pointer()
authorPaul E. McKenney <paulmck@kernel.org>
Mon, 23 Sep 2019 23:09:18 +0000 (16:09 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 30 Oct 2019 15:45:48 +0000 (08:45 -0700)
This commit replaces the use of rcu_swap_protected() with the more
intuitively appealing rcu_replace_pointer() as a step towards removing
rcu_swap_protected().

Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@mail.gmail.com/
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
[ paulmck: From rcu_replace() to rcu_replace_pointer() per Ingo Molnar. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
12 files changed:
net/sched/act_api.c
net/sched/act_csum.c
net/sched/act_ct.c
net/sched/act_ctinfo.c
net/sched/act_ife.c
net/sched/act_mirred.c
net/sched/act_mpls.c
net/sched/act_police.c
net/sched/act_sample.c
net/sched/act_skbedit.c
net/sched/act_tunnel_key.c
net/sched/act_vlan.c

index 2558f00f6b3eda64a87f63c32592c15b7a0a2bfe..3d51573d86c976d5b3d955bf1dfcd968fb0e0df5 100644 (file)
@@ -88,7 +88,7 @@ struct tcf_chain *tcf_action_set_ctrlact(struct tc_action *a, int action,
                                         struct tcf_chain *goto_chain)
 {
        a->tcfa_action = action;
-       rcu_swap_protected(a->goto_chain, goto_chain, 1);
+       goto_chain = rcu_replace_pointer(a->goto_chain, goto_chain, 1);
        return goto_chain;
 }
 EXPORT_SYMBOL(tcf_action_set_ctrlact);
index d3cfad88dc3a93368449f2aa179f94c64b7a903c..87dddbaa203135842269235bd713ee10b09c6b2a 100644 (file)
@@ -101,8 +101,8 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
 
        spin_lock_bh(&p->tcf_lock);
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(p->params, params_new,
-                          lockdep_is_held(&p->tcf_lock));
+       params_new = rcu_replace_pointer(p->params, params_new,
+                                        lockdep_is_held(&p->tcf_lock));
        spin_unlock_bh(&p->tcf_lock);
 
        if (goto_ch)
index fcc46025e79086bffb21b4c9db451d92003872eb..2d5ab233349eafd8486540f9a27b67db0b1d17b7 100644 (file)
@@ -722,7 +722,8 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,
 
        spin_lock_bh(&c->tcf_lock);
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(c->params, params, lockdep_is_held(&c->tcf_lock));
+       params = rcu_replace_pointer(c->params, params,
+                                    lockdep_is_held(&c->tcf_lock));
        spin_unlock_bh(&c->tcf_lock);
 
        if (goto_ch)
index 0dbcfd1dca7bf354a51892adeed5a5fc3b4889fd..c599818978461111ad81fc8b8aefde87cac87ff8 100644 (file)
@@ -257,8 +257,8 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
 
        spin_lock_bh(&ci->tcf_lock);
        goto_ch = tcf_action_set_ctrlact(*a, actparm->action, goto_ch);
-       rcu_swap_protected(ci->params, cp_new,
-                          lockdep_is_held(&ci->tcf_lock));
+       cp_new = rcu_replace_pointer(ci->params, cp_new,
+                                    lockdep_is_held(&ci->tcf_lock));
        spin_unlock_bh(&ci->tcf_lock);
 
        if (goto_ch)
index 3a31e241c6472b42d37414f68ba18c16bd1a9f19..2ea2e164e3bd110e05d0ae34e514b928c5cb29cd 100644 (file)
@@ -594,7 +594,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
                spin_lock_bh(&ife->tcf_lock);
        /* protected by tcf_lock when modifying existing action */
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(ife->params, p, 1);
+       p = rcu_replace_pointer(ife->params, p, 1);
 
        if (exists)
                spin_unlock_bh(&ife->tcf_lock);
index 9ce073a05414ae3289190446cb6cee057588f07d..0c2f737b72f2fba1f1ce6bf5502c36535789cb81 100644 (file)
@@ -178,8 +178,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
                        goto put_chain;
                }
                mac_header_xmit = dev_is_mac_header_xmit(dev);
-               rcu_swap_protected(m->tcfm_dev, dev,
-                                  lockdep_is_held(&m->tcf_lock));
+               dev = rcu_replace_pointer(m->tcfm_dev, dev,
+                                         lockdep_is_held(&m->tcf_lock));
                if (dev)
                        dev_put(dev);
                m->tcfm_mac_header_xmit = mac_header_xmit;
index e168df0e008acef81e579900602138b5da683111..5b3031c3e81d727f88a0d29fcb27968777dccb6d 100644 (file)
@@ -258,7 +258,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,
 
        spin_lock_bh(&m->tcf_lock);
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(m->mpls_p, p, lockdep_is_held(&m->tcf_lock));
+       p = rcu_replace_pointer(m->mpls_p, p, lockdep_is_held(&m->tcf_lock));
        spin_unlock_bh(&m->tcf_lock);
 
        if (goto_ch)
index 89c04c52af3dab3d7fc1fbd1d08a3f112c33ac72..caa91cf8791ba4e75af20a128f76f99c6522b1c3 100644 (file)
@@ -191,9 +191,9 @@ static int tcf_police_init(struct net *net, struct nlattr *nla,
                police->tcfp_ptoks = new->tcfp_mtu_ptoks;
        spin_unlock_bh(&police->tcfp_lock);
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(police->params,
-                          new,
-                          lockdep_is_held(&police->tcf_lock));
+       new = rcu_replace_pointer(police->params,
+                                 new,
+                                 lockdep_is_held(&police->tcf_lock));
        spin_unlock_bh(&police->tcf_lock);
 
        if (goto_ch)
index 514456a0b9a83204142e3422dc5d8e7469343eb4..4deeaf268693c9981f1a489e3ba612072e04eab0 100644 (file)
@@ -102,8 +102,8 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
        s->rate = rate;
        s->psample_group_num = psample_group_num;
-       rcu_swap_protected(s->psample_group, psample_group,
-                          lockdep_is_held(&s->tcf_lock));
+       psample_group = rcu_replace_pointer(s->psample_group, psample_group,
+                                           lockdep_is_held(&s->tcf_lock));
 
        if (tb[TCA_SAMPLE_TRUNC_SIZE]) {
                s->truncate = true;
index 6a8d3337c577493dc9dcc2b70e7946abbc165cfa..c38cc394576324fc363f9f184b72a58c9e863a2f 100644 (file)
@@ -206,8 +206,8 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
 
        spin_lock_bh(&d->tcf_lock);
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(d->params, params_new,
-                          lockdep_is_held(&d->tcf_lock));
+       params_new = rcu_replace_pointer(d->params, params_new,
+                                        lockdep_is_held(&d->tcf_lock));
        spin_unlock_bh(&d->tcf_lock);
        if (params_new)
                kfree_rcu(params_new, rcu);
index 2f83a79f76aae656fcea6f2d4a35d45c22e2a501..20d7ca49f7cb828b233ca550a9744ca6e2952df7 100644 (file)
@@ -381,8 +381,8 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
 
        spin_lock_bh(&t->tcf_lock);
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(t->params, params_new,
-                          lockdep_is_held(&t->tcf_lock));
+       params_new = rcu_replace_pointer(t->params, params_new,
+                                        lockdep_is_held(&t->tcf_lock));
        spin_unlock_bh(&t->tcf_lock);
        tunnel_key_release_params(params_new);
        if (goto_ch)
index 08aaf719a70fbbc1577705712f2cf6d3d5b0202e..7aca1f0ecc21e57291a9e4b1158de38d97f4fa2a 100644 (file)
@@ -220,7 +220,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
 
        spin_lock_bh(&v->tcf_lock);
        goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
-       rcu_swap_protected(v->vlan_p, p, lockdep_is_held(&v->tcf_lock));
+       p = rcu_replace_pointer(v->vlan_p, p, lockdep_is_held(&v->tcf_lock));
        spin_unlock_bh(&v->tcf_lock);
 
        if (goto_ch)