Index: linux-2.6.21-rc1/mm/slub.c =================================================================== --- linux-2.6.21-rc1.orig/mm/slub.c 2007-02-23 12:00:19.000000000 -0800 +++ linux-2.6.21-rc1/mm/slub.c 2007-02-23 12:00:24.000000000 -0800 @@ -439,10 +439,14 @@ { struct page *page; + BUG_ON(flags & ~(GFP_DMA | GFP_LEVEL_MASK | __GFP_NO_GROW)); + if (flags & __GFP_NO_GROW) + return NULL; + if (flags & __GFP_WAIT) local_irq_enable(); - page = allocate_slab(s, flags, node); + page = allocate_slab(s, flags & GFP_LEVEL_MASK, node); if (!page) goto out; @@ -1008,7 +1012,7 @@ spin_lock_irqsave(&s->list_lock, flags); list_for_each_entry_safe(page, h, list, lru) if (!page->inuse) { - list_del(&s->partial); + list_del(&page->lru); discard_slab(s, page); } else slabs_inuse++; @@ -1138,39 +1142,42 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags) { int index = kmalloc_index(size) - KMALLOC_SHIFT_LOW; - struct kmem_cache *s; - struct kmem_cache *x; - size_t realsize; - BUG_ON(size < 0); + BUG_ON(size <= 0); - if (!(flags & SLUB_DMA)) - return &kmalloc_caches[index]; - - s = kmalloc_caches_dma[index]; - if (s) - return s; +#ifdef CONFIG_ZONE_DMA + if ((flags & SLUB_DMA)) { + struct kmem_cache *s; + struct kmem_cache *x; + size_t realsize; + + s = kmalloc_caches_dma[index]; + if (s) + return s; - /* Dynamically create dma cache */ - x = kmalloc(sizeof(struct kmem_cache), flags & ~(__GFP_DMA)); + /* Dynamically create dma cache */ + x = kmalloc(sizeof(struct kmem_cache), flags & ~(__GFP_DMA)); - if (!x) - panic("Unable to allocate memory for dma cache\n"); + if (!x) + panic("Unable to allocate memory for dma cache\n"); #ifdef KMALLOC_EXTRA - if (index <= KMALLOC_SHIFT_HIGH - KMALLOC_SHIFT_LOW) + if (index <= KMALLOC_SHIFT_HIGH - KMALLOC_SHIFT_LOW) #endif - realsize = 1 << index; + realsize = 1 << index; #ifdef KMALLOC_EXTRA - else if (index == KMALLOC_EXTRAS) - realsize = 96; - else - realsize = 192; + else if (index == KMALLOC_EXTRAS) + realsize = 96; + else + realsize = 192; #endif - s = create_kmalloc_cache(x, "kmalloc_dma", realsize); - kmalloc_caches_dma[index] = s; - return s; + s = create_kmalloc_cache(x, "kmalloc_dma", realsize); + kmalloc_caches_dma[index] = s; + return s; + } +#endif + return &kmalloc_caches[index]; } void *__kmalloc(size_t size, gfp_t flags) @@ -1607,4 +1614,5 @@ return 0; } __initcall(cpucache_init); +#endif