Skip to contentSkip to conversation

slub: correctly bootstrap boot caches

PATCH In review Glauber Costa 5 participants 12 messages Feb 22, 2013 – Feb 27, 2013 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 slub: correctly bootstrap boot caches

After we create a boot cache, we may allocate from it until it is bootstraped. This will move the page from the partial list to the cpu slab list. If this happens, the loop:

	list_for_each_entry(p, &n->partial, lru)

that we use to scan for all partial pages will yield nothing, and the pages will keep pointing to the boot cpu cache, which is of course, invalid. To do that, we should flush the cache to make sure that the cpu slab is back to the partial list.

 mm/slub.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
---
 mm/slub.c | 6 ++++++
 1 file changed, 6 insertions(+)
mm/slub.c +6 -0
index ba2ca53..31a494c 100644
@@ -3617,6 +3617,12 @@ static struct kmem_cache * __init bootstrap(struct kmem_cache *static_cache)
 
 	memcpy(s, static_cache, kmem_cache->object_size);
 
+	/*
+	 * This runs very early, and only the boot processor is supposed to be
+	 * up.  Even if it weren't true, IRQs are not up so we couldn't fire
+	 * IPIs around.
+	 */
+	__flush_cpu_slab(s, smp_processor_id());
 	for_each_node_state(node, N_NORMAL_MEMORY) {
 		struct kmem_cache_node *n = get_node(s, node);
 		struct page *p;
Signature · 7 lines
1.8.1.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · Glauber Costa

After we create a boot cache, we may allocate from it until it is bootstraped. This will move the page from the partial list to the cpu slab list. If this happens, the loop:

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 8 lines · Glauber Costa
Quoted 4 lines · Christoph Lameter

Argh. This one was the final version:

https://patchwork.kernel.org/patch/2009521/

It seems it would work. It is all the same to me.
Which one do you prefer?

Flushing seems to be simpler and less code.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

2013/2/23 Christoph Lameter <[email protected]>:

Quoted 5 lines · Glauber Costa
Quoted 4 lines · Christoph Lameter
Quoted 2 lines

Argh. This one was the final version:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

https://patchwork.kernel.org/patch/2009521/

It seems it would work. It is all the same to me.
Which one do you prefer?

Flushing seems to be simpler and less code.

Hello, Christoph, Glauber.

With flushing, deactivate_slab() occur and it has some overhead to deactivate objects.
If my patch properly fix this situation, it is better to use mine which has no overhead.

Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw
Quoted 4 lines · JoonSoo Kim

With flushing, deactivate_slab() occur and it has some overhead to deactivate objects.
If my patch properly fix this situation, it is better to use mine which has no overhead.

Well this occurs during boot and its not that performance critical.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw

Hello, Christoph.

Quoted 8 lines · Christoph Lameter
Quoted 4 lines · JoonSoo Kim

With flushing, deactivate_slab() occur and it has some overhead to deactivate objects.
If my patch properly fix this situation, it is better to use mine which has no overhead.

Well this occurs during boot and its not that performance critical.

Hmm...
Yes, this is not performance critical place, but why do we use a sub-optimal solution?

And flushing is abstration for complicated logic, so I think that my raw implemntation is better for understanding.

But, I have no objection to merge Glauber's one
if you think that is better.

Thanks.

Quoted 6 lines

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw
In reply to Christoph Lameter
Quoted 5 lines · Christoph Lameter
Quoted 3 lines · Glauber Costa
Quoted 2 lines · Christoph Lameter

Argh. This one was the final version:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

https://patchwork.kernel.org/patch/2009521/

It seems it would work. It is all the same to me.
Which one do you prefer?

Flushing seems to be simpler and less code.

Well, I completely lost track of what to apply... Can someone please send me the final version that everybody agrees on with proper ACKs and other attributions?

#12 lore raw
Quoted 9 lines · Pekka Enberg
Quoted 8 lines · Christoph Lameter
Quoted 6 lines · Glauber Costa
Quoted 4 lines · Christoph Lameter

Argh. This one was the final version:

https://patchwork.kernel.org/patch/2009521/

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

It seems it would work. It is all the same to me.
Which one do you prefer?

Flushing seems to be simpler and less code.

Well, I completely lost track of what to apply... Can someone please send me the final version that everybody agrees on with proper ACKs and other attributions?

You can apply this one as-is with Christoph's ACK.

#13 lore raw
Quoted 1 line · Glauber Costa

You can apply this one as-is with Christoph's ACK.

Right.