Skip to content

Commit fe36bb8

Browse files
committed
Merge tag 'trace-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing updates from Steven Rostedt: - Add options to the osnoise tracer: - 'panic_on_stop' option that panics the kernel if osnoise is greater than some user defined threshold. - 'preempt' option, to test noise while preemption is disabled - 'irq' option, to test noise when interrupts are disabled - Add .percent and .graph suffix to histograms to give different outputs - Add nohitcount to disable showing hitcount in histogram output - Add new __cpumask() to trace event fields to annotate that a unsigned long array is a cpumask to user space and should be treated as one. - Add trace_trigger kernel command line parameter to enable trace event triggers at boot up. Useful to trace stack traces, disable tracing and take snapshots. - Fix x86/kmmio mmio tracer to work with the updates to lockdep - Unify the panic and die notifiers - Add back ftrace_expect reference that is used to extract more information in the ftrace_bug() code. - Have trigger filter parsing errors show up in the tracing error log. - Updated MAINTAINERS file to add kernel tracing mailing list and patchwork info - Use IDA to keep track of event type numbers. - And minor fixes and clean ups * tag 'trace-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (44 commits) tracing: Fix cpumask() example typo tracing: Improve panic/die notifiers ftrace: Prevent RCU stall on PREEMPT_VOLUNTARY kernels tracing: Do not synchronize freeing of trigger filter on boot up tracing: Remove pointer (asterisk) and brackets from cpumask_t field tracing: Have trigger filter parsing errors show up in error_log x86/mm/kmmio: Remove redundant preempt_disable() tracing: Fix infinite loop in tracing_read_pipe on overflowed print_trace_line Documentation/osnoise: Add osnoise/options documentation tracing/osnoise: Add preempt and/or irq disabled options tracing/osnoise: Add PANIC_ON_STOP option Documentation/osnoise: Escape underscore of NO_ prefix tracing: Fix some checker warnings tracing/osnoise: Make osnoise_options static tracing: remove unnecessary trace_trigger ifdef ring-buffer: Handle resize in early boot up tracing/hist: Fix issue of losting command info in error_log tracing: Fix issue of missing one synthetic field tracing/hist: Fix out-of-bound write on 'action_data.var_ref_idx' tracing/hist: Fix wrong return value in parse_action_params() ...
2 parents 851f657 + eb9d589 commit fe36bb8

36 files changed

+843
-219
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6266,6 +6266,25 @@
62666266
See also Documentation/trace/ftrace.rst "trace options"
62676267
section.
62686268

6269+
trace_trigger=[trigger-list]
6270+
[FTRACE] Add a event trigger on specific events.
6271+
Set a trigger on top of a specific event, with an optional
6272+
filter.
6273+
6274+
The format is is "trace_trigger=<event>.<trigger>[ if <filter>],..."
6275+
Where more than one trigger may be specified that are comma deliminated.
6276+
6277+
For example:
6278+
6279+
trace_trigger="sched_switch.stacktrace if prev_state == 2"
6280+
6281+
The above will enable the "stacktrace" trigger on the "sched_switch"
6282+
event but only trigger it if the "prev_state" of the "sched_switch"
6283+
event is "2" (TASK_UNINTERUPTIBLE).
6284+
6285+
See also "Event triggers" in Documentation/trace/events.rst
6286+
6287+
62696288
traceoff_on_warning
62706289
[FTRACE] enable this option to disable tracing when a
62716290
warning is hit. This turns off "tracing_on". Tracing can

Documentation/trace/histogram.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Documentation written by Tom Zanussi
2525

2626
hist:keys=<field1[,field2,...]>[:values=<field1[,field2,...]>]
2727
[:sort=<field1[,field2,...]>][:size=#entries][:pause][:continue]
28-
[:clear][:name=histname1][:<handler>.<action>] [if <filter>]
28+
[:clear][:name=histname1][:nohitcount][:<handler>.<action>] [if <filter>]
2929

3030
When a matching event is hit, an entry is added to a hash table
3131
using the key(s) and value(s) named. Keys and values correspond to
@@ -79,6 +79,8 @@ Documentation written by Tom Zanussi
7979
.log2 display log2 value rather than raw number
8080
.buckets=size display grouping of values rather than raw number
8181
.usecs display a common_timestamp in microseconds
82+
.percent display a number of percentage value
83+
.graph display a bar-graph of a value
8284
============= =================================================
8385

8486
Note that in general the semantics of a given field aren't
@@ -137,6 +139,12 @@ Documentation written by Tom Zanussi
137139
existing trigger, rather than via the '>' operator, which will cause
138140
the trigger to be removed through truncation.
139141

142+
The 'nohitcount' (or NOHC) parameter will suppress display of
143+
raw hitcount in the histogram. This option requires at least one
144+
value field which is not a 'raw hitcount'. For example,
145+
'hist:...:vals=hitcount:nohitcount' is rejected, but
146+
'hist:...:vals=hitcount.percent:nohitcount' is OK.
147+
140148
- enable_hist/disable_hist
141149

142150
The enable_hist and disable_hist triggers can be used to have one

Documentation/trace/osnoise-tracer.rst

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ Note that the example above shows a high number of HW noise samples.
9292
The reason being is that this sample was taken on a virtual machine,
9393
and the host interference is detected as a hardware interference.
9494

95-
Tracer options
96-
---------------------
95+
Tracer Configuration
96+
--------------------
9797

9898
The tracer has a set of options inside the osnoise directory, they are:
9999

@@ -109,6 +109,27 @@ The tracer has a set of options inside the osnoise directory, they are:
109109
- tracing_threshold: the minimum delta between two time() reads to be
110110
considered as noise, in us. When set to 0, the default value will
111111
be used, which is currently 5 us.
112+
- osnoise/options: a set of on/off options that can be enabled by
113+
writing the option name to the file or disabled by writing the option
114+
name preceded with the 'NO\_' prefix. For example, writing
115+
NO_OSNOISE_WORKLOAD disables the OSNOISE_WORKLOAD option. The
116+
special DEAFAULTS option resets all options to the default value.
117+
118+
Tracer Options
119+
--------------
120+
121+
The osnoise/options file exposes a set of on/off configuration options for
122+
the osnoise tracer. These options are:
123+
124+
- DEFAULTS: reset the options to the default value.
125+
- OSNOISE_WORKLOAD: do not dispatch osnoise workload (see dedicated
126+
section below).
127+
- PANIC_ON_STOP: call panic() if the tracer stops. This option serves to
128+
capture a vmcore.
129+
- OSNOISE_PREEMPT_DISABLE: disable preemption while running the osnoise
130+
workload, allowing only IRQ and hardware-related noise.
131+
- OSNOISE_IRQ_DISABLE: disable IRQs while running the osnoise workload,
132+
allowing only NMIs and hardware-related noise, like hwlat tracer.
112133

113134
Additional Tracing
114135
------------------
@@ -150,3 +171,10 @@ tracepoints is smaller than eight us reported in the sample_threshold.
150171
The reason roots in the overhead of the entry and exit code that happens
151172
before and after any interference execution. This justifies the dual
152173
approach: measuring thread and tracing.
174+
175+
Running osnoise tracer without workload
176+
---------------------------------------
177+
178+
By enabling the osnoise tracer with the NO_OSNOISE_WORKLOAD option set,
179+
the osnoise: tracepoints serve to measure the execution time of
180+
any type of Linux task, free from the interference of other tasks.

MAINTAINERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8528,6 +8528,9 @@ FUNCTION HOOKS (FTRACE)
85288528
M: Steven Rostedt <[email protected]>
85298529
M: Masami Hiramatsu <[email protected]>
85308530
R: Mark Rutland <[email protected]>
8531+
8532+
8533+
Q: https://patchwork.kernel.org/project/linux-trace-kernel/list/
85318534
S: Maintained
85328535
T: git git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
85338536
F: Documentation/trace/ftrace*
@@ -11606,6 +11609,9 @@ M: Naveen N. Rao <[email protected]>
1160611609
M: Anil S Keshavamurthy <[email protected]>
1160711610
M: "David S. Miller" <[email protected]>
1160811611
M: Masami Hiramatsu <[email protected]>
11612+
11613+
11614+
Q: https://patchwork.kernel.org/project/linux-trace-kernel/list/
1160911615
S: Maintained
1161011616
T: git git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
1161111617
F: Documentation/trace/kprobes.rst
@@ -21079,6 +21085,9 @@ F: drivers/hwmon/pmbus/tps546d24.c
2107921085
TRACING
2108021086
M: Steven Rostedt <[email protected]>
2108121087
M: Masami Hiramatsu <[email protected]>
21088+
21089+
21090+
Q: https://patchwork.kernel.org/project/linux-trace-kernel/list/
2108221091
S: Maintained
2108321092
T: git git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
2108421093
F: Documentation/trace/*

arch/x86/kernel/ftrace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ void ftrace_replace_code(int enable)
221221

222222
ret = ftrace_verify_code(rec->ip, old);
223223
if (ret) {
224+
ftrace_expected = old;
224225
ftrace_bug(ret, rec);
226+
ftrace_expected = NULL;
225227
return;
226228
}
227229
}

arch/x86/mm/kmmio.c

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ struct kmmio_context {
6262
int active;
6363
};
6464

65-
static DEFINE_SPINLOCK(kmmio_lock);
65+
/*
66+
* The kmmio_lock is taken in int3 context, which is treated as NMI context.
67+
* This causes lockdep to complain about it bein in both NMI and normal
68+
* context. Hide it from lockdep, as it should not have any other locks
69+
* taken under it, and this is only enabled for debugging mmio anyway.
70+
*/
71+
static arch_spinlock_t kmmio_lock = __ARCH_SPIN_LOCK_UNLOCKED;
6672

6773
/* Protected by kmmio_lock */
6874
unsigned int kmmio_count;
@@ -240,15 +246,14 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
240246
page_base &= page_level_mask(l);
241247

242248
/*
243-
* Preemption is now disabled to prevent process switch during
244-
* single stepping. We can only handle one active kmmio trace
249+
* Hold the RCU read lock over single stepping to avoid looking
250+
* up the probe and kmmio_fault_page again. The rcu_read_lock_sched()
251+
* also disables preemption and prevents process switch during
252+
* the single stepping. We can only handle one active kmmio trace
245253
* per cpu, so ensure that we finish it before something else
246-
* gets to run. We also hold the RCU read lock over single
247-
* stepping to avoid looking up the probe and kmmio_fault_page
248-
* again.
254+
* gets to run.
249255
*/
250-
preempt_disable();
251-
rcu_read_lock();
256+
rcu_read_lock_sched_notrace();
252257

253258
faultpage = get_kmmio_fault_page(page_base);
254259
if (!faultpage) {
@@ -317,8 +322,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
317322
return 1; /* fault handled */
318323

319324
no_kmmio:
320-
rcu_read_unlock();
321-
preempt_enable_no_resched();
325+
rcu_read_unlock_sched_notrace();
322326
return ret;
323327
}
324328

@@ -346,19 +350,18 @@ static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs)
346350
ctx->probe->post_handler(ctx->probe, condition, regs);
347351

348352
/* Prevent racing against release_kmmio_fault_page(). */
349-
spin_lock(&kmmio_lock);
353+
arch_spin_lock(&kmmio_lock);
350354
if (ctx->fpage->count)
351355
arm_kmmio_fault_page(ctx->fpage);
352-
spin_unlock(&kmmio_lock);
356+
arch_spin_unlock(&kmmio_lock);
353357

354358
regs->flags &= ~X86_EFLAGS_TF;
355359
regs->flags |= ctx->saved_flags;
356360

357361
/* These were acquired in kmmio_handler(). */
358362
ctx->active--;
359363
BUG_ON(ctx->active);
360-
rcu_read_unlock();
361-
preempt_enable_no_resched();
364+
rcu_read_unlock_sched_notrace();
362365

363366
/*
364367
* if somebody else is singlestepping across a probe point, flags
@@ -440,7 +443,8 @@ int register_kmmio_probe(struct kmmio_probe *p)
440443
unsigned int l;
441444
pte_t *pte;
442445

443-
spin_lock_irqsave(&kmmio_lock, flags);
446+
local_irq_save(flags);
447+
arch_spin_lock(&kmmio_lock);
444448
if (get_kmmio_probe(addr)) {
445449
ret = -EEXIST;
446450
goto out;
@@ -460,7 +464,9 @@ int register_kmmio_probe(struct kmmio_probe *p)
460464
size += page_level_size(l);
461465
}
462466
out:
463-
spin_unlock_irqrestore(&kmmio_lock, flags);
467+
arch_spin_unlock(&kmmio_lock);
468+
local_irq_restore(flags);
469+
464470
/*
465471
* XXX: What should I do here?
466472
* Here was a call to global_flush_tlb(), but it does not exist
@@ -494,7 +500,8 @@ static void remove_kmmio_fault_pages(struct rcu_head *head)
494500
struct kmmio_fault_page **prevp = &dr->release_list;
495501
unsigned long flags;
496502

497-
spin_lock_irqsave(&kmmio_lock, flags);
503+
local_irq_save(flags);
504+
arch_spin_lock(&kmmio_lock);
498505
while (f) {
499506
if (!f->count) {
500507
list_del_rcu(&f->list);
@@ -506,7 +513,8 @@ static void remove_kmmio_fault_pages(struct rcu_head *head)
506513
}
507514
f = *prevp;
508515
}
509-
spin_unlock_irqrestore(&kmmio_lock, flags);
516+
arch_spin_unlock(&kmmio_lock);
517+
local_irq_restore(flags);
510518

511519
/* This is the real RCU destroy call. */
512520
call_rcu(&dr->rcu, rcu_free_kmmio_fault_pages);
@@ -540,14 +548,16 @@ void unregister_kmmio_probe(struct kmmio_probe *p)
540548
if (!pte)
541549
return;
542550

543-
spin_lock_irqsave(&kmmio_lock, flags);
551+
local_irq_save(flags);
552+
arch_spin_lock(&kmmio_lock);
544553
while (size < size_lim) {
545554
release_kmmio_fault_page(addr + size, &release_list);
546555
size += page_level_size(l);
547556
}
548557
list_del_rcu(&p->list);
549558
kmmio_count--;
550-
spin_unlock_irqrestore(&kmmio_lock, flags);
559+
arch_spin_unlock(&kmmio_lock);
560+
local_irq_restore(flags);
551561

552562
if (!release_list)
553563
return;

include/linux/ring_buffer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ void ring_buffer_change_overwrite(struct trace_buffer *buffer, int val);
113113

114114
struct ring_buffer_event *ring_buffer_lock_reserve(struct trace_buffer *buffer,
115115
unsigned long length);
116-
int ring_buffer_unlock_commit(struct trace_buffer *buffer,
117-
struct ring_buffer_event *event);
116+
int ring_buffer_unlock_commit(struct trace_buffer *buffer);
118117
int ring_buffer_write(struct trace_buffer *buffer,
119118
unsigned long length, void *data);
120119

include/linux/trace_events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ struct trace_event_functions {
136136

137137
struct trace_event {
138138
struct hlist_node node;
139-
struct list_head list;
140139
int type;
141140
struct trace_event_functions *funcs;
142141
};
@@ -235,7 +234,8 @@ void tracing_record_taskinfo_sched_switch(struct task_struct *prev,
235234
void tracing_record_cmdline(struct task_struct *task);
236235
void tracing_record_tgid(struct task_struct *task);
237236

238-
int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...);
237+
int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...)
238+
__printf(3, 4);
239239

240240
struct event_filter;
241241

include/linux/trace_seq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ extern int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str,
9797
const void *buf, size_t len, bool ascii);
9898

9999
#else /* CONFIG_TRACING */
100-
static inline void trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
100+
static inline __printf(2, 3)
101+
void trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
101102
{
102103
}
103104
static inline void

include/trace/bpf_probe.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#undef __get_bitmask
2222
#define __get_bitmask(field) (char *)__get_dynamic_array(field)
2323

24+
#undef __get_cpumask
25+
#define __get_cpumask(field) (char *)__get_dynamic_array(field)
26+
2427
#undef __get_sockaddr
2528
#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
2629

@@ -40,6 +43,9 @@
4043
#undef __get_rel_bitmask
4144
#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
4245

46+
#undef __get_rel_cpumask
47+
#define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field)
48+
4349
#undef __get_rel_sockaddr
4450
#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
4551

0 commit comments

Comments
 (0)