ANDROID: vendor_hook: Add hook to skip swapcache

We want to skip swapcache in some scenarios to reduce
swap cache

Bug: 300857016
Change-Id: I8cbc45733d861be6f56628b40a1ef936cae3b45d
Signed-off-by: Xiaojun Ji <jixj@motorola.com>
This commit is contained in:
Xiaojun Ji 2023-09-14 15:48:05 +08:00 committed by Xiaojun Ji
parent 909a83a97d
commit 3718ea1e77
3 changed files with 7 additions and 1 deletions

View File

@ -496,6 +496,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dma_buf_stats_teardown);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wakeup_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_skip_swapcache);
/*
* For type visibility
*/

View File

@ -356,6 +356,9 @@ DECLARE_HOOK(android_vh_compact_finished,
DECLARE_HOOK(android_vh_madvise_cold_or_pageout_abort,
TP_PROTO(struct vm_area_struct *vma, bool *abort_madvise),
TP_ARGS(vma, abort_madvise));
DECLARE_HOOK(android_vh_skip_swapcache,
TP_PROTO(swp_entry_t entry, bool *skip),
TP_ARGS(entry, skip));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_MM_H */

View File

@ -3663,8 +3663,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
if (!page) {
struct swap_info_struct *si = swp_swap_info(entry);
bool skip_swapcache = false;
if (data_race(si->flags & SWP_SYNCHRONOUS_IO) &&
trace_android_vh_skip_swapcache(entry, &skip_swapcache);
if ((data_race(si->flags & SWP_SYNCHRONOUS_IO) || skip_swapcache) &&
__swap_count(entry) == 1) {
/* skip swapcache */
gfp_t flags = GFP_HIGHUSER_MOVABLE;