Port-amd64 archive

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

Re: AVX support



Le 29/12/2016 à 12:36, David Laight a écrit :
Back then I had written a patch to switch to a dynamic FPU area - that is,
the
kernel allocates dynamically an fpu area for each lwp, the first time they
use the fpu. But for some reason I've never committed it.

Not much point, it probably saves very little memory and adds a dufficult
to recover 'malloc fail'.

The point was not to save memory, it was just to avoid collision between FPU
states and the kernel stack.

It does indeed introduce a difficult to recover malloc fail, but it is already
what we're doing on sparc64 [1] - I'm not saying that having a PR_WAITOK in
interrupt context is a particularly good idea, but just that dynamic FPU areas
are already handled this way on other architectures.

[...]

The AVX save area is only written if the process has used the avx registers.
There is also an instruction to clear the 'avx used' flag.
Since the avx regs are 'caller saved' they don't need to be
preserved by system calls. So system call entry can mark the avx
registers as 'don't save, restore as zeros'.
Then if a process sleeps in a system call only the small part of the
save area that contains the x87 regs would be accessed if/when
the state is saved.
On a context switch from a hardware interrupt all the user regs
need saving - but the kernel stack use is minimal.
Getting it right with lazy fpu save/restore is 'interesting'
but not impossible.

That's not what I understood last time I read the specification. I perhaps
missed something obvious; I'll have to recheck.

[1] https://nxr.netbsd.org/xref/src/sys/arch/sparc64/sparc64/trap.c#696


Home | Main Index | Thread Index | Old Index