Skip to content

Commit

Permalink
Merge tag 'trace-v5.17-rc4' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:

 - rtla (Real-Time Linux Analysis tool):
    - fix typo in man page
    - Update API -e to -E before it is released
    - Error message fix and memory leak fix

 - Partially uninline trace event soft disable to shrink text

 - Fix function graph start up test

 - Have triggers affect the trace instance they are in and not top level

 - Have osnoise sleep in the units it says it uses

 - Remove unused ftrace stub function

 - Remove event probe redundant info from event in the buffer

 - Fix group ownership setting in tracefs

 - Ensure trace buffer is minimum size to prevent crashes

* tag 'trace-v5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  rtla/osnoise: Fix error message when failing to enable trace instance
  rtla/osnoise: Free params at the exit
  rtla/hist: Make -E the short version of --entries
  tracing: Fix selftest config check for function graph start up test
  tracefs: Set the group ownership in apply_options() not parse_options()
  tracing/osnoise: Make osnoise_main to sleep for microseconds
  ftrace: Remove unused ftrace_startup_enable() stub
  tracing: Ensure trace buffer is at least 4096 bytes large
  tracing: Uninline trace_trigger_soft_disabled() partly
  eprobes: Remove redundant event type information
  tracing: Have traceon and traceoff trigger honor the instance
  tracing: Dump stacktrace trigger to the corresponding instance
  rtla: Fix systme -> system typo on man page
  • Loading branch information
torvalds committed Feb 26, 2022
2 parents e41898d + 90f59ee commit 2293be5
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 79 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
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
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 @@ -699,6 +699,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 @@ -708,20 +710,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
1 change: 0 additions & 1 deletion kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7191,7 +7191,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
10 changes: 6 additions & 4 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1474,10 +1474,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
73 changes: 66 additions & 7 deletions kernel/trace/trace_events_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ event_triggers_call(struct trace_event_file *file,
}
EXPORT_SYMBOL_GPL(event_triggers_call);

bool __trace_trigger_soft_disabled(struct trace_event_file *file)
{
unsigned long eflags = file->flags;

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;
}
EXPORT_SYMBOL_GPL(__trace_trigger_soft_disabled);

/**
* event_triggers_post_call - Call 'post_triggers' for a trace event
* @file: The trace_event_file associated with the event
Expand Down Expand Up @@ -1295,6 +1309,16 @@ traceon_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event)
{
struct trace_event_file *file = data->private_data;

if (file) {
if (tracer_tracing_is_on(file->tr))
return;

tracer_tracing_on(file->tr);
return;
}

if (tracing_is_on())
return;

Expand All @@ -1306,23 +1330,43 @@ traceon_count_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event)
{
if (tracing_is_on())
return;
struct trace_event_file *file = data->private_data;

if (file) {
if (tracer_tracing_is_on(file->tr))
return;
} else {
if (tracing_is_on())
return;
}

if (!data->count)
return;

if (data->count != -1)
(data->count)--;

tracing_on();
if (file)
tracer_tracing_on(file->tr);
else
tracing_on();
}

static void
traceoff_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event)
{
struct trace_event_file *file = data->private_data;

if (file) {
if (!tracer_tracing_is_on(file->tr))
return;

tracer_tracing_off(file->tr);
return;
}

if (!tracing_is_on())
return;

Expand All @@ -1334,16 +1378,26 @@ traceoff_count_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event)
{
if (!tracing_is_on())
return;
struct trace_event_file *file = data->private_data;

if (file) {
if (!tracer_tracing_is_on(file->tr))
return;
} else {
if (!tracing_is_on())
return;
}

if (!data->count)
return;

if (data->count != -1)
(data->count)--;

tracing_off();
if (file)
tracer_tracing_off(file->tr);
else
tracing_off();
}

static int
Expand Down Expand Up @@ -1540,7 +1594,12 @@ stacktrace_trigger(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event)
{
trace_dump_stack(STACK_SKIP);
struct trace_event_file *file = data->private_data;

if (file)
__trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP);
else
trace_dump_stack(STACK_SKIP);
}

static void
Expand Down
53 changes: 32 additions & 21 deletions kernel/trace/trace_osnoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,37 @@ static int run_osnoise(void)
static struct cpumask osnoise_cpumask;
static struct cpumask save_cpumask;

/*
* osnoise_sleep - sleep until the next period
*/
static void osnoise_sleep(void)
{
u64 interval;
ktime_t wake_time;

mutex_lock(&interface_lock);
interval = osnoise_data.sample_period - osnoise_data.sample_runtime;
mutex_unlock(&interface_lock);

/*
* differently from hwlat_detector, the osnoise tracer can run
* without a pause because preemption is on.
*/
if (!interval) {
/* Let synchronize_rcu_tasks() make progress */
cond_resched_tasks_rcu_qs();
return;
}

wake_time = ktime_add_us(ktime_get(), interval);
__set_current_state(TASK_INTERRUPTIBLE);

while (schedule_hrtimeout_range(&wake_time, 0, HRTIMER_MODE_ABS)) {
if (kthread_should_stop())
break;
}
}

/*
* osnoise_main - The osnoise detection kernel thread
*
Expand All @@ -1444,30 +1475,10 @@ static struct cpumask save_cpumask;
*/
static int osnoise_main(void *data)
{
u64 interval;

while (!kthread_should_stop()) {

run_osnoise();

mutex_lock(&interface_lock);
interval = osnoise_data.sample_period - osnoise_data.sample_runtime;
mutex_unlock(&interface_lock);

do_div(interval, USEC_PER_MSEC);

/*
* differently from hwlat_detector, the osnoise tracer can run
* without a pause because preemption is on.
*/
if (interval < 1) {
/* Let synchronize_rcu_tasks() make progress */
cond_resched_tasks_rcu_qs();
continue;
}

if (msleep_interruptible(interval))
break;
osnoise_sleep();
}

return 0;
Expand Down
Loading

0 comments on commit 2293be5

Please sign in to comment.