Slab defrag: get and kick kmem_cache_ops methods Add the two methods and add the display of the methods via the proc interface. Signed-off-by: Christoph Lameter --- include/linux/slab.h | 31 +++++++++++++++++++++++++++++++ mm/slub.c | 14 ++++++++++++++ 2 files changed, 45 insertions(+) Index: linux-2.6.23-rc1/include/linux/slab.h =================================================================== --- linux-2.6.23-rc1.orig/include/linux/slab.h 2007-07-29 00:30:52.000000000 -0700 +++ linux-2.6.23-rc1/include/linux/slab.h 2007-07-29 00:33:28.000000000 -0700 @@ -53,6 +53,37 @@ int slab_is_available(void); struct kmem_cache_ops { void (*ctor)(void *, struct kmem_cache *, unsigned long); + + /* + * Called with slab lock held and interrupts disabled. + * No slab operation may be performed. + * + * Parameters passed are the number of objects to process + * and an array of pointers to objects for which we + * need references. + * + * Returns a pointer that is passed to the kick function. + * If all objects cannot be moved then the pointer may + * indicate that this wont work and then kick can simply + * remove the references that were already obtained. + * + * The array passed to get() is also passed to kick(). The + * function may remove objects by setting array elements to NULL. + */ + void *(*get)(struct kmem_cache *, int nr, void **); + + /* + * Called with no locks held and interrupts enabled. + * Any operation may be performed in kick(). + * + * Parameters passed are the number of objects in the array, + * the array of pointers to the objects and the pointer + * returned by get(). + * + * Success is checked by examining the number of remaining + * objects in the slab. + */ + void (*kick)(struct kmem_cache *, int nr, void **, void *private); }; struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, Index: linux-2.6.23-rc1/mm/slub.c =================================================================== --- linux-2.6.23-rc1.orig/mm/slub.c 2007-07-29 00:33:22.000000000 -0700 +++ linux-2.6.23-rc1/mm/slub.c 2007-07-29 00:33:28.000000000 -0700 @@ -3324,6 +3324,20 @@ static ssize_t ops_show(struct kmem_cach x += sprint_symbol(buf + x, (unsigned long)s->ops->ctor); x += sprintf(buf + x, "\n"); } + + if (s->ops->get) { + x += sprintf(buf + x, "get : "); + x += sprint_symbol(buf + x, + (unsigned long)s->ops->get); + x += sprintf(buf + x, "\n"); + } + + if (s->ops->kick) { + x += sprintf(buf + x, "kick : "); + x += sprint_symbol(buf + x, + (unsigned long)s->ops->kick); + x += sprintf(buf + x, "\n"); + } return x; } SLAB_ATTR_RO(ops);