[GIT PULL] tracing: minor fixes

Steven Rostedt posted 1 patch 4 years, 3 months ago
kernel/trace/ftrace.c        |  4 ++--
kernel/trace/trace_osnoise.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 2 deletions(-)
[GIT PULL] tracing: minor fixes
Posted by Steven Rostedt 4 years, 3 months ago

Linus,

Minor tracing fixes:

 - Fix unregistering the same event twice a the user could disable
   the event osnoise will disable on unregistering.

 - Inform RCU of a quiescent state in the osnoise testing thread.

 - Fix some kerneldoc comments.


Please pull the latest trace-v5.17-rc6 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v5.17-rc6

Tag SHA1: c61cf6d2e56a0cd22a9d95f2006e91e895b512a2
Head SHA1: 78cbc6513217b00be6a9904415ef7ff3619eb035


Daniel Bristot de Oliveira (1):
      tracing/osnoise: Do not unregister events twice

Jiapeng Chong (1):
      ftrace: Fix some W=1 warnings in kernel doc comments

Nicolas Saenz Julienne (1):
      tracing/osnoise: Force quiescent states while tracing

----
 kernel/trace/ftrace.c        |  4 ++--
 kernel/trace/trace_osnoise.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
---------------------------
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index a4b462b6f944..6105b7036482 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -7790,7 +7790,7 @@ int ftrace_is_dead(void)
 
 /**
  * register_ftrace_function - register a function for profiling
- * @ops - ops structure that holds the function for profiling.
+ * @ops:	ops structure that holds the function for profiling.
  *
  * Register a function to be called by all functions in the
  * kernel.
@@ -7817,7 +7817,7 @@ EXPORT_SYMBOL_GPL(register_ftrace_function);
 
 /**
  * unregister_ftrace_function - unregister a function for profiling.
- * @ops - ops structure that holds the function to unregister
+ * @ops:	ops structure that holds the function to unregister
  *
  * Unregister a function that was added to be called by ftrace profiling.
  */
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index cfddb30e65ab..5e3c62a08fc0 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1386,6 +1386,26 @@ static int run_osnoise(void)
 					osnoise_stop_tracing();
 		}
 
+		/*
+		 * In some cases, notably when running on a nohz_full CPU with
+		 * a stopped tick PREEMPT_RCU has no way to account for QSs.
+		 * This will eventually cause unwarranted noise as PREEMPT_RCU
+		 * will force preemption as the means of ending the current
+		 * grace period. We avoid this problem by calling
+		 * rcu_momentary_dyntick_idle(), which performs a zero duration
+		 * EQS allowing PREEMPT_RCU to end the current grace period.
+		 * This call shouldn't be wrapped inside an RCU critical
+		 * section.
+		 *
+		 * Note that in non PREEMPT_RCU kernels QSs are handled through
+		 * cond_resched()
+		 */
+		if (IS_ENABLED(CONFIG_PREEMPT_RCU)) {
+			local_irq_disable();
+			rcu_momentary_dyntick_idle();
+			local_irq_enable();
+		}
+
 		/*
 		 * For the non-preemptive kernel config: let threads runs, if
 		 * they so wish.
@@ -2200,6 +2220,17 @@ static void osnoise_workload_stop(void)
 	if (osnoise_has_registered_instances())
 		return;
 
+	/*
+	 * If callbacks were already disabled in a previous stop
+	 * call, there is no need to disable then again.
+	 *
+	 * For instance, this happens when tracing is stopped via:
+	 * echo 0 > tracing_on
+	 * echo nop > current_tracer.
+	 */
+	if (!trace_osnoise_callback_enabled)
+		return;
+
 	trace_osnoise_callback_enabled = false;
 	/*
 	 * Make sure that ftrace_nmi_enter/exit() see
Re: [GIT PULL] tracing: minor fixes
Posted by Linus Torvalds 4 years, 3 months ago
On Thu, Mar 10, 2022 at 2:45 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
>  - Fix unregistering the same event twice a the user could disable
>    the event osnoise will disable on unregistering.

What? That sounds like a (bad) markov chain text generator made random
commit noises.

I tried to edit that to something that actually makes some sense, but
who knows..

                  Linus
Re: [GIT PULL] tracing: minor fixes
Posted by Steven Rostedt 4 years, 3 months ago
On Thu, 10 Mar 2022 17:28:31 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Thu, Mar 10, 2022 at 2:45 PM Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> >  - Fix unregistering the same event twice a the user could disable
> >    the event osnoise will disable on unregistering.  
> 
> What? That sounds like a (bad) markov chain text generator made random
> commit noises.
> 
> I tried to edit that to something that actually makes some sense, but
> who knows..

Ah sorry. That was something difficult to shorten, and I wrote that up at
the end of the night.

tracepoints will warn if you try to unregister a callback that is not
registered. It doesn't break anything to do so, but because tracepoints are
asynchronous, and when the user reads the ring buffer it triggers calls to
special functions associated to a tracepoint, unregistering twice usually
is because of a bug that can cause a hard to debug situation. So we warn if
a callback is unregistered from a tracepoint that is not currently
registered.

What happened above is that the osnoise tracer registered callbacks to the
tracepoints. And it unregisters them when the tracer is stopped (echo 0
into tracing_on) or removed (echo nop > current_tracer). If the user stops
osnoise with the echo 0 to tracing_on that will cause the tracepoint
callbacks to be unregistered. If the user then turns off osnoise, then it
will unregister the callbacks again, even though they were no longer
registered.

Basically it was just an accounting error.

-- Steve
Re: [GIT PULL] tracing: minor fixes
Posted by pr-tracker-bot@kernel.org 4 years, 3 months ago
The pull request you sent on Thu, 10 Mar 2022 17:45:45 -0500:

> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git trace-v5.17-rc6

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/dda64ead7e82caa47fafe0edc36067ee64df2203

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html