[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241122123817.GC24815@redhat.com>
Date: Fri, 22 Nov 2024 13:38:17 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Frederic Weisbecker <frederic@...nel.org>
Cc: Anthony Mallet <anthony.mallet@...s.fr>,
Anna-Maria Behnsen <anna-maria@...utronix.de>,
linux-kernel@...r.kernel.org, Dmitry Vyukov <dvyukov@...gle.com>,
Marco Elver <elver@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: posix timer freeze after some random time, under pthread
create/destroy load
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;
Powered by blists - more mailing lists