Skip to content

Commit

Permalink
Merge tag 'trace-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:

 - Fix memory leak on error path of process_system_preds()

 - Lock inversion fix with updating tgid recording option

 - Fix histogram compare function on big endian machines

 - Fix histogram trigger function on big endian machines

 - Make trace_printk() irq sync on init for kprobe selftest correctness

* tag 'trace-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Fix endianness bug in histogram trigger
  samples/trace_printk: Wait for IRQ work to finish
  tracing: Fix lock inversion in trace_event_enable_tgid_record()
  tracing: Have the histogram compare functions convert to u64 first
  tracing: Avoid memory leak in process_system_preds()
  • Loading branch information
Linus Torvalds committed Dec 21, 2019
2 parents 4746104 + fe6e096 commit b8e382a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
8 changes: 8 additions & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4685,6 +4685,10 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)

int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
{
if ((mask == TRACE_ITER_RECORD_TGID) ||
(mask == TRACE_ITER_RECORD_CMD))
lockdep_assert_held(&event_mutex);

/* do nothing if flag is already set */
if (!!(tr->trace_flags & mask) == !!enabled)
return 0;
Expand Down Expand Up @@ -4752,6 +4756,7 @@ static int trace_set_options(struct trace_array *tr, char *option)

cmp += len;

mutex_lock(&event_mutex);
mutex_lock(&trace_types_lock);

ret = match_string(trace_options, -1, cmp);
Expand All @@ -4762,6 +4767,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
ret = set_tracer_flag(tr, 1 << ret, !neg);

mutex_unlock(&trace_types_lock);
mutex_unlock(&event_mutex);

/*
* If the first trailing whitespace is replaced with '\0' by strstrip,
Expand Down Expand Up @@ -8076,9 +8082,11 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
if (val != 0 && val != 1)
return -EINVAL;

mutex_lock(&event_mutex);
mutex_lock(&trace_types_lock);
ret = set_tracer_flag(tr, 1 << index, val);
mutex_unlock(&trace_types_lock);
mutex_unlock(&event_mutex);

if (ret < 0)
return ret;
Expand Down
8 changes: 4 additions & 4 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ void trace_event_enable_cmd_record(bool enable)
struct trace_event_file *file;
struct trace_array *tr;

mutex_lock(&event_mutex);
lockdep_assert_held(&event_mutex);

do_for_each_event_file(tr, file) {

if (!(file->flags & EVENT_FILE_FL_ENABLED))
Expand All @@ -334,15 +335,15 @@ void trace_event_enable_cmd_record(bool enable)
clear_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags);
}
} while_for_each_event_file();
mutex_unlock(&event_mutex);
}

void trace_event_enable_tgid_record(bool enable)
{
struct trace_event_file *file;
struct trace_array *tr;

mutex_lock(&event_mutex);
lockdep_assert_held(&event_mutex);

do_for_each_event_file(tr, file) {
if (!(file->flags & EVENT_FILE_FL_ENABLED))
continue;
Expand All @@ -356,7 +357,6 @@ void trace_event_enable_tgid_record(bool enable)
&file->flags);
}
} while_for_each_event_file();
mutex_unlock(&event_mutex);
}

static int __ftrace_event_enable_disable(struct trace_event_file *file,
Expand Down
2 changes: 1 addition & 1 deletion kernel/trace/trace_events_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,
parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);
return -EINVAL;
fail_mem:
kfree(filter);
__free_filter(filter);
/* If any call succeeded, we still need to sync */
if (!fail)
tracepoint_synchronize_unregister();
Expand Down
21 changes: 20 additions & 1 deletion kernel/trace/trace_events_hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
strscpy(str_field, str_val, STR_VAR_LEN_MAX);
n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
} else {
entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
struct synth_field *field = event->fields[i];
u64 val = var_ref_vals[var_ref_idx + i];

switch (field->size) {
case 1:
*(u8 *)&entry->fields[n_u64] = (u8)val;
break;

case 2:
*(u16 *)&entry->fields[n_u64] = (u16)val;
break;

case 4:
*(u32 *)&entry->fields[n_u64] = (u32)val;
break;

default:
entry->fields[n_u64] = val;
break;
}
n_u64++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions kernel/trace/tracing_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ static int tracing_map_cmp_atomic64(void *val_a, void *val_b)
#define DEFINE_TRACING_MAP_CMP_FN(type) \
static int tracing_map_cmp_##type(void *val_a, void *val_b) \
{ \
type a = *(type *)val_a; \
type b = *(type *)val_b; \
type a = (type)(*(u64 *)val_a); \
type b = (type)(*(u64 *)val_b); \
\
return (a > b) ? 1 : ((a < b) ? -1 : 0); \
}
Expand Down
1 change: 1 addition & 0 deletions samples/trace_printk/trace-printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static int __init trace_printk_init(void)

/* Kick off printing in irq context */
irq_work_queue(&irqwork);
irq_work_sync(&irqwork);

trace_printk("This is a %s that will use trace_bprintk()\n",
"static string");
Expand Down

0 comments on commit b8e382a

Please sign in to comment.