From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AA68407571 for ; Thu, 11 Jun 2026 15:29:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781191776; cv=none; b=UQPjI8LYPL4zxFJkaAHD2zuGO7edyOSRV+NSbWG/KIJ38cEQgIHsMGUt6FuZECBGg86sjodiqW8PbPURs5VLTSsBvhl25bKNTHtt0egyTawvYBMYDTEfBn7nr/MBR12CmXD5PS3vk6us3s9+OOJC667A/Qe+b/wY4JpciMdchMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781191776; c=relaxed/simple; bh=W4sGE5y60NuRQQFw/ECXJXbsg8my09kl0Yt2sv8zJiQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t41nSU2C3MO68sayUmSNq+ZZZmRtVVu5mkPr3k7/JwviFXg5pv7lGbIgybobrZ3v7tNT8Dmn6sWE1Y81UiSUE23Cl0z0CIwLrjWrNgzKuhc7KEaYFQO4NQV3dYOm9Lt8zde1XQf+LDoXcqHvRN1iVXRvwOsMHYN+5Hvw5biyY+c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=iQch3SOL; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="iQch3SOL" 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 DF66E1DB5; Thu, 11 Jun 2026 08:29:29 -0700 (PDT) Received: from arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 55C7C3FB90; Thu, 11 Jun 2026 08:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781191774; bh=W4sGE5y60NuRQQFw/ECXJXbsg8my09kl0Yt2sv8zJiQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iQch3SOLhzVqV8/aboIlwSht9zx1/eZ2W6j/y2yy4/sRxrRJs0AJKtfxlcAeUOqZc dAOaukrfwSSISm+5AgEoBUbT9FqBdUqh+7wQTqgCKUxBP6y3IppU7DDVHUWmU4f2/t 2iCp4e7Ig21CuPh3NYbyKjqjhz3osfzhW74iUlQc= Date: Thu, 11 Jun 2026 16:29:29 +0100 From: Catalin Marinas To: sk@gentwo.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Will Deacon , 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: <20260609213615.2788698-2-sk@gentwo.org> 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. -- Catalin