All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valentin Schneider <vschneid@redhat.com>
To: Wander Lairson Costa <wander@redhat.com>,
	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>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Wander Lairson Costa <wander@redhat.com>,
	Oleg Nesterov <oleg@redhat.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>
Subject: Re: [PATCH v2 0/4] Fix put_task_struct() calls under PREEMPT_RT
Date: Fri, 20 Jan 2023 17:45:01 +0000	[thread overview]
Message-ID: <xhsmhy1pxgkwy.mognet@vschneid.remote.csb> (raw)
In-Reply-To: <20230120150246.20797-1-wander@redhat.com>

On 20/01/23 12:02, Wander Lairson Costa wrote:
> put_task_struct() decrements a usage counter and calls
> __put_task_struct() if the counter reaches zero.
>
> __put_task_struct() indirectly acquires a spinlock, which is a sleeping
> lock under PREEMPT_RT. Therefore, we can't call put_task_struct() in an
> atomic context in RT kernels.
>
> This patch series introduces put_task_struct_atomic_safe(), which defers
> the call to __put_task_struct() to a process context when compiled with
> PREEMPT_RT.
>
> It also fixes known problematic call sites.
>

Browsing around put_task_struct() callsites gives me the impression there
are more problematic call sites lurking around, which makes me wonder:
should we make the PREEMPT_RT put_task_struct() *always* be done via
call_rcu()?

The task's stack is actually always freed that way in put_task_stack(), cf.

  e540bf3162e8 ("fork: Only cache the VMAP stack in finish_task_switch()")

> Changelog:
> ==========
>
> v2:
>  * Add the put_task_struct_atomic_safe() function that is responsible for
>    handling the conditions to call put_task_struct().
>  * Replace put_task_struct() by put_task_struct_atomic_safe() in known
>    atomic call sites.
>
> Wander Lairson Costa (4):
>   sched/task: Add the put_task_struct_atomic_safe function
>   sched/deadline: fix inactive_task_timer splat
>   sched/rt: use put_task_struct_atomic_safe() to avoid potential splat
>   sched/core: use put_task_struct_atomic_safe() to avoid potential splat
>
>  include/linux/sched/task.h | 21 +++++++++++++++++++++
>  kernel/fork.c              |  8 ++++++++
>  kernel/sched/core.c        |  2 +-
>  kernel/sched/deadline.c    |  2 +-
>  kernel/sched/rt.c          |  4 ++--
>  5 files changed, 33 insertions(+), 4 deletions(-)
>
> --
> 2.39.0


  parent reply	other threads:[~2023-01-20 17:46 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 ` [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 ` Valentin Schneider [this message]
2023-01-20 20:14   ` [PATCH v2 0/4] Fix put_task_struct() calls under PREEMPT_RT 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=xhsmhy1pxgkwy.mognet@vschneid.remote.csb \
    --to=vschneid@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=catalin.marinas@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=ebiederm@xmission.com \
    --cc=fenghua.yu@intel.com \
    --cc=geert@linux-m68k.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=rmk+kernel@armlinux.org.uk \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.