aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2013-12-15 23:15:09 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-18 12:52:07 -0500
commit89819dc01f4c5920783f561597a48d9d75220e9e (patch)
tree2c37980c3b2cc34fece254b4e15b8fb56a24cead /include/net
parent369ba56787d7469c0afda70bb9ff76ad5faaead5 (diff)
net_sched: convert tcf_hashinfo to hlist and use spinlock
So that we don't need to play with singly linked list, and since the code is not on hot path, we can use spinlock instead of rwlock. Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/act_api.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 2b5ec5abfeb3..22418d1a8396 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -9,7 +9,7 @@
9#include <net/pkt_sched.h> 9#include <net/pkt_sched.h>
10 10
11struct tcf_common { 11struct tcf_common {
12 struct tcf_common *tcfc_next; 12 struct hlist_node tcfc_head;
13 u32 tcfc_index; 13 u32 tcfc_index;
14 int tcfc_refcnt; 14 int tcfc_refcnt;
15 int tcfc_bindcnt; 15 int tcfc_bindcnt;
@@ -22,7 +22,7 @@ struct tcf_common {
22 spinlock_t tcfc_lock; 22 spinlock_t tcfc_lock;
23 struct rcu_head tcfc_rcu; 23 struct rcu_head tcfc_rcu;
24}; 24};
25#define tcf_next common.tcfc_next 25#define tcf_head common.tcfc_head
26#define tcf_index common.tcfc_index 26#define tcf_index common.tcfc_index
27#define tcf_refcnt common.tcfc_refcnt 27#define tcf_refcnt common.tcfc_refcnt
28#define tcf_bindcnt common.tcfc_bindcnt 28#define tcf_bindcnt common.tcfc_bindcnt
@@ -36,9 +36,9 @@ struct tcf_common {
36#define tcf_rcu common.tcfc_rcu 36#define tcf_rcu common.tcfc_rcu
37 37
38struct tcf_hashinfo { 38struct tcf_hashinfo {
39 struct tcf_common **htab; 39 struct hlist_head *htab;
40 unsigned int hmask; 40 unsigned int hmask;
41 rwlock_t lock; 41 spinlock_t lock;
42}; 42};
43 43
44static inline unsigned int tcf_hash(u32 index, unsigned int hmask) 44static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
@@ -48,12 +48,16 @@ static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
48 48
49static inline int tcf_hashinfo_init(struct tcf_hashinfo *hf, unsigned int mask) 49static inline int tcf_hashinfo_init(struct tcf_hashinfo *hf, unsigned int mask)
50{ 50{
51 rwlock_init(&hf->lock); 51 int i;
52
53 spin_lock_init(&hf->lock);
52 hf->hmask = mask; 54 hf->hmask = mask;
53 hf->htab = kzalloc((mask + 1) * sizeof(struct tcf_common *), 55 hf->htab = kzalloc((mask + 1) * sizeof(struct hlist_head),
54 GFP_KERNEL); 56 GFP_KERNEL);
55 if (!hf->htab) 57 if (!hf->htab)
56 return -ENOMEM; 58 return -ENOMEM;
59 for (i = 0; i < mask + 1; i++)
60 INIT_HLIST_HEAD(&hf->htab[i]);
57 return 0; 61 return 0;
58} 62}
59 63