From patchwork Fri Jun 22 03:51:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10481119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1DFF60380 for ; Fri, 22 Jun 2018 03:55:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B47A928F91 for ; Fri, 22 Jun 2018 03:55:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A89B228F98; Fri, 22 Jun 2018 03:55:15 +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 E99AF28F91 for ; Fri, 22 Jun 2018 03:55:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 719C26B0005; Thu, 21 Jun 2018 23:55:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6C5746B0006; Thu, 21 Jun 2018 23:55:11 -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 56A3E6B0008; Thu, 21 Jun 2018 23:55:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id 11C1E6B0005 for ; Thu, 21 Jun 2018 23:55:11 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id i12-v6so2114164pgt.13 for ; Thu, 21 Jun 2018 20:55:11 -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=WIQMCkq+6NmugFcmQlmkxPKDAtRU6DNJ1vG6zC3NdlU=; b=NFGfq474ujJvz/hnudwAWIMnYGxInylWXz4UbzTxgHzwbu8qaimSpAtn3NAzu96SG/ g1ELv+Fwnc4GL7TbTD4QNZbePZJmruC4gMyDkTYw2Ee2jKAIe/6UvcSPzrd2nzvu5K5S O8Ilb+6kSieFj+n6J3MusNwqUBPrWbnwuTm1Z9MKiDf8olE0ZvTN0eV67f32PmSsK8du qvQmB2ToE4zEjm9FipDRgST5t+RMx/y5/TEGidWYKWJGz2XNwYCL64b0VcTfUX2/6MX3 qLZtYh5A3XDEqpvkE/UfycmR7NZvfwkCE/3M77UnfyVqFwQuw1ettv0SK+IJD9FyVNMu 0o0w== 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: APt69E2j0PL3EZnUc93ItdUvd2wZNG/KK818h15GRWrywbpFrM0EUfrw u4s1CdvzbzB6LSWbgtesW79/XosFSt+/TPvQroE14nvemq6u6vODBPnM24IAbG9pkWs7IqY3PyD EsCof/OIKHbOWsDuKxs+2azG2Pe7C2zqnhJxRzCg1/UqVOJN3naZ80+p/j1ModfbuMA== X-Received: by 2002:a17:902:a3:: with SMTP id a32-v6mr31678043pla.62.1529639710762; Thu, 21 Jun 2018 20:55:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ3ygi2wgrASHNZN8aLI+p0M2bcTN4K7vB3D/ABpHiIqnfUEWLtODsQEb075y0GdU8bdXDO X-Received: by 2002:a17:902:a3:: with SMTP id a32-v6mr31678009pla.62.1529639710005; Thu, 21 Jun 2018 20:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529639709; cv=none; d=google.com; s=arc-20160816; b=eIVkdkVZvheDpr938ZUMNWZe4QBY8OL9TF9rWODviKYsgIp9ToXdkbtkEBbBANymPd ppbD/gsl6TpwMSSNd//kteeJTTF6ddWLeBPrzLS7tvEO1EjxeaaGeTRdwzEAFmXXvur3 8YefP60KctXq8S11o8JoX5X4o+Z73NH6FZTu1QfhhqwlF0XuWb+T+Nl6Dg+032ZeqTMb SkEFKZhUIiUBhiQFcts9FgOvmy/n+07csbHP1a2D2YnQhz9Nfm18M1XdhGM9qJo4vHP0 LUcKk+8pvS5+xxqi1lEqXI3uwQRJibQQQQBynHV0nJmxtnVge1oSGspFf7bz+nDhApf3 XMsQ== 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=WIQMCkq+6NmugFcmQlmkxPKDAtRU6DNJ1vG6zC3NdlU=; b=yoOF323ViR7e8ORyaN1ZBxkhZ1kHtgh69XGt02naC9bGg4uIjkyCgfuAQgH0DYBLdz dMRJztF4EEuG3/W7lNC0XFW1LEOlcrYG8m6jykJfp8SIYSVRw3NehdTBMZelVs18bIr5 1rGHEP0Bx+hxJpKE/462aLoxtn+9fhIEgWlCcJde29yycNniFa5YlAt0KLWr9eUFi5Z/ r/GpHGKpDeUzF2Ik4L80Zxuyew7bFhd4jT3oZGdSQvuhfKNX6Zm8/y4GlS81FrzRG4jP Y4RpaOkm28TB5yx7lYBP5Pm+GrkTasPi9wTtn4ApCj4vAXNCwpS7lhIm+A1np2mVB3uV fAqg== 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 q13-v6si6671342plr.220.2018.06.21.20.55.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 20:55:09 -0700 (PDT) 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 fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 20:55:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,255,1526367600"; d="scan'208";a="65335051" Received: from wanpingl-mobl.ccr.corp.intel.com (HELO yhuang6-ux31a.ccr.corp.intel.com) ([10.254.212.200]) by fmsmga004.fm.intel.com with ESMTP; 21 Jun 2018 20:55:07 -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 -mm -v4 01/21] mm, THP, swap: Enable PMD swap operations for CONFIG_THP_SWAP Date: Fri, 22 Jun 2018 11:51:31 +0800 Message-Id: <20180622035151.6676-2-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180622035151.6676-1-ying.huang@intel.com> References: <20180622035151.6676-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 From: Huang Ying Previously, the PMD swap operations are only enabled for CONFIG_ARCH_ENABLE_THP_MIGRATION. Because they are only used by the THP migration support. We will support PMD swap mapping to the huge swap cluster and swapin the THP as a whole. That will be enabled via CONFIG_THP_SWAP and needs these PMD swap operations. So enable the PMD swap operations for CONFIG_THP_SWAP too. 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 ++++++++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 99ecde23c3ec..13bf58838daf 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1224,7 +1224,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 +#if defined(CONFIG_ARCH_ENABLE_THP_MIGRATION) || defined(CONFIG_THP_SWAP) 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 f59639afaa39..bb8354981a36 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 +#if !defined(CONFIG_ARCH_ENABLE_THP_MIGRATION) && !defined(CONFIG_THP_SWAP) 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 1d3877c39a00..f1be5a52f5c8 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -258,17 +258,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); - +#if defined(CONFIG_ARCH_ENABLE_THP_MIGRATION) || defined(CONFIG_THP_SWAP) static inline swp_entry_t pmd_to_swp_entry(pmd_t pmd) { swp_entry_t arch_entry; @@ -286,6 +276,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) { @@ -306,16 +318,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;