public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Anthony Mallet <anthony.mallet@laas.fr>
Subject: Re: [PATCH] posix-timers: Target group sigqueue to current task only if not exiting
Date: Mon, 25 Nov 2024 12:12:55 +0100	[thread overview]
Message-ID: <20241125111254.GB20402@redhat.com> (raw)
In-Reply-To: <CACT4Y+YQGLtD0673Oxm2=0mHy9cSx1wTPtVCyxjORSv47M+vUw@mail.gmail.com>

On 11/25, Dmitry Vyukov wrote:
>
> On Sat, 23 Nov 2024 at 11:13, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > On 11/23, Frederic Weisbecker wrote:
> > >
> > > - * the same thread group as the target process, which avoids
> > > - * unnecessarily waking up a potentially idle task.
> > > + * the same thread group as the target process and its sighand is
> > > + * stable, which avoids unnecessarily waking up a potentially idle task.
> > >   */
> > >  static inline struct task_struct *posixtimer_get_target(struct k_itimer *tmr)
> > >  {
> > >       struct task_struct *t = pid_task(tmr->it_pid, tmr->it_pid_type);
> > >
> > > -     if (t && tmr->it_pid_type != PIDTYPE_PID && same_thread_group(t, current))
> > > +     if (t && tmr->it_pid_type != PIDTYPE_PID &&
> > > +         same_thread_group(t, current) && !current->exit_state)
> > >               t = current;
> >
> > Thanks!
> >
> > Acked-by: Oleg Nesterov <oleg@redhat.com>
>
> Can't the group leader be exiting as well?

It can. It is even possible that the group leader is already a zombie.

But this is fine. release_task(zombie-or-exiting-leader) (which does __exit_signal()
and clears ->sighand) won't be called until all the sub-threads have exited.

And. If all the sub-threads (and the group leader) have exited, then send_sigqueue()
makes no sense, the whole process is dead. so we do not care if lock_task_sighand()
fails in this case.

> Though, that's still an
> improvements. People usually don't do that (exiting from main w/o
> killing the process).

See above. Nothing to improve, AFAICS.

> So thanks for the fix.

Yes, thank you Anthony and Frederic!

Oleg.


  reply	other threads:[~2024-11-25 11:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-22 23:48 [PATCH] posix-timers: Target group sigqueue to current task only if not exiting Frederic Weisbecker
2024-11-23 10:13 ` Oleg Nesterov
2024-11-25  9:46   ` Dmitry Vyukov
2024-11-25 11:12     ` Oleg Nesterov [this message]
2024-11-25 11:19       ` Dmitry Vyukov
2024-11-29 12:26 ` [tip: timers/urgent] " tip-bot2 for Frederic Weisbecker

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=20241125111254.GB20402@redhat.com \
    --to=oleg@redhat.com \
    --cc=anna-maria@linutronix.de \
    --cc=anthony.mallet@laas.fr \
    --cc=dvyukov@google.com \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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