Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Will Deacon <will@kernel.org>
Cc: Linu Cherian <linu.cherian@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Kevin Brodsky <kevin.brodsky@arm.com>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Yang Shi <yang@os.amperecomputing.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Huang Ying <ying.huang@linux.alibaba.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	shameerali.kolothum.thodi@huawei.com
Subject: Re: [PATCH v2] arm64: tlbflush: Don't broadcast if mm was only active on local cpu
Date: Fri, 19 Jun 2026 16:54:22 +0100	[thread overview]
Message-ID: <b4e02fed-0f52-47ec-8e52-ad390c61bbcd@arm.com> (raw)
In-Reply-To: <ajVhiCXYmbDq-qTi@willie-the-truck>

On 19/06/2026 16:34, Will Deacon wrote:
> On Mon, Jun 15, 2026 at 04:41:04PM +0100, Ryan Roberts wrote:
>> On 15/06/2026 15:43, Will Deacon wrote:
>>> On Mon, Jun 15, 2026 at 12:21:19PM +0100, Ryan Roberts wrote:
>>>>>> +	self = smp_processor_id();
>>>>>> +
>>>>>> +	/*
>>>>>> +	 * The load of mm->context.active_cpu must not be reordered before the
>>>>>> +	 * store to the pgtable that necessitated this flush. This ensures that
>>>>>> +	 * if the value read is our cpu id, then no other cpu can have seen the
>>>>>> +	 * old pgtable value and therefore does not need this old value to be
>>>>>> +	 * flushed from its tlb. But we don't want to upgrade the dsb(ishst),
>>>>>> +	 * needed to make the pgtable updates visible to the walker, to a
>>>>>> +	 * dsb(ish) by default. So speculatively load without a barrier and if
>>>>>> +	 * it indicates our cpu id, then upgrade the barrier and re-load.
>>>>>> +	 */
>>>>>> +	active = READ_ONCE(mm->context.active_cpu);
>>>>>> +	if (active == self) {
>>>>>> +		dsb(ish);
>>>>>> +		active = READ_ONCE(mm->context.active_cpu);
>>>>>> +	} else {
>>>>>> +		dsb(ishst);
>>>>>> +	}
>>>>>
>>>>> Why can't you just do:
>>>>>
>>>>> 	dsb(ishst);
>>>>> 	active = READ_ONCE(mm->context.active_cpu);
>>>>>
>>>>> ?
>>>>
>>>> Prior to this optimization, we always issued a dsb(ishst) here. Catalin
>>>> suggested the same simplification against the RFC. I believe Linu tried it but
>>>> saw regressions; Hopefully Linu can provide the details.
>>>
>>> I don't follow...
>>>
>>> The old code always did dsb(ishst). The proposed code here does either
>>> dsb(ish) or dsb(ishst). How can that possibly be faster?
>>
>> Ugh, sorry - I read your suggestion as unconditionally issuing a dsb(ish).
>>
>> Ignore my previous answer, and now I'll demonstrate my total lack of
>> understanding of barriers instead...
>>
>> As the comment says, "The load of mm->context.active_cpu must not be reordered
>> before the store to the pgtable that necessitated this flush". I thought that a
>> dsb(ishst) would only provide ordering between stores. Don't we need the
>> dsb(ish) to prevent the load from being reordered before the store?
> 
> dsb(ishst) orders prior stores -> everything later. That's why it works
> today for ordered a PTE write before a TLBI (which isn't a store).

Ahh, that simplifies things then!

> 
> Will



  reply	other threads:[~2026-06-19 15:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23 13:47 [PATCH v2] arm64: tlbflush: Don't broadcast if mm was only active on local cpu Linu Cherian
2026-06-14 11:04 ` Will Deacon
2026-06-14 11:33   ` Will Deacon
2026-06-15 11:21   ` Ryan Roberts
2026-06-15 14:43     ` Will Deacon
2026-06-15 15:41       ` Ryan Roberts
2026-06-16  5:05         ` Linu Cherian
2026-06-19 15:34         ` Will Deacon
2026-06-19 15:54           ` Ryan Roberts [this message]
2026-06-16  5:00       ` Linu Cherian
2026-06-18  6:01       ` Linu Cherian
2026-06-16  4:54     ` Linu Cherian
2026-06-15 12:39   ` Mark Rutland
2026-06-15 14:44     ` Will Deacon
2026-06-16  6:13       ` Mark Rutland
2026-06-17 13:58         ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4e02fed-0f52-47ec-8e52-ad390c61bbcd@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=kevin.brodsky@arm.com \
    --cc=linu.cherian@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=will@kernel.org \
    --cc=yang@os.amperecomputing.com \
    --cc=ying.huang@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox