Re: [PATCH 1/3] x86/mm: Correct the actual count of available global ASIDs

From: Rik van Riel
Date: Sat Mar 29 2025 - 13:29:58 EST


On Sat, 2025-03-29 at 21:05 +0800, Hou Wenlong wrote:
>
> +++ b/arch/x86/mm/tlb.c
> @@ -279,7 +279,7 @@ static DEFINE_RAW_SPINLOCK(global_asid_lock);
>  static u16 last_global_asid = MAX_ASID_AVAILABLE;
>  static DECLARE_BITMAP(global_asid_used, MAX_ASID_AVAILABLE);
>  static DECLARE_BITMAP(global_asid_freed, MAX_ASID_AVAILABLE);
> -static int global_asid_available = MAX_ASID_AVAILABLE -
> TLB_NR_DYN_ASIDS - 1;
> +static int global_asid_available = MAX_ASID_AVAILABLE -
> TLB_NR_DYN_ASIDS;

Unfortunately we are limited by the PCID space.

A process with ASID N will get PCID N+1.

The PCID space has the same size (and maximum value)
as the ASID space.

That means we cannot use the top ASID value.

Alternatively, I suppose we could have ASID and PCID
line up, and always exclude ASID 0 from being used.

That might (maybe) be prettier code, but it isn't what
we have today.


--
All Rights Reversed.