Merge branch 'tip/perf/urgent-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/urgent
Pull tracing fixes from Steven Rostedt. Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
commit
1f1b396758
|
@ -2881,11 +2881,25 @@ static int set_tracer_option(struct tracer *trace, char *cmp, int neg)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void set_tracer_flags(unsigned int mask, int enabled)
|
||||
/* Some tracers require overwrite to stay enabled */
|
||||
int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
|
||||
{
|
||||
if (tracer->enabled && (mask & TRACE_ITER_OVERWRITE) && !set)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_tracer_flag(unsigned int mask, int enabled)
|
||||
{
|
||||
/* do nothing if flag is already set */
|
||||
if (!!(trace_flags & mask) == !!enabled)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
/* Give the tracer a chance to approve the change */
|
||||
if (current_trace->flag_changed)
|
||||
if (current_trace->flag_changed(current_trace, mask, !!enabled))
|
||||
return -EINVAL;
|
||||
|
||||
if (enabled)
|
||||
trace_flags |= mask;
|
||||
|
@ -2895,18 +2909,24 @@ static void set_tracer_flags(unsigned int mask, int enabled)
|
|||
if (mask == TRACE_ITER_RECORD_CMD)
|
||||
trace_event_enable_cmd_record(enabled);
|
||||
|
||||
if (mask == TRACE_ITER_OVERWRITE)
|
||||
if (mask == TRACE_ITER_OVERWRITE) {
|
||||
ring_buffer_change_overwrite(global_trace.buffer, enabled);
|
||||
#ifdef CONFIG_TRACER_MAX_TRACE
|
||||
ring_buffer_change_overwrite(max_tr.buffer, enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mask == TRACE_ITER_PRINTK)
|
||||
trace_printk_start_stop_comm(enabled);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int trace_set_options(char *option)
|
||||
{
|
||||
char *cmp;
|
||||
int neg = 0;
|
||||
int ret = 0;
|
||||
int ret = -ENODEV;
|
||||
int i;
|
||||
|
||||
cmp = strstrip(option);
|
||||
|
@ -2916,19 +2936,20 @@ static int trace_set_options(char *option)
|
|||
cmp += 2;
|
||||
}
|
||||
|
||||
mutex_lock(&trace_types_lock);
|
||||
|
||||
for (i = 0; trace_options[i]; i++) {
|
||||
if (strcmp(cmp, trace_options[i]) == 0) {
|
||||
set_tracer_flags(1 << i, !neg);
|
||||
ret = set_tracer_flag(1 << i, !neg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no option could be set, test the specific tracer options */
|
||||
if (!trace_options[i]) {
|
||||
mutex_lock(&trace_types_lock);
|
||||
if (!trace_options[i])
|
||||
ret = set_tracer_option(current_trace, cmp, neg);
|
||||
mutex_unlock(&trace_types_lock);
|
||||
}
|
||||
|
||||
mutex_unlock(&trace_types_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -2938,6 +2959,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
|
|||
size_t cnt, loff_t *ppos)
|
||||
{
|
||||
char buf[64];
|
||||
int ret;
|
||||
|
||||
if (cnt >= sizeof(buf))
|
||||
return -EINVAL;
|
||||
|
@ -2947,7 +2969,9 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
|
|||
|
||||
buf[cnt] = 0;
|
||||
|
||||
trace_set_options(buf);
|
||||
ret = trace_set_options(buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*ppos += cnt;
|
||||
|
||||
|
@ -3251,6 +3275,9 @@ static int tracing_set_tracer(const char *buf)
|
|||
goto out;
|
||||
|
||||
trace_branch_disable();
|
||||
|
||||
current_trace->enabled = false;
|
||||
|
||||
if (current_trace->reset)
|
||||
current_trace->reset(tr);
|
||||
|
||||
|
@ -3295,6 +3322,7 @@ static int tracing_set_tracer(const char *buf)
|
|||
}
|
||||
|
||||
current_trace = t;
|
||||
current_trace->enabled = true;
|
||||
trace_branch_enable(tr);
|
||||
out:
|
||||
mutex_unlock(&trace_types_lock);
|
||||
|
@ -4781,7 +4809,13 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
|
|||
|
||||
if (val != 0 && val != 1)
|
||||
return -EINVAL;
|
||||
set_tracer_flags(1 << index, val);
|
||||
|
||||
mutex_lock(&trace_types_lock);
|
||||
ret = set_tracer_flag(1 << index, val);
|
||||
mutex_unlock(&trace_types_lock);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*ppos += cnt;
|
||||
|
||||
|
|
|
@ -283,11 +283,15 @@ struct tracer {
|
|||
enum print_line_t (*print_line)(struct trace_iterator *iter);
|
||||
/* If you handled the flag setting, return 0 */
|
||||
int (*set_flag)(u32 old_flags, u32 bit, int set);
|
||||
/* Return 0 if OK with change, else return non-zero */
|
||||
int (*flag_changed)(struct tracer *tracer,
|
||||
u32 mask, int set);
|
||||
struct tracer *next;
|
||||
struct tracer_flags *flags;
|
||||
bool print_max;
|
||||
bool use_max_tr;
|
||||
bool allocated_snapshot;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
|
||||
|
@ -943,6 +947,8 @@ extern const char *__stop___trace_bprintk_fmt[];
|
|||
|
||||
void trace_printk_init_buffers(void);
|
||||
void trace_printk_start_comm(void);
|
||||
int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
|
||||
int set_tracer_flag(unsigned int mask, int enabled);
|
||||
|
||||
#undef FTRACE_ENTRY
|
||||
#define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
|
||||
|
|
|
@ -32,7 +32,7 @@ enum {
|
|||
|
||||
static int trace_type __read_mostly;
|
||||
|
||||
static int save_lat_flag;
|
||||
static int save_flags;
|
||||
|
||||
static void stop_irqsoff_tracer(struct trace_array *tr, int graph);
|
||||
static int start_irqsoff_tracer(struct trace_array *tr, int graph);
|
||||
|
@ -558,8 +558,11 @@ static void stop_irqsoff_tracer(struct trace_array *tr, int graph)
|
|||
|
||||
static void __irqsoff_tracer_init(struct trace_array *tr)
|
||||
{
|
||||
save_lat_flag = trace_flags & TRACE_ITER_LATENCY_FMT;
|
||||
trace_flags |= TRACE_ITER_LATENCY_FMT;
|
||||
save_flags = trace_flags;
|
||||
|
||||
/* non overwrite screws up the latency tracers */
|
||||
set_tracer_flag(TRACE_ITER_OVERWRITE, 1);
|
||||
set_tracer_flag(TRACE_ITER_LATENCY_FMT, 1);
|
||||
|
||||
tracing_max_latency = 0;
|
||||
irqsoff_trace = tr;
|
||||
|
@ -573,10 +576,13 @@ static void __irqsoff_tracer_init(struct trace_array *tr)
|
|||
|
||||
static void irqsoff_tracer_reset(struct trace_array *tr)
|
||||
{
|
||||
int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
|
||||
int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
|
||||
|
||||
stop_irqsoff_tracer(tr, is_graph());
|
||||
|
||||
if (!save_lat_flag)
|
||||
trace_flags &= ~TRACE_ITER_LATENCY_FMT;
|
||||
set_tracer_flag(TRACE_ITER_LATENCY_FMT, lat_flag);
|
||||
set_tracer_flag(TRACE_ITER_OVERWRITE, overwrite_flag);
|
||||
}
|
||||
|
||||
static void irqsoff_tracer_start(struct trace_array *tr)
|
||||
|
@ -609,6 +615,7 @@ static struct tracer irqsoff_tracer __read_mostly =
|
|||
.print_line = irqsoff_print_line,
|
||||
.flags = &tracer_flags,
|
||||
.set_flag = irqsoff_set_flag,
|
||||
.flag_changed = trace_keep_overwrite,
|
||||
#ifdef CONFIG_FTRACE_SELFTEST
|
||||
.selftest = trace_selftest_startup_irqsoff,
|
||||
#endif
|
||||
|
@ -642,6 +649,7 @@ static struct tracer preemptoff_tracer __read_mostly =
|
|||
.print_line = irqsoff_print_line,
|
||||
.flags = &tracer_flags,
|
||||
.set_flag = irqsoff_set_flag,
|
||||
.flag_changed = trace_keep_overwrite,
|
||||
#ifdef CONFIG_FTRACE_SELFTEST
|
||||
.selftest = trace_selftest_startup_preemptoff,
|
||||
#endif
|
||||
|
@ -677,6 +685,7 @@ static struct tracer preemptirqsoff_tracer __read_mostly =
|
|||
.print_line = irqsoff_print_line,
|
||||
.flags = &tracer_flags,
|
||||
.set_flag = irqsoff_set_flag,
|
||||
.flag_changed = trace_keep_overwrite,
|
||||
#ifdef CONFIG_FTRACE_SELFTEST
|
||||
.selftest = trace_selftest_startup_preemptirqsoff,
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,7 @@ static void __wakeup_reset(struct trace_array *tr);
|
|||
static int wakeup_graph_entry(struct ftrace_graph_ent *trace);
|
||||
static void wakeup_graph_return(struct ftrace_graph_ret *trace);
|
||||
|
||||
static int save_lat_flag;
|
||||
static int save_flags;
|
||||
|
||||
#define TRACE_DISPLAY_GRAPH 1
|
||||
|
||||
|
@ -540,8 +540,11 @@ static void stop_wakeup_tracer(struct trace_array *tr)
|
|||
|
||||
static int __wakeup_tracer_init(struct trace_array *tr)
|
||||
{
|
||||
save_lat_flag = trace_flags & TRACE_ITER_LATENCY_FMT;
|
||||
trace_flags |= TRACE_ITER_LATENCY_FMT;
|
||||
save_flags = trace_flags;
|
||||
|
||||
/* non overwrite screws up the latency tracers */
|
||||
set_tracer_flag(TRACE_ITER_OVERWRITE, 1);
|
||||
set_tracer_flag(TRACE_ITER_LATENCY_FMT, 1);
|
||||
|
||||
tracing_max_latency = 0;
|
||||
wakeup_trace = tr;
|
||||
|
@ -563,12 +566,15 @@ static int wakeup_rt_tracer_init(struct trace_array *tr)
|
|||
|
||||
static void wakeup_tracer_reset(struct trace_array *tr)
|
||||
{
|
||||
int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
|
||||
int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
|
||||
|
||||
stop_wakeup_tracer(tr);
|
||||
/* make sure we put back any tasks we are tracing */
|
||||
wakeup_reset(tr);
|
||||
|
||||
if (!save_lat_flag)
|
||||
trace_flags &= ~TRACE_ITER_LATENCY_FMT;
|
||||
set_tracer_flag(TRACE_ITER_LATENCY_FMT, lat_flag);
|
||||
set_tracer_flag(TRACE_ITER_OVERWRITE, overwrite_flag);
|
||||
}
|
||||
|
||||
static void wakeup_tracer_start(struct trace_array *tr)
|
||||
|
@ -594,6 +600,7 @@ static struct tracer wakeup_tracer __read_mostly =
|
|||
.print_line = wakeup_print_line,
|
||||
.flags = &tracer_flags,
|
||||
.set_flag = wakeup_set_flag,
|
||||
.flag_changed = trace_keep_overwrite,
|
||||
#ifdef CONFIG_FTRACE_SELFTEST
|
||||
.selftest = trace_selftest_startup_wakeup,
|
||||
#endif
|
||||
|
@ -615,6 +622,7 @@ static struct tracer wakeup_rt_tracer __read_mostly =
|
|||
.print_line = wakeup_print_line,
|
||||
.flags = &tracer_flags,
|
||||
.set_flag = wakeup_set_flag,
|
||||
.flag_changed = trace_keep_overwrite,
|
||||
#ifdef CONFIG_FTRACE_SELFTEST
|
||||
.selftest = trace_selftest_startup_wakeup,
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue