2020-04-21 20:13:52 +00:00
|
|
|
From 97846d957dd8a3d2b13c5095b2487c4977f0cb93 Mon Sep 17 00:00:00 2001
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
Date: Tue, 31 May 2011 16:59:16 +0200
|
2020-04-21 20:13:52 +00:00
|
|
|
Subject: [PATCH 105/325] sched: Move task_struct cleanup to RCU
|
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.115-rt48.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
__put_task_struct() does quite some expensive work. We don't want to
|
|
|
|
burden random tasks with that.
|
|
|
|
|
|
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
include/linux/sched.h | 3 +++
|
|
|
|
include/linux/sched/task.h | 11 ++++++++++-
|
|
|
|
kernel/fork.c | 15 ++++++++++++++-
|
2018-08-27 14:32:32 +00:00
|
|
|
3 files changed, 27 insertions(+), 2 deletions(-)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/include/linux/sched.h b/include/linux/sched.h
|
2020-02-21 18:07:43 +00:00
|
|
|
index a90b6be626cd..0b8850b6093b 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/include/linux/sched.h
|
|
|
|
+++ b/include/linux/sched.h
|
2019-11-25 00:04:39 +00:00
|
|
|
@@ -1194,6 +1194,9 @@ struct task_struct {
|
2018-08-27 14:32:32 +00:00
|
|
|
unsigned int sequential_io;
|
|
|
|
unsigned int sequential_io_avg;
|
|
|
|
#endif
|
|
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
|
|
+ struct rcu_head put_rcu;
|
|
|
|
+#endif
|
|
|
|
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
|
|
|
|
unsigned long task_state_change;
|
|
|
|
#endif
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
|
2020-01-03 23:36:11 +00:00
|
|
|
index 44c6f15800ff..d2b33e57c636 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/include/linux/sched/task.h
|
|
|
|
+++ b/include/linux/sched/task.h
|
2020-01-03 23:36:11 +00:00
|
|
|
@@ -90,6 +90,15 @@ extern void sched_exec(void);
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)
|
|
|
|
|
|
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
|
|
+extern void __put_task_struct_cb(struct rcu_head *rhp);
|
|
|
|
+
|
|
|
|
+static inline void put_task_struct(struct task_struct *t)
|
|
|
|
+{
|
|
|
|
+ if (atomic_dec_and_test(&t->usage))
|
|
|
|
+ call_rcu(&t->put_rcu, __put_task_struct_cb);
|
|
|
|
+}
|
|
|
|
+#else
|
|
|
|
extern void __put_task_struct(struct task_struct *t);
|
|
|
|
|
|
|
|
static inline void put_task_struct(struct task_struct *t)
|
2020-01-03 23:36:11 +00:00
|
|
|
@@ -97,7 +106,7 @@ static inline void put_task_struct(struct task_struct *t)
|
2018-08-27 14:32:32 +00:00
|
|
|
if (atomic_dec_and_test(&t->usage))
|
|
|
|
__put_task_struct(t);
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+#endif
|
|
|
|
struct task_struct *task_rcu_dereference(struct task_struct **ptask);
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/kernel/fork.c b/kernel/fork.c
|
2020-02-21 18:07:43 +00:00
|
|
|
index ccfcd44a370f..309f4a20d4ac 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/kernel/fork.c
|
|
|
|
+++ b/kernel/fork.c
|
2020-02-21 18:07:43 +00:00
|
|
|
@@ -676,7 +676,9 @@ static inline void put_signal_struct(struct signal_struct *sig)
|
2018-08-27 14:32:32 +00:00
|
|
|
if (atomic_dec_and_test(&sig->sigcnt))
|
|
|
|
free_signal_struct(sig);
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
|
|
+static
|
|
|
|
+#endif
|
|
|
|
void __put_task_struct(struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
WARN_ON(!tsk->exit_state);
|
2020-02-21 18:07:43 +00:00
|
|
|
@@ -693,7 +695,18 @@ void __put_task_struct(struct task_struct *tsk)
|
2018-08-27 14:32:32 +00:00
|
|
|
if (!profile_handoff_task(tsk))
|
|
|
|
free_task(tsk);
|
|
|
|
}
|
|
|
|
+#ifndef CONFIG_PREEMPT_RT_BASE
|
|
|
|
EXPORT_SYMBOL_GPL(__put_task_struct);
|
|
|
|
+#else
|
|
|
|
+void __put_task_struct_cb(struct rcu_head *rhp)
|
|
|
|
+{
|
|
|
|
+ struct task_struct *tsk = container_of(rhp, struct task_struct, put_rcu);
|
|
|
|
+
|
|
|
|
+ __put_task_struct(tsk);
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL_GPL(__put_task_struct_cb);
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
void __init __weak arch_task_cache_init(void) { }
|
|
|
|
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-04-09 19:44:24 +00:00
|
|
|
2.25.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|