summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0108-kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches-rt/0108-kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch')
-rw-r--r--debian/patches-rt/0108-kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/debian/patches-rt/0108-kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch b/debian/patches-rt/0108-kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch
new file mode 100644
index 000000000..da1b8eee6
--- /dev/null
+++ b/debian/patches-rt/0108-kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch
@@ -0,0 +1,70 @@
+From 3028eeca5a3657762aa36512dac687f987462a80 Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Mon, 21 Nov 2016 19:31:08 +0100
+Subject: [PATCH 108/347] kernel/sched: move stack + kprobe clean up to
+ __put_task_struct()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.246-rt110.tar.xz
+
+There is no need to free the stack before the task struct (except for reasons
+mentioned in commit 68f24b08ee89 ("sched/core: Free the stack early if
+CONFIG_THREAD_INFO_IN_TASK")). This also comes handy on -RT because we can't
+free memory in preempt disabled region.
+
+Cc: stable-rt@vger.kernel.org #for kprobe_flush_task()
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/fork.c | 10 ++++++++++
+ kernel/sched/core.c | 9 ---------
+ 2 files changed, 10 insertions(+), 9 deletions(-)
+
+diff --git a/kernel/fork.c b/kernel/fork.c
+index 114ff9724b02..efe690af29f1 100644
+--- a/kernel/fork.c
++++ b/kernel/fork.c
+@@ -40,6 +40,7 @@
+ #include <linux/hmm.h>
+ #include <linux/fs.h>
+ #include <linux/mm.h>
++#include <linux/kprobes.h>
+ #include <linux/vmacache.h>
+ #include <linux/nsproxy.h>
+ #include <linux/capability.h>
+@@ -698,6 +699,15 @@ void __put_task_struct(struct task_struct *tsk)
+ WARN_ON(atomic_read(&tsk->usage));
+ WARN_ON(tsk == current);
+
++ /*
++ * Remove function-return probe instances associated with this
++ * task and put them back on the free list.
++ */
++ kprobe_flush_task(tsk);
++
++ /* Task is done with its stack. */
++ put_task_stack(tsk);
++
+ cgroup_free(tsk);
+ task_numa_free(tsk, true);
+ security_task_free(tsk);
+diff --git a/kernel/sched/core.c b/kernel/sched/core.c
+index 676b9b213991..089779e18440 100644
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -2746,15 +2746,6 @@ static struct rq *finish_task_switch(struct task_struct *prev)
+ if (prev->sched_class->task_dead)
+ prev->sched_class->task_dead(prev);
+
+- /*
+- * Remove function-return probe instances associated with this
+- * task and put them back on the free list.
+- */
+- kprobe_flush_task(prev);
+-
+- /* Task is done with its stack. */
+- put_task_stack(prev);
+-
+ put_task_struct(prev);
+ }
+
+--
+2.36.1
+