Re: [PATCH v10 09/12] x86/mm: enable broadcast TLB invalidation for multi-threaded processes
From: Brendan Jackman
Date: Wed Feb 12 2025 - 08:29:46 EST
On Tue, 11 Feb 2025 at 22:09, Rik van Riel <riel@xxxxxxxxxxx> wrote:
> + /* Transition from global->local ASID does not currently happen. */
> + if (!global_asid && is_global_asid(prev_asid))
> + return true;
What about a WARN_ON_ONCE? Then the code contains evidence that the
comment is true. IIUC this isn't just a "not implemented feature",
rather there is plenty of other code that would need to be updated to
make it safe.
> +static void use_global_asid(struct mm_struct *mm)
> +{
> + u16 asid;
> +
> + guard(raw_spinlock_irqsave)(&global_asid_lock);
> +
> + /* This process is already using broadcast TLB invalidation. */
> + if (READ_ONCE(mm->context.global_asid))
> + return;
> +
> + /* The last global ASID was consumed while waiting for the lock. */
> + if (!READ_ONCE(global_asid_available)) {
I think the READ_ONCE is unnecessary while we have the spinlock, it's
fine if this read gets split or whatever?
Ditto for mm->context.global_asid, it's only modified with the lock held.