From patchwork Thu Aug 28 14:45:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 36240 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CB4BC202DD for ; Thu, 28 Aug 2014 14:49:34 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 142sf5167730ykq.8 for ; Thu, 28 Aug 2014 07:49:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=5oxTVCMbsKGYv8OgqrzhXvgzt4eQiJOjfYFBEkHL9Jo=; b=F3H5NG3J6cbmY+kGNvguYSRPLhrzJTHJTHrKuknRfJRvOdAeNwysqxd3zhSXpV7AaV G+2LFQvx08S/NEahUfqxmxooQ8WOgHQN00NMrlEP7EylhAU2HwXkgNci+uzzwDrLDGI6 OkizME/5otxmUMoSRRxP0wkcqw4pUCKaGTSrw9nmA49BD2XM1D11J1iz+ac5AhO1AFfi OK+1lnsG1l+HB4tNT4SmZMKzpBM1ti4RRXCrB0UkU2R+SsBEzBYUcZ5VBQT2gaQGKta2 ygpqd1kCFCN99smb2hx2DfHDQQUYPO49Av35I6S66L1DwcndX2FE6ubB7DTdljZ5s/cO AnZQ== X-Gm-Message-State: ALoCoQnLYCP99/rhoigPwd6QfHfIpZ3E4h8wawxVXp9jjhhrbk+GgzMBEHRIHpCnLA9UEgyzQThK X-Received: by 10.224.21.129 with SMTP id j1mr2325179qab.7.1409237374647; Thu, 28 Aug 2014 07:49:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.17 with SMTP id 17ls575178qgm.63.gmail; Thu, 28 Aug 2014 07:49:34 -0700 (PDT) X-Received: by 10.52.246.198 with SMTP id xy6mr3092391vdc.7.1409237374431; Thu, 28 Aug 2014 07:49:34 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id j6si3745685vcs.30.2014.08.28.07.49.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 07:49:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id hy4so933278vcb.33 for ; Thu, 28 Aug 2014 07:49:34 -0700 (PDT) X-Received: by 10.52.94.108 with SMTP id db12mr3160632vdb.8.1409237374335; Thu, 28 Aug 2014 07:49:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp248716vcb; Thu, 28 Aug 2014 07:49:33 -0700 (PDT) X-Received: by 10.66.161.169 with SMTP id xt9mr6739557pab.102.1409237373416; Thu, 28 Aug 2014 07:49:33 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id bx1si6946814pad.129.2014.08.28.07.49.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Aug 2014 07:49:31 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XN0yG-0004K2-V1; Thu, 28 Aug 2014 14:46:40 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XN0xb-0003kr-4V for linux-arm-kernel@bombadil.infradead.org; Thu, 28 Aug 2014 14:45:59 +0000 Received: from mail-we0-f170.google.com ([74.125.82.170]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XN0xY-000561-05 for linux-arm-kernel@lists.infradead.org; Thu, 28 Aug 2014 14:45:57 +0000 Received: by mail-we0-f170.google.com with SMTP id p10so885531wes.15 for ; Thu, 28 Aug 2014 07:45:31 -0700 (PDT) X-Received: by 10.194.57.237 with SMTP id l13mr5962415wjq.102.1409237130207; Thu, 28 Aug 2014 07:45:30 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id js2sm10538153wjc.9.2014.08.28.07.45.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Aug 2014 07:45:29 -0700 (PDT) From: Steve Capper To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, linux@arm.linux.org.uk, linux-arch@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org Subject: [PATCH V3 5/6] arm64: mm: Enable HAVE_RCU_TABLE_FREE logic Date: Thu, 28 Aug 2014 15:45:06 +0100 Message-Id: <1409237107-24228-6-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1409237107-24228-1-git-send-email-steve.capper@linaro.org> References: <1409237107-24228-1-git-send-email-steve.capper@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140828_154556_059806_D262EDFF X-CRM114-Status: GOOD ( 13.03 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on casper.infradead.org summary: Content analysis details: (-2.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.170 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.170 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: mark.rutland@arm.com, anders.roxell@linaro.org, peterz@infradead.org, gary.robertson@linaro.org, will.deacon@arm.com, mgorman@suse.de, dann.frazier@canonical.com, Steve Capper , christoffer.dall@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: steve.capper@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In order to implement fast_get_user_pages we need to ensure that the page table walker is protected from page table pages being freed from under it. This patch enables HAVE_RCU_TABLE_FREE, any page table pages belonging to address spaces with multiple users will be call_rcu_sched freed. Meaning that disabling interrupts will block the free and protect the fast gup page walker. Signed-off-by: Steve Capper Tested-by: Dann Frazier Acked-by: Catalin Marinas --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/tlb.h | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index fd4e81a..ce9062b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -54,6 +54,7 @@ config ARM64 select HAVE_PERF_EVENTS select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP + select HAVE_RCU_TABLE_FREE select HAVE_SYSCALL_TRACEPOINTS select IRQ_DOMAIN select MODULES_USE_ELF_RELA diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h index 62731ef..a82c0c5 100644 --- a/arch/arm64/include/asm/tlb.h +++ b/arch/arm64/include/asm/tlb.h @@ -23,6 +23,20 @@ #include +#include +#include + +#ifdef CONFIG_HAVE_RCU_TABLE_FREE + +#define tlb_remove_entry(tlb, entry) tlb_remove_table(tlb, entry) +static inline void __tlb_remove_table(void *_table) +{ + free_page_and_swap_cache((struct page *)_table); +} +#else +#define tlb_remove_entry(tlb, entry) tlb_remove_page(tlb, entry) +#endif /* CONFIG_HAVE_RCU_TABLE_FREE */ + /* * There's three ways the TLB shootdown code is used: * 1. Unmapping a range of vmas. See zap_page_range(), unmap_region(). @@ -88,7 +102,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, { pgtable_page_dtor(pte); tlb_add_flush(tlb, addr); - tlb_remove_page(tlb, pte); + tlb_remove_entry(tlb, pte); } #if CONFIG_ARM64_PGTABLE_LEVELS > 2 @@ -96,7 +110,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) { tlb_add_flush(tlb, addr); - tlb_remove_page(tlb, virt_to_page(pmdp)); + tlb_remove_entry(tlb, virt_to_page(pmdp)); } #endif @@ -105,7 +119,7 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp, unsigned long addr) { tlb_add_flush(tlb, addr); - tlb_remove_page(tlb, virt_to_page(pudp)); + tlb_remove_entry(tlb, virt_to_page(pudp)); } #endif