summaryrefslogtreecommitdiff
path: root/include/linux/debugobjects.h
diff options
context:
space:
mode:
authorVlastimil Babka (SUSE) <vbabka@kernel.org>2026-08-24 14:57:07 +0200
committerVlastimil Babka (SUSE) <vbabka@kernel.org>2026-08-24 14:57:07 +0200
commit160dcfe7f94346623abe9e3c9cb4173908698422 (patch)
tree1a6d96aa31e652fc32da2265b4712c8e0aa7b100 /include/linux/debugobjects.h
parent7e98f856395618011c517f767fb80ac3fe90de2b (diff)
parenta6172cca157f3f50c9744a8b9b563f8b14371ed9 (diff)
Merge branch 'slab/for-7.3/objext_split' into slab/for-next
Merge series "mm/slab, alloc_tag: reduce obj_ext memory waste" from myself. From the cover letter [1]: It's been bothering me that the memory usage of struct slabobj_ext depend only on config options and not whether the fields are actually used. So with both CONFIG_MEMCG=y and CONFIG_MEM_ALLOC_PROFILING=y there is always objcg field and codetag_ref field. And thus: 1) Having memory allocation profiling config-enabled but not boot-enabled means wasted memory on unused codetag_refs. This makes it less suitable for a general distro config and the page allocator side doesn't suffer from this, only slab and percpu. 2) Complementary, with memory allocation profiling enabled, there are caches/slabs that don't need the objcg field, so memory is wasted on those. This series should solve the point 1) fully for slab; pcpuobj_ext handling can be perhaps improved similarly, haven't looked into that. For 2) it avoids allocating objcg fields for KMALLOC_NORMAL and KMALLOC_NO_OBJ_EXT caches where we know they are not necessary because kmalloc() with __GFP_ACCOUNT will pick a KMALLOC_CGROUP type (except with SLUB_TINY). The named kmem_caches are tricky. They can be created with SLAB_ACCOUNT and then we know objcg fields are always needed. But also they can be created without SLAB_ACCOUNT and then some allocations have __GFP_ACCOUNT and some not and we don't know that in advance. This series introduces a SLAB_MAY_ACCOUNT flag that's currently internal only and is applied to all caches (unless kmem accounting is disabled) except KMALLOC_NORMAL (unless that aliases KMALLOC_RECLAIM) and KMALLOC_NO_OBJ_EXT. As a followup we can make SLAB_MAY_ACCOUNT explicit and add it to to caches where we know __GFP_ACCOUNT is used. Then we could only honour __GFP_ACCOUNT for those, while warning for an unexpected usage elsewhere. To check for regressions, I forward-ported a microbenchmark hacked into slub_kunit that was used to evaluate sheaves. Tried 3 scenarios, MEMCG and KFENCE were always enabled: - CONFIG_MEM_ALLOC_PROFILING=n - CONFIG_MEM_ALLOC_PROFILING=y but _ENABLED_BY_DEFAULT=n - same but booted with sysctl.vm.mem_profiling=1 The results are quite noisy, but no regression was apparent, except perhaps few percents for the last case. I don't expect it will be visible in any real workloads. Link: https://lore.kernel.org/all/20260727-b4-objext_split-v3-0-c29ef0f1f257@kernel.org/ [1]
Diffstat (limited to 'include/linux/debugobjects.h')
0 files changed, 0 insertions, 0 deletions