[PATCH 1/2] mm, frontswap: Fix frontswap_map issue with THP

From: Hui Zhu
Date: Mon Oct 14 2019 - 23:49:34 EST


Shrink will try to use frontswap interface store the THP as a normal
page in __frontswap_store:
if (ret == 0) {
__frontswap_set(sis, offset);
inc_frontswap_succ_stores();
} else {
It should set all bits with THP.

This commit set all bits with THP.

Signed-off-by: Hui Zhu <teawaterz@xxxxxxxxxxxxxxxxx>
---
mm/frontswap.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mm/frontswap.c b/mm/frontswap.c
index 60bb20e..f07ea63 100644
--- a/mm/frontswap.c
+++ b/mm/frontswap.c
@@ -274,8 +274,12 @@ int __frontswap_store(struct page *page)
break;
}
if (ret == 0) {
- __frontswap_set(sis, offset);
- inc_frontswap_succ_stores();
+ int i, nr = hpage_nr_pages(page);
+
+ for (i = 0; i < nr; i++) {
+ __frontswap_set(sis, offset + i);
+ inc_frontswap_succ_stores();
+ }
} else {
inc_frontswap_failed_stores();
}
--
2.7.4