From patchwork Wed Dec 11 12:07:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 11284841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94F1A138D for ; Wed, 11 Dec 2019 12:31:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 587BD214AF for ; Wed, 11 Dec 2019 12:31:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SBq4aNiE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 587BD214AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E93E76B31F4; Wed, 11 Dec 2019 07:31:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF3596B31F7; Wed, 11 Dec 2019 07:31:28 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFA696B31F9; Wed, 11 Dec 2019 07:31:28 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id 960F66B31F4 for ; Wed, 11 Dec 2019 07:31:28 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 4C5F7181AEF1D for ; Wed, 11 Dec 2019 12:31:28 +0000 (UTC) X-FDA: 76252796256.17.cow80_4703d39144b51 X-Spam-Summary: 2,0,0,0f555f5125f5e321,d41d8cd98f00b204,peterz@infradead.org,:will@kernel.org:aneesh.kumar@linux.ibm.com:akpm@linux-foundation.org:npiggin@gmail.com:peterz@infradead.org:linux-arch@vger.kernel.org::linux-kernel@vger.kernel.org:ysato@users.sourceforge.jp:dalias@libc.org:davem@davemloft.net:deller@gmx.de:geert@linux-m68k.org:paulburton@kernel.org:tony.luck@intel.com:rth@twiddle.net:nickhu@andestech.com:paul.walmsley@sifive.com,RULES_HIT:41:152:355:379:800:960:965:966:968:973:988:989:1183:1260:1261:1277:1313:1314:1345:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:1981:2194:2196:2198:2199:2200:2201:2393:2559:2562:2731:2903:3138:3139:3140:3141:3142:3354:3865:3867:3868:3871:3872:4250:4385:4390:4395:4605:5007:6119:6261:6653:6742:7903:8603:8634:10004:10394:10400:11026:11473:11657:11658:11914:12043:12048:12291:12296:12297:12438:12517:12519:14181:14394:14659:14721:21080:21451:21627:21789:21990:30012:30054:30055,0,RBL:205.233.59.134:@infradead.org:.lbl 8.mailsh X-HE-Tag: cow80_4703d39144b51 X-Filterd-Recvd-Size: 5351 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Dec 2019 12:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jViyJyc27KPeg0UifOYoPRTZbieI85V/fY78N3x1I9Q=; b=SBq4aNiEimiVT923ThYU5T1BWY 1WNnRyNYHvP1B55z03gtpKtRHJrKE3sDnwyC18/WB2fa0c5zoyj7LRl1xxxuH96nlcXzvKUozyFBQ mMNNucnRFKyqNGv6M4ytMrNGLAOfH6CBHfZvSuR6lCMu4KyI9xagC5pKzO8do81f2ZOlvGuEMp5Kn GEdrD4AlyxqDBgDNVVTr9+yIUK+01uWon5q2BFxFAjACCOnhnIqnB7C7ff1U0F8OOeD8Lb9NJqNWp 3WHFrNTCKMuDW6Af4PkXTSSefss8rQ+YyYORfzaadXfM/l9DDICk9KCGu6VUN1Y3iV+fRJ5Ua9GKm RvNrOqMw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1if191-0003sm-AO; Wed, 11 Dec 2019 12:31:07 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id EB92F306BB9; Wed, 11 Dec 2019 13:29:43 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 4206520137CB5; Wed, 11 Dec 2019 13:31:02 +0100 (CET) Message-Id: <20191211122956.285169327@infradead.org> User-Agent: quilt/0.65 Date: Wed, 11 Dec 2019 13:07:24 +0100 From: Peter Zijlstra To: Will Deacon , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Peter Zijlstra Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yoshinori Sato , Rich Felker , "David S. Miller" , Helge Deller , Geert Uytterhoeven , Paul Burton , Tony Luck , Richard Henderson , Nick Hu , Paul Walmsley Subject: [PATCH 11/17] parisc/tlb: Fix __p*_free_tlb() References: <20191211120713.360281197@infradead.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Just like regular pages, page directories need to observe the following order: 1) unhook 2) TLB invalidate 3) free to ensure it is safe against concurrent accesses. Because PARISC has non-page-size PMDs, use a custom table freeer. Signed-off-by: Peter Zijlstra (Intel) --- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/pgalloc.h | 25 ++++++++++++++++++++++--- arch/parisc/include/asm/tlb.h | 7 +++++-- 3 files changed, 28 insertions(+), 5 deletions(-) --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -62,6 +62,7 @@ config PARISC select HAVE_FTRACE_MCOUNT_RECORD if HAVE_DYNAMIC_FTRACE select HAVE_KPROBES_ON_FTRACE select HAVE_DYNAMIC_FTRACE_WITH_REGS + select MMU_GATHER_TABLE_FREE if PGTABLE_LEVELS >= 3 help The PA-RISC microprocessor is designed by Hewlett-Packard and used --- a/arch/parisc/include/asm/pgalloc.h +++ b/arch/parisc/include/asm/pgalloc.h @@ -73,7 +73,7 @@ static inline pmd_t *pmd_alloc_one(struc return pmd; } -static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) +static inline bool __pmd_free(struct mm_struct *mm, pmd_t *pmd) { if (pmd_flag(*pmd) & PxD_FLAG_ATTACHED) { /* @@ -83,11 +83,28 @@ static inline void pmd_free(struct mm_st * done by generic mm code. */ mm_inc_nr_pmds(mm); - return; + return false; } - free_pages((unsigned long)pmd, PMD_ORDER); + return true; +} + +static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) +{ + if (__pmd_free(mm, pmd)) + free_pages((unsigned long)pmd, PMD_ORDER); } +static inline void __tlb_remove_table(void *table) +{ + free_pages((unsigned long)table, PMD_ORDER); +} + +#define __pmd_free_tlb(tlb, pmd, addr) \ +do { \ + if (__pmd_free((tlb)->mm, (pmd))) \ + tlb_remove_table((tlb), (pmd)); \ +} while (0) + #else /* Two Level Page Table Support for pmd's */ @@ -101,6 +118,8 @@ static inline void pmd_free(struct mm_st #define pmd_free(mm, x) do { } while (0) #define pgd_populate(mm, pmd, pte) BUG() +#define __pmd_free_tlb(tlb, pmd, addr) do { } while (0) + #endif static inline void --- a/arch/parisc/include/asm/tlb.h +++ b/arch/parisc/include/asm/tlb.h @@ -4,7 +4,10 @@ #include -#define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd) -#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte) +#define __pte_free_tlb(tlb,pte,addr) \ +do { \ + pgtable_pte_page_dtor(pte); \ + tlb_remove_page((tlb), (pte)); \ +} while (0) #endif