[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5171500c01604a70b55529d8cd780a57@AcuMS.aculab.com>
Date: Mon, 6 Mar 2023 16:57:57 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Huacai Chen' <chenhuacai@...ngson.cn>,
Arnd Bergmann <arnd@...db.de>,
Huacai Chen <chenhuacai@...nel.org>
CC: "loongarch@...ts.linux.dev" <loongarch@...ts.linux.dev>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
Xuefeng Li <lixuefeng@...ngson.cn>,
Guo Ren <guoren@...nel.org>, Xuerui Wang <kernel@...0n.name>,
Jiaxun Yang <jiaxun.yang@...goat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"loongson-kernel@...ts.loongnix.cn"
<loongson-kernel@...ts.loongnix.cn>
Subject: RE: [PATCH V3] LoongArch: Provide kernel fpu functions
From: Huacai Chen
> Sent: 06 March 2023 10:00
>
> Provide kernel_fpu_begin()/kernel_fpu_end() to allow the kernel itself
> to use fpu. They can be used by some other kernel components, e.g., the
> AMDGPU graphic driver for DCN.
>
...
> +void kernel_fpu_end(void)
> +{
> + if (!this_cpu_read(in_kernel_fpu))
> + return;
Shouldn't it be better for that to be a counter?
Not sure what anyone else does.
> +
> + if (!is_fpu_owner())
> + disable_fpu();
> + else
> + _restore_fp(¤t->thread.fpu);
Does that actual do the restore?
You really don't need to do it until 'return to user'.
That will speed up a subsequent kernel_fpu_begin().
If fact, couldn't kernel_fpu_end() just be preemt_enable()?
David
> +
> + this_cpu_write(in_kernel_fpu, false);
> + preempt_enable();
> +}
> +EXPORT_SYMBOL(kernel_fpu_end);
> --
> 2.39.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists