ANDROID: vendor_hooks: mm: add hook to count the number pages
allocated for each slab Add the tracing interface on the kmalloc_large allocation path, which can detect the number of pages allocated by the slab, and if exceeds a threshold, trigger a panic or other actions. Bug: 312897430 Change-Id: I5575d0e4f91dab1c6e074f3e907fee8ea9327fd7 Signed-off-by: Fangzheng Zhang <fangzheng.zhang@unisoc.com>
This commit is contained in:
parent
4326c78f84
commit
aa71a02cf3
@ -363,3 +363,4 @@ 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);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_large_alloced);
|
||||
|
@ -199,6 +199,9 @@ DECLARE_HOOK(android_vh_adjust_kvmalloc_flags,
|
||||
DECLARE_HOOK(android_vh_slab_folio_alloced,
|
||||
TP_PROTO(unsigned int order, gfp_t flags),
|
||||
TP_ARGS(order, flags));
|
||||
DECLARE_HOOK(android_vh_kmalloc_large_alloced,
|
||||
TP_PROTO(struct page *page, unsigned int order, gfp_t flags),
|
||||
TP_ARGS(page, order, flags));
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
@ -1102,6 +1102,8 @@ static void *__kmalloc_large_node(size_t size, gfp_t flags, int node)
|
||||
PAGE_SIZE << order);
|
||||
}
|
||||
|
||||
trace_android_vh_kmalloc_large_alloced(page, order, flags);
|
||||
|
||||
ptr = kasan_kmalloc_large(ptr, size, flags);
|
||||
/* As ptr might get tagged, call kmemleak hook after KASAN. */
|
||||
kmemleak_alloc(ptr, size, 1, flags);
|
||||
|
Loading…
Reference in New Issue
Block a user