aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2012-10-24 02:43:00 -0400
committerPekka Enberg <penberg@kernel.org>2012-10-24 02:43:00 -0400
commitb4f591c45f1de0f5b8ad8da508a892b571a53202 (patch)
tree28ab1a1786c555987ab50f1044143204f538a602 /mm/slub.c
parent837d678dc264c797c16f81cf56f615f7544891c1 (diff)
parent0d7561c61d76690ed84bd1016acc0fcbff063205 (diff)
Merge branch 'slab/procfs' into slab/next
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c77
1 files changed, 11 insertions, 66 deletions
diff --git a/mm/slub.c b/mm/slub.c
index e7aec2001ae5..16274b273c61 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5399,49 +5399,14 @@ __initcall(slab_sysfs_init);
5399 * The /proc/slabinfo ABI 5399 * The /proc/slabinfo ABI
5400 */ 5400 */
5401#ifdef CONFIG_SLABINFO 5401#ifdef CONFIG_SLABINFO
5402static void print_slabinfo_header(struct seq_file *m) 5402void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo)
5403{
5404 seq_puts(m, "slabinfo - version: 2.1\n");
5405 seq_puts(m, "# name <active_objs> <num_objs> <object_size> "
5406 "<objperslab> <pagesperslab>");
5407 seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
5408 seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
5409 seq_putc(m, '\n');
5410}
5411
5412static void *s_start(struct seq_file *m, loff_t *pos)
5413{
5414 loff_t n = *pos;
5415
5416 mutex_lock(&slab_mutex);
5417 if (!n)
5418 print_slabinfo_header(m);
5419
5420 return seq_list_start(&slab_caches, *pos);
5421}
5422
5423static void *s_next(struct seq_file *m, void *p, loff_t *pos)
5424{
5425 return seq_list_next(p, &slab_caches, pos);
5426}
5427
5428static void s_stop(struct seq_file *m, void *p)
5429{
5430 mutex_unlock(&slab_mutex);
5431}
5432
5433static int s_show(struct seq_file *m, void *p)
5434{ 5403{
5435 unsigned long nr_partials = 0; 5404 unsigned long nr_partials = 0;
5436 unsigned long nr_slabs = 0; 5405 unsigned long nr_slabs = 0;
5437 unsigned long nr_inuse = 0;
5438 unsigned long nr_objs = 0; 5406 unsigned long nr_objs = 0;
5439 unsigned long nr_free = 0; 5407 unsigned long nr_free = 0;
5440 struct kmem_cache *s;
5441 int node; 5408 int node;
5442 5409
5443 s = list_entry(p, struct kmem_cache, list);
5444
5445 for_each_online_node(node) { 5410 for_each_online_node(node) {
5446 struct kmem_cache_node *n = get_node(s, node); 5411 struct kmem_cache_node *n = get_node(s, node);
5447 5412
@@ -5454,41 +5419,21 @@ static int s_show(struct seq_file *m, void *p)
5454 nr_free += count_partial(n, count_free); 5419 nr_free += count_partial(n, count_free);
5455 } 5420 }
5456 5421
5457 nr_inuse = nr_objs - nr_free; 5422 sinfo->active_objs = nr_objs - nr_free;
5458 5423 sinfo->num_objs = nr_objs;
5459 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", s->name, nr_inuse, 5424 sinfo->active_slabs = nr_slabs;
5460 nr_objs, s->size, oo_objects(s->oo), 5425 sinfo->num_slabs = nr_slabs;
5461 (1 << oo_order(s->oo))); 5426 sinfo->objects_per_slab = oo_objects(s->oo);
5462 seq_printf(m, " : tunables %4u %4u %4u", 0, 0, 0); 5427 sinfo->cache_order = oo_order(s->oo);
5463 seq_printf(m, " : slabdata %6lu %6lu %6lu", nr_slabs, nr_slabs,
5464 0UL);
5465 seq_putc(m, '\n');
5466 return 0;
5467} 5428}
5468 5429
5469static const struct seq_operations slabinfo_op = { 5430void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *s)
5470 .start = s_start,
5471 .next = s_next,
5472 .stop = s_stop,
5473 .show = s_show,
5474};
5475
5476static int slabinfo_open(struct inode *inode, struct file *file)
5477{ 5431{
5478 return seq_open(file, &slabinfo_op);
5479} 5432}
5480 5433
5481static const struct file_operations proc_slabinfo_operations = { 5434ssize_t slabinfo_write(struct file *file, const char __user *buffer,
5482 .open = slabinfo_open, 5435 size_t count, loff_t *ppos)
5483 .read = seq_read,
5484 .llseek = seq_lseek,
5485 .release = seq_release,
5486};
5487
5488static int __init slab_proc_init(void)
5489{ 5436{
5490 proc_create("slabinfo", S_IRUSR, NULL, &proc_slabinfo_operations); 5437 return -EIO;
5491 return 0;
5492} 5438}
5493module_init(slab_proc_init);
5494#endif /* CONFIG_SLABINFO */ 5439#endif /* CONFIG_SLABINFO */