diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-11-04 20:08:22 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-11-04 20:08:22 +0100 |
commit | 24057fd4f494a00573d34adeaa7042721c1a06a0 (patch) | |
tree | ca69cfd03461c148c60ba0137d20b93976f61b61 /sys/src/9/zynq | |
parent | 04ce485f1b4453335db70b4a1b5d2c96458db3c1 (diff) |
kernel: introduce per process FPU struct (PFPU) for more flexible machine specific fpu handling
introducing the PFPU structue which allows the machine specific
code some flexibility on how to handle the FPU process state.
for example, in the pc and pc64 kernel, the FPsave structure is
arround 512 bytes. with avx512, it could grow up to 2K. instead
of embedding that into the Proc strucutre, it is more effective
to allocate it on first use of the fpu, as most processes do not
use simd or floating point in the first place. also, the FPsave
structure has special 16 byte alignment constraint, which further
favours dynamic allocation.
this gets rid of the memmoves in pc/pc64 kernels for the aligment.
there is also devproc, which is now checking if the fpsave area
is actually valid before reading it, avoiding debuggers to see
garbage data.
the Notsave structure is gone now, as it was not used on any
machine.
Diffstat (limited to 'sys/src/9/zynq')
-rw-r--r-- | sys/src/9/zynq/dat.h | 18 | ||||
-rw-r--r-- | sys/src/9/zynq/main.c | 4 | ||||
-rw-r--r-- | sys/src/9/zynq/trap.c | 6 |
3 files changed, 12 insertions, 16 deletions
diff --git a/sys/src/9/zynq/dat.h b/sys/src/9/zynq/dat.h index 7431ed803..59b60ba19 100644 --- a/sys/src/9/zynq/dat.h +++ b/sys/src/9/zynq/dat.h @@ -1,13 +1,13 @@ typedef struct Conf Conf; typedef struct Confmem Confmem; typedef struct FPsave FPsave; +typedef struct PFPU PFPU; typedef struct L1 L1; typedef struct Label Label; typedef struct Lock Lock; typedef struct KMap KMap; typedef struct MMMU MMMU; typedef struct Mach Mach; -typedef struct Notsave Notsave; typedef struct Page Page; typedef struct Proc Proc; typedef struct PMMU PMMU; @@ -43,9 +43,12 @@ struct FPsave uchar regs[256]; }; -/* - * FPsave.status - */ +struct PFPU +{ + int fpstate; + FPsave fpsave[1]; +}; + enum { FPinit, @@ -80,13 +83,6 @@ struct Conf }; /* - * things saved in the Proc structure during a notify - */ -struct Notsave { - int emptiness; -}; - -/* * MMU stuff in proc */ #define NCOLOR 1 diff --git a/sys/src/9/zynq/main.c b/sys/src/9/zynq/main.c index c281a5330..9056f57d8 100644 --- a/sys/src/9/zynq/main.c +++ b/sys/src/9/zynq/main.c @@ -50,10 +50,10 @@ procfork(Proc *p) s = splhi(); switch(up->fpstate & ~FPillegal){ case FPactive: - fpsave(&up->fpsave); + fpsave(up->fpsave); up->fpstate = FPinactive; case FPinactive: - p->fpsave = up->fpsave; + memmove(p->fpsave, up->fpsave, sizeof(FPsave)); p->fpstate = FPinactive; } splx(s); diff --git a/sys/src/9/zynq/trap.c b/sys/src/9/zynq/trap.c index 510860b63..cb35b4a9d 100644 --- a/sys/src/9/zynq/trap.c +++ b/sys/src/9/zynq/trap.c @@ -134,7 +134,7 @@ mathtrap(Ureg *, ulong) break; case FPinactive: s = splhi(); - fprestore(&up->fpsave); + fprestore(up->fpsave); up->fpstate = FPactive; splx(s); break; @@ -304,7 +304,7 @@ notify(Ureg *ureg) return 0; if(up->fpstate == FPactive){ - fpsave(&up->fpsave); + fpsave(up->fpsave); up->fpstate = FPinactive; } up->fpstate |= FPillegal; @@ -517,7 +517,7 @@ procsave(Proc *p) if(p->state == Moribund) fpclear(); else - fpsave(&p->fpsave); + fpsave(p->fpsave); p->fpstate = FPinactive; } cycles(&t); |