From patchwork Fri Dec 14 06:27:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10730639 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9D9A91E for ; Fri, 14 Dec 2018 06:28:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B62542A21D for ; Fri, 14 Dec 2018 06:28:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8FEE2BE76; Fri, 14 Dec 2018 06:28:40 +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 B1DEF2AAE1 for ; Fri, 14 Dec 2018 06:28:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68FB68E01BB; Fri, 14 Dec 2018 01:28:34 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 63F948E0014; Fri, 14 Dec 2018 01:28:34 -0500 (EST) 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 52FAA8E01BB; Fri, 14 Dec 2018 01:28:34 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 109138E0014 for ; Fri, 14 Dec 2018 01:28:34 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id a10so2932122plp.14 for ; Thu, 13 Dec 2018 22:28:34 -0800 (PST) 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=7Xky8fq8ebLSHZnapWHSGLx0rwhW1evYiCK055LhMTQ=; b=mljgiMz2BXQRAda7LoUFdo9XuSy3X5lPIcwHLTOrhlsQLAYcYSnp54NjholMivFj1o qOzcjCPhOogC9zn636lbQpOXHoqwdTy2/eAd8CpBSnNcmuopQhbNUEkagl8FGGJZNz+I OB0wD7p2LsnYCTHKeY7Q0ZHZqAhTRE7Xu+wVx5G1+29TqJ3T9irdUv409YHR/Qhq/3Pp 0QcdIomaNw0dIPqYvV8WB4K+KqiwBpSaKh/WFUzGXwyPASrDe669eIo1xDdAKiBvicai Sb4Juw5gFsiYjBr+sEAaooVMejksU7S622MXqz/s0WKFgTRpT2tSipDa5qaSB6tLT8vl FmDQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AA+aEWYmfh36SLzsgfD+bV8LKKHNPBBxgHFbHrJmvlbodJ+Ycufuy0/0 XR0UY5GfS8S/nTvWBSN8nXYCoLL2VkERtBnYTjx0p2YFCQz2ia/vda/g/ruY7i9GnJDCNj8osZ8 Bf/J9fcloU1ZaSTLdb6RoiggHF5fSQawUxkW1cIzNKv/oNH7sgc/4MNH03jGyem/L4g== X-Received: by 2002:a63:9501:: with SMTP id p1mr1649316pgd.149.1544768913687; Thu, 13 Dec 2018 22:28:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/WEDPWJEAiBcTa7owlQE9xioVoXvT9jWl44qZ9DnSyRkdXh54xnD1d3gL/mKKzJ55VY1Jfl X-Received: by 2002:a63:9501:: with SMTP id p1mr1649296pgd.149.1544768913054; Thu, 13 Dec 2018 22:28:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544768913; cv=none; d=google.com; s=arc-20160816; b=wsCZjAgcpR6kJK3+zQyVo3a0F0CRZ+XMCrJ6J87vzhSPrf4GWh97WI4t6EY/YKHhw0 hCQZRDxKyCe4zmuC5b23GAFBy8/F/vTlkaF0xGX9hN/pyzikle1MPbxOUExKFTQJ6s+1 ntfFYht/k5eHOqIC166BNAVRfQmWHYJhdtwG42A8dw9+NRpAsZinws7bl2wmXg3sEvZh Svyw5Tmf5VjJ4pmBkfJLtSRzXOwiaFf/iHiOAfJaUbcz+SRenxRuNaQ8eZ2VZ7b14f3B KwSgrwbjyOzX/wrrd+Brt+JfW8pav8B43NCaiu6Cu4bQkgQ4EJ6H4z78+FDbfQdtl2XI v0rw== 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; bh=7Xky8fq8ebLSHZnapWHSGLx0rwhW1evYiCK055LhMTQ=; b=ZMbLCOJIlX0x+4iqtGDHcwma0bBtA08BcRSvDXS0TyZwEgDyRfM7PCjNWOqppI3UzO l8U040bEW6NOUfbS6fJYakx4KO4+yE0HQn9yYgs5echLw6sw+StjkqRMrVXoWVkNp2mj Mnq1OA730UelGBmJf5UCNeveN+bnzHRQOrx98WpqPXCfsTCn/GJwDWhwySlPwpm4hJz6 aj18V1rZNwnXSxmdLflQoD8io5MSnBULDc5zq72vBGsaw+msh+xcr26swSF767EpMVeT fqf0kJ4ayVLuCunpmb+O/smlJZ3P2TX1Fisb8s66pLGHgO26W5oFdDFF8iNGD/8/yb4J ODxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id d8si1744446plo.196.2018.12.13.22.28.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 22:28:33 -0800 (PST) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Dec 2018 22:28:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,351,1539673200"; d="scan'208";a="125841094" Received: from yhuang-mobile.sh.intel.com ([10.239.197.226]) by fmsmga002.fm.intel.com with ESMTP; 13 Dec 2018 22:28:30 -0800 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 , Daniel Jordan Subject: [PATCH -V9 18/21] swap: Support PMD swap mapping for MADV_WILLNEED Date: Fri, 14 Dec 2018 14:27:51 +0800 Message-Id: <20181214062754.13723-19-ying.huang@intel.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181214062754.13723-1-ying.huang@intel.com> References: <20181214062754.13723-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 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 Cc: Daniel Jordan --- mm/madvise.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index c1845dab2dd4..84d055c19dd4 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 (IS_ENABLED(CONFIG_THP_SWAP) && 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, 0)) + split_huge_swap_pmd(vma, pmd, start, pmdval); + } else { + page = read_swap_cache_async(entry, + GFP_HIGHUSER_MOVABLE, + vma, start, false); + if (page) { + /* The swap cluster has been split under us */ + 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);