Re: [patch 12/23] SLUB: Trigger defragmentation from memory reclaim

From: Johannes Weiner
Date: Wed Nov 07 2007 - 04:30:01 EST


Hi Christoph,

On Tue, Nov 06, 2007 at 05:11:42PM -0800, Christoph Lameter wrote:
> Index: linux-2.6/include/linux/slab.h
> ===================================================================
> --- linux-2.6.orig/include/linux/slab.h 2007-11-06 12:37:51.000000000 -0800
> +++ linux-2.6/include/linux/slab.h 2007-11-06 12:53:40.000000000 -0800
> @@ -63,6 +63,7 @@ void kmem_cache_free(struct kmem_cache *
> unsigned int kmem_cache_size(struct kmem_cache *);
> const char *kmem_cache_name(struct kmem_cache *);
> int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
> +int kmem_cache_defrag(int node);

The definition in slab.c always returns 0. Wouldn't a static inline
function in the header be better?


> * Returns the number of slab objects which we shrunk.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> */
> unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
> - unsigned long lru_pages)
> + unsigned long lru_pages, struct zone *zone)
> {
> struct shrinker *shrinker;
> unsigned long ret = 0;
> @@ -210,6 +218,8 @@ unsigned long shrink_slab(unsigned long
> shrinker->nr += total_scan;
> }
> up_read(&shrinker_rwsem);
> + if (gfp_mask & __GFP_FS)
> + kmem_cache_defrag(zone ? zone_to_nid(zone) : -1);
> return ret;
> }

What about the objects that kmem_cache_defrag() releases? Shouldn't
they be counted too?

ret += kmem_cache_defrag(...)

Or am I overseeing something here?

Hannes
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/