From: Jens Axboe <[email protected]>
To: Stefan Metzmacher <[email protected]>
Cc: io-uring <[email protected]>
Subject: Re: Problems with io_threads
Date: Fri, 19 Mar 2021 19:20:52 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 3/19/21 6:25 PM, Stefan Metzmacher wrote:
> Am 20.03.21 um 00:46 schrieb Jens Axboe:
>> On Mar 19, 2021, at 5:27 PM, Stefan Metzmacher <[email protected]> wrote:
>>>
>>> Hi Jens,
>>>
>>> as said before I found some problems related to
>>> the new io_threads together with signals.
>>>
>>> I applied the diff (at the end) to examples/io_uring-cp.c
>>> in order to run endless in order to give me time to
>>> look at /proc/...
>>>
>>> Trying to attach gdb --pid to the pid of the main process (thread group)
>>> it goes into an endless loop because it can't attach to the io_threads.
>>>
>>> Sending kill -STOP to the main pid causes the io_threads to spin cpu
>>> at 100%.
>>>
>>> Can you try to reproduce and fix it? Maybe same_thread_group() should not match?
>>
>> Definitely, I’ll go over this shortly and make sure we handle (and ignore) signals correctly.
>
> Thanks! Also a kill -9 to a io_thread kills the application.
OK, this I believe should take care of it - ignore STOP specifically for
PF_IO_WORKER, and disallow any signal sent to a worker.
diff --git a/kernel/signal.c b/kernel/signal.c
index ba4d1ef39a9e..b113bf647fb4 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -833,6 +833,9 @@ static int check_kill_permission(int sig, struct kernel_siginfo *info,
if (!valid_signal(sig))
return -EINVAL;
+ /* PF_IO_WORKER threads don't take any signals */
+ if (t->flags & PF_IO_WORKER)
+ return -EPERM;
if (!si_fromuser(info))
return 0;
@@ -2346,6 +2349,10 @@ static bool do_signal_stop(int signr)
t = current;
while_each_thread(current, t) {
+ /* don't STOP PF_IO_WORKER threads */
+ if (t->flags & PF_IO_WORKER)
+ continue;
+
/*
* Setting state to TASK_STOPPED for a group
* stop is always done with the siglock held,
--
Jens Axboe
prev parent reply other threads:[~2021-03-20 1:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 23:27 Problems with io_threads Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 00/10] Complete setup before calling wake_up_new_task() and improve task->comm Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 01/10] kernel: always initialize task->pf_io_worker to NULL Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 02/10] io_uring: io_sq_thread() no longer needs to reset current->pf_io_worker Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 03/10] io-wq: call set_task_comm() before wake_up_new_task() Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 04/10] io_uring: complete sq_thread setup before calling wake_up_new_task() Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 05/10] io-wq: protect against future set_task_comm() overflows Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 06/10] io_uring: " Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 07/10] fs/proc: hide PF_IO_WORKER in get_task_cmdline() Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 08/10] fs/proc: protect /proc/<pid>/[task/<tid>]/comm for PF_IO_WORKER Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 09/10] io-wq: add io_wq_worker_comm() helper function for dynamic proc_task_comm() generation Stefan Metzmacher
2021-03-15 17:01 ` [RFC PATCH 10/10] fs/proc: make use of io_wq_worker_comm() for PF_IO_WORKER threads Stefan Metzmacher
2021-03-17 22:42 ` [RFC PATCH 00/10] Complete setup before calling wake_up_new_task() and improve task->comm Jens Axboe
2021-03-17 23:06 ` Stefan Metzmacher
2021-03-17 23:26 ` Jens Axboe
2021-03-20 0:00 ` [PATCH v2 0/5] " Stefan Metzmacher
2021-03-20 0:00 ` [PATCH v2 1/5] kernel: always initialize task->pf_io_worker to NULL Stefan Metzmacher
2021-03-20 0:00 ` [PATCH v2 2/5] io_uring: io_sq_thread() no longer needs to reset current->pf_io_worker Stefan Metzmacher
2021-03-20 0:00 ` [PATCH v2 3/5] io-wq: call set_task_comm() before wake_up_new_task() Stefan Metzmacher
2021-03-20 0:00 ` [PATCH v2 4/5] io_uring: complete sq_thread setup before calling wake_up_new_task() Stefan Metzmacher
2021-03-20 0:00 ` [PATCH v2 5/5] fs/proc: hide PF_IO_WORKER in get_task_cmdline() Stefan Metzmacher
2021-03-20 1:24 ` [PATCH v2 0/5] Complete setup before calling wake_up_new_task() and improve task->comm Jens Axboe
2021-03-20 19:22 ` Stefan Metzmacher
2021-03-20 22:39 ` Jens Axboe
2021-03-19 23:46 ` Problems with io_threads Jens Axboe
2021-03-20 0:25 ` Stefan Metzmacher
2021-03-20 1:20 ` Jens Axboe [this message]
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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