Skip to content

Commit

Permalink
Merge branch 'trace/for-next-rtla' into trace/for-next
Browse files Browse the repository at this point in the history
  • Loading branch information
rostedt committed Mar 21, 2022
2 parents 795301d + 75016ca commit c87857e
Show file tree
Hide file tree
Showing 29 changed files with 1,084 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Documentation/tools/rtla/common_hist_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Set the histogram bucket size (default *1*).

**-e**, **--entries** *N*
**-E**, **--entries** *N*

Set the number of entries of the histogram (default 256).

Expand Down
19 changes: 19 additions & 0 deletions Documentation/tools/rtla/common_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@

Save the stopped trace to [*file|osnoise_trace.txt*].

**-e**, **--event** *sys:event*

Enable an event in the trace (**-t**) session. The argument can be a specific event, e.g., **-e** *sched:sched_switch*, or all events of a system group, e.g., **-e** *sched*. Multiple **-e** are allowed. It is only active when **-t** or **-a** are set.

**--filter** *<filter>*

Filter the previous **-e** *sys:event* event with *<filter>*. For further information about event filtering see https://www.kernel.org/doc/html/latest/trace/events.html#event-filtering.

**--trigger** *<trigger>*
Enable a trace event trigger to the previous **-e** *sys:event*.
If the *hist:* trigger is activated, the output histogram will be automatically saved to a file named *system_event_hist.txt*.
For example, the command:

rtla <command> <mode> -t -e osnoise:irq_noise --trigger="hist:key=desc,duration/1000:sort=desc,duration/1000:vals=hitcount"

Will automatically save the content of the histogram associated to *osnoise:irq_noise* event in *osnoise_irq_noise_hist.txt*.

For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers.

**-P**, **--priority** *o:prio|r:prio|f:prio|d:runtime:period*

Set scheduling parameters to the osnoise tracer threads, the format to set the priority are:
Expand Down
2 changes: 1 addition & 1 deletion Documentation/tools/rtla/common_osnoise_description.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The **rtla osnoise** tool is an interface for the *osnoise* tracer. The
*osnoise* tracer dispatches a kernel thread per-cpu. These threads read the
time in a loop while with preemption, softirq and IRQs enabled, thus
allowing all the sources of operating systme noise during its execution.
allowing all the sources of operating system noise during its execution.
The *osnoise*'s tracer threads take note of the delta between each time
read, along with an interference counter of all sources of interference.
At the end of each period, the *osnoise* tracer displays a summary of
Expand Down
10 changes: 10 additions & 0 deletions Documentation/tools/rtla/common_osnoise_options.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**-a**, **--auto** *us*

Set the automatic trace mode. This mode sets some commonly used options
while debugging the system. It is equivalent to use **-s** *us* **-T 1 -t**.

**-p**, **--period** *us*

Set the *osnoise* tracer period in microseconds.
Expand All @@ -15,3 +20,8 @@

Stop the trace if the total sample is higher than the argument in microseconds.
If **-T** is set, it will also save the trace to the output.

**-T**, **--threshold** *us*

Specify the minimum delta between two time reads to be considered noise.
The default threshold is *5 us*.
12 changes: 12 additions & 0 deletions Documentation/tools/rtla/common_timerlat_options.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
**-a**, **--auto** *us*

Set the automatic trace mode. This mode sets some commonly used options
while debugging the system. It is equivalent to use **-T** *us* **-s** *us*
**-t**. By default, *timerlat* tracer uses FIFO:95 for *timerlat* threads,
thus equilavent to **-P** *f:95*.

**-p**, **--period** *us*

Set the *timerlat* tracer period in microseconds.
Expand All @@ -14,3 +21,8 @@

Save the stack trace at the *IRQ* if a *Thread* latency is higher than the
argument in us.

**--dma-latency** *us*
Set the /dev/cpu_dma_latency to *us*, aiming to bound exit from idle latencies.
*cyclictest* sets this value to *0* by default, use **--dma-latency** *0* to have
similar results.
2 changes: 1 addition & 1 deletion Documentation/tools/rtla/rtla-osnoise-hist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ default). The reason for reducing the runtime is to avoid starving the
**rtla** tool. The tool is also set to run for *one minute*. The output
histogram is set to group outputs in buckets of *10us* and *25* entries::

[root@f34 ~/]# rtla osnoise hist -P F:1 -c 0-11 -r 900000 -d 1M -b 10 -e 25
[root@f34 ~/]# rtla osnoise hist -P F:1 -c 0-11 -r 900000 -d 1M -b 10 -E 25
# RTLA osnoise histogram
# Time unit is microseconds (us)
# Duration: 0 00:01:00
Expand Down
5 changes: 3 additions & 2 deletions fs/tracefs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
if (!gid_valid(gid))
return -EINVAL;
opts->gid = gid;
set_gid(tracefs_mount->mnt_root, gid);
break;
case Opt_mode:
if (match_octal(&args[0], &option))
Expand All @@ -291,7 +290,9 @@ static int tracefs_apply_options(struct super_block *sb)
inode->i_mode |= opts->mode;

inode->i_uid = opts->uid;
inode->i_gid = opts->gid;

/* Set all the group ids to the mount option */
set_gid(sb->s_root, opts->gid);

return 0;
}
Expand Down
22 changes: 12 additions & 10 deletions include/linux/trace_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ event_triggers_post_call(struct trace_event_file *file,

bool trace_event_ignore_this_pid(struct trace_event_file *trace_file);

bool __trace_trigger_soft_disabled(struct trace_event_file *file);

/**
* trace_trigger_soft_disabled - do triggers and test if soft disabled
* @file: The file pointer of the event to test
Expand All @@ -715,20 +717,20 @@ bool trace_event_ignore_this_pid(struct trace_event_file *trace_file);
* triggers that require testing the fields, it will return true,
* otherwise false.
*/
static inline bool
static __always_inline bool
trace_trigger_soft_disabled(struct trace_event_file *file)
{
unsigned long eflags = file->flags;

if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) {
if (eflags & EVENT_FILE_FL_TRIGGER_MODE)
event_triggers_call(file, NULL, NULL, NULL);
if (eflags & EVENT_FILE_FL_SOFT_DISABLED)
return true;
if (eflags & EVENT_FILE_FL_PID_FILTER)
return trace_event_ignore_this_pid(file);
}
return false;
if (likely(!(eflags & (EVENT_FILE_FL_TRIGGER_MODE |
EVENT_FILE_FL_SOFT_DISABLED |
EVENT_FILE_FL_PID_FILTER))))
return false;

if (likely(eflags & EVENT_FILE_FL_TRIGGER_COND))
return false;

return __trace_trigger_soft_disabled(file);
}

#ifdef CONFIG_BPF_EVENTS
Expand Down
5 changes: 2 additions & 3 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7193,7 +7193,6 @@ static int __init ftrace_nodyn_init(void)
core_initcall(ftrace_nodyn_init);

static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; }
static inline void ftrace_startup_enable(int command) { }
static inline void ftrace_startup_all(int command) { }

# define ftrace_startup_sysctl() do { } while (0)
Expand Down Expand Up @@ -7793,7 +7792,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.
Expand All @@ -7820,7 +7819,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.
*/
Expand Down
14 changes: 8 additions & 6 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata;
static int __init set_trace_boot_options(char *str)
{
strlcpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
return 0;
return 1;
}
__setup("trace_options=", set_trace_boot_options);

Expand All @@ -256,7 +256,7 @@ static int __init set_trace_boot_clock(char *str)
{
strlcpy(trace_boot_clock_buf, str, MAX_TRACER_SIZE);
trace_boot_clock = trace_boot_clock_buf;
return 0;
return 1;
}
__setup("trace_clock=", set_trace_boot_clock);

Expand Down Expand Up @@ -1484,10 +1484,12 @@ static int __init set_buf_size(char *str)
if (!str)
return 0;
buf_size = memparse(str, &str);
/* nr_entries can not be zero */
if (buf_size == 0)
return 0;
trace_buf_size = buf_size;
/*
* nr_entries can not be zero and the startup
* tests require some buffer space. Therefore
* ensure we have at least 4096 bytes of buffer.
*/
trace_buf_size = max(4096UL, buf_size);
return 1;
}
__setup("trace_buf_size=", set_buf_size);
Expand Down
1 change: 0 additions & 1 deletion kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ struct kprobe_trace_entry_head {

struct eprobe_trace_entry_head {
struct trace_entry ent;
unsigned int type;
};

struct kretprobe_trace_entry_head {
Expand Down
16 changes: 7 additions & 9 deletions kernel/trace/trace_eprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,13 @@ static int trace_eprobe_tp_arg_update(struct trace_eprobe *ep, int i)

static int eprobe_event_define_fields(struct trace_event_call *event_call)
{
int ret;
struct eprobe_trace_entry_head field;
struct trace_probe *tp;

tp = trace_probe_primary_from_call(event_call);
if (WARN_ON_ONCE(!tp))
return -ENOENT;

DEFINE_FIELD(unsigned int, type, FIELD_STRING_TYPE, 0);

return traceprobe_define_arg_fields(event_call, sizeof(field), tp);
}

Expand All @@ -270,23 +267,28 @@ print_eprobe_event(struct trace_iterator *iter, int flags,
struct trace_event_call *pevent;
struct trace_event *probed_event;
struct trace_seq *s = &iter->seq;
struct trace_eprobe *ep;
struct trace_probe *tp;
unsigned int type;

field = (struct eprobe_trace_entry_head *)iter->ent;
tp = trace_probe_primary_from_call(
container_of(event, struct trace_event_call, event));
if (WARN_ON_ONCE(!tp))
goto out;

ep = container_of(tp, struct trace_eprobe, tp);
type = ep->event->event.type;

trace_seq_printf(s, "%s: (", trace_probe_name(tp));

probed_event = ftrace_find_event(field->type);
probed_event = ftrace_find_event(type);
if (probed_event) {
pevent = container_of(probed_event, struct trace_event_call, event);
trace_seq_printf(s, "%s.%s", pevent->class->system,
trace_event_name(pevent));
} else {
trace_seq_printf(s, "%u", field->type);
trace_seq_printf(s, "%u", type);
}

trace_seq_putc(s, ')');
Expand Down Expand Up @@ -498,10 +500,6 @@ __eprobe_trace_func(struct eprobe_data *edata, void *rec)
return;

entry = fbuffer.entry = ring_buffer_event_data(fbuffer.event);
if (edata->ep->event)
entry->type = edata->ep->event->event.type;
else
entry->type = 0;
store_trace_args(&entry[1], &edata->ep->tp, rec, sizeof(*entry), dsize);

trace_event_buffer_commit(&fbuffer);
Expand Down
6 changes: 3 additions & 3 deletions kernel/trace/trace_events_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2308,9 +2308,9 @@ parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file,
/*
* For backward compatibility, if field_name
* was "cpu", then we treat this the same as
* common_cpu.
* common_cpu. This also works for "CPU".
*/
if (strcmp(field_name, "cpu") == 0) {
if (field && field->filter_type == FILTER_CPU) {
*flags |= HIST_FIELD_FL_CPU;
} else {
hist_err(tr, HIST_ERR_FIELD_NOT_FOUND,
Expand Down Expand Up @@ -4851,7 +4851,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data)

if (hist_field->flags & HIST_FIELD_FL_STACKTRACE)
cmp_fn = tracing_map_cmp_none;
else if (!field)
else if (!field || hist_field->flags & HIST_FIELD_FL_CPU)
cmp_fn = tracing_map_cmp_num(hist_field->size,
hist_field->is_signed);
else if (is_string_field(field))
Expand Down

0 comments on commit c87857e

Please sign in to comment.