From 8e6550add2d133105d93fe04c0e2f2fe4df36cb9 Mon Sep 17 00:00:00 2001 From: Tangquan Zheng Date: Tue, 29 Aug 2023 17:44:48 +0800 Subject: [PATCH] ANDROID: vendor_hooks: Add tune swappiness hook in get_scan_count() Add hook in get_scan_count() for customized swappiness. Partial cherry-pick of aosp/2119426. Bug: 297985476 Change-Id: I9d4074cf1a4097ff2a96be04646a01624cbd8dc3 Signed-off-by: Tangquan Zheng --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/vmscan.h | 3 +++ mm/vmscan.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 1f31007f8c65..9a310923f1ed 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -322,6 +322,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around_migrate_folio); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_test_clear_look_around_ref); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_scan_type); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_swappiness); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_signal_whether_wake); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_check); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_freeze_whether_wake); diff --git a/include/trace/hooks/vmscan.h b/include/trace/hooks/vmscan.h index d66ab9279266..e6594ca0d299 100644 --- a/include/trace/hooks/vmscan.h +++ b/include/trace/hooks/vmscan.h @@ -43,6 +43,9 @@ enum scan_balance; DECLARE_HOOK(android_vh_tune_scan_type, TP_PROTO(enum scan_balance *scan_type), TP_ARGS(scan_type)); +DECLARE_HOOK(android_vh_tune_swappiness, + TP_PROTO(int *swappiness), + TP_ARGS(swappiness)); #endif /* _TRACE_HOOK_VMSCAN_H */ /* This part must be outside protection */ #include diff --git a/mm/vmscan.c b/mm/vmscan.c index b12f027ff098..6be9bee3eca1 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2966,6 +2966,8 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, goto out; } + + trace_android_vh_tune_swappiness(&swappiness); /* * Global reclaim will swap to prevent OOM even with no * swappiness, but memcg users want to use this knob to