From patchwork Thu Aug 21 15:43:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 35772 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f72.google.com (mail-qg0-f72.google.com [209.85.192.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5D05320540 for ; Thu, 21 Aug 2014 15:46:00 +0000 (UTC) Received: by mail-qg0-f72.google.com with SMTP id j5sf16465955qga.7 for ; Thu, 21 Aug 2014 08:46:00 -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=x/dyY+mGCbfp46v8EwsL/MJ30CM2gdt4gobilnJo86I=; b=JHWs9egJt9fPQ+Y9yKYFnWUBKciPolw4AFVTjDFLJu4vcXjFeUz2Kr1xcQZT960fo/ TKTNbkHgQtMdSC1KbcLSThUFcINUaETlsRgO96cJd9ye3kFbGgPIw29YzboktCkDpZex kYPXMiFL+bHF4I/vBnsdjESLhj8/mgKaogLrgbKbzDUGeurdt91bCdeATkUFjkUuv6tm cL09zO2GnmGElGtTaZJ+WreRus2cp3FrDAqoV0o3jnF5ZcHH1FRwx5a9hkn7HJ0Qv5wS tjAq7L5ozqziKQQ2AV584eRzGjSHO8aRuBhSLArjqkCKgmyAt2xmmV2ST72pMj3J88YF q/9A== X-Gm-Message-State: ALoCoQnAYmfzNtyUVbChIQzBTCEuz4VkgPRG4wDrYok1Xlcu5FLzhP1dsiBcLCiNxsP3CtvFeBSl X-Received: by 10.224.169.20 with SMTP id w20mr29865916qay.4.1408635960190; Thu, 21 Aug 2014 08:46:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.17.47 with SMTP id 44ls830130qgc.11.gmail; Thu, 21 Aug 2014 08:46:00 -0700 (PDT) X-Received: by 10.221.24.135 with SMTP id re7mr560755vcb.53.1408635960086; Thu, 21 Aug 2014 08:46:00 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id v3si12471783vdv.28.2014.08.21.08.46.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Aug 2014 08:46:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id id10so10768352vcb.7 for ; Thu, 21 Aug 2014 08:46:00 -0700 (PDT) X-Received: by 10.220.184.70 with SMTP id cj6mr42182202vcb.5.1408635960008; Thu, 21 Aug 2014 08:46:00 -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 uj3csp146049vcb; Thu, 21 Aug 2014 08:45:59 -0700 (PDT) X-Received: by 10.69.25.35 with SMTP id in3mr62686985pbd.63.1408635959150; Thu, 21 Aug 2014 08:45:59 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id uf7si36950891pbc.8.2014.08.21.08.45.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Aug 2014 08:45:59 -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 1XKUXp-0001BZ-7n; Thu, 21 Aug 2014 15:44:57 +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 1XKUXB-0000dO-Gm for linux-arm-kernel@bombadil.infradead.org; Thu, 21 Aug 2014 15:44:17 +0000 Received: from mail-wi0-f176.google.com ([209.85.212.176]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XKUX8-0008AK-EY for linux-arm-kernel@lists.infradead.org; Thu, 21 Aug 2014 15:44:15 +0000 Received: by mail-wi0-f176.google.com with SMTP id bs8so8906355wib.15 for ; Thu, 21 Aug 2014 08:43:51 -0700 (PDT) X-Received: by 10.180.187.197 with SMTP id fu5mr23811974wic.64.1408635831546; Thu, 21 Aug 2014 08:43:51 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id wi9sm67591585wjc.23.2014.08.21.08.43.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Aug 2014 08:43:49 -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 Subject: [PATH V2 5/6] arm64: mm: Enable HAVE_RCU_TABLE_FREE logic Date: Thu, 21 Aug 2014 16:43:31 +0100 Message-Id: <1408635812-31584-6-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1408635812-31584-1-git-send-email-steve.capper@linaro.org> References: <1408635812-31584-1-git-send-email-steve.capper@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140821_164414_503060_0960FA1B X-CRM114-Status: GOOD ( 12.93 ) 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) [209.85.212.176 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 [209.85.212.176 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 , akpm@linux-foundation.org, 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.176 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 --- 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