kmem_cache_alloc_node
Subsystems (3)
Hi,
I've written a prototype kmem_cache_alloc_node function: I'm not yet convinced that it's really necessary to guarantee that kmalloc and kmem_cache_alloc are strictly node-local (adds noticable costs to the hot paths, and many objects will be touched by multiple nodes anyway), but at least the cpu bound data structures should be allocated from the right node. The attached patch adds a simple kmem_cache_alloc_node function and moves the cpu local structures within slab onto the right node.
One problem is the bootstrap: there is an alloc_pages_node(,,cpu_to_node()) during CPU_UP_PREPARE: Does that work, or is that too early?
Please test it, I don't have access to suitable hardware.
The patch also includes fixes for two accounting bugs in error paths, I'll send them seperately to Andrew. --
Manfred
// $Header$
// Kernel Version:
// VERSION = 2 // PATCHLEVEL = 6 // SUBLEVEL = 0 // EXTRAVERSION = -test11
include/linux/slab.h +1 -0
@@ -62,6 +62,7 @@extern int kmem_cache_destroy (kmem_cache_t *);extern int kmem_cache_shrink (kmem_cache_t *);extern void *kmem_cache_alloc (kmem_cache_t *,int ); +extern void *kmem_cache_alloc_node (kmem_cache_t *,int );extern void kmem_cache_free (kmem_cache_t *,void *);extern unsigned int kmem_cache_size (kmem_cache_t *);
mm/slab.c +130 -54
278 lines not on this page · raw message
include/linux/page-flags.h +1 -0
@@ -133,6 +133,7 @@#define inc_page_state (member) mod_page_state(member, 1UL)#define dec_page_state (member) mod_page_state(member, 0UL - 1) +#define add_page_state (member,delta) mod_page_state(member, (delta))#define sub_page_state (member,delta) mod_page_state(member, 0UL - (delta))
Quoted 13 lines · Manfred Spraul
I've written a prototype
kmem_cache_alloc_nodefunction: I'm not yet convinced that it's really necessary to guarantee that kmalloc andkmem_cache_allocare strictly node-local (adds noticable costs to the hot paths, and many objects will be touched by multiple nodes anyway), but at least the cpu bound data structures should be allocated from the right node.
The attached patch adds a simplekmem_cache_alloc_nodefunction and moves the cpu local structures within slab onto the right node. One problem is the bootstrap: there is an alloc_pages_node(,,cpu_to_node()) duringCPU_UP_PREPARE: Does that work, or is that too early?
Please test it, I don't have access to suitable hardware.
Quoted 2 lines
The patch also includes fixes for two accounting bugs in error paths, I'll send them seperately to Andrew.
Hi Manfred,
I just booted this patch on a 4 quad NUMAQ successfully, this was
only a test boot, i'll get around to having a closer look a bit later on.
Thanks