Skip to content

Commit

Permalink
[POWERPC] Make rheap safe for spinlocks
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
  • Loading branch information
Timur Tabi authored and Kumar Gala committed Apr 17, 2008
1 parent 998c610 commit 3a2f020
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/powerpc/lib/rheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 3a2f020

Please sign in to comment.