ANDROID: clear memory trylock-bit when page_locked.

Clearing trylock-bit of page shrinked by shrnk_page_list in advance
which avoids page in other scene with the trylock-bit.

The page with trylock-bit will be added ret_pages and handled in
trace_android_vh_handle_failed_page_trylock. If the page carried with
trylock-bit after unlocked by shrink_page_list will cause some error-issues
in other scene, so clear trylock-bit here.
trace_android_vh_page_trylock_get_result will clear trylock-bit and return
if page tyrlock failed in reclaim-process. Here we just want to clear
trylock-bit so that ignore page_trylock_result.

TODO: trace_android_vh_page_trylock_get_result should be changed to a
different hook which correctly reflects the usage here, which is to clear
the try-lock bit.

Fixes: 309a6bf81a ("ANDROID: vendor_hook: Add hook to not be stuck ro rmap lock in kswapd or direct_reclaim")

Bug: 240003372

Signed-off-by: Peifeng Li <lipeifeng@oppo.com>
Change-Id: Ifecd308573ef37a51e33856a0b3bb93cd67289ac
This commit is contained in:
Peifeng Li
2023-04-11 14:59:40 +08:00
committed by Treehugger Robot
parent 805cf52991
commit 5e6e9c596b

View File

@@ -1409,6 +1409,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
unsigned int nr_reclaimed = 0;
unsigned int pgactivate = 0;
bool do_demote_pass;
bool page_trylock_result;
memset(stat, 0, sizeof(*stat));
cond_resched();
@@ -1831,6 +1832,21 @@ activate_locked:
count_memcg_page_event(page, PGACTIVATE);
}
keep_locked:
/*
* The page with trylock-bit will be added ret_pages and
* handled in trace_android_vh_handle_failed_page_trylock.
* If the page carried with trylock-bit after unlocked by
* shrink_page_list will cause some error-issues in other
* scene, so clear trylock-bit here.
* trace_android_vh_page_trylock_get_result will clear
* trylock-bit and return if page tyrlock failed in
* reclaim-process. Here we just want to clear trylock-bit
* so that ignore page_trylock_result.
* TODO: trace_android_vh_page_trylock_get_result should be
* changed to a different hook which correctly reflects the
* usage here, which is to clear the try-lock bit.
*/
trace_android_vh_page_trylock_get_result(page, &page_trylock_result);
unlock_page(page);
keep:
list_add(&page->lru, &ret_pages);