From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sinmsgout02.his.huawei.com (sinmsgout02.his.huawei.com [119.8.177.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B1F262FEC for ; Tue, 27 Jan 2026 14:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=119.8.177.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769522909; cv=none; b=rqOcH35ETOKuRiZhGT9ggfYcn7N6eVVdhrnSFx/3Dha8R1+L9zmkLqWfIsQIrCngjB6H37zZZGwYbo3D/aTvfn3DOwxyPbDAyPYTKNY8cPZiIDxEYptVhvuMIeIuf9mWZ9A2lT+hSmZRFV4NqOZrcbKnOAO9PSqlVNy057HaNIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769522909; c=relaxed/simple; bh=bnXhfsnJnJ6ZOoXSBUNVH8wlWi10EJ15hfUu1mQMOm8=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ey2ZmOOLalfZltNjbGiucNeRFhlzQwYMC3xJNHIobFr9DWTjp+sN8SG3xULQrmT2SK55hnPBfqhx0IgbokFIeJhvGX0AvE34KsBz/uiGAxpPVv1Gu+WFHp/UITptQG0fLzDqqFFwvhbtpI7fc2+sZ4r5cgr+4OOTeRzFunqN/ZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=metBWbtU; arc=none smtp.client-ip=119.8.177.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="metBWbtU" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=7VhVYjAL+9B/5gShYMZ4DL4GYoMJtixTu4K7JK6MEVM=; b=metBWbtUdCsraqZM8TdPcGgtLBdcSkktI4ukGcjUaURF+l1pCsvjXbZap2TcnTZZ4QZGKbos2 MovR4sky54CtHJsFrbg6y2dANAcRljo3+UORhXstCwvC5aRD6chXTEMBsPePnRfsdjKd4lzpBth EeQBoPY5S31gJayW3th1+pU= Received: from frasgout.his.huawei.com (unknown [172.18.146.33]) by sinmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4f0nHf4dQYz1vnyV; Tue, 27 Jan 2026 22:05:50 +0800 (CST) Received: from mail.maildlp.com (unknown [172.18.224.107]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4f0nKq0nd2zJ46cX; Tue, 27 Jan 2026 22:07:43 +0800 (CST) Received: from dubpeml500005.china.huawei.com (unknown [7.214.145.207]) by mail.maildlp.com (Postfix) with ESMTPS id 1F23340571; Tue, 27 Jan 2026 22:08:19 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml500005.china.huawei.com (7.214.145.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 27 Jan 2026 14:08:18 +0000 Date: Tue, 27 Jan 2026 14:08:16 +0000 From: Jonathan Cameron To: Ryan Roberts CC: Will Deacon , Ard Biesheuvel , Catalin Marinas , Mark Rutland , Linus Torvalds , Oliver Upton , Marc Zyngier , "Dev Jain" , Linu Cherian , , Subject: Re: [PATCH v2 12/13] arm64: mm: Wrap flush_tlb_page() around ___flush_tlb_range() Message-ID: <20260127140816.00001b43@huawei.com> In-Reply-To: <8184baab-8774-4a73-8cee-d8d3e22553c0@arm.com> References: <20260119172202.1681510-1-ryan.roberts@arm.com> <20260119172202.1681510-13-ryan.roberts@arm.com> <20260127125933.00006101@huawei.com> <8184baab-8774-4a73-8cee-d8d3e22553c0@arm.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100009.china.huawei.com (7.191.174.83) To dubpeml500005.china.huawei.com (7.214.145.207) On Tue, 27 Jan 2026 14:03:43 +0000 Ryan Roberts wrote: > On 27/01/2026 12:59, Jonathan Cameron wrote: > > On Mon, 19 Jan 2026 17:21:59 +0000 > > Ryan Roberts wrote: > > > >> Flushing a page from the tlb is just a special case of flushing a range. > >> So let's rework flush_tlb_page() so that it simply wraps > >> ___flush_tlb_range(). While at it, let's also update the API to take the > >> same flags that we use when flushing a range. This allows us to delete > >> all the ugly "_nosync", "_local" and "_nonotify" variants. > >> > >> Thanks to constant folding, all of the complex looping and tlbi-by-range > >> options get eliminated so that the generated code for flush_tlb_page() > >> looks very similar to the previous version. > >> > >> Reviewed-by: Linu Cherian > >> Signed-off-by: Ryan Roberts > > > > So this does include the use of the > > > > Case TLBF_NOBROADCAST from previous patch, but only whilst (I think) > > slightly changing behavior. > > > > Gah. I'm regretting looking at this series. The original code is really hard to > > read :) Rather you than me to fix it! > > > >> static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end) > >> { > >> const unsigned long stride = PAGE_SIZE; > >> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > >> index be9dab2c7d6a..f91aa686f142 100644 > >> --- a/arch/arm64/mm/fault.c > >> +++ b/arch/arm64/mm/fault.c > >> @@ -239,7 +239,7 @@ int __ptep_set_access_flags(struct vm_area_struct *vma, > >> * flush_tlb_fix_spurious_fault(). > >> */ > >> if (dirty) > >> - local_flush_tlb_page(vma, address); > >> + __flush_tlb_page(vma, address, TLBF_NOBROADCAST); > > > > Ultimately I think this previously did __tlbi(vale1) and now does __tlbi(vae1) > > Original call was to __local_flush_tlb_page_notify_nosync() > > No not quite; the new code is still doing __tlbi(vale1). > > The trick is that the __flush_tlb_page() wrapper unconditionally adds > TLBF_NOWALKCACHE to the flags. Since this API is operating on a *page* it is > implicit that we should only be evicting a leaf entry (as per the old > implementation). > > You'll see I've also updated the documentation to make that clear in tlbflush.h. > > Now that you have raised it, I can see how it might be confusing though, since > __flush_tlb_page() does not explicitly have TLBF_NOWALKCACHE. We could require > all __flush_tlb_page() callers to explicitly pass TLBF_NOWALKCACHE if you think > that helps? It would still be implicit for flush_tlb_page() (the generic kernel > API) though. Ah. I'd indeed missed that tweaking of the flags. Not sure. You probably have a better feel for this ABI than I do and the likely expectations of users. J > > > > > I'd like to see that sort of change called out and explained in the patch description. > > It's a broader scoped flush so not a bug, but still a functional change. > > As I say, the emitted code is the same. It's my new API that's the problem here... > > Thanks, > Ryan > > > > >> return 1; > >> } > >> > > > >