From: "Hou Wenlong" <houwenlong.hwl@antgroup.com>
To: Rik van Riel <riel@surriel.com>
Cc: linux-kernel@vger.kernel.org,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 1/3] x86/mm: Correct the actual count of available global ASIDs
Date: Mon, 31 Mar 2025 11:46:26 +0800 [thread overview]
Message-ID: <20250331034626.GA88569@k08j02272.eu95sqa> (raw)
In-Reply-To: <a84047c77c1a5f16b0d25f0cee6fe86487d14a5b.camel@surriel.com>
On Sun, Mar 30, 2025 at 01:29:25AM +0800, Rik van Riel wrote:
> 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.
>
Thank you for your quick reply!
Since the size of the bitmap is 'MAX_ASID_AVAILABLE', the maximum ASID
value that can be allocated from the bitmap is 'MAX_ASID_AVAILABLE-1'.
This matches the comments stating that the valid ASID range for global
ASID allocation is [TLB_NR_DYN_ASIDS, MAX_ASID_AVAILABLE-1]. It is a
close interval so the size should be '(MAX_ASID_AVAILABLE-1)-TLB_NR_DYN_ASIDS+1',
regardless of the value of 'MAX_ASID_AVAILABLE'. Moreover, 'MAX_ASID_AVAILABLE'
has already taken the reserved PCID 0 into account; 'MAX_ASID_AVAILABLE-1' is a
valid ASID, and the associated PCID 'MAX_ASID_AVAILABLE' is also a valid PCID.
Did I miss something?
> 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.
>
Yes, I agree. Excluding ASID 0 and using PCID as ASID makes the code
clearer in global ASID allocation.
>
> --
> All Rights Reversed.
next prev parent reply other threads:[~2025-03-31 3:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-29 13:05 [PATCH 0/3] Fix some ASID range size calculation issues in global ASID allocation Hou Wenlong
2025-03-29 13:05 ` [PATCH 1/3] x86/mm: Correct the actual count of available global ASIDs Hou Wenlong
2025-03-29 17:29 ` Rik van Riel
2025-03-31 3:46 ` Hou Wenlong [this message]
2025-03-29 13:05 ` [PATCH 2/3] mm/tlb: Fix wrong judgement in allocate_global_asid() Hou Wenlong
2025-03-29 17:33 ` Rik van Riel
2025-03-31 5:12 ` Hou Wenlong
2025-03-31 12:58 ` Hou Wenlong
2025-03-29 13:05 ` [PATCH 3/3] x86/mm: Fix wrong usage of 'MAX_ASID_AVAILABLE' in global ASID allocation Hou Wenlong
2025-03-30 1:11 ` Rik van Riel
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=20250331034626.GA88569@k08j02272.eu95sqa \
--to=houwenlong.hwl@antgroup.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®