aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-11-19 03:03:09 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-20 07:14:28 -0500
commit47a1a1d4be2910b13a8e90f75c17e253c39531ff (patch)
treec900f283bd96f0b26236152ada24f9a113f65e2b /net/sched
parentb94c8afcba3ae6584653b98e315446ea83be6ea5 (diff)
pkt_sched: remove unnecessary xchg() in packet classifiers
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>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/cls_api.c3
-rw-r--r--net/sched/cls_basic.c2
-rw-r--r--net/sched/cls_cgroup.c4
-rw-r--r--net/sched/cls_fw.c2
-rw-r--r--net/sched/cls_route.c2
-rw-r--r--net/sched/cls_tcindex.c6
-rw-r--r--net/sched/cls_u32.c11
7 files changed, 12 insertions, 18 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 16e7ac9774e5..173fcc4b050d 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -531,7 +531,8 @@ void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
531 if (src->action) { 531 if (src->action) {
532 struct tc_action *act; 532 struct tc_action *act;
533 tcf_tree_lock(tp); 533 tcf_tree_lock(tp);
534 act = xchg(&dst->action, src->action); 534 act = dst->action;
535 dst->action = src->action;
535 tcf_tree_unlock(tp); 536 tcf_tree_unlock(tp);
536 if (act) 537 if (act)
537 tcf_action_destroy(act, TCA_ACT_UNBIND); 538 tcf_action_destroy(act, TCA_ACT_UNBIND);
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index 956915c217d6..4e2bda854119 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -102,7 +102,7 @@ static inline void basic_delete_filter(struct tcf_proto *tp,
102 102
103static void basic_destroy(struct tcf_proto *tp) 103static void basic_destroy(struct tcf_proto *tp)
104{ 104{
105 struct basic_head *head = (struct basic_head *) xchg(&tp->root, NULL); 105 struct basic_head *head = tp->root;
106 struct basic_filter *f, *n; 106 struct basic_filter *f, *n;
107 107
108 list_for_each_entry_safe(f, n, &head->flist, link) { 108 list_for_each_entry_safe(f, n, &head->flist, link) {
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 53ada2c0e41c..0d68b1975983 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -201,9 +201,7 @@ static int cls_cgroup_change(struct tcf_proto *tp, unsigned long base,
201 201
202static void cls_cgroup_destroy(struct tcf_proto *tp) 202static void cls_cgroup_destroy(struct tcf_proto *tp)
203{ 203{
204 struct cls_cgroup_head *head; 204 struct cls_cgroup_head *head = tp->root;
205
206 head = (struct cls_cgroup_head *)xchg(&tp->root, NULL);
207 205
208 if (head) { 206 if (head) {
209 tcf_exts_destroy(tp, &head->exts); 207 tcf_exts_destroy(tp, &head->exts);
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index b0f90e593af0..6d6e87585fb1 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -148,7 +148,7 @@ fw_delete_filter(struct tcf_proto *tp, struct fw_filter *f)
148 148
149static void fw_destroy(struct tcf_proto *tp) 149static void fw_destroy(struct tcf_proto *tp)
150{ 150{
151 struct fw_head *head = (struct fw_head*)xchg(&tp->root, NULL); 151 struct fw_head *head = tp->root;
152 struct fw_filter *f; 152 struct fw_filter *f;
153 int h; 153 int h;
154 154
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index e3d8455eebc2..bdf1f4172eef 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -260,7 +260,7 @@ route4_delete_filter(struct tcf_proto *tp, struct route4_filter *f)
260 260
261static void route4_destroy(struct tcf_proto *tp) 261static void route4_destroy(struct tcf_proto *tp)
262{ 262{
263 struct route4_head *head = xchg(&tp->root, NULL); 263 struct route4_head *head = tp->root;
264 int h1, h2; 264 int h1, h2;
265 265
266 if (head == NULL) 266 if (head == NULL)
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 7a7bff5ded24..e806f2314b5e 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -13,12 +13,6 @@
13#include <net/netlink.h> 13#include <net/netlink.h>
14#include <net/pkt_cls.h> 14#include <net/pkt_cls.h>
15 15
16
17/*
18 * Not quite sure if we need all the xchgs Alexey uses when accessing things.
19 * Can always add them later ... :)
20 */
21
22/* 16/*
23 * Passing parameters to the root seems to be done more awkwardly than really 17 * Passing parameters to the root seems to be done more awkwardly than really
24 * necessary. At least, u32 doesn't seem to use such dirty hacks. To be 18 * necessary. At least, u32 doesn't seem to use such dirty hacks. To be
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 246f9065ce34..05d178008cbc 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -387,7 +387,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
387static void u32_destroy(struct tcf_proto *tp) 387static void u32_destroy(struct tcf_proto *tp)
388{ 388{
389 struct tc_u_common *tp_c = tp->data; 389 struct tc_u_common *tp_c = tp->data;
390 struct tc_u_hnode *root_ht = xchg(&tp->root, NULL); 390 struct tc_u_hnode *root_ht = tp->root;
391 391
392 WARN_ON(root_ht == NULL); 392 WARN_ON(root_ht == NULL);
393 393
@@ -479,7 +479,7 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
479 err = -EINVAL; 479 err = -EINVAL;
480 if (tb[TCA_U32_LINK]) { 480 if (tb[TCA_U32_LINK]) {
481 u32 handle = nla_get_u32(tb[TCA_U32_LINK]); 481 u32 handle = nla_get_u32(tb[TCA_U32_LINK]);
482 struct tc_u_hnode *ht_down = NULL; 482 struct tc_u_hnode *ht_down = NULL, *ht_old;
483 483
484 if (TC_U32_KEY(handle)) 484 if (TC_U32_KEY(handle))
485 goto errout; 485 goto errout;
@@ -493,11 +493,12 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
493 } 493 }
494 494
495 tcf_tree_lock(tp); 495 tcf_tree_lock(tp);
496 ht_down = xchg(&n->ht_down, ht_down); 496 ht_old = n->ht_down;
497 n->ht_down = ht_down;
497 tcf_tree_unlock(tp); 498 tcf_tree_unlock(tp);
498 499
499 if (ht_down) 500 if (ht_old)
500 ht_down->refcnt--; 501 ht_old->refcnt--;
501 } 502 }
502 if (tb[TCA_U32_CLASSID]) { 503 if (tb[TCA_U32_CLASSID]) {
503 n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]); 504 n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]);