aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/slab.c26
-rw-r--r--mm/slab.h16
-rw-r--r--mm/slab_common.c18
-rw-r--r--mm/slub.c24
4 files changed, 57 insertions, 27 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 73811ca0ae29..6d5c83c6ddd5 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4276,9 +4276,8 @@ out:
4276} 4276}
4277 4277
4278#ifdef CONFIG_SLABINFO 4278#ifdef CONFIG_SLABINFO
4279int slabinfo_show(struct seq_file *m, void *p) 4279void get_slabinfo(struct kmem_cache *cachep, struct slabinfo *sinfo)
4280{ 4280{
4281 struct kmem_cache *cachep = list_entry(p, struct kmem_cache, list);
4282 struct slab *slabp; 4281 struct slab *slabp;
4283 unsigned long active_objs; 4282 unsigned long active_objs;
4284 unsigned long num_objs; 4283 unsigned long num_objs;
@@ -4333,13 +4332,20 @@ int slabinfo_show(struct seq_file *m, void *p)
4333 if (error) 4332 if (error)
4334 printk(KERN_ERR "slab: cache %s error: %s\n", name, error); 4333 printk(KERN_ERR "slab: cache %s error: %s\n", name, error);
4335 4334
4336 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", 4335 sinfo->active_objs = active_objs;
4337 name, active_objs, num_objs, cachep->size, 4336 sinfo->num_objs = num_objs;
4338 cachep->num, (1 << cachep->gfporder)); 4337 sinfo->active_slabs = active_slabs;
4339 seq_printf(m, " : tunables %4u %4u %4u", 4338 sinfo->num_slabs = num_slabs;
4340 cachep->limit, cachep->batchcount, cachep->shared); 4339 sinfo->shared_avail = shared_avail;
4341 seq_printf(m, " : slabdata %6lu %6lu %6lu", 4340 sinfo->limit = cachep->limit;
4342 active_slabs, num_slabs, shared_avail); 4341 sinfo->batchcount = cachep->batchcount;
4342 sinfo->shared = cachep->shared;
4343 sinfo->objects_per_slab = cachep->num;
4344 sinfo->cache_order = cachep->gfporder;
4345}
4346
4347void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
4348{
4343#if STATS 4349#if STATS
4344 { /* list3 stats */ 4350 { /* list3 stats */
4345 unsigned long high = cachep->high_mark; 4351 unsigned long high = cachep->high_mark;
@@ -4369,8 +4375,6 @@ int slabinfo_show(struct seq_file *m, void *p)
4369 allochit, allocmiss, freehit, freemiss); 4375 allochit, allocmiss, freehit, freemiss);
4370 } 4376 }
4371#endif 4377#endif
4372 seq_putc(m, '\n');
4373 return 0;
4374} 4378}
4375 4379
4376#define MAX_SLABINFO_WRITE 128 4380#define MAX_SLABINFO_WRITE 128
diff --git a/mm/slab.h b/mm/slab.h
index 3442eb83ee1e..5a43c2f13621 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -49,8 +49,22 @@ int __kmem_cache_shutdown(struct kmem_cache *);
49 49
50struct seq_file; 50struct seq_file;
51struct file; 51struct file;
52int slabinfo_show(struct seq_file *m, void *p);
53 52
53struct slabinfo {
54 unsigned long active_objs;
55 unsigned long num_objs;
56 unsigned long active_slabs;
57 unsigned long num_slabs;
58 unsigned long shared_avail;
59 unsigned int limit;
60 unsigned int batchcount;
61 unsigned int shared;
62 unsigned int objects_per_slab;
63 unsigned int cache_order;
64};
65
66void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo);
67void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *s);
54ssize_t slabinfo_write(struct file *file, const char __user *buffer, 68ssize_t slabinfo_write(struct file *file, const char __user *buffer,
55 size_t count, loff_t *ppos); 69 size_t count, loff_t *ppos);
56#endif 70#endif
diff --git a/mm/slab_common.c b/mm/slab_common.c
index c64a0438c1f3..5fb753da6cf0 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -242,7 +242,23 @@ static void s_stop(struct seq_file *m, void *p)
242 242
243static int s_show(struct seq_file *m, void *p) 243static int s_show(struct seq_file *m, void *p)
244{ 244{
245 return slabinfo_show(m, p); 245 struct kmem_cache *s = list_entry(p, struct kmem_cache, list);
246 struct slabinfo sinfo;
247
248 memset(&sinfo, 0, sizeof(sinfo));
249 get_slabinfo(s, &sinfo);
250
251 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
252 s->name, sinfo.active_objs, sinfo.num_objs, s->size,
253 sinfo.objects_per_slab, (1 << sinfo.cache_order));
254
255 seq_printf(m, " : tunables %4u %4u %4u",
256 sinfo.limit, sinfo.batchcount, sinfo.shared);
257 seq_printf(m, " : slabdata %6lu %6lu %6lu",
258 sinfo.active_slabs, sinfo.num_slabs, sinfo.shared_avail);
259 slabinfo_show_stats(m, s);
260 seq_putc(m, '\n');
261 return 0;
246} 262}
247 263
248/* 264/*
diff --git a/mm/slub.c b/mm/slub.c
index 6b5ee3472e18..472e739278b4 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5405,18 +5405,14 @@ __initcall(slab_sysfs_init);
5405 * The /proc/slabinfo ABI 5405 * The /proc/slabinfo ABI
5406 */ 5406 */
5407#ifdef CONFIG_SLABINFO 5407#ifdef CONFIG_SLABINFO
5408int slabinfo_show(struct seq_file *m, void *p) 5408void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo)
5409{ 5409{
5410 unsigned long nr_partials = 0; 5410 unsigned long nr_partials = 0;
5411 unsigned long nr_slabs = 0; 5411 unsigned long nr_slabs = 0;
5412 unsigned long nr_inuse = 0;
5413 unsigned long nr_objs = 0; 5412 unsigned long nr_objs = 0;
5414 unsigned long nr_free = 0; 5413 unsigned long nr_free = 0;
5415 struct kmem_cache *s;
5416 int node; 5414 int node;
5417 5415
5418 s = list_entry(p, struct kmem_cache, list);
5419
5420 for_each_online_node(node) { 5416 for_each_online_node(node) {
5421 struct kmem_cache_node *n = get_node(s, node); 5417 struct kmem_cache_node *n = get_node(s, node);
5422 5418
@@ -5429,16 +5425,16 @@ int slabinfo_show(struct seq_file *m, void *p)
5429 nr_free += count_partial(n, count_free); 5425 nr_free += count_partial(n, count_free);
5430 } 5426 }
5431 5427
5432 nr_inuse = nr_objs - nr_free; 5428 sinfo->active_objs = nr_objs - nr_free;
5429 sinfo->num_objs = nr_objs;
5430 sinfo->active_slabs = nr_slabs;
5431 sinfo->num_slabs = nr_slabs;
5432 sinfo->objects_per_slab = oo_objects(s->oo);
5433 sinfo->cache_order = oo_order(s->oo);
5434}
5433 5435
5434 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", s->name, nr_inuse, 5436void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *s)
5435 nr_objs, s->size, oo_objects(s->oo), 5437{
5436 (1 << oo_order(s->oo)));
5437 seq_printf(m, " : tunables %4u %4u %4u", 0, 0, 0);
5438 seq_printf(m, " : slabdata %6lu %6lu %6lu", nr_slabs, nr_slabs,
5439 0UL);
5440 seq_putc(m, '\n');
5441 return 0;
5442} 5438}
5443 5439
5444ssize_t slabinfo_write(struct file *file, const char __user *buffer, 5440ssize_t slabinfo_write(struct file *file, const char __user *buffer,