From: Peter Zijlstra <peterz@infradead.org>
To: Pavel Begunkov <asml.silence@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>,
io-uring@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
Tycho Andersen <tandersen@netflix.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, Julian Orth <ju.orth@gmail.com>,
Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 2/2] kernel: rerun task_work while freezing in get_signal()
Date: Mon, 8 Jul 2024 20:48:14 +0200 [thread overview]
Message-ID: <20240708184814.GD27299@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <62c11b59-c909-4c60-8370-77729544ec0a@gmail.com>
On Mon, Jul 08, 2024 at 04:40:07PM +0100, Pavel Begunkov wrote:
> > > --- a/kernel/signal.c
> > > +++ b/kernel/signal.c
> > > @@ -2694,6 +2694,10 @@ bool get_signal(struct ksignal *ksig)
> > > try_to_freeze();
> > > relock:
> > > + clear_notify_signal();
> > > + if (unlikely(task_work_pending(current)))
> > > + task_work_run();
> > > +
> > > spin_lock_irq(&sighand->siglock);
> >
> > Well, but can't we kill the same code at the start of get_signal() then?
> > Of course, in this case get_signal() should check signal_pending(), not
> > task_sigpending().
>
> Should be fine, but I didn't want to change the
> try_to_freeze() -> __refrigerator() path, which also reschedules.
>
> > Or perhaps something like the patch below makes more sense? I dunno...
>
> It needs a far backporting, I'd really prefer to keep it
> lean and without more side effects if possible, unless
> there is a strong opinion on that.
It's been a minute since I dug my way through the signal code, but I
think I slightly favour Oleg's version for not duplicating that
task_work_run().
> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index 1f9dd41c04be..e2ae85293fbb 100644
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -2676,6 +2676,7 @@ bool get_signal(struct ksignal *ksig)
> > struct signal_struct *signal = current->signal;
> > int signr;
> > +start:
> > clear_notify_signal();
> > if (unlikely(task_work_pending(current)))
> > task_work_run();
> > @@ -2760,10 +2761,11 @@ bool get_signal(struct ksignal *ksig)
> > if (current->jobctl & JOBCTL_TRAP_MASK) {
> > do_jobctl_trap();
> > spin_unlock_irq(&sighand->siglock);
> > + goto relock;
> > } else if (current->jobctl & JOBCTL_TRAP_FREEZE)
> > do_freezer_trap();
> > -
> > - goto relock;
> > + goto start;
> > + }
> > }
> > /*
> >
>
> --
> Pavel Begunkov
next prev parent reply other threads:[~2024-07-08 18:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-07 16:32 [PATCH 0/2] fix task_work interation with freezing Pavel Begunkov
2024-07-07 16:32 ` [PATCH 1/2] io_uring/io-wq: limit retrying worker initialisation Pavel Begunkov
2024-07-07 16:32 ` [PATCH 2/2] kernel: rerun task_work while freezing in get_signal() Pavel Begunkov
2024-07-08 10:42 ` Oleg Nesterov
2024-07-08 15:40 ` Pavel Begunkov
2024-07-08 18:48 ` Peter Zijlstra [this message]
2024-07-09 10:36 ` Oleg Nesterov
2024-07-09 14:05 ` Pavel Begunkov
2024-07-09 16:39 ` Tejun Heo
2024-07-09 19:07 ` Oleg Nesterov
2024-07-09 19:26 ` Pavel Begunkov
2024-07-09 19:38 ` Oleg Nesterov
2024-07-09 19:55 ` Pavel Begunkov
2024-07-10 0:54 ` Tejun Heo
2024-07-10 17:53 ` Pavel Begunkov
2024-07-10 19:10 ` Oleg Nesterov
2024-07-10 19:20 ` Tejun Heo
2024-07-10 21:34 ` Oleg Nesterov
2024-07-10 22:01 ` Tejun Heo
2024-07-10 22:17 ` Oleg Nesterov
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=20240708184814.GD27299@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=ju.orth@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=tandersen@netflix.com \
--cc=tglx@linutronix.de \
--cc=tj@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.