From patchwork Wed Oct 10 07:19:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10634097 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 7B86C14DB for ; Wed, 10 Oct 2018 07:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51AF3294F6 for ; Wed, 10 Oct 2018 07:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 434F4296AF; Wed, 10 Oct 2018 07:27:17 +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 1F6BD294F6 for ; Wed, 10 Oct 2018 07:27:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0D3D6B0003; Wed, 10 Oct 2018 03:27:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DBAE76B0008; Wed, 10 Oct 2018 03:27:14 -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 CBF276B000A; Wed, 10 Oct 2018 03:27:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 899256B0003 for ; Wed, 10 Oct 2018 03:27:14 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id i189-v6so3041376pge.6 for ; Wed, 10 Oct 2018 00:27:14 -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=rslseqXvqXyhQLlVzgKsZG8t3WvvfzaMGcv0UgKXarE=; b=GnmYiRXKcwABMpc+ar/Akbw981fCp4/A56gXXnh2siyRPSSMTGyV+ZwZ7rM58yVMLV qDBD6/HZ4WCndSh2izhRsJO/QAZOy3qLLxTE5nj2ycJh26U9Uxh51yfcuac7WXoWFk3b 3LS4O10UeNYRPzHcvcnwtiiHBYkpnZLWn52B/LE3oqwbSLaFN9w6gv/frJo0OIxOGp14 Nb4HeKZEMH+XkO3Q/jSKC7vxgy4xrHhfae7B1VcB9Jefcc8Y/ua1xO0TX1nZO4BHue2m zb6ufAZlTvA1rbI2DL5Cs5Yxi4q4qbOowCxNxlYHeuqSOzmR25PWLNs6IGIb4Un7IxIt ssQA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 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: ABuFfoiT4jyuQcySYndlhPTiVWd0qCUtmVoLPS1tREPVA+z4IWuDJFBw OfeALlrsAI6qgl1HmNKFzc+DdAaX/gooAQYW8+gypQ2wJh7OBWPN90Ird1PpEubMQBS11Fgm5sh VS9gzxozOGw7K7h7JLv33UlSYS8nY/fengeghhzmQhYTtRusmW1TXs9soE9KV8RqgFw== X-Received: by 2002:a63:4a64:: with SMTP id j36-v6mr28777355pgl.168.1539156434200; Wed, 10 Oct 2018 00:27:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV634jmJnR7ApxtwfXEN9vxL5EU3T7VIsZ3Km8QmllDMee+BOYm7s5+bkqFuqIRi5ylgI1KMx X-Received: by 2002:a63:4a64:: with SMTP id j36-v6mr28777311pgl.168.1539156433379; Wed, 10 Oct 2018 00:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539156433; cv=none; d=google.com; s=arc-20160816; b=NtGMAYksJRH0Yfw/GOxHXQ2uxjWWFlrOMGHKSzQAlnMtTNJHCmkq3a78JxYYmXrXgB f8P10ofBZrgBGS5TkPxJR8H3ZUl3+KDGXm8x//Sz7O53wbBWCfbuMRDr5v/EHeKAVp4Y QzRIKH4SlA5zRzhS805SB3hD6xHgWvCNjOUnruQaPT3j94eA43Z5lGEZiuddeqQ2LCuy cugJSalQv08JTrObmb4L3LoiCYTXAJcR/zoSre8GVw/USjJDX6swah2laIB+ShifNLT0 IQZk3+VpoZH8dUezl6HyssjAQNXn7xhKBZjOvlDVJO4Ck2xkSyRITchq96OijcZXVBUX ZtFA== 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=rslseqXvqXyhQLlVzgKsZG8t3WvvfzaMGcv0UgKXarE=; b=LxhsWEd9ZEqVenuGFEgqmHM1yXoT92woBXy1YPFwESybTXwhl3Fi3QHHZ2kDGC4Qt7 3cGm17ZIEtwWUQkeLnoLHaqoWPDAbXzOwwxK449BV0dVVfS6QW8DhgnPLkrYI8nDN4K5 8PO7KctaAnKjuY5XC5p10ZNq2Egiit/T2DiKSFOlvCPZgB0jgftKIy8tBDesi6XQvd50 2iYnkLBqDk4AfxJjBtzK/hcI73AdjrJODQEXNyve6XT9qcIuPQ2CgUX8BnoQbuJWOcRD HcFHYGnJrzrphP/LX9sNTu9yLM6QzZyP42QQlzKIPoKHnXhFEvMSaTbtd+2KRfCREa5l fCAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id e2-v6si30331496pfh.64.2018.10.10.00.27.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 00:27:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 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 orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2018 00:27:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,363,1534834800"; d="scan'208";a="93869956" Received: from yhuang-mobile.sh.intel.com ([10.239.198.87]) by fmsmga002.fm.intel.com with ESMTP; 10 Oct 2018 00:18:55 -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 -V6 01/21] swap: Enable PMD swap operations for CONFIG_THP_SWAP Date: Wed, 10 Oct 2018 15:19:04 +0800 Message-Id: <20181010071924.18767-2-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20181010071924.18767-1-ying.huang@intel.com> References: <20181010071924.18767-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 5657a20e0c59..eb1e9d17371b 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 b1006cdf3aff..44f7d72010fd 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -424,6 +424,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