diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-30 21:49:51 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-30 21:49:51 -0400 |
commit | 0d63bd45cc2aa8ed98e6cf3f62ac133599fa8177 (patch) | |
tree | 2bf3ca698c5fec1b7fa4ea1c912deea4725758e9 /mm/slub.c | |
parent | a7eab32c3580c6f4c051c5a16cad8877307b853f (diff) |
verify_obj_has_alloc_tag()memalloc_prof_debug
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c index 0809760cf789..3ed15d3cd029 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4494,6 +4494,32 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x) return cachep; } +#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG +void verify_slab_obj_has_alloc_tag(void *ptr) +{ + if (!mem_alloc_profiling_enabled()) + return; + + if (!ptr) + return; + + struct kmem_cache *s = cache_from_obj(s, ptr); + struct slab *slab = virt_to_slab(ptr); + if (!slab) + return; + + struct slabobj_ext *obj_exts = slab_obj_exts(slab); + if (!obj_exts) + return; + + unsigned idx = obj_to_index(s, slab, ptr); + if (idx >= objs_per_slab(s, slab)) + return; + + alloc_tag_sub_check(&obj_exts[idx].ref); +} +#endif + /** * kmem_cache_free - Deallocate an object * @s: The cache the allocation was from. |