summaryrefslogtreecommitdiff
path: root/mm/kfence
diff options
context:
space:
mode:
authorVlastimil Babka (SUSE) <vbabka@kernel.org>2026-07-27 14:54:07 +0200
committerVlastimil Babka (SUSE) <vbabka@kernel.org>2026-08-04 12:30:45 +0200
commita6172cca157f3f50c9744a8b9b563f8b14371ed9 (patch)
tree21376edb17ba5b156d9792aefcee6a995ec81d02 /mm/kfence
parentd4404b0f5b8b0ff4656d018a0ddfafdbd78879e2 (diff)
mm/slab, kfence, memcg: completely remove obj_ext for kfence objects
We have already disabled memory allocation profiling for objects allocated for KFENCE to avoid complexity. KFENCE allocations are rare and there can be only CONFIG_KFENCE_NUM_OBJECTS (default to 255) outstanding ones at any time, so they are among noise in the profiling stats. For the same reasons, we can stop memcg_kmem accounting of kfence objects as their memory usage will be negligible wrt any practical memcg limits. This allows us simplifying the code and getting rid of is_kfence_address() checks in various places, including slab_obj_ext()'s usage of obj_to_index(). Instead we rely on the fact that slab_obj_exts() will now always return 0 for a kfence object's fake slab, which makes those places unreachable. All we need to do to keep this assumption valid is not to allocate obj_exts for kfence objects, so the checks need to guard alloc_slab_obj_exts() where necessary. Suggested-by: Harry Yoo <harry@kernel.org> Link: https://patch.msgid.link/20260727-b4-objext_split-v3-13-c29ef0f1f257@kernel.org Reviewed-by: Hao Li <hao.li@linux.dev> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Diffstat (limited to 'mm/kfence')
-rw-r--r--mm/kfence/core.c12
-rw-r--r--mm/kfence/kfence.h3
2 files changed, 0 insertions, 15 deletions
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 7da3be9fbf5d..90925c646c4c 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -636,14 +636,6 @@ static unsigned long kfence_init_pool(void)
page = pfn_to_page(start_pfn + i);
__SetPageSlab(page);
-#ifdef CONFIG_MEMCG
- struct slab *slab = page_slab(page);
- slab->obj_exts = (unsigned long)&kfence_metadata_init[i / 2 - 1].obj_exts |
- MEMCG_DATA_OBJEXTS;
-#ifdef CONFIG_64BIT
- slab->obj_exts_needs_objcg = 1;
-#endif
-#endif
}
/*
@@ -707,10 +699,6 @@ reset_slab:
continue;
page = pfn_to_page(start_pfn + i);
-#ifdef CONFIG_MEMCG
- struct slab *slab = page_slab(page);
- slab->obj_exts = 0;
-#endif
__ClearPageSlab(page);
}
diff --git a/mm/kfence/kfence.h b/mm/kfence/kfence.h
index 1f618f9b0d12..e6b4bf349ff7 100644
--- a/mm/kfence/kfence.h
+++ b/mm/kfence/kfence.h
@@ -102,9 +102,6 @@ struct kfence_metadata {
struct kfence_track free_track __guarded_by(&lock);
/* For updating alloc_covered on frees. */
u32 alloc_stack_hash __guarded_by(&lock);
-#ifdef CONFIG_MEMCG
- struct slabobj_ext obj_exts;
-#endif
};
#define KFENCE_METADATA_SIZE PAGE_ALIGN(sizeof(struct kfence_metadata) * \