Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp558347imm; Wed, 23 May 2018 01:29:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrIyQggx0HV2imcuMe7oIsAqnAEl47h1vGAGAl03N0ZJRFjsOHMYeRHY0+G/vpUWOLFFJ3P X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr1989283plu.22.1527064191845; Wed, 23 May 2018 01:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527064191; cv=none; d=google.com; s=arc-20160816; b=qMMPMXXkggEovSpjo5SDQoSCnknFe+MMd2LlxGJnK8P1gHEXVF+Rzi7M+9cjaRQCwh uPurkpHnTWSO/jWcvSMHCksA9Dq0vBXGWkg7uIYDS9yzOSrJKa+AliMhIfLBow2OwDiO QIs96FjMRcNPdhIEBc+CQhcFpCHvw3Rlu1Zu9yo0RoFuYrpqqOWYUg7ENoUC0lgmqbbk tKGW2cUxu6W+VnZcAUb2kpeRshWGUPaKtrMqpvJA7YiIskkypp0xbFE0/ibzrApSpBzq 3rPQ8a85GZrNgv4EU8IJQD7ZuY777cc70pxyg3gYBmJHKPshT64pvbBcpwpvv1nWfhIi px0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=3ZzLloSB2+bT79w24CysRz2CYqCB4fAK5OfwVM4vocE=; b=iuJBWSamQoiPP/k3xkeVlsa7B83fGkMRCwIR36QL9OCbTAxH2D/Vd2VA5dQjxI5wsX O7mrEI65LeN00bPSwdyd/OxJEjvXnf6ui1f8Sud0k5JKWPrzYQJzmJ48p0zwTj/M4RDr YG7u0+sBkVYN88q8bWgckFnu7Tdm1Y4kyvWu/0Bo8nFudOYZiM9cfxgJn/WMJ3KHkCho /zcbSfARHL1DVG1lpLuGBrSfI94ojjNgCDtt1zpgvgkhn3iGq5vgEYbcL8Us1pbuqg6S S86bqIeyRtgrWYfuY+SPhCnRXgCT6xUqfCFb1/4d9S5aYr4G+KYzMpWLbdnDjxsxTAUy 51/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10-v6si11286576pge.483.2018.05.23.01.29.37; Wed, 23 May 2018 01:29:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754466AbeEWI3A (ORCPT + 99 others); Wed, 23 May 2018 04:29:00 -0400 Received: from mga03.intel.com ([134.134.136.65]:7732 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754467AbeEWI1W (ORCPT ); Wed, 23 May 2018 04:27:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2018 01:27:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,432,1520924400"; d="scan'208";a="57726260" Received: from yhuang6-ux31a.sh.intel.com ([10.239.197.97]) by fmsmga001.fm.intel.com with ESMTP; 23 May 2018 01:27:17 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , "Kirill A. Shutemov" , Andrea Arcangeli , Michal Hocko , Johannes Weiner , Shaohua Li , Hugh Dickins , Minchan Kim , Rik van Riel , Dave Hansen , Naoya Horiguchi , Zi Yan Subject: [PATCH -mm -V3 17/21] mm, THP, swap: Support PMD swap mapping for MADV_WILLNEED Date: Wed, 23 May 2018 16:26:21 +0800 Message-Id: <20180523082625.6897-18-ying.huang@intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180523082625.6897-1-ying.huang@intel.com> References: <20180523082625.6897-1-ying.huang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Ying 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" Cc: "Kirill A. Shutemov" Cc: Andrea Arcangeli Cc: Michal Hocko Cc: Johannes Weiner Cc: Shaohua Li Cc: Hugh Dickins Cc: Minchan Kim Cc: Rik van Riel Cc: Dave Hansen Cc: Naoya Horiguchi Cc: Zi Yan --- mm/madvise.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index e03e85a20fb4..44a0a62f4848 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.1