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

From: Dave Hansen
Date: Fri Jan 28 2022 - 19:12:18 EST


On 1/27/22 09:54, ira.weiny@xxxxxxxxx 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?

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?