Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/vm/slabinfo: Handle files in debugfs

Commit 64dd68497be76 relocated and renamed the alloc_calls and
free_calls files from /sys/kernel/slab/NAME/*_calls over to
/sys/kernel/debug/slab/NAME/*_calls but didn't update the slabinfo tool
with the new location.

This change will now have slabinfo look at the new location (and filenames)
with a fallback to the prior files.

Fixes: 64dd68497be76 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs")
Cc: stable@vger.kernel.org
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Tested-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

authored by

Stéphane Graber and committed by
Vlastimil Babka
0c7e0d69 efb93527

+24 -2
+24 -2
tools/vm/slabinfo.c
··· 233 233 return l; 234 234 } 235 235 236 + static unsigned long read_debug_slab_obj(struct slabinfo *s, const char *name) 237 + { 238 + char x[128]; 239 + FILE *f; 240 + size_t l; 241 + 242 + snprintf(x, 128, "/sys/kernel/debug/slab/%s/%s", s->name, name); 243 + f = fopen(x, "r"); 244 + if (!f) { 245 + buffer[0] = 0; 246 + l = 0; 247 + } else { 248 + l = fread(buffer, 1, sizeof(buffer), f); 249 + buffer[l] = 0; 250 + fclose(f); 251 + } 252 + return l; 253 + } 236 254 237 255 /* 238 256 * Put a size string together ··· 427 409 { 428 410 printf("\n%s: Kernel object allocation\n", s->name); 429 411 printf("-----------------------------------------------------------------------\n"); 430 - if (read_slab_obj(s, "alloc_calls")) 412 + if (read_debug_slab_obj(s, "alloc_traces")) 413 + printf("%s", buffer); 414 + else if (read_slab_obj(s, "alloc_calls")) 431 415 printf("%s", buffer); 432 416 else 433 417 printf("No Data\n"); 434 418 435 419 printf("\n%s: Kernel object freeing\n", s->name); 436 420 printf("------------------------------------------------------------------------\n"); 437 - if (read_slab_obj(s, "free_calls")) 421 + if (read_debug_slab_obj(s, "free_traces")) 422 + printf("%s", buffer); 423 + else if (read_slab_obj(s, "free_calls")) 438 424 printf("%s", buffer); 439 425 else 440 426 printf("No Data\n");