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 5CFB03C9EE8 for ; Tue, 16 Jun 2026 04:54:49 +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=1781585692; cv=none; b=HLDQjDbyuvtx7dRGg6xyE2eD7N+DGsdPsrd4bkU6IjtdKPpJAVCUYyVd7X5x2IKlWbeonK5Txby8DZshgYdxnb2xnWbvAwVgj2R/0IYW/qplQNArU7mrbR3KbMBy2oCqOJNPW8ByEPd2nGuP3BQkRHqccNHbSopFVatdR0h5/pc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781585692; c=relaxed/simple; bh=oKz+HJ9pfRoiE5HleCp1vs2MiUNVGxNe7CgkVBr+6fs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cNkcg9ny3h6uUq9P6v03FMbdMoF82LqtWZP66Xqoi2ghZwvVmrbM85Rrx35sjf6UortATbklMzUfCzcAd99B4bZJGN9W0kazUZZ3Co9wYkqdAX8Xpf0f5q3Hcs/qiCQPi2jFrR4qVqrHVbc6sNcNf+Ov6FU+b09JHj3u9+7eR5c= 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=fntFIpro; 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="fntFIpro" 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 B957C3D4B; Mon, 15 Jun 2026 21:54:43 -0700 (PDT) Received: from localhost (a079125.arm.com [10.164.21.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AF8433F915; Mon, 15 Jun 2026 21:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781585688; bh=oKz+HJ9pfRoiE5HleCp1vs2MiUNVGxNe7CgkVBr+6fs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fntFIproCDmJJPxD2df3CzDmzl1XA/tWcXEQadLNp20l+9amK/EPUn88T43eEdW8G KL67ttC9Ysk9/U8QlSk+elYsz/H0nFLuEc50bndsxtlwFtEKqIgjhgIhwQ7FlIQ11n pb04an62webziHWqcsbMiizgPYujU2i5f1eJaO8o= Date: Tue, 16 Jun 2026 10:24:44 +0530 From: Linu Cherian To: Ryan Roberts Cc: Will Deacon , Catalin Marinas , Kevin Brodsky , Anshuman Khandual , Yang Shi , Mark Rutland , Huang Ying , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] arm64: tlbflush: Don't broadcast if mm was only active on local cpu Message-ID: References: <20260523134710.3827956-1-linu.cherian@arm.com> 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: Hi, On Mon, Jun 15, 2026 at 12:21:19PM +0100, Ryan Roberts wrote: > On 14/06/2026 12:04, Will Deacon wrote: > > On Sat, May 23, 2026 at 07:17:10PM +0530, Linu Cherian 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 > >> --- > >> Changelog from RFC v1: > >> - Adapted for v7.1 flush tlb API changes > >> No changes in core logic > >> - Collected Rb and Tb tags > >> - lat_mmap benchmark showed dsb(ishst) performs better than dsb(ish), > >> hence retained dsb(ishst) in flush_tlb_user_pre > >> > >> > >> Testing with 7.1-rc4 : > >> +-----------------------+---------------------------------------------------+-------------+ > >> | Benchmark | Result Class | Improvement| > >> +=======================+===================================================+=============+ > >> | perf/syscall | fork (ops/sec) | (I) 3.25% | > >> +-----------------------+---------------------------------------------------+-------------+ > >> | pts/memtier-benchmark | Protocol: Redis Clients: 100 Ratio: 1:5 (Ops/sec) | (I) 2.70% | > >> | | Protocol: Redis Clients: 100 Ratio: 5:1 (Ops/sec) | (I) 2.13% | > >> +-----------------------+---------------------------------------------------+-------------+ > > > > I think we need a much more comprehensive set of benchmarks before we can > > begin to consider a change like this. > > I believe that Linu ran a wider set of benchmarks and didn't find any > regressions. These are just the ones that show improvement (Linu, please correct > me and/or provide details). Yes, thats correct. -- Thanks, Linu Cherian.