ANDROID: vendor_hooks: Add hook in kmalloc_slab()

Add hook in kmalloc_slab() for debug kmalloc slab memory leak.

Bug: 197614797
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: I402a9f968f2bf1e75daa461c05a53a8fabf70028
(cherry picked from commit 94fbab9d6c82befb547f75433dd886f2611071a6)
This commit is contained in:
Liujie Xie
2021-08-25 02:26:18 +08:00
committed by Suren Baghdasaryan
parent fcacd896ec
commit 4a9e3b2ca6
3 changed files with 9 additions and 0 deletions

View File

@@ -358,6 +358,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_css_offline);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_css_online);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_slab);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_looper_state_registered);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_thread_read);

View File

@@ -139,6 +139,9 @@ DECLARE_HOOK(android_vh_rmqueue,
unsigned int alloc_flags, int migratetype),
TP_ARGS(preferred_zone, zone, order,
gfp_flags, alloc_flags, migratetype));
DECLARE_HOOK(android_vh_kmalloc_slab,
TP_PROTO(unsigned int index, gfp_t flags, struct kmem_cache **s),
TP_ARGS(index, flags, s));
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */

View File

@@ -743,6 +743,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)
@@ -755,6 +756,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];
}