[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220421182325.GC20402@redhat.com>
Date: Thu, 21 Apr 2022 20:23:26 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: rjw@...ysocki.net, mingo@...nel.org, vincent.guittot@...aro.org,
dietmar.eggemann@....com, rostedt@...dmis.org, mgorman@...e.de,
ebiederm@...ssion.com, bigeasy@...utronix.de,
Will Deacon <will@...nel.org>, linux-kernel@...r.kernel.org,
tj@...nel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH v2 2/5] sched,ptrace: Fix ptrace_check_attach() vs
PREEMPT_RT
On 04/21, Peter Zijlstra wrote:
>
> Rework ptrace_check_attach() / ptrace_unfreeze_traced() to not rely on
> task->__state as much.
Looks good after the quick glance... but to me honest I got lost and
I need to apply these patches and read the code carefully.
However, I am not able to do this until Monday, sorry.
Just one nit for now,
> static void ptrace_unfreeze_traced(struct task_struct *task)
> {
> - if (READ_ONCE(task->__state) != __TASK_TRACED)
> + if (!task_is_traced(task))
> return;
>
> WARN_ON(!task->ptrace || task->parent != current);
>
> - /*
> - * PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely.
> - * Recheck state under the lock to close this race.
> - */
> spin_lock_irq(&task->sighand->siglock);
> - if (READ_ONCE(task->__state) == __TASK_TRACED) {
> + if (task_is_traced(task)) {
I think ptrace_unfreeze_traced() should not use task_is_traced() at all.
I think a single lockless
if (task->jobctl & JOBCTL_DELAY_WAKEKILL)
return;
at the start should be enough?
Nobody else can set this flag. It can be cleared by the tracee if it was
woken up, so perhaps we can check it again but afaics this is not strictly
needed.
> +// WARN_ON_ONCE(!(task->jobctl & JOBCTL_DELAY_WAKEKILL));
Did you really want to add the commented WARN_ON_ONCE?
Oleg.
Powered by blists - more mailing lists