Port-amd64 archive

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

Re: AVX support



On Mon, Aug 15, 2016 at 09:57:05AM +0200, Maxime Villard wrote:
> Le 12/08/2016 ? 18:22, Erik Fair a ?crit :
> >Has AVX support in NetBSD (context switching) been revisited yet?
> >
> 
> I did check for that two or three weeks ago, and as far as I can tell, 
> NetBSD supports AVX-256 and AVX-512 (contrary to the other BSDs).

I added support for everything that would trigger 'fpu exception'
interrupts.
I think the latest extensions are fpu ones - so won't be saved
correctly.

> When context-switching, the fpu is saved, and the AVX states are part of 
> this since they are explicitly enabled in XCR0 [1].
> By the way, there are already definitions for the AVX structures
> in the XSAVE area [2] (which are never used
> since they don't need to be).
> 
> One huge problem that struck me was that the fpu state is placed in the 
> kernel stack, which means we lose ~2500 bytes of stack.
> With the latest MPX states and the future extensions, we will lose
> even more memory. The priority is moving the fpu out of the pcb.
...

There isn't really a problem.
All of the AVX (and later) registers are defined to be caller saved.
The system call entry path can 'invalidate' all the extra state so
that a sleep with a deep kernel stack will only ever save the x87
registers.
The full 2.5k+ would only need saving after a context switch from
a hardware interrupt.
So the save area can overlap the stack.
I didn't code that in though.


	David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index