ANDROID: mm: Add a vendor hook for slab page alloced checking

The vendor hook provides a way to monitor the usage status of the slab.
It will be a necessary maintenance measure to know whether the slab is abnormal in advance,
and can help us to debug/show slabinfo.

Bug: 289328049
Test: build pass
Change-Id: I594bc58149d7cf25b5f268d4da56955a3b9a5aa9
Signed-off-by: Fangzheng Zhang <fangzheng.zhang@unisoc.com>
This commit is contained in:
Fangzheng Zhang
2023-06-29 17:12:37 +08:00
committed by Treehugger Robot
parent 692292011e
commit d75757f165
4 changed files with 13 additions and 0 deletions

View File

@@ -440,6 +440,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rmqueue_smallest_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_one_page_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_use_cma_first_check);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_page_alloced);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_order_alloced);
/*
* For type visibility
*/

View File

@@ -211,6 +211,12 @@ DECLARE_HOOK(android_vh_alloc_highpage_movable_gfp_adjust,
DECLARE_HOOK(android_vh_anon_gfp_adjust,
TP_PROTO(gfp_t *gfp_mask),
TP_ARGS(gfp_mask));
DECLARE_HOOK(android_vh_slab_page_alloced,
TP_PROTO(struct page *page, size_t size, gfp_t flags),
TP_ARGS(page, size, flags));
DECLARE_HOOK(android_vh_kmalloc_order_alloced,
TP_PROTO(struct page *page, size_t size, gfp_t flags),
TP_ARGS(page, size, flags));
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */

View File

@@ -1002,6 +1002,9 @@ void *kmalloc_order(size_t size, gfp_t flags, unsigned int order)
mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B,
PAGE_SIZE << order);
}
trace_android_vh_kmalloc_order_alloced(page, size, flags);
ret = kasan_kmalloc_large(ret, size, flags);
/* As ret might get tagged, call kmemleak hook after KASAN. */
kmemleak_alloc(ret, size, 1, flags);

View File

@@ -1794,6 +1794,8 @@ static inline struct page *alloc_slab_page(struct kmem_cache *s,
else
page = __alloc_pages_node(node, flags, order);
trace_android_vh_slab_page_alloced(page, s->size, flags);
return page;
}