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 <huangzq2@motorola.com>
Reviewed-on: https://gerrit.mot.com/1900258
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1902453
Reviewed-by: Yonghui Jia <jiayh2@motorola.com>
Reviewed-by: Zhizhong Ge <gezz1@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
This commit is contained in:
huangzq2 2021-03-13 19:39:45 +08:00 • committed by Xiaojun Ji
commit 0daa6e1781

View file

@ -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;
}