From patchwork Fri Dec 7 05:41:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10717473 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 36BF9109C for ; Fri, 7 Dec 2018 05:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24A1E2EC81 for ; Fri, 7 Dec 2018 05:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18F732EC8B; Fri, 7 Dec 2018 05:42:21 +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 934B12EC81 for ; Fri, 7 Dec 2018 05:42:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAD576B7EB1; Fri, 7 Dec 2018 00:42:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D321B6B7EB3; Fri, 7 Dec 2018 00:42:17 -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 B8B8A6B7EB4; Fri, 7 Dec 2018 00:42:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 61A1C6B7EB1 for ; Fri, 7 Dec 2018 00:42:17 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id l131so1846948pga.2 for ; Thu, 06 Dec 2018 21:42:17 -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=eHCfojupe637JnGFz/yRaskx3CwIUMdVvylmAhyeWmM=; b=V3oVBuFImEFkCQ4xwK4T4rCWpgZUnN0UoIEq8I6oTmenn/EOZmqkkTR+uHnnha0D4E Mm+htb2n2OOx0vL6H/d1sp1z2NCK3buFe+zV8r7bAC14WBf763KoA8R9c0fP/2d5bu8Y v7dEGe+lxUFRY+lyCFguZNxl1cNQD7/MI/O9vAN2qIUCAwrlcYYmdcmtSxuzlgaMOh+I 5r9zEry6VDTeABvmqIZBGSMsqeVwFQHbmvs4pNK34BVPEeAbS7qb1VBTgDMGS4/6erHc JCFUVJVIryy6lQIRnBGuV0OOnmEaOpsguginHwb+mJ3EcIc91MNmvXyRy9BW9PxluS72 Gz9w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 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+aEWZIh/LnsanGiPy/3SQhJc0SgmMYhTPXNilkRPEcCRgVftl9tF28 /JzDXnTOmN+Gg389RPfXWy7NAza5IrCNq1b1uxqYs4Kk7SztI4QtJi3hirfaDQGtkZwhLmtd+sq T9XQ1bKtueT0Hl+gBoXUIGnU/PIW54HhwJ49jzcjVYnzhf+VtO+TNVqQgyJKnD2qqbQ== X-Received: by 2002:a17:902:442:: with SMTP id 60mr846066ple.73.1544161337061; Thu, 06 Dec 2018 21:42:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/XWcktqEAEcO7AS46jiQa4+VLqxjc8Kt7UCB9g0l1Ib8qa6zlKZdXofK5IkqMu+UbNQQrqt X-Received: by 2002:a17:902:442:: with SMTP id 60mr846041ple.73.1544161336066; Thu, 06 Dec 2018 21:42:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544161336; cv=none; d=google.com; s=arc-20160816; b=JoWlpNgomXJkrF4rS8YbMJnGhiIRIcqWXvd9B2IoNuxkT7tooVx0nPWLhcYCV7VFA/ SEefETJnTsVenzCfZ5ZgGSGlV19TmJrnX3hAhoTD4IwL23Cr5UbT1OoCWgN/FiI8pUCr BcSBdr+LC291ARfb/FEnJXEq8kc7yPsY5cHOwuyEQRx4AQn6REbiVattlwkCC6YOcAcT cxwkfMcFYnkVcCynuBmuRgRb8Wxpu9kmhAl7u9s0pI0nWReWDkxWq4w3IXPSwAiP9LNb PHKkIPAh4oZrxjgHRTu2sJZFjI98kpETscLhCu44QzueYYvfhi0daHVPw/TP3GYQOScG IFnw== 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=eHCfojupe637JnGFz/yRaskx3CwIUMdVvylmAhyeWmM=; b=PbwQYJmildv72sNWp4j3jYjmBOr9T700IX68YKYY2l1q5hPH7ohzATSeWbB06xZJoi w4QrF59/v3ylnx1RI4u+5H5k4NKf8jFPIUZGcmd9yv3D6WzwSCTUR38kzroZtTQUSv/d bUBYm8pYfmhNMvrO3/QiXjjheVvEeiIxMU0+/x3ubcxzrDbWK+O3NN90PBEliakrQsj4 43aUEo9T7qmhs8VFwzBOwulXSebq6vIA1ZvzEd4He1fRdClkAhUcaw52y/Ikpha2bluE yHU1IIvwAHpAYI17ZTYEjxJuHVbPxfxTt2u//RORRjUPl0IgsDuvMEO3C/iPQZXlViQj eB0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id cf16si2126256plb.227.2018.12.06.21.42.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 21:42:16 -0800 (PST) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 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 fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2018 21:42:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,324,1539673200"; d="scan'208";a="105567329" Received: from yhuang-mobile.sh.intel.com ([10.239.196.133]) by fmsmga007.fm.intel.com with ESMTP; 06 Dec 2018 21:42:12 -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 -V8 17/21] swap: Support PMD swap mapping for MADV_WILLNEED Date: Fri, 7 Dec 2018 13:41:17 +0800 Message-Id: <20181207054122.27822-18-ying.huang@intel.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181207054122.27822-1-ying.huang@intel.com> References: <20181207054122.27822-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 0c1f96c605f8..52d27e04a204 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);