public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	William White <chwhite@redhat.com>,
	Daniel Bristot de Oliveira <bristot@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>
Subject: [for-next][PATCH 10/13] tracing/osnoise: Skip running osnoise if all instances are off
Date: Wed, 21 Jun 2023 12:29:33 -0400	[thread overview]
Message-ID: <20230621162946.318422585@goodmis.org> (raw)
In-Reply-To: 20230621162923.953123395@goodmis.org

From: Daniel Bristot de Oliveira <bristot@kernel.org>

In the case of all tracing instances being off, sleep for the entire
period.

 Q: Why not kill all threads so?
 A: It is valid and useful to start the threads with tracing off.
For example, rtla disables tracing, starts the tracer, applies the
scheduling setup to the threads, e.g., sched priority and cgroup,
and then begin tracing with all set.

Skipping the period helps to speed up rtla setup and save the
trace after a stop tracing.

Link: https://lkml.kernel.org/r/aa4dd9b7e76fcb63901fe5407e15ec002b318599.1686063934.git.bristot@kernel.org

Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: William White <chwhite@redhat.com>
Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace_osnoise.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index c265ec5f1726..220172cb874d 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1285,6 +1285,22 @@ static __always_inline void osnoise_stop_tracing(void)
 	rcu_read_unlock();
 }
 
+/*
+ * osnoise_has_tracing_on - Check if there is at least one instance on
+ */
+static __always_inline int osnoise_has_tracing_on(void)
+{
+	struct osnoise_instance *inst;
+	int trace_is_on = 0;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(inst, &osnoise_instances, list)
+		trace_is_on += tracer_tracing_is_on(inst->tr);
+	rcu_read_unlock();
+
+	return trace_is_on;
+}
+
 /*
  * notify_new_max_latency - Notify a new max latency via fsnotify interface.
  */
@@ -1517,13 +1533,16 @@ static struct cpumask save_cpumask;
 /*
  * osnoise_sleep - sleep until the next period
  */
-static void osnoise_sleep(void)
+static void osnoise_sleep(bool skip_period)
 {
 	u64 interval;
 	ktime_t wake_time;
 
 	mutex_lock(&interface_lock);
-	interval = osnoise_data.sample_period - osnoise_data.sample_runtime;
+	if (skip_period)
+		interval = osnoise_data.sample_period;
+	else
+		interval = osnoise_data.sample_period - osnoise_data.sample_runtime;
 	mutex_unlock(&interface_lock);
 
 	/*
@@ -1604,8 +1623,14 @@ static int osnoise_main(void *data)
 		if (osnoise_migration_pending())
 			break;
 
+		/* skip a period if tracing is off on all instances */
+		if (!osnoise_has_tracing_on()) {
+			osnoise_sleep(true);
+			continue;
+		}
+
 		run_osnoise();
-		osnoise_sleep();
+		osnoise_sleep(false);
 	}
 
 	migrate_enable();
-- 
2.39.2

  parent reply	other threads:[~2023-06-21 16:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21 16:29 [for-next][PATCH 00/13] tracing: Updates for 6.5 Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 02/13] function_graph: Support recording and printing the return value of function Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 03/13] tracing: Add documentation for funcgraph-retval and funcgraph-retval-hex Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 04/13] arm64: ftrace: Enable HAVE_FUNCTION_GRAPH_RETVAL Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 05/13] x86/ftrace: " Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 06/13] LoongArch: ftrace: " Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 07/13] selftests/ftrace: Add funcgraph-retval test case Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 08/13] ftrace: Show all functions with addresses in available_filter_functions_addrs Steven Rostedt
2023-06-22  7:30   ` Jackie Liu
2023-06-21 16:29 ` [for-next][PATCH 09/13] tracing/osnoise: Switch from PF_NO_SETAFFINITY to migrate_disable Steven Rostedt
2023-06-21 16:29 ` Steven Rostedt [this message]
2023-06-21 16:29 ` [for-next][PATCH 11/13] tracing/timerlat: Add user-space interface Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 12/13] tracing/boot: Replace strlcpy with strscpy Steven Rostedt
2023-06-21 16:29 ` [for-next][PATCH 13/13] riscv: ftrace: Enable HAVE_FUNCTION_GRAPH_RETVAL Steven Rostedt
     [not found] ` <20230621162944.507694485@goodmis.org>
2023-06-21 16:36   ` [for-next][PATCH 01/13] fgraph: Add declaration of "struct fgraph_ret_regs" Steven Rostedt

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=20230621162946.318422585@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=bristot@kernel.org \
    --cc=chwhite@redhat.com \
    --cc=corbet@lwn.net \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.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