forked from rrcarlosr/Jetpack
90 lines
2.6 KiB
Diff
90 lines
2.6 KiB
Diff
From 1467faf21897d6b1587ee70f781ca0b64a245f6a Mon Sep 17 00:00:00 2001
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
Date: Tue, 31 May 2011 16:59:16 +0200
|
|
Subject: [PATCH 129/352] sched: Move task_struct cleanup to RCU
|
|
|
|
__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>
|
|
---
|
|
include/linux/sched.h | 13 +++++++++++++
|
|
kernel/fork.c | 15 ++++++++++++++-
|
|
2 files changed, 27 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/include/linux/sched.h b/include/linux/sched.h
|
|
index d57d9ef..3ca69a0 100644
|
|
--- a/include/linux/sched.h
|
|
+++ b/include/linux/sched.h
|
|
@@ -2142,6 +2142,9 @@ struct task_struct {
|
|
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
|
|
@@ -2403,6 +2406,15 @@ extern struct pid *cad_pid;
|
|
extern void free_task(struct task_struct *tsk);
|
|
#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)
|
|
@@ -2410,6 +2422,7 @@ static inline void put_task_struct(struct task_struct *t)
|
|
if (atomic_dec_and_test(&t->usage))
|
|
__put_task_struct(t);
|
|
}
|
|
+#endif
|
|
|
|
struct task_struct *task_rcu_dereference(struct task_struct **ptask);
|
|
struct task_struct *try_get_task_struct(struct task_struct **ptask);
|
|
diff --git a/kernel/fork.c b/kernel/fork.c
|
|
index 206afae..2a04c19 100644
|
|
--- a/kernel/fork.c
|
|
+++ b/kernel/fork.c
|
|
@@ -386,7 +386,9 @@ static inline void put_signal_struct(struct signal_struct *sig)
|
|
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);
|
|
@@ -403,7 +405,18 @@ void __put_task_struct(struct task_struct *tsk)
|
|
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) { }
|
|
|
|
--
|
|
2.7.4
|
|
|