Bug 8912 - slub memory allocation with GFP_DMA and without __GFP_WAIT can fail even if there is enough memory
Summary: slub memory allocation with GFP_DMA and without __GFP_WAIT can fail even if t...
Status: DEFERRED WILL_FIX_LATER
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Slab Allocator (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Christoph Lameter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-20 08:20 UTC by Matti Linnanvuori
Modified: 2008-02-10 22:19 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.23-rc3
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Matti Linnanvuori 2007-08-20 08:20:30 UTC
Most recent kernel where this bug did not occur: unknown
Distribution: mainline
Hardware Environment: irrelevant
Software Environment: 2.6.23-rc3
Problem Description: slub memory allocation with GFP_DMA and without __GFP_WAIT can fail even if there is enough memory because of trying to acquire a semaphore only once.

Steps to reproduce: try to allocate memory with GFP_DMA and without __GFP_WAIT when some other thread is holding the slub semaphore.

Bug 8790's Attachment 12368 [details]'s patch is buggy because function dma_cache_add_func does not disable interrupts before acquiring the spin lock and function dma_kmalloc_cache can spin forever trying to acquire the spin lock if called from interrupt context.
Comment 1 Christoph Lameter 2007-08-20 11:51:18 UTC
This is restricted only to kmalloc allocations using GFP_ATOMIC and GFP_DMA. It is not a general issue with slabs. And it only can occur the first time a certain size of the dma kmalloc array is used.

As already explained in Bug 8790: GFP_ATOMIC/GFP_DMA kmallocsare retried. Holding the slub_lock is restricted to short time periods during slab creation/removal and cpu hotplug events. Its unlikely to occur and there is no report that indicates that is a problem.

Andi Kleen is in the process of removing all dma slab users from the kernel. We may remove support for dma kmalloc slabs entirely.
Comment 2 Natalie Protasevich 2008-02-07 00:54:40 UTC
What's the status on this, has it caused any problems to you Matti?
Comment 3 Matti Linnanvuori 2008-02-07 03:59:33 UTC
It has not caused any errors to me as far as I know. I found out about the problem through code inspection.
Comment 4 Natalie Protasevich 2008-02-10 22:19:00 UTC
Since the problem is recognized and is being addressed by the redesign that is explained in #1 by Christoph I am changing status to "fix later".

Note You need to log in before you can comment on or make changes to this bug.