[SLUB] __GFP_MOVABLE and SLAB_TEMPORARY support Slabs that are reclaimable fit the definition of the objects in ZONE_MOVABLE. So set __GFP_MOVABLE on them (this only works on platforms where there is no HIGHMEM). Also add the SLAB_TEMPORARY flag for slab caches that allocate objects that have a short lifetime. Slabs with SLAB_TEMPORARY also are allocated with __GFP_MOVABLE. Reclaim on them works by isolating the slab for awhile and waiting for the objects to expire. The skbuff_head_cache is a prime example of such a slab. Add the SLAB_TEMPORARY flag to it. Signed-off-by: Christoph Lameter --- include/linux/slab.h | 1 + mm/slub.c | 8 +++++++- net/core/skbuff.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2007-08-08 20:36:42.000000000 -0700 +++ linux-2.6/mm/slub.c 2007-08-08 20:42:26.000000000 -0700 @@ -1066,6 +1066,11 @@ static struct page *allocate_slab(struct if (s->flags & SLAB_CACHE_DMA) flags |= SLUB_DMA; +#ifndef CONFIG_HIGHMEM + if (s->kick || s->flags & SLAB_TEMPORARY) + flags |= __GFP_MOVABLE; +#endif + if (node == -1) page = alloc_pages(flags, s->order); else @@ -1143,7 +1148,8 @@ static struct page *new_slab(struct kmem if (s->flags & (SLAB_DEBUG_FREE | SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | SLAB_TRACE)) SetSlabDebug(page); - if (s->kick) + + if (s->flags & SLAB_TEMPORARY || s->kick) SetSlabReclaimable(page); out: Index: linux-2.6/include/linux/slab.h =================================================================== --- linux-2.6.orig/include/linux/slab.h 2007-08-08 20:36:02.000000000 -0700 +++ linux-2.6/include/linux/slab.h 2007-08-08 20:37:36.000000000 -0700 @@ -23,6 +23,7 @@ #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */ #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */ #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ +#define SLAB_TEMPORARY 0x00008000UL /* Only volatile objects */ #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ #define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ #define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ Index: linux-2.6/net/core/skbuff.c =================================================================== --- linux-2.6.orig/net/core/skbuff.c 2007-08-08 19:29:19.000000000 -0700 +++ linux-2.6/net/core/skbuff.c 2007-08-08 20:37:36.000000000 -0700 @@ -2020,7 +2020,7 @@ void __init skb_init(void) skbuff_head_cache = kmem_cache_create("skbuff_head_cache", sizeof(struct sk_buff), 0, - SLAB_HWCACHE_ALIGN|SLAB_PANIC, + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_TEMPORARY, NULL); skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache", (2*sizeof(struct sk_buff)) +