Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E139576026 for ; Sun, 14 Jun 2026 09:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781430254; cv=none; b=ngOsfoBoytoFqy9fooS9p2MPu4hXfXmgkk5lOXf1OrTtfA1DBPdJXLUKo1OLPPX2bHDhCrJnnIGTbj9+v9b0pcXXjSAn6gvDZ6foHR0GQNFXk845RHMbk/cLtct2sj+Ahj+HMaIg3bzGpG3DjVEe+rovsWasYZEkv1/HJXL6seE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781430254; c=relaxed/simple; bh=sRP/rLyWaz33iH35VvbIpeRXrKrJ/gKfLZsauoZmAXk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Gaq1sQxXQvqMnctZXJnFRvi+Va7R3VY7/cBBFh7+3dJN5dwsGFvG5Uk0UXFxdV6m0C6eCj2XWGXssOtslEs2aLL6ab6kiJ5lEAwGvdAxRoF463ySRlRbW46CPDQCEZHi9ZKJM4pTFtnFX+jO3xuEw/7uEfRYACtTFa8Xeb/B1Jg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PHXiPLJ/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PHXiPLJ/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA3F71F000E9; Sun, 14 Jun 2026 09:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781430253; bh=Q8EvjVihfI26BEVs2HPcIc2E2fqgxAiSxDYAkfFNUH8=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=PHXiPLJ/KCRkg26Rd2plr0CDbM7KJnG5oooL8TAiIeKipYQtv81cnN5+SCIQudha1 sw+WB5aP/5vaEzukp9yBII1tA8NHAxBz+c30c/YBJzL3P8Cw6oSUZwqU+JAnxnLw9e l4Yhw2AWaG6gNB4JSLhH7D4f3G+8lGyWWYR6+vsHqMT6gPeDjZruOQkNbisim9DKty oroxHX+E1hbidS6zBa286zJg38tAD3TS5qkC+yWAnKJmVj4+XJhttou21wspJKzM9d XdxilPTq6cssoTv9L7NQMMVANjDo3nzME++Fkac3uoPlFG11Hg6sODWe3e9AuGWC3V Z9e2Y0JZCYBjg== Date: Sun, 14 Jun 2026 10:44:07 +0100 From: Will Deacon To: Catalin Marinas Cc: sk@gentwo.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ryan Roberts , Andrew Morton , David Hildenbrand , Anshuman Khandual , Mike Rapoport , Dev Jain , Kevin Brodsky , Marc Zyngier , Oliver Upton , cl@gentwo.org, Huang Ying , Linu Cherian Subject: Re: [PATCH 1/2] arm64: tlbflush: Don't broadcast if mm was only active on local cpu Message-ID: References: <20260609213615.2788698-1-sk@gentwo.org> <20260609213615.2788698-2-sk@gentwo.org> 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-Disposition: inline In-Reply-To: On Thu, Jun 11, 2026 at 04:29:29PM +0100, Catalin Marinas wrote: > On Tue, Jun 09, 2026 at 02:34:32PM -0700, sk@gentwo.org wrote: > > From: Ryan Roberts > > > > There are 3 variants of tlb flush that invalidate user mappings: > > flush_tlb_mm(), flush_tlb_page() and __flush_tlb_range(). All of these > > would previously unconditionally broadcast their tlbis to all cpus in > > the inner shareable domain. > > > > But this is a waste of effort if we can prove that the mm for which we > > are flushing the mappings has only ever been active on the local cpu. In > > that case, it is safe to avoid the broadcast and simply invalidate the > > current cpu. > > > > So let's track in mm_context_t::active_cpu either the mm has never been > > active on any cpu, has been active on more than 1 cpu, or has been > > active on precisely 1 cpu - and in that case, which one. We update this > > when switching context, being careful to ensure that it gets updated > > *before* installing the mm's pgtables. On the reader side, we ensure we > > read *after* the previous write(s) to the pgtable(s) that necessitated > > the tlb flush have completed. This guarrantees that if a cpu that is > > doing a tlb flush sees it's own id in active_cpu, then the old pgtable > > entry cannot have been seen by any other cpu and we can flush only the > > local cpu. > > > > Signed-off-by: Ryan Roberts > > Reviewed-by: Catalin Marinas > > Tested-by: Huang Ying > > [linu.cherian@arm.com: Adapted for v7.1 flush tlb API changes] > > Signed-off-by: Linu Cherian > > Nit: if you repost someone's patch, please add your signed-off-by. I have a feeling this patch is horribly broken, so I'll reply on the original. Will