From 24057fd4f494a00573d34adeaa7042721c1a06a0 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 4 Nov 2017 20:08:22 +0100 Subject: 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. --- sys/src/9/teg2/dat.h | 24 ++++++++++-------------- sys/src/9/teg2/fpiarm.c | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'sys/src/9/teg2') diff --git a/sys/src/9/teg2/dat.h b/sys/src/9/teg2/dat.h index 0aa54a7d0..30dd4b5eb 100644 --- a/sys/src/9/teg2/dat.h +++ b/sys/src/9/teg2/dat.h @@ -24,6 +24,7 @@ enum { typedef struct Conf Conf; typedef struct Confmem Confmem; typedef struct FPsave FPsave; +typedef struct PFPU PFPU; typedef struct ISAConf ISAConf; typedef struct Isolated Isolated; typedef struct Label Label; @@ -33,7 +34,6 @@ typedef struct Memcache Memcache; typedef struct MMMU MMMU; typedef struct Mach Mach; typedef u32int Mreg; /* Msr - bloody UART */ -typedef struct Notsave Notsave; typedef struct Page Page; typedef struct Pcisiz Pcisiz; typedef struct Pcidev Pcidev; @@ -72,14 +72,14 @@ struct Label uintptr pc; }; +/* + * emulated or vfp3 floating point + */ enum { Maxfpregs = 32, /* could be 16 or 32, see Mach.fpnregs */ Nfpctlregs = 16, }; -/* - * emulated or vfp3 floating point - */ struct FPsave { ulong status; @@ -94,9 +94,12 @@ struct FPsave uintptr pc; /* of failed fp instr. */ }; -/* - * FPsave.fpstate - */ +struct PFPU +{ + int fpstate; + FPsave fpsave[1]; +}; + enum { FPinit, @@ -135,13 +138,6 @@ struct Conf int monitor; /* flag */ }; -/* - * things saved in the Proc structure during a notify - */ -struct Notsave { - int emptiness; -}; - /* * MMU stuff in Mach. */ diff --git a/sys/src/9/teg2/fpiarm.c b/sys/src/9/teg2/fpiarm.c index d92455328..cefddc3e5 100644 --- a/sys/src/9/teg2/fpiarm.c +++ b/sys/src/9/teg2/fpiarm.c @@ -650,7 +650,7 @@ fpiarm(Ureg *ur) if(up == nil) panic("fpiarm not in a process"); - ufp = &up->fpsave; + ufp = up->fpsave; /* * because all the emulated fp state is in the proc structure, * it need not be saved/restored -- cgit v1.2.3