Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp378827imm; Thu, 21 Jun 2018 21:00:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImpGPxGKPI20uFn4ncVHwvCKfekfJUEB2YkOBaL6HsTjoAvtA+bM2UyA5D8G6fF3MKdGpx X-Received: by 2002:a63:6f89:: with SMTP id k131-v6mr25004585pgc.345.1529640052024; Thu, 21 Jun 2018 21:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529640051; cv=none; d=google.com; s=arc-20160816; b=lxL29o4ee+5lXJ2L1IwWKMli+hcqZ7IKY/vDY9HnA1uVKVuhc3B3bu/DFIz4fnxsLO BkPSZ3xcMDCM++gOlSRHcW4tlbjOTHhr2L5mXLziBVojJL8CCfdlTx5OfVI8MqFeaT6r Y8arkAIMb8d8nXJWpGcmYZiSC+NXjRa1tWQIThrkvA0W11ditSyx1WtFhf5FviA/GiDN xfU2KVOav9qleUUnFDlZE/xke0Bl4xq2tZjM1OG7z1RXq6Na4Q1RKJIvnShWrDYQafd2 XJH6C2ZTOqN+cXOyR+XwjdSxNldqy0IjDc8RLQpS9UvBDGir681t0Zov7YYFV8AIxEtV rw+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WIQMCkq+6NmugFcmQlmkxPKDAtRU6DNJ1vG6zC3NdlU=; b=JKHN1i5pPB5KhBCVx3CetC8vvgiAoioCD9k3NT+9BJpPlaSNJstOMXa9Yn6/MNiCVu 1Leg18claZIEE/OSKqcjvtjskAZkX+1mIOzmgJ9KpKgWRfvN6CcLrE4Cy6WK0z8IEPS6 aaLuUXoIZOFhc4J6X3pzFXpnriiP2RS5cUP8ELG+RKHbEzSsc9uRv1Mg9y6cg5+cSLnD Gn70n8HIPBX5D01rRv5SQQ6lFFWd815WTx2ppkAgwdUuHA7znySwh+3ukjdemq1FNwQz EvryMtcIohiNuefr4gk7HaMqkc2QyQIIhRKJZlBQjK1B8MF3w4RHwvc40Y083iu6WVmq IlOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13-v6si5160441pgp.341.2018.06.21.21.00.37; Thu, 21 Jun 2018 21:00:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934442AbeFVDzL (ORCPT + 99 others); Thu, 21 Jun 2018 23:55:11 -0400 Received: from mga11.intel.com ([192.55.52.93]:48405 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934399AbeFVDzJ (ORCPT ); Thu, 21 Jun 2018 23:55:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.16.4