2020-10-12 12:52:06 +00:00
|
|
|
From e71acb0a092bf3c2381586a3f9368df59ed9ce0b Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <e71acb0a092bf3c2381586a3f9368df59ed9ce0b.1601675152.git.zanussi@kernel.org>
|
|
|
|
In-Reply-To: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
|
|
|
References: <5b5a156f9808b1acf1205606e03da117214549ea.1601675151.git.zanussi@kernel.org>
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
Date: Mon, 21 Nov 2016 19:31:08 +0100
|
2020-09-04 20:10:21 +00:00
|
|
|
Subject: [PATCH 108/333] kernel/sched: move stack + kprobe clean up to
|
2018-08-27 14:32:32 +00:00
|
|
|
__put_task_struct()
|
2020-10-12 12:52:06 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.148-rt64.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
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>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
kernel/fork.c | 10 ++++++++++
|
|
|
|
kernel/sched/core.c | 9 ---------
|
2018-08-27 14:32:32 +00:00
|
|
|
2 files changed, 10 insertions(+), 9 deletions(-)
|
|
|
|
|
2019-11-25 00:04:39 +00:00
|
|
|
diff --git a/kernel/fork.c b/kernel/fork.c
|
2020-02-21 18:07:43 +00:00
|
|
|
index d4ec53c72577..29b54a64daf5 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- 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>
|
2020-02-21 18:07:43 +00:00
|
|
|
@@ -698,6 +699,15 @@ void __put_task_struct(struct task_struct *tsk)
|
2018-08-27 14:32:32 +00:00
|
|
|
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);
|
2019-08-18 21:33:52 +00:00
|
|
|
task_numa_free(tsk, true);
|
2018-08-27 14:32:32 +00:00
|
|
|
security_task_free(tsk);
|
2019-11-25 00:04:39 +00:00
|
|
|
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
|
2020-08-28 04:53:35 +00:00
|
|
|
index ec979c93a488..3600139cb690 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/kernel/sched/core.c
|
|
|
|
+++ b/kernel/sched/core.c
|
2020-08-28 04:53:35 +00:00
|
|
|
@@ -2743,15 +2743,6 @@ static struct rq *finish_task_switch(struct task_struct *prev)
|
2018-08-27 14:32:32 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
2.17.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|