ANDROID: vendor_hooks: mm: add hook to count the number pages

allocated for each slab

We want to add an interface that can detect the number of pages
allocated by the slab, and if exceeds a threshold, trigger a
panic or other actions.

Bug: 302090264
Change-Id: I8fcae6a97046806376b95b66085dd5b852c2d1e8
Signed-off-by: Haonan Wang <haonan.wang@unisoc.com>
This commit is contained in:
Haonan Wang 2023-09-26 19:40:57 +08:00 committed by Todd Kjos
parent a59b32866c
commit 6e881bf034
3 changed files with 7 additions and 0 deletions

View File

@ -362,3 +362,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_early_resume_begin);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_get_folio);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_blk_mq_rw_recovery);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sd_update_bus_speed_mode);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_folio_alloced);

View File

@ -196,6 +196,9 @@ DECLARE_HOOK(android_vh_mm_alloc_pages_may_oom_exit,
DECLARE_HOOK(android_vh_adjust_kvmalloc_flags,
TP_PROTO(unsigned int order, gfp_t *alloc_flags),
TP_ARGS(order, alloc_flags));
DECLARE_HOOK(android_vh_slab_folio_alloced,
TP_PROTO(unsigned int order, gfp_t flags),
TP_ARGS(order, flags));
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */

View File

@ -43,6 +43,7 @@
#include <linux/debugfs.h>
#include <trace/events/kmem.h>
#include <trace/hooks/mm.h>
#include "internal.h"
@ -1823,6 +1824,8 @@ static inline struct slab *alloc_slab_page(gfp_t flags, int node,
if (page_is_pfmemalloc(folio_page(folio, 0)))
slab_set_pfmemalloc(slab);
trace_android_vh_slab_folio_alloced(order, flags);
return slab;
}