linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/3] Introduce put_task_struct_atomic_sleep()
@ 2023-04-14 12:55 Wander Lairson Costa
  2023-04-14 12:55 ` [PATCH v6 1/3] sched/core: warn on call put_task_struct in invalid context Wander Lairson Costa
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Wander Lairson Costa @ 2023-04-14 12:55 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, Will Deacon, Waiman Long, Boqun Feng,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, Daniel Bristot de Oliveira,
	Valentin Schneider, Eric W. Biederman, Wander Lairson Costa,
	Andrew Morton, Guo Ren, Kefeng Wang, Oleg Nesterov,
	Liam R. Howlett, Vlastimil Babka, Christian Brauner, Andrei Vagin,
	Shakeel Butt, open list, open list:PERFORMANCE EVENTS SUBSYSTEM

The put_task_struct() function reduces a usage counter and invokes
__put_task_struct() when the counter reaches zero.

In the case of __put_task_struct(), it indirectly acquires a spinlock,
which operates as a sleeping lock under the PREEMPT_RT configuration.
As a result, invoking put_task_struct() within an atomic context is
not feasible for real-time (RT) kernels.

To address this issue, this patch series introduces a new function
called put_task_struct_atomic_safe(). When compiled with the
PREEMPT_RT configuration, this function defers the call to
__put_task_struct() to a process context.

Additionally, the patch series rectifies known problematic call sites
to ensure smooth functioning.

Changelog
=========

v1:
* Initial implementation fixing the splat.

v2:
* Isolate the logic in its own function.
* Fix two more cases caught in review.

v3:
* Change __put_task_struct() to handle the issue internally.

v4:
* Explain why call_rcu() is safe to call from interrupt context.

v5:
* Explain why __put_task_struct() doesn't conflict with
  put_task_sruct_rcu_user.

v6:
* As per Sebastian's review, revert back the implementation of v2
  with a distinct function.
* Add a check in put_task_struct() to warning when called from a
  non-sleepable context.
* Address more call sites.

Wander Lairson Costa (3):
  sched/core: warn on call put_task_struct in invalid context
  sched/task: Add the put_task_struct_atomic_safe() function
  treewide: replace put_task_struct() witht the atomic safe version

 include/linux/sched/task.h | 45 ++++++++++++++++++++++++++++++++++++++
 kernel/events/core.c       |  6 ++---
 kernel/fork.c              |  8 +++++++
 kernel/locking/rtmutex.c   | 10 ++++-----
 kernel/sched/core.c        |  6 ++---
 kernel/sched/deadline.c    | 16 +++++++-------
 kernel/sched/rt.c          |  4 ++--
 7 files changed, 74 insertions(+), 21 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-04-24 21:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-14 12:55 [PATCH v6 0/3] Introduce put_task_struct_atomic_sleep() Wander Lairson Costa
2023-04-14 12:55 ` [PATCH v6 1/3] sched/core: warn on call put_task_struct in invalid context Wander Lairson Costa
2023-04-14 12:55 ` [PATCH v6 2/3] sched/task: Add the put_task_struct_atomic_safe() function Wander Lairson Costa
2023-04-17 18:51   ` Waiman Long
2023-04-18 14:18     ` Wander Lairson Costa
2023-04-18 14:26       ` Waiman Long
2023-04-24 18:09   ` Paul E. McKenney
2023-04-24 18:43     ` Wander Lairson Costa
2023-04-24 18:52       ` Paul E. McKenney
2023-04-24 20:34         ` Wander Lairson Costa
2023-04-24 21:54           ` Paul E. McKenney
2023-04-24 20:34         ` Steven Rostedt
2023-04-14 12:55 ` [PATCH v6 3/3] treewide: replace put_task_struct() witht the atomic safe version Wander Lairson Costa
2023-04-17 18:53   ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).