Index: linux-2.6.20-mm2/mm/slub.c =================================================================== --- linux-2.6.20-mm2.orig/mm/slub.c 2007-02-22 11:00:28.000000000 -0800 +++ linux-2.6.20-mm2/mm/slub.c 2007-02-24 16:19:08.000000000 -0800 @@ -439,10 +439,14 @@ static struct page *new_slab(struct kmem { 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 @@ static int free_list(struct kmem_cache * 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 *create_kmalloc 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 @@ static int __init cpucache_init(void) return 0; } __initcall(cpucache_init); +#endif Index: linux-2.6.20-mm2/include/linux/slub_def.h =================================================================== --- linux-2.6.20-mm2.orig/include/linux/slub_def.h 2007-02-23 06:14:48.000000000 -0800 +++ linux-2.6.20-mm2/include/linux/slub_def.h 2007-02-24 16:19:08.000000000 -0800 @@ -156,4 +156,14 @@ static inline void *kmalloc_node(size_t } #endif +/* + * Handle static declarations of caches + */ +int kmem_cache_open(struct kmem_cache *s, + const char *name, size_t size, + size_t align, unsigned long flags, + void (*ctor)(void *, struct kmem_cache *, unsigned long), + void (*dtor)(void *, struct kmem_cache *, unsigned long)); +int kmem_cache_close(struct kmem_cache *s); + #endif /* _LINUX_SLUB_DEF_H */