Skip to content

Commit

Permalink
slab: move FULL state transition to an initcall
Browse files Browse the repository at this point in the history
During kmem_cache_init_late(), we transition to the LATE state,
and after some more work, to the FULL state, its last state

This is quite different from slub, that will only transition to
its last state (previously SYSFS), in a (late)initcall, after a lot
more of the kernel is ready.

This means that in slab, we have no way to taking actions dependent
on the initialization of other pieces of the kernel that are supposed
to start way after kmem_init_late(), such as cgroups initialization.

To achieve more consistency in this behavior, that patch only
transitions to the UP state in kmem_init_late. In my analysis,
setup_cpu_cache() should be happy to test for >= UP, instead of
== FULL. It also has passed some tests I've made.

We then only mark FULL state after the reap timers are in place,
meaning that no further setup is expected.

Signed-off-by: Glauber Costa <glommer@parallels.com>
Acked-by: Christoph Lameter <cl@linux.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
  • Loading branch information
Glauber Costa authored and Pekka Enberg committed Jul 2, 2012
1 parent d97d476 commit a164f89
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,9 +1668,6 @@ void __init kmem_cache_init_late(void)
BUG();
mutex_unlock(&cache_chain_mutex);

/* Done! */
g_cpucache_up = FULL;

/*
* Register a cpu startup notifier callback that initializes
* cpu_cache_get for all new cpus
Expand Down Expand Up @@ -1700,6 +1697,9 @@ static int __init cpucache_init(void)
*/
for_each_online_cpu(cpu)
start_cpu_timer(cpu);

/* Done! */
g_cpucache_up = FULL;
return 0;
}
__initcall(cpucache_init);
Expand Down Expand Up @@ -2167,7 +2167,7 @@ static size_t calculate_slab_order(struct kmem_cache *cachep,

static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
{
if (g_cpucache_up == FULL)
if (g_cpucache_up >= LATE)
return enable_cpucache(cachep, gfp);

if (g_cpucache_up == NONE) {
Expand Down

0 comments on commit a164f89

Please sign in to comment.