All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier Langlois <olivier@trillion01.com>
To: Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] io_uring: handle signals before letting io-worker exit
Date: Thu, 27 May 2021 12:09:46 -0400	[thread overview]
Message-ID: <6b67bd40815f779059f7f3d3ad22f638789452b1.camel@trillion01.com> (raw)
In-Reply-To: <7e10ffd2-5948-3869-b0dc-fd81d693fe33@kernel.dk>

On Thu, 2021-05-27 at 09:30 -0600, Jens Axboe wrote:
> > > 
> > Jens,
> > 
> > You are 100% correct. In fact, this is the same problem for ALL
> > currently existing and future io threads. Therefore, I start to
> > think
> > that the right place for the fix might be straight into
> > do_exit()...
> 
> That is what I was getting at. To avoid poluting do_exit() with it, I
> think it'd be best to add an io_thread_exit() that simply does:
> 
> void io_thread_exit(void)
> {
>         if (signal_pending(current)) {
>                 struct ksignal ksig;
>                 get_signal(&ksig);
>         }
>         do_exit(0);
> }
> 
> and convert the do_exit() calls in io_uring/io-wq to io_thread_exit()
> instead.
> 
IMHO, that would be an acceptable compromise because it does fix my
problem. However, I am of the opinion that it wouldn't be poluting
do_exit() and would in fact be the right place to do it considering
that create_io_thread() is in kernel and theoritically, anyone can call
it to create an io_thread and would be susceptible to get bitten by the
exact same problem and would have to come up with a similar solution if
it is not addressed directly by the kernel.

Also, since I have submitted the patch, I have made the following
realization:

I got bitten by the problem because of a race condition between the io-
mgr thread and its io-wrks threads for processing their pending SIGKILL
and the proposed patch does correct my problem.

The issue would have most likely been buried by 5.13 io-mgr removal...

BUT, even the proposed patch isn't 100% perfect. AFAIK, it is still
possible, but very unlikely, to get a signal between calling
signal_pending() and do_exit().

It might be possible to implement the solution and be 100% correct all
the time by doing it inside do_exit()... I am currently eyeing
exit_signals() as a potential good site for the patch...



      reply	other threads:[~2021-05-27 16:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <60ae94d1.1c69fb81.94f7a.2a35SMTPIN_ADDED_MISSING@mx.google.com>
2021-05-27 13:46 ` [PATCH] io_uring: handle signals before letting io-worker exit Jens Axboe
2021-05-27 15:21   ` Olivier Langlois
2021-05-27 15:30     ` Jens Axboe
2021-05-27 16:09       ` Olivier Langlois [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 \
    --in-reply-to=6b67bd40815f779059f7f3d3ad22f638789452b1.camel@trillion01.com \
    --to=olivier@trillion01.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 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.