Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5947794rdb; Thu, 14 Dec 2023 04:31:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWbJ5GDAfZKFHvlAOvr5oYPm3Qt9QhGMRSUWLbgr77c6GTB9qi1F1eOsi8qeVz9NgOe5a7 X-Received: by 2002:a05:6358:5922:b0:170:c6b9:2e1d with SMTP id g34-20020a056358592200b00170c6b92e1dmr5109260rwf.28.1702557094700; Thu, 14 Dec 2023 04:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702557094; cv=none; d=google.com; s=arc-20160816; b=AeEASqZF/fjDiSIgff8OgUiFe/qmXtwwBgYfWkzq5gjKKDxYdnE9t8s+J2ewSPMGVs qPvUFss/xbC64VKnHV8HT/zvthaoWGgyl19I8CSj/BoMRPtl6jFxEYIqNpkv8gWoXri0 cYBWi7VnkK5lMmJQMv0AtnVwu/pAIuIEtBUiW2s8Jyw4taqMOpKQRbP6HRP8PDMu3wci +5D6KnPX1tEneWEjMCHfStGvpDgutj5xD1wcg3iqKtuUZ1MuocxJmKgbJTzn1+uWlD1f vu19wUpJfCYUTlGsaJnCU9unfJF4h+afMgzWpyQYKTxuUpndu7Bs78bW/bBKSH0/jzdJ J8Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=nN76uONfzkqwG7UCgZs6LZweSp6nMEX1KWNvoL2agrQ=; fh=yq/uBspOgohrLPi7wUUq9+G63nHWttwLL68HRqZzNWI=; b=FFFfgmkZXewzhq4/KuWOGUF1xJQcpVl87ttAs2/PkEqr3NA6/IcArUj2BlTEPDN5Ab EJUkxvCnWjdzcItdjWi62yx1WRDaLJZSmklRrtOCYlZBGZytl0OHoQubZ81Pw+v1cmAk HhnVWX2gtSnoCygwkFwKefDJWtMZ6srP3tuwXOtXxFGo7zPargNYghnhGJjNYp+mLLSy Eqidp0vVMu6D2iaKLFS2ddbhxXHYjPPSuw727f8orCHvHSDy4OeTbioBfQUfpFHW54T+ Dup/fv59FF6N8k1BmjhjSBANC1V3Sewq6BuyCgZFiBLq+qwRIxmHxdJnnNrwPxQTW6E5 iS0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id ft11-20020a17090b0f8b00b0028af654a12fsi1889204pjb.148.2023.12.14.04.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 04:31:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E075F84AA9C1; Thu, 14 Dec 2023 04:31:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573054AbjLNMbK (ORCPT + 99 others); Thu, 14 Dec 2023 07:31:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573099AbjLNMa4 (ORCPT ); Thu, 14 Dec 2023 07:30:56 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BEB3C12B for ; Thu, 14 Dec 2023 04:31:02 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 07E66C15; Thu, 14 Dec 2023 04:31:48 -0800 (PST) Received: from [10.57.86.13] (unknown [10.57.86.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 22BF53F738; Thu, 14 Dec 2023 04:30:58 -0800 (PST) Message-ID: Date: Thu, 14 Dec 2023 12:30:55 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 12/15] arm64/mm: Split __flush_tlb_range() to elide trailing DSB Content-Language: en-GB To: Will Deacon , Ryan Roberts , 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 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> <20231214121336.GA1015@willie-the-truck> From: Robin Murphy In-Reply-To: <20231214121336.GA1015@willie-the-truck> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 14 Dec 2023 04:31:32 -0800 (PST) On 2023-12-14 12:13 pm, Will Deacon wrote: > 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. I would agree, and the spec for CMD_ATC_INV does call out a TLBI->sync->ATCI->sync sequence. At the moment the SVA notifier is issuing its own command-based TLBIs anyway so the necessary sync is implicit there, but if and when we get BTM support wired up properly it would be nice not to have to bodge in an additional sync/DSB. Cheers, Robin.