From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 565BDC4167D for ; Thu, 14 Dec 2023 12:13:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9E026B00D6; Thu, 14 Dec 2023 07:13:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D4D546B00D8; Thu, 14 Dec 2023 07:13:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C13716B03D9; Thu, 14 Dec 2023 07:13:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B26326B00D6 for ; Thu, 14 Dec 2023 07:13:48 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 87EC5140C8D for ; Thu, 14 Dec 2023 12:13:48 +0000 (UTC) X-FDA: 81565314936.23.7B267C1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id C18F5160018 for ; Thu, 14 Dec 2023 12:13:46 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZIl4tQ4t; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702556026; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wZcBJJ9hn8fPFYEAv3UJQ9N9We0suiVDp29IV4j0pG4=; b=1Siq6mDfnzXDqGjhc5IhO2hY76FloYGYmGtJ+69qYLtGeyFa4ZLIduxDTr6Hg3EIDOWQSf 1tWe85/dQ/iJtlNtTrd4Y1zWuv8qcLsw91oHtpP03I/4PzNxbkPp8LIgCCbOQy6ydJmrhs qvmDgJftHZZus/O7XOtJ68ASeL/iLj0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZIl4tQ4t; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702556026; a=rsa-sha256; cv=none; b=kAJ7RmhQGx4H7vdRMdndomuytVNRa9BbOqGvxBoTLjFcwE/4DDGfr1WOgbPYhMjwKNC5UD Eyvk3YJhoAwZkUgclG2BtUpcrTxC9yOdHCs2oZZUQLREVNeFM4YNQygQpZoLU57Kmnswab 4MWXchAcKBEIY7JFM5dVPx9sQcLHVSY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B5586621F3; Thu, 14 Dec 2023 12:13:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E84BC433C7; Thu, 14 Dec 2023 12:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702556025; bh=zGI9MKm0R/y1myqJM3IMh1whT+Jpo0eTry8ctu4P1bE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZIl4tQ4tSkoE1FaBtknKS70y7rg0PHYdhs8pC5K0km1raen4r8b8buSTrlB/cQeS5 V88CmYspZi4PyQ7fUpZk1k02eq8RZ9Lazj9PQ6GQB3OMdzr5/BWdRoXx4mzwa0Nw2u HJLI2chg1HTUpTbbQZNm66O6fqhzGQh4eyeyhZOcU4pbElBM+hwMZXajVWJZzfOZw5 d8CnikTugVZdXY0UacDQpykecqCZLVHnxOHxyijCDVCzf6o1ioEjtNo/dpj4d3HJbC 2AeWA7gxst5ON/uHCIS780fqlq6nWAjEExI5RDXm5i/5JQHQfDRf8q9o2JqlWZFm0i oVkGVEehtCQRQ== Date: Thu, 14 Dec 2023 12:13:36 +0000 From: Will Deacon To: Ryan Roberts , robin.murphy@arm.com, jean-philippe@linaro.org Cc: Catalin Marinas , Ard Biesheuvel , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Anshuman Khandual , Matthew Wilcox , Yu Zhao , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 12/15] arm64/mm: Split __flush_tlb_range() to elide trailing DSB Message-ID: <20231214121336.GA1015@willie-the-truck> References: <20231204105440.61448-1-ryan.roberts@arm.com> <20231204105440.61448-13-ryan.roberts@arm.com> <20231212113517.GA28857@willie-the-truck> <0969c413-bf40-4c46-9f1e-a92101ff2d2e@arm.com> <2e6f06d3-6c8e-4b44-b6f2-e55bd5be83d6@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2e6f06d3-6c8e-4b44-b6f2-e55bd5be83d6@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: C18F5160018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: w8bt4xahmz46nw8p16hcyc6bokyja3cz X-HE-Tag: 1702556026-230897 X-HE-Meta: U2FsdGVkX1+gIkcq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4EDukahetSCfQwNRlgPF6WyqZT2BEGcIWdXum+42gKnbP4wuCfbmkFFLqSshe+Gh034ObMsJ62iagf/5b4mMg9MXSkdeohznhMVUjJMw0SqqaxY/biC0sZQ4ItBdm9XDTFhmsvJ7AKZQRmDFFhVT3aU/rAeGkcxNSggj2SxKkJcMouagQbw94oeESWOK0By3FSsh3dZLDjWfOEQCI5ZDoX2w== 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: List-Subscribe: List-Unsubscribe: On Thu, Dec 14, 2023 at 11:53:52AM +0000, Ryan Roberts wrote: > On 12/12/2023 11:47, Ryan Roberts wrote: > > On 12/12/2023 11:35, Will Deacon wrote: > >> On Mon, Dec 04, 2023 at 10:54:37AM +0000, Ryan Roberts wrote: > >>> diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h > >>> index bb2c2833a987..925ef3bdf9ed 100644 > >>> --- a/arch/arm64/include/asm/tlbflush.h > >>> +++ b/arch/arm64/include/asm/tlbflush.h > >>> @@ -399,7 +399,7 @@ do { \ > >>> #define __flush_s2_tlb_range_op(op, start, pages, stride, tlb_level) \ > >>> __flush_tlb_range_op(op, start, pages, stride, 0, tlb_level, false) > >>> > >>> -static inline void __flush_tlb_range(struct vm_area_struct *vma, > >>> +static inline void __flush_tlb_range_nosync(struct vm_area_struct *vma, > >>> unsigned long start, unsigned long end, > >>> unsigned long stride, bool last_level, > >>> int tlb_level) > >>> @@ -431,10 +431,19 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, > >>> else > >>> __flush_tlb_range_op(vae1is, start, pages, stride, asid, tlb_level, true); > >>> > >>> - dsb(ish); > >>> mmu_notifier_arch_invalidate_secondary_tlbs(vma->vm_mm, start, end); > >>> } > >>> > >>> +static inline void __flush_tlb_range(struct vm_area_struct *vma, > >>> + unsigned long start, unsigned long end, > >>> + unsigned long stride, bool last_level, > >>> + int tlb_level) > >>> +{ > >>> + __flush_tlb_range_nosync(vma, start, end, stride, > >>> + last_level, tlb_level); > >>> + dsb(ish); > >>> +} > >> > >> Hmm, are you sure it's safe to defer the DSB until after the secondary TLB > >> invalidation? It will have a subtle effect on e.g. an SMMU participating > >> in broadcast TLB maintenance, because now the ATC will be invalidated > >> before completion of the TLB invalidation and it's not obviously safe to me. > > > > I'll be honest; I don't know that it's safe. The notifier calls turned up during > > a rebase and I stared at it for a while, before eventually concluding that I > > should just follow the existing pattern in __flush_tlb_page_nosync(): That one > > calls the mmu notifier without the dsb, then flush_tlb_page() does the dsb > > after. So I assumed it was safe. > > > > If you think it's not safe, I guess there is a bug to fix in > > __flush_tlb_page_nosync()? > > Did you have an opinion on this? I'm just putting together a v4 of this series, > and I'll remove this optimization if you think it's unsound. But in that case, I > guess we have an existing bug to fix too? Sorry, Ryan, I've not had a chance to look into it in more detail. But as you rightly point out, you're not introducing the issue (assuming it is one), so I don't think it needs to hold you up. Your code just makes the thing more "obvious" to me. Robin, Jean-Philippe -- do we need to make sure that the SMMU has completed its TLB invalidation before issuing an ATC invalidate? My half-baked worry is whether or not an ATS request could refill the ATC before the TLBI has completed, therefore rendering the ATC invalidation useless. Will