118 lines
3.8 KiB
Diff
118 lines
3.8 KiB
Diff
From: Cyrill Gorcunov <gorcunov@openvz.org>
|
|
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 <gorcunov@openvz.org>
|
|
---
|
|
|
|
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 <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
|
|
#include <linux/compiler.h>
|
|
|
|
+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 **)\
|