linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wangyangbo <yangbonis@icloud.com>
To: tsbogend@alpha.franken.de, hejinyang@loongson.cn,
	chenhuacai@kernel.org, peterz@infradead.org, frederic@kernel.org,
	axboe@kernel.dk
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	xiehuanjun@uniontech.com, wangyangbo <yangbonis@icloud.com>
Subject: [PATCH 0/1] Create kernel thread possibly with USEDFPU flag in mips
Date: Mon, 13 Sep 2021 13:36:23 +0800	[thread overview]
Message-ID: <cover.1631510421.git.yangbonis@icloud.com> (raw)

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


             reply	other threads:[~2021-09-13  5:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13  5:36 wangyangbo [this message]
2021-09-13  5:37 ` [PATCH 1/1] MIPS: Fix fpu trap invoked by io-worker wangyangbo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1631510421.git.yangbonis@icloud.com \
    --to=yangbonis@icloud.com \
    --cc=axboe@kernel.dk \
    --cc=chenhuacai@kernel.org \
    --cc=frederic@kernel.org \
    --cc=hejinyang@loongson.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=xiehuanjun@uniontech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).