diff options
author | Ying Xue <ying.xue@windriver.com> | 2014-08-29 05:09:07 -0400 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2014-08-29 05:40:03 -0400 |
commit | 0244790c8ad2408dfb313e5c886e6e5a808ea946 (patch) | |
tree | 8d1868c1455d876f535b2a82ac8dee0fc2690dde | |
parent | a3d1214688d5259a200414def4d38f1e4531febd (diff) |
xfrm: remove useless hash_resize_mutex locks
In xfrm_state.c, hash_resize_mutex is defined as a local variable
and only used in xfrm_hash_resize() which is declared as a work
handler of xfrm.state_hash_work. But when the xfrm.state_hash_work
work is put in the global workqueue(system_wq) with schedule_work(),
the work will be really inserted in the global workqueue if it was
not already queued, otherwise, it is still left in the same position
on the the global workqueue. This means the xfrm_hash_resize() work
handler is only executed once at any time no matter how many times
its work is scheduled, that is, xfrm_hash_resize() is not called
concurrently at all, so hash_resize_mutex is redundant for us.
Cc: Christophe Gouault <christophe.gouault@6wind.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
-rw-r--r-- | net/xfrm/xfrm_state.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 0ab54134bb40..de971b6d38c5 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -97,8 +97,6 @@ static unsigned long xfrm_hash_new_size(unsigned int state_hmask) | |||
97 | return ((state_hmask + 1) << 1) * sizeof(struct hlist_head); | 97 | return ((state_hmask + 1) << 1) * sizeof(struct hlist_head); |
98 | } | 98 | } |
99 | 99 | ||
100 | static DEFINE_MUTEX(hash_resize_mutex); | ||
101 | |||
102 | static void xfrm_hash_resize(struct work_struct *work) | 100 | static void xfrm_hash_resize(struct work_struct *work) |
103 | { | 101 | { |
104 | struct net *net = container_of(work, struct net, xfrm.state_hash_work); | 102 | struct net *net = container_of(work, struct net, xfrm.state_hash_work); |
@@ -107,22 +105,20 @@ static void xfrm_hash_resize(struct work_struct *work) | |||
107 | unsigned int nhashmask, ohashmask; | 105 | unsigned int nhashmask, ohashmask; |
108 | int i; | 106 | int i; |
109 | 107 | ||
110 | mutex_lock(&hash_resize_mutex); | ||
111 | |||
112 | nsize = xfrm_hash_new_size(net->xfrm.state_hmask); | 108 | nsize = xfrm_hash_new_size(net->xfrm.state_hmask); |
113 | ndst = xfrm_hash_alloc(nsize); | 109 | ndst = xfrm_hash_alloc(nsize); |
114 | if (!ndst) | 110 | if (!ndst) |
115 | goto out_unlock; | 111 | return; |
116 | nsrc = xfrm_hash_alloc(nsize); | 112 | nsrc = xfrm_hash_alloc(nsize); |
117 | if (!nsrc) { | 113 | if (!nsrc) { |
118 | xfrm_hash_free(ndst, nsize); | 114 | xfrm_hash_free(ndst, nsize); |
119 | goto out_unlock; | 115 | return; |
120 | } | 116 | } |
121 | nspi = xfrm_hash_alloc(nsize); | 117 | nspi = xfrm_hash_alloc(nsize); |
122 | if (!nspi) { | 118 | if (!nspi) { |
123 | xfrm_hash_free(ndst, nsize); | 119 | xfrm_hash_free(ndst, nsize); |
124 | xfrm_hash_free(nsrc, nsize); | 120 | xfrm_hash_free(nsrc, nsize); |
125 | goto out_unlock; | 121 | return; |
126 | } | 122 | } |
127 | 123 | ||
128 | spin_lock_bh(&net->xfrm.xfrm_state_lock); | 124 | spin_lock_bh(&net->xfrm.xfrm_state_lock); |
@@ -148,9 +144,6 @@ static void xfrm_hash_resize(struct work_struct *work) | |||
148 | xfrm_hash_free(odst, osize); | 144 | xfrm_hash_free(odst, osize); |
149 | xfrm_hash_free(osrc, osize); | 145 | xfrm_hash_free(osrc, osize); |
150 | xfrm_hash_free(ospi, osize); | 146 | xfrm_hash_free(ospi, osize); |
151 | |||
152 | out_unlock: | ||
153 | mutex_unlock(&hash_resize_mutex); | ||
154 | } | 147 | } |
155 | 148 | ||
156 | static DEFINE_SPINLOCK(xfrm_state_afinfo_lock); | 149 | static DEFINE_SPINLOCK(xfrm_state_afinfo_lock); |