linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make rheap safe for spinlocks
@ 2008-04-14 15:43 Timur Tabi
  2008-04-14 19:58 ` Kumar Gala
  2008-04-17 14:57 ` Kumar Gala
  0 siblings, 2 replies; 4+ messages in thread
From: Timur Tabi @ 2008-04-14 15:43 UTC (permalink / raw)
  To: paulus, linuxppc-dev; +Cc: Timur Tabi

The rheap allocation function, rh_alloc, could call kmalloc with GFP_KERNEL.
This can sleep, which means you couldn't hold a spinlock while called rh_alloc.
Change all kmalloc calls to use GFP_ATOMIC so that it won't sleep.  This is
safe because only small blocks are allocated.

Signed-off-by: Timur Tabi <timur@freescale.com>
---

This patch is for 2.6.26.

 arch/powerpc/lib/rheap.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c
index 22c3b4f..29b2941 100644
--- a/arch/powerpc/lib/rheap.c
+++ b/arch/powerpc/lib/rheap.c
@@ -54,7 +54,7 @@ static int grow(rh_info_t * info, int max_blocks)
 
 	new_blocks = max_blocks - info->max_blocks;
 
-	block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_KERNEL);
+	block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_ATOMIC);
 	if (block == NULL)
 		return -ENOMEM;
 
@@ -258,7 +258,7 @@ rh_info_t *rh_create(unsigned int alignment)
 	if ((alignment & (alignment - 1)) != 0)
 		return ERR_PTR(-EINVAL);
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kmalloc(sizeof(*info), GFP_ATOMIC);
 	if (info == NULL)
 		return ERR_PTR(-ENOMEM);
 
-- 
1.5.3

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

* Re: [PATCH] Make rheap safe for spinlocks
  2008-04-14 15:43 [PATCH] Make rheap safe for spinlocks Timur Tabi
@ 2008-04-14 19:58 ` Kumar Gala
  2008-04-14 20:02   ` Timur Tabi
  2008-04-17 14:57 ` Kumar Gala
  1 sibling, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2008-04-14 19:58 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev, paulus


On Apr 14, 2008, at 10:43 AM, Timur Tabi wrote:
> The rheap allocation function, rh_alloc, could call kmalloc with  
> GFP_KERNEL.
> This can sleep, which means you couldn't hold a spinlock while  
> called rh_alloc.
> Change all kmalloc calls to use GFP_ATOMIC so that it won't sleep.   
> This is
> safe because only small blocks are allocated.
>
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
>
> This patch is for 2.6.26.

Is this need to fix a bug with an existing driver of for a new driver?

- k

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

* Re: [PATCH] Make rheap safe for spinlocks
  2008-04-14 19:58 ` Kumar Gala
@ 2008-04-14 20:02   ` Timur Tabi
  0 siblings, 0 replies; 4+ messages in thread
From: Timur Tabi @ 2008-04-14 20:02 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, paulus

Kumar Gala wrote:

> Is this need to fix a bug with an existing driver of for a new driver?

Both.  The ucc_geth driver calls qe_muram_alloc() with spinlocks held.  The 8610
DIU driver does something similar, but it's targeted for 2.6.26.

I'm hesitant to recommend inclusion in 2.6.25 because I haven't tested the fix
throughly enough to know that it doesn't break something else.  Technically, it
could result in qe_muram_alloc() failing.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: [PATCH] Make rheap safe for spinlocks
  2008-04-14 15:43 [PATCH] Make rheap safe for spinlocks Timur Tabi
  2008-04-14 19:58 ` Kumar Gala
@ 2008-04-17 14:57 ` Kumar Gala
  1 sibling, 0 replies; 4+ messages in thread
From: Kumar Gala @ 2008-04-17 14:57 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev, paulus


On Apr 14, 2008, at 10:43 AM, Timur Tabi wrote:
> The rheap allocation function, rh_alloc, could call kmalloc with  
> GFP_KERNEL.
> This can sleep, which means you couldn't hold a spinlock while  
> called rh_alloc.
> Change all kmalloc calls to use GFP_ATOMIC so that it won't sleep.   
> This is
> safe because only small blocks are allocated.
>
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
>
> This patch is for 2.6.26.
>
> arch/powerpc/lib/rheap.c |    4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)

applied.

- k

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

end of thread, other threads:[~2008-04-17 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-14 15:43 [PATCH] Make rheap safe for spinlocks Timur Tabi
2008-04-14 19:58 ` Kumar Gala
2008-04-14 20:02   ` Timur Tabi
2008-04-17 14:57 ` Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).