From: Frederic Weisbecker <frederic@kernel.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Anthony Mallet <anthony.mallet@laas.fr>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
linux-kernel@vger.kernel.org, Dmitry Vyukov <dvyukov@google.com>,
Marco Elver <elver@google.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: posix timer freeze after some random time, under pthread create/destroy load
Date: Fri, 22 Nov 2024 13:58:07 +0100 [thread overview]
Message-ID: <Z0B_38aWqStmhN24@pavilion.home> (raw)
In-Reply-To: <20241122123817.GC24815@redhat.com>
Le Fri, Nov 22, 2024 at 01:38:17PM +0100, Oleg Nesterov a écrit :
> On 11/22, Frederic Weisbecker wrote:
> >
> > Le Fri, Nov 22, 2024 at 12:49:50PM +0100, Oleg Nesterov a écrit :
> > > On 11/22, Frederic Weisbecker wrote:
> > > >
> > > >
> > > > Right, I don't mind either way,
> > >
> > > Me too, so feel free to ignore,
> > >
> > > > though if it's past PF_EXITING,
> > > > complete_signal() -> wants_signal() will defer to another thread anyway, right?
> > >
> > > Right. So I think it would be better to rely on complete_signal() in this
> > > case even if the current logic is very simple and dumb.
> >
> > Just to make sure I understand correctly, this means you'd prefer to keep
> > the PF_EXITING test?
>
> No, sorry for confusion ;)
>
> I'd prefer to check t->exit_state in send_sigqueue() and let complete_signal()
> pick another thread if "t->flags & PF_EXITING" is already set.
>
> But I am fine either way, up to you.
Ok I'm good with t->exit_state, I'm cooking that.
>
> I guess we can even avoid the additional check altogether, something like below.
> Again, up to you. Your approach looks simpler and doesn't need more comments.
>
> Oleg.
>
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -1966,7 +1966,7 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
> {
> int sig = q->info.si_signo;
> struct sigpending *pending;
> - struct task_struct *t;
> + struct task_struct *g, *t;
> unsigned long flags;
> int ret, result;
>
> @@ -1989,12 +1989,12 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
> * the same thread group as the target process, which avoids
> * unnecessarily waking up a potentially idle task.
> */
> - t = pid_task(pid, type);
> - if (!t)
> + g = t = pid_task(pid, type);
> + if (!g)
> goto ret;
> if (type != PIDTYPE_PID && same_thread_group(t, current))
> t = current;
> - if (!likely(lock_task_sighand(t, &flags)))
> + if (!likely(lock_task_sighand(g, &flags)))
> goto ret;
>
> ret = 1; /* the signal is ignored */
> @@ -2022,7 +2022,7 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
> result = TRACE_SIGNAL_DELIVERED;
> out:
> trace_signal_generate(sig, &q->info, t, type != PIDTYPE_PID, result);
> - unlock_task_sighand(t, &flags);
> + unlock_task_sighand(g, &flags);
> ret:
> rcu_read_unlock();
> return ret;
>
That's nice! But with the recent changes in this area, the target pick-up
logic has moved to a separate function posixtimer_get_target() which makes
this trick a bit more difficult.
I'll stick to exit_state for now.
Thanks a lot for your insight!
prev parent reply other threads:[~2024-11-22 12:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 21:29 Anthony Mallet
2024-11-21 18:19 ` Frederic Weisbecker
2024-11-22 8:24 ` Oleg Nesterov
2024-11-22 11:05 ` Frederic Weisbecker
2024-11-22 11:49 ` Oleg Nesterov
2024-11-22 12:01 ` Frederic Weisbecker
2024-11-22 12:38 ` Oleg Nesterov
2024-11-22 12:58 ` Frederic Weisbecker [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=Z0B_38aWqStmhN24@pavilion.home \
--to=frederic@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=anthony.mallet@laas.fr \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--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
all inboxes | Powered by JetHome®