WSL2-Linux-Kernel/kernel/trace
Nicolas Saenz Julienne 42aaf726c9 tracing/osnoise: Force quiescent states while tracing
commit caf4c86bf1 upstream.

At the moment running osnoise on a nohz_full CPU or uncontested FIFO
priority and a PREEMPT_RCU kernel might have the side effect of
extending grace periods too much. This will entice RCU to force a
context switch on the wayward CPU to end the grace period, all while
introducing unwarranted noise into the tracer. This behaviour is
unavoidable as overly extending grace periods might exhaust the system's
memory.

This same exact problem is what extended quiescent states (EQS) were
created for, conversely, rcu_momentary_dyntick_idle() emulates them by
performing a zero duration EQS. So let's make use of it.

In the common case rcu_momentary_dyntick_idle() is fairly inexpensive:
atomically incrementing a local per-CPU counter and doing a store. So it
shouldn't affect osnoise's measurements (which has a 1us granularity),
so we'll call it unanimously.

The uncommon case involve calling rcu_momentary_dyntick_idle() after
having the osnoise process:

 - Receive an expedited quiescent state IPI with preemption disabled or
   during an RCU critical section. (activates rdp->cpu_no_qs.b.exp
   code-path).

 - Being preempted within in an RCU critical section and having the
   subsequent outermost rcu_read_unlock() called with interrupts
   disabled. (t->rcu_read_unlock_special.b.blocked code-path).

Neither of those are possible at the moment, and are unlikely to be in
the future given the osnoise's loop design. On top of this, the noise
generated by the situations described above is unavoidable, and if not
exposed by rcu_momentary_dyntick_idle() will be eventually seen in
subsequent rcu_read_unlock() calls or schedule operations.

Link: https://lkml.kernel.org/r/20220307180740.577607-1-nsaenzju@redhat.com

Cc: stable@vger.kernel.org
Fixes: bce29ac9ce ("trace: Add osnoise tracer")
Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Acked-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-16 14:23:43 +01:00
..
Kconfig
Makefile
blktrace.c blktrace: fix use after free for struct blk_trace 2022-03-08 19:12:43 +01:00
bpf_trace.c bpf: Remove config check to enable bpf support for branch records 2022-01-27 11:03:28 +01:00
bpf_trace.h
error_report-traces.c
fgraph.c
ftrace.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
ftrace_internal.h
kprobe_event_gen_test.c
power-traces.c
preemptirq_delay_test.c
ring_buffer.c ring-buffer: Protect ring_buffer_reset() from reentrancy 2021-11-18 19:16:03 +01:00
ring_buffer_benchmark.c
rpm-traces.c
synth_event_gen_test.c
trace.c tracing: Ensure trace buffer is at least 4096 bytes large 2022-03-16 14:23:41 +01:00
trace.h tracing: Fix pid filtering when triggers are attached 2021-12-01 09:04:43 +01:00
trace_benchmark.c
trace_benchmark.h
trace_boot.c tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks 2021-11-18 19:16:41 +01:00
trace_branch.c
trace_clock.c
trace_dynevent.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_dynevent.h
trace_entries.h
trace_eprobe.c tracing: Fix misspelling of "missing" 2021-10-29 09:54:14 -04:00
trace_event_perf.c ftrace: do CPU checking after preemption disabled 2021-11-18 19:16:20 +01:00
trace_events.c tracing: Check pid filtering when creating events 2021-12-01 09:04:55 +01:00
trace_events_filter.c tracing: Add ustring operation to filtering string pointers 2022-03-08 19:12:33 +01:00
trace_events_filter_test.h
trace_events_hist.c tracing/histogram: Fix sorting on old "cpu" value 2022-03-08 19:12:54 +01:00
trace_events_inject.c
trace_events_synth.c tracing: Do not let synth_events block other dyn_event systems during create 2022-03-08 19:12:35 +01:00
trace_events_trigger.c tracing: Have traceon and traceoff trigger honor the instance 2022-03-02 11:48:03 +01:00
trace_export.c
trace_functions.c
trace_functions_graph.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_hwlat.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c tracing: Fix return value of __setup handlers 2022-03-08 19:12:54 +01:00
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_mmiotrace.c
trace_nop.c
trace_osnoise.c tracing/osnoise: Force quiescent states while tracing 2022-03-16 14:23:43 +01:00
trace_output.c tracing: Add migrate-disabled counter to tracing output. 2021-09-03 19:42:35 -04:00
trace_output.h
trace_preemptirq.c
trace_printk.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_probe.c tracing/probes: check the return value of kstrndup() for pbuf 2022-03-08 19:12:38 +01:00
trace_probe.h
trace_probe_tmpl.h
trace_recursion_record.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_sched_switch.c
trace_sched_wakeup.c
trace_selftest.c
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_stat.c tracing: Disable "other" permission bits in the tracefs files 2021-11-18 19:16:15 +01:00
trace_stat.h
trace_synth.h tracing: synth events: increase max fields count 2021-09-08 15:29:16 -04:00
trace_syscalls.c tracing: Have syscall trace events use trace_event_buffer_lock_reserve() 2022-01-27 11:05:09 +01:00
trace_uprobe.c tracing/uprobes: Check the return value of kstrdup() for tu->filename 2022-03-08 19:12:38 +01:00
tracing_map.c tracing: Fix a kmemleak false positive in tracing_map 2021-12-17 10:30:16 +01:00
tracing_map.h