mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] staging: zcache: fix possible sleep under lock
@ 2011-08-22 19:30 Seth Jennings
  2011-08-23 15:18 ` Dan Magenheimer
  0 siblings, 1 reply; 2+ messages in thread
From: Seth Jennings @ 2011-08-22 19:30 UTC (permalink / raw)
  To: gregkh; +Cc: ascardo, dan.magenheimer, sjenning, rdunlap, devel, linux-kernel

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

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/staging/zcache/zcache-main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 855a5bb..cdf0128 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH v2] staging: zcache: fix possible sleep under lock
  2011-08-22 19:30 [PATCH v2] staging: zcache: fix possible sleep under lock Seth Jennings
@ 2011-08-23 15:18 ` Dan Magenheimer
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Magenheimer @ 2011-08-23 15:18 UTC (permalink / raw)
  To: Seth Jennings, gregkh; +Cc: ascardo, rdunlap, devel, linux-kernel

> From: Seth Jennings [mailto:sjenning@linux.vnet.ibm.com]
> Sent: Monday, August 22, 2011 1:31 PM
> To: gregkh@suse.de
> Cc: ascardo@holoscopio.com; Dan Magenheimer; sjenning@linux.vnet.ibm.com; rdunlap@xenotime.net;
> devel@driverdev.osuosl.org; linux-kernel@vger.kernel.org
> Subject: [PATCH v2] 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
> 
> Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>

Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>

> ---
>  drivers/staging/zcache/zcache-main.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
> index 855a5bb..cdf0128 100644
> --- a/drivers/staging/zcache/zcache-main.c
> +++ b/drivers/staging/zcache/zcache-main.c
> @@ -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
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-23 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-22 19:30 [PATCH v2] staging: zcache: fix possible sleep under lock Seth Jennings
2011-08-23 15:18 ` Dan Magenheimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®