aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2021-12-21 22:05:32 -0500
committerAndrea Arcangeli <aarcange@redhat.com>2023-11-11 22:03:36 -0500
commit26544b601846d246db8702ead4eb6d98c9a24e2c (patch)
treeb7def54d0e86705c367a94d0fbd37b6712fc3103
parent9088166cc63dc38823b5e9d1cb163f8e6f1dacfa (diff)
downloadaa-26544b601846d246db8702ead4eb6d98c9a24e2c.tar.gz
mm: KSM: improve reuse_swap_page for CONFIG_SWAP=n
There's no apparent reason why the SWAP=y version should have the PageKsm check while the non-swap version shouldn't have it. It's non consistent. It's safer to be consistent. PageKsm can still materialize with SWAP=n and it should be not reused. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
-rw-r--r--include/linux/swap.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h
index c86cd15bb424c4..42e38bbba605c7 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -674,8 +674,12 @@ static inline bool can_read_pin_swap_page(struct page *page)
return page_trans_huge_mapcount(page, NULL) <= 1;
}
-#define reuse_swap_page(page, total_map_swapcount) \
- (page_trans_huge_mapcount(page, total_map_swapcount) == 1)
+static inline bool reuse_swap_page(struct page *page, int *total_map_swapcount)
+{
+ if (unlikely(PageKsm(page)))
+ return false;
+ return page_trans_huge_mapcount(page, total_map_swapcount) <= 1;
+}
static inline int try_to_free_swap(struct page *page)
{