Skip to contentSkip to conversation

mm, THP, swap: support to reclaim swap space for THP swapped out

PATCH In review [email protected] 1 participant 1 message Sep 6, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 67/119 mm, THP, swap: support to reclaim swap space for THP swapped out

From: Huang Ying <[email protected]>
Subject: mm, THP, swap: support to reclaim swap space for THP swapped out

The normal swap slot reclaiming can be done when the swap count reaches SWAP_HAS_CACHE. But for the swap slot which is backing a THP, all swap slots backing one THP must be reclaimed together, because the swap slot may be used again when the THP is swapped out again later. So the swap slots backing one THP can be reclaimed together when the swap count for all swap slots for the THP reached SWAP_HAS_CACHE. In the patch, the functions to check whether the swap count for all swap slots backing one THP reached SWAP_HAS_CACHE are implemented and used when checking whether a swap slot can be reclaimed.

To make it easier to determine whether a swap slot is backing a THP, a new swap cluster flag named CLUSTER_FLAG_HUGE is added to mark a swap cluster which is backing a THP (Transparent Huge Page). Because THP swap in as a whole isn't supported now. After deleting the THP from the swap cache (for example, swapping out finished), the CLUSTER_FLAG_HUGE flag will be cleared. So that, the normal pages inside THP can be swapped in individually.

[[email protected]: fix swap_page_trans_huge_swapped on HDD]
Cc Johannes Weiner <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Shaohua Li <[email protected]>
Cc "Kirill A . Shutemov" <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Dan Williams <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Ross Zwisler <[email protected]> [for brd.c, zram_drv.c, pmem.c]
Cc Vishal L Verma <[email protected]>
Cc Naoya Horiguchi <[email protected]>

---

 include/linux/swap.h |    1 
 mm/swapfile.c        |   78 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 72 insertions(+), 7 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-thp-swap-support-to-reclaim-swap-space-for-thp-swapped-out +1 -0
diff -puN include/linux/swap.h~mm-thp-swap-support-to-reclaim-swap-space-for-thp-swapped-out include/linux/swap.h
@@ -188,6 +188,7 @@ struct swap_cluster_info {
 };
 #define CLUSTER_FLAG_FREE 1 /* This cluster is free */
 #define CLUSTER_FLAG_NEXT_NULL 2 /* This cluster has no next cluster */
+#define CLUSTER_FLAG_HUGE 4 /* This cluster is backing a transparent huge page */
 
 /*
  * We assign a cluster to each CPU, so each CPU can allocate swap entry from
mm/swapfile.c renamed from mm/swapfile.c~mm-thp-swap-support-to-reclaim-swap-space-for-thp-swapped-out +71 -7

144 lines not on this page · raw message

_