diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index ac6142a6e02a..31fc6d780981 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -117,6 +117,9 @@ DECLARE_HOOK(android_vh_mem_cgroup_css_online, DECLARE_HOOK(android_vh_mem_cgroup_css_offline, TP_PROTO(struct cgroup_subsys_state *css, struct mem_cgroup *memcg), TP_ARGS(css, memcg)); +DECLARE_HOOK(android_vh_kmalloc_slab, + TP_PROTO(unsigned int index, gfp_t flags, struct kmem_cache **s), + TP_ARGS(index, flags, s)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_MM_H */ diff --git a/mm/slab_common.c b/mm/slab_common.c index 29c857c78465..d9473ad1d233 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -641,6 +641,7 @@ static inline unsigned int size_index_elem(unsigned int bytes) struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags) { unsigned int index; + struct kmem_cache *s = NULL; if (size <= 192) { if (!size) @@ -653,6 +654,10 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags) index = fls(size - 1); } + trace_android_vh_kmalloc_slab(index, flags, &s); + if (s) + return s; + return kmalloc_caches[kmalloc_type(flags)][index]; }