public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Wander Lairson Costa <wander@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Valentin Schneider <vschneid@redhat.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Stafford Horne <shorne@gmail.com>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Andy Lutomirski <luto@kernel.org>,
	"Liam R. Howlett" <Liam.Howlett@Oracle.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Andrei Vagin <avagin@gmail.com>,
	open list <linux-kernel@vger.kernel.org>,
	Paul McKenney <paulmck@kernel.org>
Subject: Re: [PATCH v2 1/4] sched/task: Add the put_task_struct_atomic_safe function
Date: Mon, 23 Jan 2023 17:30:03 +0100	[thread overview]
Message-ID: <20230123163002.GB6268@redhat.com> (raw)
In-Reply-To: <20230120150246.20797-2-wander@redhat.com>

On 01/20, Wander Lairson Costa wrote:
>
> +static inline void put_task_struct_atomic_safe(struct task_struct *task)
> +{
> +	if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
> +		/*
> +		 * Decrement the refcount explicitly to avoid unnecessarily
> +		 * calling call_rcu.
> +		 */
> +		if (refcount_dec_and_test(&task->usage))
> +			/*
> +			 * under PREEMPT_RT, we can't call put_task_struct
> +			 * in atomic context because it will indirectly
> +			 * acquire sleeping locks.
> +			 */
> +			call_rcu(&task->rcu, __delayed_put_task_struct);
                                  ^^^^^^^^^
I am not sure the usage of task->rcu is safe...

Suppose that, before __delayed_put_task_struct() is called by RCU, this task
does the last schedule and calls put_task_struct_rcu_user().

And, can't we simply turn put_task_struct() into something like

	put_task_struct(struct task_struct *t)
	{
		if (refcount_dec_and_test(&t->usage)) {
			if (IS_ENABLED(CONFIG_PREEMPT_RT)
			    && (in_atomic() || irqs_disabled()))
				call_rcu(...);
			else
				__put_task_struct(t);
		}
	}

?

Oleg.


  reply	other threads:[~2023-01-23 16:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 15:02 [PATCH v2 0/4] Fix put_task_struct() calls under PREEMPT_RT Wander Lairson Costa
2023-01-20 15:02 ` [PATCH v2 1/4] sched/task: Add the put_task_struct_atomic_safe function Wander Lairson Costa
2023-01-23 16:30   ` Oleg Nesterov [this message]
2023-01-23 16:49     ` Oleg Nesterov
2023-01-23 17:24     ` Wander Lairson Costa
2023-01-27 15:55       ` Valentin Schneider
2023-01-30 11:49         ` Wander Lairson Costa
2023-01-30 14:46           ` Valentin Schneider
2023-01-30 14:58             ` Wander Lairson Costa
2023-01-30 15:20               ` Valentin Schneider
2023-02-17 17:35           ` Daniel Bristot de Oliveira
2023-02-17 19:04             ` luca abeni
2023-02-22 18:42               ` Wander Lairson Costa
2023-02-22 21:00                 ` luca abeni
2023-02-24  8:46                   ` luca abeni
2023-02-24 13:02                     ` Wander Lairson Costa
2023-02-24 16:01                       ` luca abeni
2023-01-20 15:02 ` [PATCH v2 2/4] sched/deadline: fix inactive_task_timer splat Wander Lairson Costa
2023-01-20 15:02 ` [PATCH v2 3/4] sched/rt: use put_task_struct_atomic_safe() to avoid potential splat Wander Lairson Costa
2023-01-25  0:16   ` Steven Rostedt
2023-01-20 15:02 ` [PATCH v2 4/4] sched/core: " Wander Lairson Costa
2023-01-20 17:45 ` [PATCH v2 0/4] Fix put_task_struct() calls under PREEMPT_RT Valentin Schneider
2023-01-20 20:14   ` Wander Lairson Costa

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=20230123163002.GB6268@redhat.com \
    --to=oleg@redhat.com \
    --cc=Liam.Howlett@Oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=ebiederm@xmission.com \
    --cc=fenghua.yu@intel.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=shorne@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=wander@redhat.com \
    --cc=wangkefeng.wang@huawei.com \
    /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