]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
pkt_sched: remove unnecessary xchg() in packet classifiers
authorPatrick McHardy <kaber@trash.net>
Wed, 19 Nov 2008 08:03:09 +0000 (08:03 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Nov 2008 12:14:28 +0000 (04:14 -0800)
The use of xchg() hasn't been necessary since 2.2.something when proper
locking was added to packet schedulers. In the case of classifiers they
mostly weren't even necessary before that since they're mainly used
to assign a NULL pointer to the filter root in the ->destroy path;
the root is destroyed immediately after that.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_api.c
net/sched/cls_basic.c
net/sched/cls_cgroup.c
net/sched/cls_fw.c
net/sched/cls_route.c
net/sched/cls_tcindex.c
net/sched/cls_u32.c

index 16e7ac9774e5aeab547d6aee1fabcab56efc7480..173fcc4b050ddac8b4470c9616216974312bc121 100644 (file)
@@ -531,7 +531,8 @@ void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
        if (src->action) {
                struct tc_action *act;
                tcf_tree_lock(tp);
-               act = xchg(&dst->action, src->action);
+               act = dst->action;
+               dst->action = src->action;
                tcf_tree_unlock(tp);
                if (act)
                        tcf_action_destroy(act, TCA_ACT_UNBIND);
index 956915c217d6dbc8599b3fa8248eedb8914160a3..4e2bda854119bf87391dc89a3cda8ce44810c5a0 100644 (file)
@@ -102,7 +102,7 @@ static inline void basic_delete_filter(struct tcf_proto *tp,
 
 static void basic_destroy(struct tcf_proto *tp)
 {
-       struct basic_head *head = (struct basic_head *) xchg(&tp->root, NULL);
+       struct basic_head *head = tp->root;
        struct basic_filter *f, *n;
 
        list_for_each_entry_safe(f, n, &head->flist, link) {
index 53ada2c0e41ce2ccc2debf5e1e1687ccb5aedd24..0d68b1975983a323775b5c4deef4f2ae1ae8ae5d 100644 (file)
@@ -201,9 +201,7 @@ static int cls_cgroup_change(struct tcf_proto *tp, unsigned long base,
 
 static void cls_cgroup_destroy(struct tcf_proto *tp)
 {
-       struct cls_cgroup_head *head;
-
-       head = (struct cls_cgroup_head *)xchg(&tp->root, NULL);
+       struct cls_cgroup_head *head = tp->root;
 
        if (head) {
                tcf_exts_destroy(tp, &head->exts);
index b0f90e593af0d510b6e61db352a8db9602830311..6d6e87585fb1a5028285210cd404ebc67547daa3 100644 (file)
@@ -148,7 +148,7 @@ fw_delete_filter(struct tcf_proto *tp, struct fw_filter *f)
 
 static void fw_destroy(struct tcf_proto *tp)
 {
-       struct fw_head *head = (struct fw_head*)xchg(&tp->root, NULL);
+       struct fw_head *head = tp->root;
        struct fw_filter *f;
        int h;
 
index e3d8455eebc29c32d37a5b2c943c07de1573b0e1..bdf1f4172eef5a7d13783e4192babb10ff526726 100644 (file)
@@ -260,7 +260,7 @@ route4_delete_filter(struct tcf_proto *tp, struct route4_filter *f)
 
 static void route4_destroy(struct tcf_proto *tp)
 {
-       struct route4_head *head = xchg(&tp->root, NULL);
+       struct route4_head *head = tp->root;
        int h1, h2;
 
        if (head == NULL)
index 7a7bff5ded2487801e3c34941c1e12b8d77926fc..e806f2314b5e24281dd4bfbe3f442d1c1ee51d41 100644 (file)
 #include <net/netlink.h>
 #include <net/pkt_cls.h>
 
-
-/*
- * Not quite sure if we need all the xchgs Alexey uses when accessing things.
- * Can always add them later ... :)
- */
-
 /*
  * Passing parameters to the root seems to be done more awkwardly than really
  * necessary. At least, u32 doesn't seem to use such dirty hacks. To be
index 246f9065ce34b0ad8f7b176807dea7d50221b087..05d178008cbc9046d682f2bc2dbc01ce1e85737b 100644 (file)
@@ -387,7 +387,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
 static void u32_destroy(struct tcf_proto *tp)
 {
        struct tc_u_common *tp_c = tp->data;
-       struct tc_u_hnode *root_ht = xchg(&tp->root, NULL);
+       struct tc_u_hnode *root_ht = tp->root;
 
        WARN_ON(root_ht == NULL);
 
@@ -479,7 +479,7 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
        err = -EINVAL;
        if (tb[TCA_U32_LINK]) {
                u32 handle = nla_get_u32(tb[TCA_U32_LINK]);
-               struct tc_u_hnode *ht_down = NULL;
+               struct tc_u_hnode *ht_down = NULL, *ht_old;
 
                if (TC_U32_KEY(handle))
                        goto errout;
@@ -493,11 +493,12 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
                }
 
                tcf_tree_lock(tp);
-               ht_down = xchg(&n->ht_down, ht_down);
+               ht_old = n->ht_down;
+               n->ht_down = ht_down;
                tcf_tree_unlock(tp);
 
-               if (ht_down)
-                       ht_down->refcnt--;
+               if (ht_old)
+                       ht_old->refcnt--;
        }
        if (tb[TCA_U32_CLASSID]) {
                n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]);