@@ -4276,54 +4276,8 @@ static void cache_reap(struct work_struct *w)
4276
4276
}
4277
4277
4278
4278
#ifdef CONFIG_SLABINFO
4279
-
4280
- static void print_slabinfo_header (struct seq_file * m )
4279
+ void get_slabinfo (struct kmem_cache * cachep , struct slabinfo * sinfo )
4281
4280
{
4282
- /*
4283
- * Output format version, so at least we can change it
4284
- * without _too_ many complaints.
4285
- */
4286
- #if STATS
4287
- seq_puts (m , "slabinfo - version: 2.1 (statistics)\n" );
4288
- #else
4289
- seq_puts (m , "slabinfo - version: 2.1\n" );
4290
- #endif
4291
- seq_puts (m , "# name <active_objs> <num_objs> <objsize> "
4292
- "<objperslab> <pagesperslab>" );
4293
- seq_puts (m , " : tunables <limit> <batchcount> <sharedfactor>" );
4294
- seq_puts (m , " : slabdata <active_slabs> <num_slabs> <sharedavail>" );
4295
- #if STATS
4296
- seq_puts (m , " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
4297
- "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>" );
4298
- seq_puts (m , " : cpustat <allochit> <allocmiss> <freehit> <freemiss>" );
4299
- #endif
4300
- seq_putc (m , '\n' );
4301
- }
4302
-
4303
- static void * s_start (struct seq_file * m , loff_t * pos )
4304
- {
4305
- loff_t n = * pos ;
4306
-
4307
- mutex_lock (& slab_mutex );
4308
- if (!n )
4309
- print_slabinfo_header (m );
4310
-
4311
- return seq_list_start (& slab_caches , * pos );
4312
- }
4313
-
4314
- static void * s_next (struct seq_file * m , void * p , loff_t * pos )
4315
- {
4316
- return seq_list_next (p , & slab_caches , pos );
4317
- }
4318
-
4319
- static void s_stop (struct seq_file * m , void * p )
4320
- {
4321
- mutex_unlock (& slab_mutex );
4322
- }
4323
-
4324
- static int s_show (struct seq_file * m , void * p )
4325
- {
4326
- struct kmem_cache * cachep = list_entry (p , struct kmem_cache , list );
4327
4281
struct slab * slabp ;
4328
4282
unsigned long active_objs ;
4329
4283
unsigned long num_objs ;
@@ -4378,13 +4332,20 @@ static int s_show(struct seq_file *m, void *p)
4378
4332
if (error )
4379
4333
printk (KERN_ERR "slab: cache %s error: %s\n" , name , error );
4380
4334
4381
- seq_printf (m , "%-17s %6lu %6lu %6u %4u %4d" ,
4382
- name , active_objs , num_objs , cachep -> size ,
4383
- cachep -> num , (1 << cachep -> gfporder ));
4384
- seq_printf (m , " : tunables %4u %4u %4u" ,
4385
- cachep -> limit , cachep -> batchcount , cachep -> shared );
4386
- seq_printf (m , " : slabdata %6lu %6lu %6lu" ,
4387
- active_slabs , num_slabs , shared_avail );
4335
+ sinfo -> active_objs = active_objs ;
4336
+ sinfo -> num_objs = num_objs ;
4337
+ sinfo -> active_slabs = active_slabs ;
4338
+ sinfo -> num_slabs = num_slabs ;
4339
+ sinfo -> shared_avail = shared_avail ;
4340
+ sinfo -> limit = cachep -> limit ;
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
+
4347
+ void slabinfo_show_stats (struct seq_file * m , struct kmem_cache * cachep )
4348
+ {
4388
4349
#if STATS
4389
4350
{ /* list3 stats */
4390
4351
unsigned long high = cachep -> high_mark ;
@@ -4414,31 +4375,8 @@ static int s_show(struct seq_file *m, void *p)
4414
4375
allochit , allocmiss , freehit , freemiss );
4415
4376
}
4416
4377
#endif
4417
- seq_putc (m , '\n' );
4418
- return 0 ;
4419
4378
}
4420
4379
4421
- /*
4422
- * slabinfo_op - iterator that generates /proc/slabinfo
4423
- *
4424
- * Output layout:
4425
- * cache-name
4426
- * num-active-objs
4427
- * total-objs
4428
- * object size
4429
- * num-active-slabs
4430
- * total-slabs
4431
- * num-pages-per-slab
4432
- * + further values on SMP and with statistics enabled
4433
- */
4434
-
4435
- static const struct seq_operations slabinfo_op = {
4436
- .start = s_start ,
4437
- .next = s_next ,
4438
- .stop = s_stop ,
4439
- .show = s_show ,
4440
- };
4441
-
4442
4380
#define MAX_SLABINFO_WRITE 128
4443
4381
/**
4444
4382
* slabinfo_write - Tuning for the slab allocator
@@ -4447,7 +4385,7 @@ static const struct seq_operations slabinfo_op = {
4447
4385
* @count: data length
4448
4386
* @ppos: unused
4449
4387
*/
4450
- static ssize_t slabinfo_write (struct file * file , const char __user * buffer ,
4388
+ ssize_t slabinfo_write (struct file * file , const char __user * buffer ,
4451
4389
size_t count , loff_t * ppos )
4452
4390
{
4453
4391
char kbuf [MAX_SLABINFO_WRITE + 1 ], * tmp ;
@@ -4490,19 +4428,6 @@ static ssize_t slabinfo_write(struct file *file, const char __user *buffer,
4490
4428
return res ;
4491
4429
}
4492
4430
4493
- static int slabinfo_open (struct inode * inode , struct file * file )
4494
- {
4495
- return seq_open (file , & slabinfo_op );
4496
- }
4497
-
4498
- static const struct file_operations proc_slabinfo_operations = {
4499
- .open = slabinfo_open ,
4500
- .read = seq_read ,
4501
- .write = slabinfo_write ,
4502
- .llseek = seq_lseek ,
4503
- .release = seq_release ,
4504
- };
4505
-
4506
4431
#ifdef CONFIG_DEBUG_SLAB_LEAK
4507
4432
4508
4433
static void * leaks_start (struct seq_file * m , loff_t * pos )
@@ -4631,6 +4556,16 @@ static int leaks_show(struct seq_file *m, void *p)
4631
4556
return 0 ;
4632
4557
}
4633
4558
4559
+ static void * s_next (struct seq_file * m , void * p , loff_t * pos )
4560
+ {
4561
+ return seq_list_next (p , & slab_caches , pos );
4562
+ }
4563
+
4564
+ static void s_stop (struct seq_file * m , void * p )
4565
+ {
4566
+ mutex_unlock (& slab_mutex );
4567
+ }
4568
+
4634
4569
static const struct seq_operations slabstats_op = {
4635
4570
.start = leaks_start ,
4636
4571
.next = s_next ,
@@ -4665,7 +4600,6 @@ static const struct file_operations proc_slabstats_operations = {
4665
4600
4666
4601
static int __init slab_proc_init (void )
4667
4602
{
4668
- proc_create ("slabinfo" ,S_IWUSR |S_IRUSR ,NULL ,& proc_slabinfo_operations );
4669
4603
#ifdef CONFIG_DEBUG_SLAB_LEAK
4670
4604
proc_create ("slab_allocators" , 0 , NULL , & proc_slabstats_operations );
4671
4605
#endif
0 commit comments