From 0daa6e1781c408fa5d2a2d6dfe1d2a569efa2d62 Mon Sep 17 00:00:00 2001 From: huangzq2 Date: Sat, 13 Mar 2021 19:39:45 +0800 Subject: [PATCH] mm: zram: free the swap slot when swap in The zram pages on backing store can not be freed when swap in, becase they have swap cache. So before these pages become drity, they will be always read from swap cache or backing store. If these pages happens to be swap out again, the swap cahce will be deleted, then they can only be loaded from backing store, not zram. Change-Id: I59a4ef1f7b6fb4ce803a56a7eaae7693a69780d4 Signed-off-by: huangzq2 Reviewed-on: https://gerrit.mot.com/1900258 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1902453 Reviewed-by: Yonghui Jia Reviewed-by: Zhizhong Ge Reviewed-by: Huosheng Liao --- mm/page_io.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index e91f008af794..6a88629a5806 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -398,11 +398,12 @@ int swap_readpage(struct page *page, bool synchronous) ret = bdev_read_page(sis->bdev, swap_page_sector(page), page); if (!ret) { - if (trylock_page(page)) { - swap_slot_free_notify(page); - unlock_page(page); - } - + /* + * Moto huangzq2: We either remove the trylock_page or use lock_page + * here, becuase trylock will always return false due to page_endio + * in zram_rw_page. + */ + swap_slot_free_notify(page); count_vm_event(PSWPIN); goto out; }