Index: linux-2.6.21-rc3-mm2/mm/slub.c =================================================================== --- linux-2.6.21-rc3-mm2.orig/mm/slub.c 2007-03-16 23:13:59.000000000 -0700 +++ linux-2.6.21-rc3-mm2/mm/slub.c 2007-03-16 23:14:36.000000000 -0700 @@ -20,7 +20,8 @@ #include #include #include - +#include +` /* * Lock order: * 1. slab_lock(page) @@ -93,11 +94,12 @@ static struct notifier_block slab_notifi static enum { DOWN, /* No slab functionality available */ PARTIAL, /* kmem_cache_open() works but kmalloc does not */ - UP /* Everything works */ + UP, /* General slabs and slab creation works */ + SYSFS /* The sysfs subsystem has been initialized */ } slab_state = DOWN; int slab_is_available(void) { - return slab_state == UP; + return slab_state > PARTIAL; } /* A list of all slab caches on the system */ @@ -1367,7 +1369,7 @@ static int init_kmem_cache_nodes(struct int node; int local_node; - if (slab_state == UP) + if (slab_state > PARTIAL) local_node = page_to_nid(virt_to_page(s)); else local_node = 0; @@ -2003,6 +2005,78 @@ void __init kmem_cache_init(void) } /* + * Needs to be called after sysfs has been brough up. Sysfs + * need the slab allocator to work so we cannot do this + * earlier. + */ +static decl_subsys(slab, NULL, NULL); + +_ATTR_RO(nr_objects); +_ATTR_RO(nr_partials); +_ATTR_RO(nr_slabs); +_ATTR_RO(nr_percpu); +_ATTR_RO(order); +_ATTR_RO(object_size); +_ATTR_RO(object_inuse); +_ATTR_RO(object_size_total); +_ATTR_RO(constructor); +_ATTR_RO(destructor); +_ATTR_RO(cache_align); +_ATTR_RO(dma); +_ATTR_RW(reclaim_account); +_ATTR_RO(destroy_by_rcu); +_ATTR_RW(memory_spread); +_ATTR_RW(debug_sanity); +_ATTR_RW(debug_redzone); +_ATTR_RW(debug_poison); +_ATTR_RW(debug_store_user); +_ATTR_RW(debug_tracking); + +#ifdef CONFIG_NUMA +_KSET(nodes); +#endif + +kmem_cache_sysfs_init(void) +{ + kset_set_kset_s(&slub_subsys, kernel_subsys); + err = subsystem_register(&slub_subsys); + if (err) + return err; + /* Global config values */ + + /* Go through all slabs and setup sysfs entries */ + for_each_entry(s, slab_list, list) { + kobject_register(s->kobj); + series of attributes + nr_objects; + nr_partials; + nr_slabs + nr_percpu + size + various flags; + dtor + ctor + alignment + objsizee; + objnuse; + objfinalsize; + objects_per_slab; + order; + + + kset_register(s->nodeset); + for_each_online_node(node) { + attribute() + nr_partials + nr_slabs + nr_active + per node info + } + } + slab_state = SYSFS; +} + +/* * Find a mergeable slab cache */ static struct kmem_cache *find_mergeable(size_t size,