[PATCH -mm -v4 17/21] mm, THP, swap: Support PMD swap mapping for MADV_WILLNEED
From: Huang, Ying
Date: Thu Jun 21 2018 - 23:57:02 EST
- Next message: Huang, Ying: "[PATCH -mm -v4 12/21] mm, THP, swap: Support PMD swap mapping in swapoff"
- Previous message: Huang, Ying: "[PATCH -mm -v4 21/21] mm, THP: Avoid to split THP when reclaim MADV_FREE THP"
- In reply to: Huang, Ying: "[PATCH -mm -v4 21/21] mm, THP: Avoid to split THP when reclaim MADV_FREE THP"
- Next in thread: Huang, Ying: "[PATCH -mm -v4 12/21] mm, THP, swap: Support PMD swap mapping in swapoff"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: Huang Ying <ying.huang@xxxxxxxxx>
During MADV_WILLNEED, for a PMD swap mapping, if THP swapin is enabled
for the VMA, the whole swap cluster will be swapin. Otherwise, the
huge swap cluster and the PMD swap mapping will be split and fallback
to PTE swap mapping.
Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx>
Cc: "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx>
Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Shaohua Li <shli@xxxxxxxxxx>
Cc: Hugh Dickins <hughd@xxxxxxxxxx>
Cc: Minchan Kim <minchan@xxxxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx>
Cc: Zi Yan <zi.yan@xxxxxxxxxxxxxx>
Cc: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx>
---
mm/madvise.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/mm/madvise.c b/mm/madvise.c
index fc423d96d4d6..6c7a96357626 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -196,14 +196,36 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start,
pte_t *orig_pte;
struct vm_area_struct *vma = walk->private;
unsigned long index;
+ swp_entry_t entry;
+ struct page *page;
+ pmd_t pmdval;
+
+ pmdval = *pmd;
+ if (thp_swap_supported() && is_swap_pmd(pmdval) &&
+ !is_pmd_migration_entry(pmdval)) {
+ entry = pmd_to_swp_entry(pmdval);
+ if (!transparent_hugepage_swapin_enabled(vma)) {
+ if (!split_swap_cluster(entry, false))
+ split_huge_swap_pmd(vma, pmd, start, pmdval);
+ } else {
+ page = read_swap_cache_async(entry,
+ GFP_HIGHUSER_MOVABLE,
+ vma, start, false);
+ /* The swap cluster has been split under us */
+ if (page) {
+ if (!PageTransHuge(page))
+ split_huge_swap_pmd(vma, pmd, start,
+ pmdval);
+ put_page(page);
+ }
+ }
+ }
if (pmd_none_or_trans_huge_or_clear_bad(pmd))
return 0;
for (index = start; index != end; index += PAGE_SIZE) {
pte_t pte;
- swp_entry_t entry;
- struct page *page;
spinlock_t *ptl;
orig_pte = pte_offset_map_lock(vma->vm_mm, pmd, start, &ptl);
--
2.16.4
- Next message: Huang, Ying: "[PATCH -mm -v4 12/21] mm, THP, swap: Support PMD swap mapping in swapoff"
- Previous message: Huang, Ying: "[PATCH -mm -v4 21/21] mm, THP: Avoid to split THP when reclaim MADV_FREE THP"
- In reply to: Huang, Ying: "[PATCH -mm -v4 21/21] mm, THP: Avoid to split THP when reclaim MADV_FREE THP"
- Next in thread: Huang, Ying: "[PATCH -mm -v4 12/21] mm, THP, swap: Support PMD swap mapping in swapoff"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]