Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp561703imm; Wed, 23 May 2018 01:33:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoTzsJ//aR1hMFWfQPOCJ3fD89XKp1SOVy8F0z8As6WqzxyNe4kGh2OhJBV68IE6+USf1mT X-Received: by 2002:a17:902:b589:: with SMTP id a9-v6mr1940360pls.161.1527064429162; Wed, 23 May 2018 01:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527064429; cv=none; d=google.com; s=arc-20160816; b=BWc/QKBQj9qcAwWhekqmxzwjEAj8lqT4sf4PNfveOAafukwHIUcOf/Ake0VGh72Xco Z+SZHtLQTiByNT1C4l3SCfHPoa6FNiz21EYJebyHrHICaIBloPU0M52eoB2a5t+8HAPC e1i3wq/aR4PDObdZ2aNIuWAwX3mrsGxNVN61gCM0ABQho0RN1XxdzRHhrrc4OoovjpX3 PjuFA9Kg1NDgb6mo3vxliYJB/lpXsoyu+WnA2fUmznR2coDQlcmBbRkbJx6W478nfOnT hqYkeP9Ay13TsiJjWutv1znloMuPp7uVS+Xyga7ZJY4qojr7m0eG7J26ZxaiBC+7wuXq qWdA== 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=K0C6gygmq55jUhquMIDZFFbicfMHgTKbDvsJfvEhTcM=; b=sXl+o6JLfPMeubA0HMLLDeoAzXrdbWPXnx4GFNO+Ww9U9VLeUOOOxwUdr92AXP/0Sf TDUljXYeRENL6+d+SnFwBFFebSe7WYtbYZwvJtRkHLNKJ6EubDe02Nj5aPwT5jOfwZ/t 4GIFz0sJyooOBTSEMdSXi7iAKg3cNfq/cOAMx7vMrBpqO1PZFN2JxW/QMVQuKFAKlIsN yoNUbG7NYWeMSKSdA/NARmYmVyvXmMVC6nizi09pCQUC6G3ASBstlugZ/JEEfvgPhcNl V/9aydALm3w8juX44sxAasiZGaOEFTA/Abq1rNI2VE673tsrcLcyLZ3c1TsBwO10cEWT lrvg== 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 s61-v6si18294936plb.271.2018.05.23.01.33.34; Wed, 23 May 2018 01:33:49 -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 S1754583AbeEWIdZ (ORCPT + 99 others); Wed, 23 May 2018 04:33:25 -0400 Received: from mga03.intel.com ([134.134.136.65]:7695 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754331AbeEWI0e (ORCPT ); Wed, 23 May 2018 04:26:34 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2018 01:26:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,432,1520924400"; d="scan'208";a="57725948" Received: from yhuang6-ux31a.sh.intel.com ([10.239.197.97]) by fmsmga001.fm.intel.com with ESMTP; 23 May 2018 01:26:31 -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 Subject: [PATCH -mm -V3 01/21] mm, THP, swap: Enable PMD swap operations for CONFIG_THP_SWAP Date: Wed, 23 May 2018 16:26:05 +0800 Message-Id: <20180523082625.6897-2-ying.huang@intel.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180523082625.6897-1-ying.huang@intel.com> References: <20180523082625.6897-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 --- 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 f1633de5a675..0dff03085197 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.1