Re: [PATCH v2 1/2] x86/fpu: Extend kernel_fpu_begin_mask() to initialize AMX state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The subject should probably be:

	Allow kernel FPU users to initialize AMX state

On 5/7/24 16:53, Chang S. Bae wrote:
> The In-Field Scan (IFS) test [1] is a destructive process, overwriting
> the existing state to test the logic on the fly. As part of this test
> process, the architectural state is saved before the test begins and
> then restored upon completion.

This should say "_most_ architectural state".

> However, due to resource constraints in storage, AMX state is excluded
> from the scope of state recovery. Consequently, AMX state must be in its
> initialized state for the IFS test to run.

This doesn't mention how this issue got introduced.  Are we all bad at
reading the SDM? :)

> When AMX workloads are running, an active user AMX state remains even
> after a context switch, optimizing to reduce the state reload cost. In
> such cases, the test cannot proceed if it is scheduled.

This is a bit out of the blue.  What does scheduling have do do with IFS?

> System administrators may attempt to mitigate this issue, by arranging
> AMX workloads not to run on CPUs selected for the tests. However, this
> approach is disruptive for managing large-scaled systems, diminishing the
> benefit of the live testing.

I personally prefer to go and mention alternative solutions *after* I've
discussed the things that are truly relevant to the problem and fix.  I
think this distracts from the real issue.

> The kernel can help by properly initializing the state before the test.
> This initialization impacts the performance to some degree. But, this
> approach is considerably cheaper than adding hardware resources and
> simpler than a userspace approach.
> 
> While fpu_idle_fpregs() can initialize the AMX state, its usage should be
> limited to specialized cases, primarily before entering the sleep state.
> The restore_fpregs_from_fpstate() function offers a suitable mechanism
> for initializing fpstate in general, which remains within the core code.

I'm not sure those last two paragraphs add much value.  I'd try to
banish most of that content to *after* you talk about the solution.  Or
maybe put it in the cover letter.

> Extend kernel_fpu_begin_mask() to allow the IFS driver to initialize AMX
> state through restore_fpregs_from_fpstate().

The function names are pretty blatantly obvious from the patch.  No need
to copy them here.

As I look closer, I'm not sure I think this is a good match for the two
other KFPU_* flags.  I don't think either KFPU_387 or KFPU_MXCSR causes
any XFEATURE to be tracked as init.  The SDM says that FNINIT "sets the
FPU control, status, tag, instruction pointer, and data pointer
registers to their default states."

Off the top of my head, I don't know how that maps to the XSAVE init
tracking but I do know that MXCSR has a very weird mapping to the first
two XSAVE features.

I really think it would be simplest to just have this whole thing do this:

	kernel_fpu_begin();

	// Zap AMX state

	kernel_fpu_end();

Where the zap is either an os_xrstor() or an explicit tile release
instruction.

It's just a matter of whether you want this to work like a regular old
kernel FPU user or you want to tie it to *only* being able to run in its
own kernel thread. -- Aside: I don't think I realized IFS had its own
thread earlier.





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux