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 <metze@xxxxxxxxx> 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