ANDROID: Add Interrupt Hook for madvise Compression

We introduce an interrupt hook in Android to manage memory compression
using madvise, improving user experience.

Currently, when a user returns to the home screen, memory compression is
triggered using madvise. The vma and PAGEOUT flag are sent to
process_madvise, initiating page reclaim.

However, if an app is re-opened soon after starting compression, the
reclaim process can cause read delays, leading to potential lag.

To resolve this, we propose to skip pte range traversal. By comparing
the vma's task uid with the current app's uid, we can identify and
interrupt the madvise operation for that vma.

Implementing this requires a vendor hook for should_end_madvise. This
allows us to skip traversal, enhancing user experience.

Bug: 307846869

Change-Id: If2bdbc200b7305e92f836353b7356aa115e00705
Signed-off-by: zihan ju <zihan.ju@transsion.com>
This commit is contained in:
zihan ju 2023-10-31 16:13:55 +08:00 committed by Treehugger Robot
parent 4e38f783da
commit 91d2427218
3 changed files with 9 additions and 0 deletions

View File

@ -474,6 +474,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_del_from_avail_list);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh___cgroup_throttle_swaprate);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_isolated_for_reclaim);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_should_end_madvise);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inactive_is_low);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snapshot_refaults);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_account_swap_pages);

View File

@ -302,6 +302,9 @@ DECLARE_HOOK(android_vh_madvise_cold_or_pageout,
DECLARE_HOOK(android_vh_page_isolated_for_reclaim,
TP_PROTO(struct mm_struct *mm, struct page *page),
TP_ARGS(mm, page));
DECLARE_HOOK(android_vh_should_end_madvise,
TP_PROTO(struct mm_struct *mm, bool *skip, bool *pageout),
TP_ARGS(mm, skip, pageout));
DECLARE_HOOK(android_vh_account_swap_pages,
TP_PROTO(struct swap_info_struct *si, bool *skip),
TP_ARGS(si, skip));

View File

@ -323,6 +323,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
LIST_HEAD(page_list);
bool allow_shared = false;
bool abort_madvise = false;
bool skip = false;
trace_android_vh_madvise_cold_or_pageout_abort(vma, &abort_madvise);
if (fatal_signal_pending(current) || abort_madvise)
@ -419,6 +420,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
if (!page)
continue;
trace_android_vh_should_end_madvise(mm, &skip, &pageout);
if (skip)
break;
/*
* Creating a THP page is expensive so split it only if we
* are sure it's worth. Split it if we are only owner.