Skip to content

Commit 0244790

Browse files
ying-xueklassert
authored andcommitted
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>
1 parent a3d1214 commit 0244790

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎net/xfrm/xfrm_state.c‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ static unsigned long xfrm_hash_new_size(unsigned int state_hmask)
9797
return ((state_hmask + 1) << 1) * sizeof(struct hlist_head);
9898
}
9999

100-
static DEFINE_MUTEX(hash_resize_mutex);
101-
102100
static void xfrm_hash_resize(struct work_struct *work)
103101
{
104102
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)
107105
unsigned int nhashmask, ohashmask;
108106
int i;
109107

110-
mutex_lock(&hash_resize_mutex);
111-
112108
nsize = xfrm_hash_new_size(net->xfrm.state_hmask);
113109
ndst = xfrm_hash_alloc(nsize);
114110
if (!ndst)
115-
goto out_unlock;
111+
return;
116112
nsrc = xfrm_hash_alloc(nsize);
117113
if (!nsrc) {
118114
xfrm_hash_free(ndst, nsize);
119-
goto out_unlock;
115+
return;
120116
}
121117
nspi = xfrm_hash_alloc(nsize);
122118
if (!nspi) {
123119
xfrm_hash_free(ndst, nsize);
124120
xfrm_hash_free(nsrc, nsize);
125-
goto out_unlock;
121+
return;
126122
}
127123

128124
spin_lock_bh(&net->xfrm.xfrm_state_lock);
@@ -148,9 +144,6 @@ static void xfrm_hash_resize(struct work_struct *work)
148144
xfrm_hash_free(odst, osize);
149145
xfrm_hash_free(osrc, osize);
150146
xfrm_hash_free(ospi, osize);
151-
152-
out_unlock:
153-
mutex_unlock(&hash_resize_mutex);
154147
}
155148

156149
static DEFINE_SPINLOCK(xfrm_state_afinfo_lock);

0 commit comments

Comments
 (0)