Re: [PATCH V8 14/44] x86/pkeys: Introduce pks_write_pkrs()

Ira Weiny
2022-01-29T00:16:55Z

On Fri, Jan 28, 2022 at 04:12:06PM -0800, Dave Hansen wrote:
> On 1/27/22 09:54, ira.weiny@intel.com wrote:
> > Writing to MSR's is inefficient. Even though the underlying
> > WRMSR(MSR_IA32_PKRS) is not serializing (see below), writing to the MSR
> > unnecessarily should be avoided. This is especially true when the value
> > of the PKS protections is unlikely to change from the default often.
>
> This probably needs some context.
>
> The most important pks_write_pkrs() user is in the scheduler, right?

This is also used during exceptions, twice. Those are probably more important.

>
> So, this is really about optimizing that scheduler code for the common
> case where, even when changing threads, the PKRS value does not change.
>
> Can you explain a bit why you expect that to be the common case?

Yes.

Ira