From e63ab9ed2622eeb853636d75fede26febebbff3b Mon Sep 17 00:00:00 2001 From: Peter Volkov Date: Wed, 22 Jul 2009 05:54:03 +0000 Subject: Backported patch to make kernel buildable with SLAB, bug #275965 thank Daniel Beckham for report and Tom Hendrikx for work with upstream. SLUB is better choice and few people want it thus added without revision bump. (Portage version: 2.2_rc33/cvs/Linux i686) --- .../files/openvz-sources-2.6.27.2.1-SLAB.patch | 117 +++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 sys-kernel/openvz-sources/files/openvz-sources-2.6.27.2.1-SLAB.patch (limited to 'sys-kernel/openvz-sources/files') diff --git a/sys-kernel/openvz-sources/files/openvz-sources-2.6.27.2.1-SLAB.patch b/sys-kernel/openvz-sources/files/openvz-sources-2.6.27.2.1-SLAB.patch new file mode 100644 index 000000000000..818425498bc8 --- /dev/null +++ b/sys-kernel/openvz-sources/files/openvz-sources-2.6.27.2.1-SLAB.patch @@ -0,0 +1,117 @@ +From: Cyrill Gorcunov +Date: Thu, 16 Jul 2009 15:22:21 +0000 (+0400) +Subject: lab: kmem_cache - fixup members and use helpers +X-Git-Url: http://git.openvz.org/?p=linux-2.6.27-openvz;a=commitdiff_plain;h=36d3fafb956540b300aa12218bcb7e9db3c5e656 + +lab: kmem_cache - fixup members and use helpers + +In a sake of SLAB memory manager usability we need +to add beancounter members and use proper helpers. + +[ bug http://bugzilla.openvz.org/show_bug.cgi?id=1232 ] + +Signed-off-by: Cyrill Gorcunov +--- + +diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h +index de03bd0..1da5551 100644 +--- a/include/linux/slab_def.h ++++ b/include/linux/slab_def.h +@@ -15,6 +15,8 @@ + #include /* kmalloc_sizes.h needs L1_CACHE_BYTES */ + #include + ++struct kmem_cache; ++ + /* + * DEBUG - 1 for kmem_cache_create() to honour; SLAB_RED_ZONE & SLAB_POISON. + * 0 for faster, smaller code (especially in the critical paths). +diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c +index 3f004b7..46a1726 100644 +--- a/kernel/pid_namespace.c ++++ b/kernel/pid_namespace.c +@@ -184,8 +184,8 @@ static int __pid_ns_attach_task(struct pid_namespace *ns, + for (type = 0; type < PIDTYPE_MAX; ++type) + INIT_HLIST_HEAD(&pid->tasks[type]); + +- old_size = pid->numbers[pid->level - 1].ns->pid_cachep->objuse; +- new_size = pid->numbers[pid->level].ns->pid_cachep->objuse; ++ old_size = kmem_cache_objuse(pid->numbers[pid->level - 1].ns->pid_cachep); ++ new_size = kmem_cache_objuse(pid->numbers[pid->level].ns->pid_cachep); + local_irq_disable(); + /* + * Depending on sizeof(struct foo), cache flags (redzoning, etc) +diff --git a/mm/slab.c b/mm/slab.c +index 8d27032..730fe63 100644 +--- a/mm/slab.c ++++ b/mm/slab.c +@@ -399,12 +399,13 @@ struct kmem_cache { + struct list_head next; + + /* 6) statistics */ +-#if STATS ++#if SLAB_STATS + unsigned long num_active; + unsigned long num_allocations; + unsigned long high_mark; + unsigned long grown; + unsigned long reaped; ++ unsigned long shrunk; + unsigned long errors; + unsigned long max_freeable; + unsigned long node_allocs; +@@ -415,7 +416,7 @@ struct kmem_cache { + atomic_t freehit; + atomic_t freemiss; + #endif +-#if DEBUG ++#if SLAB_DEBUG + /* + * If debugging is enabled, then the allocator can add additional + * fields and/or padding to every object. buffer_size contains the total +@@ -425,6 +426,9 @@ struct kmem_cache { + int obj_offset; + int obj_size; + #endif ++#ifdef CONFIG_BEANCOUNTERS ++ int objuse; ++#endif + /* + * We put nodelists[] at the end of kmem_cache, because we want to size + * this array to nr_node_ids slots instead of MAX_NUMNODES +@@ -452,11 +456,11 @@ struct kmem_cache { + #define REAPTIMEOUT_CPUC (2*HZ) + #define REAPTIMEOUT_LIST3 (4*HZ) + ++#if SLAB_STATS + #define STATS_INC_GROWN(x) ((x)->grown++) + #define STATS_ADD_REAPED(x,y) ((x)->reaped += (y)) + #define STATS_INC_SHRUNK(x) ((x)->shrunk++) + +-#if SLAB_STATS + #define STATS_INC_ACTIVE(x) ((x)->num_active++) + #define STATS_DEC_ACTIVE(x) ((x)->num_active--) + #define STATS_INC_ALLOCED(x) ((x)->num_allocations++) +@@ -479,6 +483,9 @@ struct kmem_cache { + #define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit) + #define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss) + #else ++#define STATS_INC_GROWN(x) do { } while (0) ++#define STATS_ADD_REAPED(x,y) do { } while (0) ++#define STATS_INC_SHRUNK(x) do { } while (0) + #define STATS_INC_ACTIVE(x) do { } while (0) + #define STATS_DEC_ACTIVE(x) do { } while (0) + #define STATS_INC_ALLOCED(x) do { } while (0) +@@ -841,8 +848,12 @@ int kmem_dname_objuse(void *obj) + + unsigned long ub_cache_growth(struct kmem_cache *cachep) + { ++#if SLAB_STATS + return (cachep->grown - cachep->reaped - cachep->shrunk) + << cachep->gfporder; ++#else ++ return 0; ++#endif + } + + #define slab_ubcs(cachep, slabp) ((struct user_beancounter **)\ -- cgit v1.2.3-65-gdbad