From patchwork Mon Sep 3 07:21:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10585551 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 E358913AC for ; Mon, 3 Sep 2018 07:22:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD53129189 for ; Mon, 3 Sep 2018 07:22:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF4EB2956E; Mon, 3 Sep 2018 07:22:35 +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 128BA29189 for ; Mon, 3 Sep 2018 07:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C6D16B66A7; Mon, 3 Sep 2018 03:22:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2762A6B66A8; Mon, 3 Sep 2018 03:22:34 -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 18D036B66A9; Mon, 3 Sep 2018 03:22:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id CA78C6B66A7 for ; Mon, 3 Sep 2018 03:22:33 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id a26-v6so10196678pgw.7 for ; Mon, 03 Sep 2018 00:22:33 -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=L8kQtIEtW4lg7vG3ygekpUfrSnZGs3I3qFVOP5bkFF8=; b=Q6SKVWTVH5hw3JWaBOp310XRlEdzhdEvbOM1Kya1VxhIjOtaj7p5uMLPQCWsA002MH 8stIR/8l2wt48YBkh94DWU1YvDFTe4IpOS3B0fQO972GrLLhKJUBU9Z/qA0x1qVEX5T8 fYqvtdpWt0/WwujpnrPFK2Jh3yNBJFRqim+h/G2z1TbxwjcOpKS7gGXpOmdle7qDmVfZ gaVeEs31EDP1jcAt356Qnzzcg61HWmhVgbftSCakcB9p705/09n7yma+wr4xC8Pccti/ 5v/neMML7lWkYVWXiS0uSzhlfUUfJh3sANxS+9JP1BSBjRZgQxy0bDA+pA1HtcfVHAkS YHuw== 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: APzg51AoNHViRS+HOX+6EZAvuA1IWdIkWWKp1M1qPT4Z50FtFyhI++js 9vGrp72sVfFJU0nlxr6G3NeB7h6DSXKjsNjo31+eM48qdWcePauMVOxyJh8Ufkb902exKai0YGz bvWJRaT+xrvCTg0/6Txk5QNccWcktBmGkP5n042f/LHuv4ALXHjLtpNWO3TX+Cw305A== X-Received: by 2002:a65:48c6:: with SMTP id o6-v6mr24327892pgs.99.1535959353516; Mon, 03 Sep 2018 00:22:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZhLQrqWyMiIrYQiX9ueCygIh7Z0qYUYK9hdqYY0bIKSPWt547V81/VPPblUkja9Dp1iFjm X-Received: by 2002:a65:48c6:: with SMTP id o6-v6mr24327866pgs.99.1535959352875; Mon, 03 Sep 2018 00:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535959352; cv=none; d=google.com; s=arc-20160816; b=TT9Y8TqrUcvPTDM61RS8lRAqxea782um/YFM/wFYbJaFZockscrViGlAGsK+dtrOiX osiwO/+VPM1exe9uoYGTiV04q6d3Qo/ECCK0g5Si6pdGWmWhnNbriblOOh5wFsBCJReh BBmCvsJcKtDOFvHLzc2ROjX+X4nALQh1bmv88GmBlnOseuMJmtmV4SaI8I9sHrMV5wL8 yvCPQn+o96izoEBmZ9GkghMiBuEA2fUPbKa5K5Z1EoLGcYDNbmSrO7uk69fON6Q/PIuA vDTR+ZrWoS6jdw0G5Od++hgm6LFCUy6Wn1SJUO6KZxTWdY3t3mINwSdQiO9fSTaKnlXD CqHA== 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=L8kQtIEtW4lg7vG3ygekpUfrSnZGs3I3qFVOP5bkFF8=; b=GXNGRLlYAd1EaUi/zhQ0MMHJGBqJTSxIaJzlAnlmBbSa311+shMkpCyuvTSvEUj0X8 +/hLJtCzA9wI5eEk5qjJ1KM9sMFFuBnG4h2qTkHA+MfzhRQJ26r2Ei/BYsWS7pTZ7Ry2 XJX4pWEWPbs+MijgCae4n/RuL1zP6ecDAXOmk6VzbBb9I8Gla6r9Pbdi0h+RpAHtM9KT pYoTA8JEkGQLXJowO17PCrFyCJhbLhyYa2UE2eVqVnChIzJ6CL74DYxa77dqnOp7sQKB se9id0ZqfuYPJjQWfRuQFn+0uZlWoES2jzUCBr+GNVUpcdIIMBBnMv4WhGQy7eZnIzCA nAyg== 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 r24-v6si4679764pgg.403.2018.09.03.00.22.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 00:22:32 -0700 (PDT) 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 orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2018 00:22:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,324,1531810800"; d="scan'208";a="70146848" Received: from yhuang-mobile.sh.intel.com ([10.239.196.86]) by orsmga008.jf.intel.com with ESMTP; 03 Sep 2018 00:22:14 -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 , Daniel Jordan Subject: [PATCH -V5 01/21] swap: Enable PMD swap operations for CONFIG_THP_SWAP Date: Mon, 3 Sep 2018 15:21:54 +0800 Message-Id: <20180903072214.24602-2-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180903072214.24602-1-ying.huang@intel.com> References: <20180903072214.24602-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 e4ffa565a69f..194f97dc4583 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1334,7 +1334,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 88ebc6102c7c..bf207f915967 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 ce5782ff3110..0163ff069fd1 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -430,6 +430,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