From: Oleg Nesterov <oleg@redhat.com>
To: Frederic Weisbecker <frederic@kernel.org>
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:38:17 +0100 [thread overview]
Message-ID: <20241122123817.GC24815@redhat.com> (raw)
In-Reply-To: <Z0BylnuVaxwCNP9n@pavilion.home>
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.
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;
next prev parent reply other threads:[~2024-11-22 12:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 21:29 posix timer freeze after some random time, under pthread create/destroy load 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 [this message]
2024-11-22 12:58 ` 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=20241122123817.GC24815@redhat.com \
--to=oleg@redhat.com \
--cc=anna-maria@linutronix.de \
--cc=anthony.mallet@laas.fr \
--cc=dvyukov@google.com \
--cc=elver@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