From patchwork Wed May 9 08:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10388685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 67C1C60353 for ; Wed, 9 May 2018 08:40:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57C2628E29 for ; Wed, 9 May 2018 08:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49DAF28E89; Wed, 9 May 2018 08:40:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4B7F28E1D for ; Wed, 9 May 2018 08:40:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A74446B04AD; Wed, 9 May 2018 04:40:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A23A46B04AF; Wed, 9 May 2018 04:40:04 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EF876B04B0; Wed, 9 May 2018 04:40:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 48D166B04AD for ; Wed, 9 May 2018 04:40:04 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id l85so24073593pfb.18 for ; Wed, 09 May 2018 01:40:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=3ZzLloSB2+bT79w24CysRz2CYqCB4fAK5OfwVM4vocE=; b=C94kykUafttsN0f2rN7WVvyHi5+zKZX+P3h2yXchcSdQ2Usv9f1ysUGWXUrBuAW4eD 5BoJ0G+LhAnQwT9J/E348zzJhRyV2CdMbAE+q0Ms/BwmN/Ps7qmUGBGBGafvdi8OQN/9 gEf7W6U0lUpv1HeGA3DEW4Bs/zZ7X/wWv6R0Gc9hcEr+Pjrzd5Zox0lo9IWkN99W98qM rJPIGKPJrWSlGR4N95NLn2UFCSBhucBaRHHbk6YWR+e2aM5uLhTt5jklsAxKgRgVZsh2 B+h2kROMogxxBtkSJLF5TFPsvFW0ps/JGIOAKilp+sarKN97qNIIL8m+KBGN7L/e5IJt vI6Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com X-Gm-Message-State: ALQs6tCjFaeOM679ZIXSsmxurli81VocpiuywQxYpA+uCYr6e5zBWKVr tnRetzFfAZBIuUHr11zRneJn/K5UCjOSxJbJKuBtfSpRxiV/x7GeyOcHxX0ZvaAA9NBgMPOg97s TDUCFdfMhw/Qpu6QzAaD/0q4n45Opt2BOBIJkrnJnqkr75iX94RrybNkr6qu26gWUHQ== X-Received: by 10.98.82.129 with SMTP id g123mr20488326pfb.22.1525855203937; Wed, 09 May 2018 01:40:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZquR9/PlCov7jO8TappmVgt+aoHyvRF90rIZE5M+OzWi2WnVWvyLxAevCISjhaUFTWWmtHO X-Received: by 10.98.82.129 with SMTP id g123mr20488293pfb.22.1525855202958; Wed, 09 May 2018 01:40:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525855202; cv=none; d=google.com; s=arc-20160816; b=M1j47MvgXxFrpASijLiFElvLs2TrVEZ+31iabs/svpyYVYy3iPNDEL1rIiPFZdCGb8 1sYt0Jd+2PiohOpvA4et8NdEJnQmi6MezpmVJcBWa1VtMOt/NU3hCkGITOygH+AMqb3l rApcsF6BN7U312zdb/AC9fMKkMtib1UyuMmyCIwvSeVCcrhXJEmjrndVzil4bJdg4Hvk g6skuJhx3mMyAruW6PYKzrZdBDVwxptVdRrBLCsJUi7zkJ91ruBV1YF53ASA+NTJU1Ef LP8kKnJdhcH4aeSSFwo2uuJ+emk8vY2jkkksBEoaonsNOeqgmW0OcLPOJPNfN5JLAvic X15A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=3ZzLloSB2+bT79w24CysRz2CYqCB4fAK5OfwVM4vocE=; b=Fz5aL0OvBgJatuUJvHSX0pruElG5H6FYxdQZdHp+Pb2GYuy1xp4M58B/ZAPAgHX9eR nTH+gpcWJpjlLqYFe33qi10HzjPOB34b/TMax51rR6wh2Tx8sqLCxgDlQ2mC3mAz9rQB 7IDG8+DCJP/rXtKhaese8I5yKu0XERsfrlZuzGf08oI/Mq9CnMNnxNtBZUZjq7H6InrC lzGKC1QWH4JePCj70RQn8iFmTrAjLUdeYesVM4P/s89hUu4KEJICuD0j28ol3X4uwuH5 LGMPt+r6DihpLf4Pyo4OWpa9eOi8VS8/7m4M3v6FcSPjCQG4TQ+jhJERnUlD7A9M1P4o tUbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id z9-v6si21682595plk.94.2018.05.09.01.40.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 01:40:02 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) client-ip=134.134.136.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=ying.huang@intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 01:40:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,381,1520924400"; d="scan'208";a="52769769" Received: from yhuang-gentoo.sh.intel.com ([10.239.193.148]) by fmsmga004.fm.intel.com with ESMTP; 09 May 2018 01:39:59 -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 -V2 17/21] mm, THP, swap: Support PMD swap mapping for MADV_WILLNEED Date: Wed, 9 May 2018 16:38:42 +0800 Message-Id: <20180509083846.14823-18-ying.huang@intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180509083846.14823-1-ying.huang@intel.com> References: <20180509083846.14823-1-ying.huang@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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);