From patchwork Fri Dec 7 05:41:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10717441 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 B7D02109C for ; Fri, 7 Dec 2018 05:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5D122EC6E for ; Fri, 7 Dec 2018 05:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 995672EC7A; Fri, 7 Dec 2018 05:41:36 +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 4E7672EC6E for ; Fri, 7 Dec 2018 05:41:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 681596B7E90; Fri, 7 Dec 2018 00:41:33 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 607AD6B7E92; Fri, 7 Dec 2018 00:41:33 -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 4A7DC6B7E93; Fri, 7 Dec 2018 00:41:33 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 01FB96B7E90 for ; Fri, 7 Dec 2018 00:41:33 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id 202so1838094pgb.6 for ; Thu, 06 Dec 2018 21:41:32 -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=+XqQ+IrzcJdX8WfYpVhooNemD9YpwZhT7nm5N93usAA=; b=APgXCcNUgOEthdhOLN9LfYVe+4sXWyLkToQF3jnqNQ0lLMFLxENxa5sGieuBIOaLYl NlHblwLtHKdB7Lik4ZvUQ07qB/QQNOFd6laS74c+URvDEMVBpQuW4Enjfbmf9dmMj12V UjZnMgSSggJj1CsqF/dRB06IRxTeHYPp0xApH8yA1U8tBr3nWXuT7chCXA8HtX/89vRB GQQVrefhbd0uBDfJINLAFi3kPlmoohT8p4hg4U7s/ZRSFBbrT1Sd1QXmH/5ZLxP9LxqX pBW92uEebDKRQ4KjR0icY/TsJfkBtlOZbEAtowhCrgR/vfh89gGDHbDABtcrIIrf3QTR uo3Q== 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+aEWbuV+5WuVzPpqZGGH6f/9NJeYq4PfVewQz5D+cMj+y4/G6EAEEg oysbt8Z9jf4uhddZTMyj82y1If4k3jJGit54XWtHmcTgK8aFgV0VoIL2hjIJioMoroUw1sObRij itczql7yx7QrBI6ndSKD+BUwlDCKYeoK4w4fhjCthyVtwPstNqWEfKTpxXRUL5xlPWA== X-Received: by 2002:a17:902:f24:: with SMTP id 33mr899812ply.65.1544161292657; Thu, 06 Dec 2018 21:41:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/VBL+8AWWLjdChoyydmsTKwxQQU8gdARIAFNKKxIRF3rxGVMZpldOxbFA8sbQLBycoexEHg X-Received: by 2002:a17:902:f24:: with SMTP id 33mr899778ply.65.1544161291414; Thu, 06 Dec 2018 21:41:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544161291; cv=none; d=google.com; s=arc-20160816; b=TO+Gxpk8g4/ghvZcRSC9FM+wXevr7lgTwfaCxHYkyMeWUgeaABl3Fi2yAVyw/i+coK Tvmj7DuCY4eHAHX0CW0gTfHFQneK7jLxT3wsUKrD1+VHTPdtWa5qRnJswFbxzpRhc0wp XPJWQo0GwQo2wjAjifAX9WnrmOzG4MO3IuJEstqFapnH4Xc+JjPCr7CkaeFyh8JY/qWT HiorJ33nIOrK2Hu43/Xdi6NVg5eO+TrYASYDntYhP1nCoaICq1mxMWrLReBNoTajLkCs KOGTBLT9QNcVBaNd48i10CouqpMqhcv6n0s7tOacwtn37J0cgXzJyWaQvw/K0r04tPaZ tP5Q== 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=+XqQ+IrzcJdX8WfYpVhooNemD9YpwZhT7nm5N93usAA=; b=goN2etXTMAOzoWCRi1YGLmn4324o37sEUwvred/bvdxYYm860Qcy6bUX927OEPnpg8 fQOXxzuXk0qS0WCTmagyFCJEBbz3/fOYu7imF/Sbvk8Rtg92ZUOq6stvTjwNB5vXQtMj jSl6RPgYvRvCA+6WFnSwgHHcn7HkvMUDMWhiLImhUvW6f79MGd30GXIuex6BTSrK0tWs XbheBvmMz34QUkqySmDGPzg49+1oumJ6v0/lSxOqu3cjymcQl++1aeYGgSCb0Xm0eMEU nf8CAZxtFpdMgUh1URSvh6F/7+L03z/U6Y50Lz127JbJd2ZKpLVLtCsecLMuqxEbtqEk S24w== 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.41.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 21:41:31 -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:41:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,324,1539673200"; d="scan'208";a="105567183" Received: from yhuang-mobile.sh.intel.com ([10.239.196.133]) by fmsmga007.fm.intel.com with ESMTP; 06 Dec 2018 21:41:28 -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 01/21] swap: Enable PMD swap operations for CONFIG_THP_SWAP Date: Fri, 7 Dec 2018 13:41:01 +0800 Message-Id: <20181207054122.27822-2-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 Currently, "the swap entry" in the page tables is used for a number of things outside of actual swap, like page migration, etc. We support the THP/PMD "swap entry" for page migration currently and the functions behind this are tied to page migration's config option (CONFIG_ARCH_ENABLE_THP_MIGRATION). But, we also need them for THP swap optimization. So a new config option (CONFIG_HAVE_PMD_SWAP_ENTRY) is added. It is enabled when either CONFIG_ARCH_ENABLE_THP_MIGRATION or CONFIG_THP_SWAP is enabled. And PMD swap entry functions are tied to this new config option instead. Some functions enabled by CONFIG_ARCH_ENABLE_THP_MIGRATION are for page migration only, they are still enabled only for that. 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 --- arch/x86/include/asm/pgtable.h | 2 +- include/asm-generic/pgtable.h | 2 +- include/linux/swapops.h | 44 ++++++++++++++++++---------------- mm/Kconfig | 8 +++++++ 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 40616e805292..e830ab345551 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1333,7 +1333,7 @@ static inline pte_t pte_swp_clear_soft_dirty(pte_t pte) return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY); } -#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION +#ifdef CONFIG_HAVE_PMD_SWAP_ENTRY static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd) { return pmd_set_flags(pmd, _PAGE_SWP_SOFT_DIRTY); diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 359fb935ded6..20aab7bfd487 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -675,7 +675,7 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm, #endif #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY -#ifndef CONFIG_ARCH_ENABLE_THP_MIGRATION +#ifndef CONFIG_HAVE_PMD_SWAP_ENTRY static inline pmd_t pmd_swp_mksoft_dirty(pmd_t pmd) { return pmd; diff --git a/include/linux/swapops.h b/include/linux/swapops.h index 4d961668e5fc..905ddc65caa3 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -254,17 +254,7 @@ static inline int is_write_migration_entry(swp_entry_t entry) #endif -struct page_vma_mapped_walk; - -#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION -extern void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, - struct page *page); - -extern void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, - struct page *new); - -extern void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd); - +#ifdef CONFIG_HAVE_PMD_SWAP_ENTRY static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd) { swp_entry_t arch_entry; @@ -282,6 +272,28 @@ static inline pmd_t swp_entry_to_pmd(swp_entry_t entry) arch_entry = __swp_entry(swp_type(entry), swp_offset(entry)); return __swp_entry_to_pmd(arch_entry); } +#else +static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd) +{ + return swp_entry(0, 0); +} + +static inline pmd_t swp_entry_to_pmd(swp_entry_t entry) +{ + return __pmd(0); +} +#endif + +struct page_vma_mapped_walk; + +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION +extern void set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, + struct page *page); + +extern void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, + struct page *new); + +extern void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd); static inline int is_pmd_migration_entry(pmd_t pmd) { @@ -302,16 +314,6 @@ static inline void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, static inline void pmd_migration_entry_wait(struct mm_struct *m, pmd_t *p) { } -static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd) -{ - return swp_entry(0, 0); -} - -static inline pmd_t swp_entry_to_pmd(swp_entry_t entry) -{ - return __pmd(0); -} - static inline int is_pmd_migration_entry(pmd_t pmd) { return 0; diff --git a/mm/Kconfig b/mm/Kconfig index 25c71eb8a7db..d7c5299c5b7d 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -422,6 +422,14 @@ config THP_SWAP For selection by architectures with reasonable THP sizes. +# +# "PMD swap entry" in the page table is used both for migration and +# actual swap. +# +config HAVE_PMD_SWAP_ENTRY + def_bool y + depends on THP_SWAP || ARCH_ENABLE_THP_MIGRATION + config TRANSPARENT_HUGE_PAGECACHE def_bool y depends on TRANSPARENT_HUGEPAGE