All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Create kernel thread possibly with USEDFPU flag in mips
@ 2021-09-13  5:36 wangyangbo
  2021-09-13  5:37 ` [PATCH 1/1] MIPS: Fix fpu trap invoked by io-worker wangyangbo
  0 siblings, 1 reply; 2+ messages in thread
From: wangyangbo @ 2021-09-13  5:36 UTC (permalink / raw)
  To: tsbogend, hejinyang, chenhuacai, peterz, frederic, axboe
  Cc: linux-mips, linux-kernel, xiehuanjun, wangyangbo

Hi,
I want to use new syscall io_uring in mips,

Problem:
Running ./liburing/examples/io_uring-cp of liburing in mips kernel,
[  132.538431] do_cpu invoked from kernel context![#1]:
[  132.597936] CPU: 2 PID: 4154 Comm: iou-wrk-4153 Not tainted 5.14.0-rc1+ #5
[  132.680373] Hardware name: THTF CQTL630 Series/THTF-LS3A4000-7A1000-1W-VB1-ML4A, BIOS V2.0.3 05/08/2020
[  133.560951] Hi    : 0000000000000002
[  133.603728] Lo    : 000000000c49ba60
[  133.646499] epc   : ffffffff80217670 _save_fp+0x10/0xa0
[  133.709104] ra    : ffffffff80cb9c44 __schedule+0x574/0xad8
[  133.775875] Status: 5400cce2 KX SX UX KERNEL EXL
[  133.832222] Cause : 1000002c (ExcCode 0b)
[  133.880215] PrId  : 0014c004 (ICT Loongson-3)
[  135.382659] Call Trace:
[  135.411868] [<ffffffff80217670>] _save_fp+0x10/0xa0
[  135.470296] [<ffffffff80cb9c44>] __schedule+0x574/0xad8
[  135.532893] [<ffffffff80cba22c>] schedule+0x84/0x138
[  135.592361] [<ffffffff80cbf714>] schedule_timeout+0x1bc/0x3c0
[  135.661219] [<ffffffff80510588>] io_wqe_worker+0x110/0x350
[  135.726947] [<ffffffff80205a6c>] ret_from_kernel_thread+0x14/0x1c
[  135.799981]
[  135.817718] Code: 000c6940  05a10011  00000000 <f4810a00> f4830a20  f4850a40  f4870a60  f4890a80  f48b0aa0

Reason:
io-wq, fork worker threads from original user task(commit 3bfe6106693b6b4ba175ad1f929c4660b8f59ca8).
This causes copy_thread with TIF_USEDFPU flag in mips, meaning save_fp in switch_to, triggering do_cpu trap, however cpid 1(fpu) don't allow kernel to use.

Fix:
clear FPU flag in kernel IO_WORKER thread_copy branch.

wangyangbo (1):
  MIPS: Fix fpu trap invoked by io-worker

 arch/mips/kernel/process.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] MIPS: Fix fpu trap invoked by io-worker
  2021-09-13  5:36 [PATCH 0/1] Create kernel thread possibly with USEDFPU flag in mips wangyangbo
@ 2021-09-13  5:37 ` wangyangbo
  0 siblings, 0 replies; 2+ messages in thread
From: wangyangbo @ 2021-09-13  5:37 UTC (permalink / raw)
  To: tsbogend, hejinyang, chenhuacai, peterz, frederic, axboe
  Cc: linux-mips, linux-kernel, xiehuanjun, wangyangbo

From: wangyangbo <wangyangbo@uniontech.com>

Create worker thread from original user task in mips, possibly copying
FPU flag from user task, introducing save_fp when switch_to, triggering
do_cpu trap. So clear USEDFPU flag for IO_WORKER in copy_thread.

Signed-off-by: wangyangbo <yangbonis@icloud.com>
---
 arch/mips/kernel/process.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 95aa86fa6077..0095006d48c7 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -135,6 +135,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 		status |= ST0_EXL;
 #endif
 		childregs->cp0_status = status;
+
+		if (p->flags & PF_IO_WORKER)
+			clear_tsk_thread_flag(p, TIF_USEDFPU);
 		return 0;
 	}
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-13  5:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13  5:36 [PATCH 0/1] Create kernel thread possibly with USEDFPU flag in mips wangyangbo
2021-09-13  5:37 ` [PATCH 1/1] MIPS: Fix fpu trap invoked by io-worker wangyangbo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.