Skip to content

Commit 0c7e0d6

Browse files
stgrabertehcaster
authored andcommitted
tools/vm/slabinfo: Handle files in debugfs
Commit 64dd684 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: 64dd684 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs") Cc: [email protected] Signed-off-by: Stéphane Graber <[email protected]> Tested-by: Stéphane Graber <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent efb9352 commit 0c7e0d6

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tools/vm/slabinfo.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,24 @@ static unsigned long read_slab_obj(struct slabinfo *s, const char *name)
233233
return l;
234234
}
235235

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+
}
236254

237255
/*
238256
* Put a size string together
@@ -409,14 +427,18 @@ static void show_tracking(struct slabinfo *s)
409427
{
410428
printf("\n%s: Kernel object allocation\n", s->name);
411429
printf("-----------------------------------------------------------------------\n");
412-
if (read_slab_obj(s, "alloc_calls"))
430+
if (read_debug_slab_obj(s, "alloc_traces"))
431+
printf("%s", buffer);
432+
else if (read_slab_obj(s, "alloc_calls"))
413433
printf("%s", buffer);
414434
else
415435
printf("No Data\n");
416436

417437
printf("\n%s: Kernel object freeing\n", s->name);
418438
printf("------------------------------------------------------------------------\n");
419-
if (read_slab_obj(s, "free_calls"))
439+
if (read_debug_slab_obj(s, "free_traces"))
440+
printf("%s", buffer);
441+
else if (read_slab_obj(s, "free_calls"))
420442
printf("%s", buffer);
421443
else
422444
printf("No Data\n");

0 commit comments

Comments
 (0)