staging: zcache: fix possible sleep under lock
PATCH v2 1/1 staging: zcache: fix possible sleep under lock
zcache_new_pool() calls kmalloc() with GFP_KERNEL which has __GFP_WAIT set. However, zcache_new_pool() gets called on a stack that holds the swap_lock spinlock, leading to a possible sleep-with-lock situation. The lock is obtained in enable_swap_info().
The patch replaces GFP_KERNEL with GFP_ATOMIC.
v2: replace with GFP_ATOMIC, not GFP_IOFS
--- drivers/staging/zcache/zcache-main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/zcache/zcache-main.c +1 -1
@@ -1668,7 +1668,7 @@ static int zcache_new_pool(uint16_t cli_id, uint32_t flags)if (cli ==NULL ) goto out;atomic_inc (&cli->refcount); - pool =kmalloc (sizeof (struct tmem_pool ),GFP_KERNEL ); + pool =kmalloc (sizeof (struct tmem_pool ),GFP_ATOMIC );if (pool ==NULL ) {pr_info ("zcache: pool creation failed: out of memory\n" ); goto out;
Signature · 1 line
1.7.4.1
Quoted 13 lines
From: Seth Jennings [mailto:[email protected]]
Sent: Monday, August 22, 2011 1:31 PM
To: [email protected]
Cc: [email protected]; Dan Magenheimer; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2] staging: zcache: fix possible sleep under lock
zcache_new_pool()callskmalloc()withGFP_KERNELwhich has__GFP_WAITset. However,zcache_new_pool()gets called on a stack that holds theswap_lockspinlock, leading to a possible sleep-with-lock situation. The lock is obtained inenable_swap_info().
Quoted 5 lines
The patch replaces
GFP_KERNELwithGFP_ATOMIC.v2: replace with
GFP_ATOMIC, notGFP_IOFSSigned-off-by Seth Jennings <[email protected]>
Quoted 20 lines
--- drivers/staging/zcache/zcache-main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/staging/zcache/zcache-main.c +1
-2@@ -1668,7 +1668,7 @@ static int zcache_new_pool(uint16_t cli_id, uint32_t flags)if (cli ==NULL ) goto out;atomic_inc (&cli->refcount); - pool =kmalloc (sizeof (struct tmem_pool ),GFP_KERNEL ); + pool =kmalloc (sizeof (struct tmem_pool ),GFP_ATOMIC );if (pool ==NULL ) {pr_info ("zcache: pool creation failed: out of memory\n" ); goto out; --1.7.4.1