ANDROID: vendor_hooks: add hook and OEM data for slab shrink

Some shrinker add lock in count_objects() may cause lock contention
issues and lead all task stall on slab shrink. Add vendor hook in
do_shrink_slab() for shrinker->count_objects() latency measuring.

Add 3 oem data in shrink_control struct. Two is for
shrinker->count_objects() and shrinker->scan_objects() latency
measuring, other one to store priority, some shrinker know the reclaimer
priority can control the memory reclaim more better.

Bug: 188684131

Change-Id: I80e9d90179bb52a99c54d9a067c6fcee835bb2ad
Signed-off-by: rongqianfeng <rongqianfeng@vivo.com>
This commit is contained in:
rongqianfeng 2021-05-21 10:30:14 +08:00 committed by Todd Kjos
commit bf769b7216
4 changed files with 9 additions and 0 deletions

View file

@ -240,6 +240,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_get_unmapped_area_include_reserved_zone)
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_slowpath);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_mem);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_print_slabinfo_header);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_shrink_slab);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cache_show);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpci_override_toggling);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_chk_contaminant);

View file

@ -2,6 +2,8 @@
#ifndef _LINUX_SHRINKER_H
#define _LINUX_SHRINKER_H
#include <linux/android_vendor.h>
/*
* This struct is used to pass information from page reclaim to the shrinkers.
* We consolidate the values for easier extention later.
@ -31,6 +33,7 @@ struct shrink_control {
/* current memcg being shrunk (for memcg aware shrinkers) */
struct mem_cgroup *memcg;
ANDROID_OEM_DATA_ARRAY(1, 3);
};
#define SHRINK_STOP (~0UL)

View file

@ -22,6 +22,9 @@ DECLARE_HOOK(android_vh_shrink_slab_bypass,
DECLARE_HOOK(android_vh_tune_inactive_ratio,
TP_PROTO(unsigned long *inactive_ratio, int file),
TP_ARGS(inactive_ratio, file))
DECLARE_HOOK(android_vh_do_shrink_slab,
TP_PROTO(struct shrinker *shrinker, struct shrink_control *shrinkctl, int priority),
TP_ARGS(shrinker, shrinkctl, priority));
#endif /* _TRACE_HOOK_VMSCAN_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View file

@ -445,6 +445,8 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
: SHRINK_BATCH;
long scanned = 0, next_deferred;
trace_android_vh_do_shrink_slab(shrinker, shrinkctl, priority);
if (!(shrinker->flags & SHRINKER_NUMA_AWARE))
nid = 0;