Re: [PATCH v2 4/4] x86/mm: Reset global ASID space when ASID rollover

From: Rik van Riel

Date: Tue Jan 20 2026 - 12:27:59 EST


On Tue, 2026-01-20 at 21:44 +0800, Hou Wenlong wrote:
> The global ASID allocation always searches for free ASIDs starting
> from
> the last allocated ASID and resets the ASID space when the last
> allocated ASID reaches the edge of the available ASID space. However,
> this approach fails in scenarios where the maximum ASID is allocated
> first and a smaller ASID is freed later. In such cases, the
> 'last_global_asid' may never reach the edge of the available ASID
> space,
> leading to allocation failures even when global ASIDs are available.
>
> For example, if all ASIDs are allocated in the first round and then a
> smaller ASID is freed, the ASID space can be reset because
> 'last_global_asid' equals 'MAX_ASID_AVAILABLE - 1'. The smaller ASID
> can
> then be allocated, and 'last_global_asid' is updated accordingly.
> However, when this smaller ASID is freed again, the allocation will
> fail
> since 'last_global_asid' no longer equals 'MAX_ASID_AVAILABLE - 1',
> preventing the ASID space from being reset. To address this issue,
> the
> global ASID space should be reset based on ASID rollover rather than
> depending on the value of 'last_global_asid'.
>
> Fixes: d504d1247e36 ("x86/mm: Add global ASID allocation helper
> functions")
> Signed-off-by: Hou Wenlong <houwenlong.hwl@xxxxxxxxxxxx>

Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx>

--
All Rights Reversed.