From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [patch 3/5] sched: Move kprobes cleanup out of finish_task_switch()
Date: Tue, 28 Sep 2021 14:24:28 +0200 (CEST) [thread overview]
Message-ID: <20210928122411.537994026@linutronix.de> (raw)
In-Reply-To: 20210928122339.502270600@linutronix.de
Doing cleanups in the tail of schedule() is a latency punishment for the
incoming task. The point of invoking kprobes_task_flush() for a dead task
is that the instances are returned and cannot leak when __schedule() is
kprobed.
Move it into the delayed cleanup.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
---
kernel/exit.c | 2 ++
kernel/kprobes.c | 8 ++++----
kernel/sched/core.c | 6 ------
3 files changed, 6 insertions(+), 10 deletions(-)
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -64,6 +64,7 @@
#include <linux/rcuwait.h>
#include <linux/compat.h>
#include <linux/io_uring.h>
+#include <linux/kprobes.h>
#include <linux/uaccess.h>
#include <asm/unistd.h>
@@ -168,6 +169,7 @@ static void delayed_put_task_struct(stru
{
struct task_struct *tsk = container_of(rhp, struct task_struct, rcu);
+ kprobe_flush_task(tsk);
perf_event_delayed_put(tsk);
trace_sched_process_free(tsk);
put_task_struct(tsk);
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1250,10 +1250,10 @@ void kprobe_busy_end(void)
}
/*
- * This function is called from finish_task_switch when task tk becomes dead,
- * so that we can recycle any function-return probe instances associated
- * with this task. These left over instances represent probed functions
- * that have been called but will never return.
+ * This function is called from delayed_put_task_struct() when a task is
+ * dead and cleaned up to recycle any function-return probe instances
+ * associated with this task. These left over instances represent probed
+ * functions that have been called but will never return.
*/
void kprobe_flush_task(struct task_struct *tk)
{
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4846,12 +4846,6 @@ static struct rq *finish_task_switch(str
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);
next prev parent reply other threads:[~2021-09-28 12:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-28 12:24 [patch 0/5] sched: Miscellaneous RT related tweaks Thomas Gleixner
2021-09-28 12:24 ` [patch 1/5] sched: Limit the number of task migrations per batch on RT Thomas Gleixner
2021-10-01 15:05 ` [tip: sched/core] " tip-bot2 for Thomas Gleixner
2021-10-05 14:11 ` tip-bot2 for Thomas Gleixner
2021-09-28 12:24 ` [patch 2/5] sched: Disable TTWU_QUEUE " Thomas Gleixner
2021-10-01 15:05 ` [tip: sched/core] " tip-bot2 for Thomas Gleixner
2021-10-05 14:11 ` tip-bot2 for Thomas Gleixner
2021-09-28 12:24 ` Thomas Gleixner [this message]
2021-10-01 15:05 ` [tip: sched/core] sched: Move kprobes cleanup out of finish_task_switch() tip-bot2 for Thomas Gleixner
2021-10-05 14:11 ` tip-bot2 for Thomas Gleixner
2021-09-28 12:24 ` [patch 4/5] sched: Delay task stack freeing on RT Thomas Gleixner
2021-09-29 11:54 ` Peter Zijlstra
2021-10-01 16:12 ` Andy Lutomirski
2021-10-01 17:24 ` Thomas Gleixner
2021-10-01 18:48 ` Andy Lutomirski
2021-10-01 19:02 ` Andy Lutomirski
2021-10-01 20:54 ` Thomas Gleixner
2021-09-28 12:24 ` [patch 5/5] sched: Move mmdrop to RCU " Thomas Gleixner
2021-09-29 12:02 ` Peter Zijlstra
2021-09-29 13:05 ` Thomas Gleixner
2021-10-01 15:05 ` [tip: sched/core] " tip-bot2 for Thomas Gleixner
2021-10-05 14:11 ` tip-bot2 for Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210928122411.537994026@linutronix.de \
--to=tglx@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).