From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751476AbdCRJvi (ORCPT ); Sat, 18 Mar 2017 05:51:38 -0400 Received: from terminus.zytor.com ([65.50.211.136]:55280 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751105AbdCRJvh (ORCPT ); Sat, 18 Mar 2017 05:51:37 -0400 Date: Sat, 18 Mar 2017 02:50:43 -0700 From: "tip-bot for Kirill A. Shutemov" Message-ID: Cc: steve.capper@linaro.org, aneesh.kumar@linux.vnet.ibm.com, dann.frazier@canonical.com, torvalds@linux-foundation.org, mingo@kernel.org, bp@alien8.de, peterz@infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, riel@redhat.com, kirill.shutemov@linux.intel.com, dave.hansen@intel.com, hpa@zytor.com, catalin.marinas@arm.com, tglx@linutronix.de Reply-To: bp@alien8.de, linux-kernel@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, dann.frazier@canonical.com, aneesh.kumar@linux.vnet.ibm.com, steve.capper@linaro.org, mingo@kernel.org, hpa@zytor.com, dave.hansen@intel.com, kirill.shutemov@linux.intel.com, catalin.marinas@arm.com, tglx@linutronix.de, akpm@linux-foundation.org, riel@redhat.com In-Reply-To: <20170316152655.37789-4-kirill.shutemov@linux.intel.com> References: <20170316152655.37789-4-kirill.shutemov@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] mm/gup: Move page table entry dereference into helper function Git-Commit-ID: 0005d20b2ff1e501e186b3b3bc587085ac305fdc X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0005d20b2ff1e501e186b3b3bc587085ac305fdc Gitweb: http://git.kernel.org/tip/0005d20b2ff1e501e186b3b3bc587085ac305fdc Author: Kirill A. Shutemov AuthorDate: Thu, 16 Mar 2017 18:26:51 +0300 Committer: Ingo Molnar CommitDate: Sat, 18 Mar 2017 09:48:02 +0100 mm/gup: Move page table entry dereference into helper function This is a preparation patch for the transition of x86 to the generic GUP_fast() implementation. On x86 PAE, page table entry is larger than sizeof(long) and we would need to provide a helper that can read the entry atomically. Signed-off-by: Kirill A. Shutemov Cc: Andrew Morton Cc: Aneesh Kumar K . V Cc: Borislav Petkov Cc: Catalin Marinas Cc: Dann Frazier Cc: Dave Hansen Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Rik van Riel Cc: Steve Capper Cc: Thomas Gleixner Cc: linux-arch@vger.kernel.org Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20170316152655.37789-4-kirill.shutemov@linux.intel.com Signed-off-by: Ingo Molnar --- mm/gup.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a62a778c..e83db38 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1189,6 +1189,17 @@ struct page *get_dump_page(unsigned long addr) */ #ifdef CONFIG_HAVE_GENERIC_RCU_GUP +#ifndef gup_get_pte +/* + * We assume that the PTE can be read atomically. If this is not the case for + * your architecture, please provide the helper. + */ +static inline pte_t gup_get_pte(pte_t *ptep) +{ + return READ_ONCE(*ptep); +} +#endif + #ifdef __HAVE_ARCH_PTE_SPECIAL static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, int write, struct page **pages, int *nr) @@ -1198,14 +1209,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, ptem = ptep = pte_offset_map(&pmd, addr); do { - /* - * In the line below we are assuming that the pte can be read - * atomically. If this is not the case for your architecture, - * please wrap this in a helper function! - * - * for an example see gup_get_pte in arch/x86/mm/gup.c - */ - pte_t pte = READ_ONCE(*ptep); + pte_t pte = gup_get_pte(ptep); struct page *head, *page; /*