Skip to content

Commit af961f8

Browse files
committed
Merge branch 'slab/for-6.1/slub_debug_waste' into slab/for-next
A patch from Feng Tang that enhances the existing debugfs alloc_traces file for kmalloc caches with information about how much space is wasted by allocations that needs less space than the particular kmalloc cache provides.
2 parents 0bdcef5 + 6edf257 commit af961f8

File tree

4 files changed

+142
-50
lines changed

4 files changed

+142
-50
lines changed

Documentation/mm/slub.rst

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -400,21 +400,30 @@ information:
400400
allocated objects. The output is sorted by frequency of each trace.
401401

402402
Information in the output:
403-
Number of objects, allocating function, minimal/average/maximal jiffies since alloc,
404-
pid range of the allocating processes, cpu mask of allocating cpus, and stack trace.
403+
Number of objects, allocating function, possible memory wastage of
404+
kmalloc objects(total/per-object), minimal/average/maximal jiffies
405+
since alloc, pid range of the allocating processes, cpu mask of
406+
allocating cpus, numa node mask of origins of memory, and stack trace.
405407

406408
Example:::
407409

408-
1085 populate_error_injection_list+0x97/0x110 age=166678/166680/166682 pid=1 cpus=1::
409-
__slab_alloc+0x6d/0x90
410-
kmem_cache_alloc_trace+0x2eb/0x300
411-
populate_error_injection_list+0x97/0x110
412-
init_error_injection+0x1b/0x71
413-
do_one_initcall+0x5f/0x2d0
414-
kernel_init_freeable+0x26f/0x2d7
415-
kernel_init+0xe/0x118
416-
ret_from_fork+0x22/0x30
417-
410+
338 pci_alloc_dev+0x2c/0xa0 waste=521872/1544 age=290837/291891/293509 pid=1 cpus=106 nodes=0-1
411+
__kmem_cache_alloc_node+0x11f/0x4e0
412+
kmalloc_trace+0x26/0xa0
413+
pci_alloc_dev+0x2c/0xa0
414+
pci_scan_single_device+0xd2/0x150
415+
pci_scan_slot+0xf7/0x2d0
416+
pci_scan_child_bus_extend+0x4e/0x360
417+
acpi_pci_root_create+0x32e/0x3b0
418+
pci_acpi_scan_root+0x2b9/0x2d0
419+
acpi_pci_root_add.cold.11+0x110/0xb0a
420+
acpi_bus_attach+0x262/0x3f0
421+
device_for_each_child+0xb7/0x110
422+
acpi_dev_for_each_child+0x77/0xa0
423+
acpi_bus_attach+0x108/0x3f0
424+
device_for_each_child+0xb7/0x110
425+
acpi_dev_for_each_child+0x77/0xa0
426+
acpi_bus_attach+0x108/0x3f0
418427

419428
2. free_traces::
420429

include/linux/slab.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#define SLAB_RED_ZONE ((slab_flags_t __force)0x00000400U)
3030
/* DEBUG: Poison objects */
3131
#define SLAB_POISON ((slab_flags_t __force)0x00000800U)
32+
/* Indicate a kmalloc slab */
33+
#define SLAB_KMALLOC ((slab_flags_t __force)0x00001000U)
3234
/* Align objs on cache lines */
3335
#define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U)
3436
/* Use GFP_DMA memory */

mm/slab_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name,
661661
if (!s)
662662
panic("Out of memory when creating slab %s\n", name);
663663

664-
create_boot_cache(s, name, size, flags, useroffset, usersize);
664+
create_boot_cache(s, name, size, flags | SLAB_KMALLOC, useroffset,
665+
usersize);
665666
kasan_cache_create_kmalloc(s);
666667
list_add(&s->list, &slab_caches);
667668
s->refcount = 1;

0 commit comments

Comments
 (0)