From: Wander Lairson Costa <wander@redhat.com>
To: 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>, Guo Ren <guoren@kernel.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Oleg Nesterov <oleg@redhat.com>,
Wander Lairson Costa <wander@redhat.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>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v2 3/4] sched/rt: use put_task_struct_atomic_safe() to avoid potential splat
Date: Fri, 20 Jan 2023 12:02:41 -0300 [thread overview]
Message-ID: <20230120150246.20797-4-wander@redhat.com> (raw)
In-Reply-To: <20230120150246.20797-1-wander@redhat.com>
rto_push_irq_work_func() is called in hardirq context, and it calls
push_rt_task(), which calls put_task_struct().
If the kernel is compiled with PREEMPT_RT and put_task_struct() reaches
zero usage count, it triggers a splat because __put_task_struct()
indirectly acquires sleeping locks.
The put_task_struct() call pairs with an earlier get_task_struct(),
which makes the probability of the usage count reaches zero pretty
low. In any case, let's play safe and use the atomic safe version.
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
kernel/sched/rt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index ed2a47e4ddae..30a4e9607bec 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2147,7 +2147,7 @@ static int push_rt_task(struct rq *rq, bool pull)
/*
* Something has shifted, try again.
*/
- put_task_struct(next_task);
+ put_task_struct_atomic_safe(next_task);
next_task = task;
goto retry;
}
@@ -2160,7 +2160,7 @@ static int push_rt_task(struct rq *rq, bool pull)
double_unlock_balance(rq, lowest_rq);
out:
- put_task_struct(next_task);
+ put_task_struct_atomic_safe(next_task);
return ret;
}
--
2.39.0
next prev parent reply other threads:[~2023-01-20 15:04 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
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 ` Wander Lairson Costa [this message]
2023-01-25 0:16 ` [PATCH v2 3/4] sched/rt: use put_task_struct_atomic_safe() to avoid potential splat 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=20230120150246.20797-4-wander@redhat.com \
--to=wander@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=guoren@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--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=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