From: Dave Hansen <dave.hansen@intel.com>
To: andrew.cooper3@citrix.com, Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, jannh@google.com, x86@kernel.org,
luto@kernel.org, peterz@infradead.org
Subject: Re: [PATCH] x86/mm: Remove "INVPCID single" feature tracking
Date: Fri, 14 Jul 2023 16:01:59 -0700 [thread overview]
Message-ID: <92462889-16e9-5c7b-a524-fe53859f93c1@intel.com> (raw)
In-Reply-To: <df0750e0-dd6f-7418-53bd-64a9ad1e0086@citrix.com>
On 7/14/23 13:27, andrew.cooper3@citrix.com wrote:
>> + /* If PTI is off there is no user PCID and nothing to flush. */
>> if (!static_cpu_has(X86_FEATURE_PTI))
>> return;
>
> As a minor observation, the common case is for the function to exit
> here, but you've got both this_cpu_read()'s ahead of a full compiler
> memory barrier.
>
> If you move them here, you'll drop the reads from the common case.
> But...
That's a good point. I was depending on the generosity of the compiler
but the invlpg throws that out the window. I'll move them around.
>> /*
>> - * Some platforms #GP if we call invpcid(type=1/2) before CR4.PCIDE=1.
>> - * Just use invalidate_user_asid() in case we are called early.
>> + * invpcid_flush_one(pcid>0) will #GP if CR4.PCIDE==0. Check
>> + * 'cpu_pcide' to ensure that *this* CPU will not trigger those
>> + * #GP's even if called before CR4.PCIDE has been initialized.
>> */
>> - if (!this_cpu_has(X86_FEATURE_INVPCID_SINGLE))
>> - invalidate_user_asid(loaded_mm_asid);
>> - else
>> + if (boot_cpu_has(X86_FEATURE_INVPCID) && cpu_pcide)
> ... why can't this just be && loaded_mm_asid ?
>
> There's no plausible way the asid can be nonzero here without CR4.PCIDE
> being set, and that avoids looking at cr4 directly.
Except that 0 is a valid, normal 'loaded_mm_asid' value. It would be
quite possible to have loaded_mm_asid==0 during normal runtime which
would drop down into the invalidate_user_asid() case. It would work,
but it would be unnecessarily destructive to the TLB.
I guess we _could_ adjust the asids to go from 1=>TLB_NR_DYN_ASIDS
instead of 0=>TLB_NR_DYN_ASIDS-1. *But*, PTI is slow path code these
days. I'd rather read one more (presumably) cache hot variable that's
logically clear than go messing with the ASID allocation code making
ASID 0 even more special.
prev parent reply other threads:[~2023-07-14 23:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 18:35 Dave Hansen
2023-07-14 20:27 ` andrew.cooper3
2023-07-14 23:01 ` Dave Hansen [this message]
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=92462889-16e9-5c7b-a524-fe53859f93c1@intel.com \
--to=dave.hansen@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=dave.hansen@linux.intel.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--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®