[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220314185429.GA30364@redhat.com>
Date: Mon, 14 Mar 2022 19:54:30 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: linux-kernel@...r.kernel.org, Ben Segall <bsegall@...gle.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Mel Gorman <mgorman@...e.de>,
Peter Zijlstra <peterz@...radead.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
Vincent Guittot <vincent.guittot@...aro.org>
Subject: Re: [PATCH] ptrace: fix ptrace vs tasklist_lock race on PREEMPT_RT.
I never really understood ->saved_state logic. Will read this patch
tomorrow, but at first glance this patch doesn't solve all problems.
On 03/02, Sebastian Andrzej Siewior wrote:
>
> +static inline bool __task_state_match_eq(struct task_struct *tsk, long state)
> +{
> + bool match = false;
> +
> + if (READ_ONCE(tsk->__state) == state)
> + match = true;
> + else if (tsk->saved_state == state)
> + match = true;
> + return match;
> +}
...
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3239,7 +3239,8 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
> * is actually now running somewhere else!
> */
> while (task_running(rq, p)) {
> - if (match_state && unlikely(READ_ONCE(p->__state) != match_state))
> + if (match_state &&
> + unlikely(!task_state_match_eq(p, match_state)))
> return 0;
So wait_task_inactive() can return 0 but the task can run after that, right?
This is not what we want...
Oleg.
Powered by blists - more mailing lists