Re: [PATCH v2 1/2] x86/fpu: Extend kernel_fpu_begin_mask() to initialize AMX state
From: Dave Hansen
Date: Thu May 09 2024 - 14:50:56 EST
On 5/9/24 11:41, Chang S. Bae wrote:
> On 5/9/2024 10:36 AM, Dave Hansen wrote:
>>
>> I'd probably just do this:
>>
>> + kernel_fpu_begin();
>> + // AMX *MUST* be in the init state for the wrmsr() to work.
>> + // But, the more in the init state, the less state the test
>> + // has to save and restore. Just zap everything.
>> + restore_fpregs_from_fpstate(&init_fpstate,
>> + fpu_user_cfg.max_features);
>> +
>
> I assume that this snippet goes to the IFS driver side. Then, we need
> to introduce and export a new wrapper for this.
> restore_fpregs_from_fpstate() and its arguments are not accessible as
> of now.
Yes, a new wrapper to initialize all the user FPU state is fine.
> Also, I think we should encapsulate them. If we follow this style, we
> could have invoked tilerelease() directly from the idle driver, right?
You could have... But I think the point there truly was to do a minimal
amount of work because you're going idle and need to race to get there.
The path to idle is super hot and you don't want to do _any_ additional
work. It's worth writing highly AMX-specific code because generic code
would be slow there.
The IFS path is a super duper slow one. It takes *FOREVER*. I like the
idea of being simple, dumb and slow.