Commit b8e382a1 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/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()
parents 4746104a fe6e096a
...@@ -4685,6 +4685,10 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set) ...@@ -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) 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 */ /* do nothing if flag is already set */
if (!!(tr->trace_flags & mask) == !!enabled) if (!!(tr->trace_flags & mask) == !!enabled)
return 0; return 0;
...@@ -4752,6 +4756,7 @@ static int trace_set_options(struct trace_array *tr, char *option) ...@@ -4752,6 +4756,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
cmp += len; cmp += len;
mutex_lock(&event_mutex);
mutex_lock(&trace_types_lock); mutex_lock(&trace_types_lock);
ret = match_string(trace_options, -1, cmp); ret = match_string(trace_options, -1, cmp);
...@@ -4762,6 +4767,7 @@ static int trace_set_options(struct trace_array *tr, char *option) ...@@ -4762,6 +4767,7 @@ static int trace_set_options(struct trace_array *tr, char *option)
ret = set_tracer_flag(tr, 1 << ret, !neg); ret = set_tracer_flag(tr, 1 << ret, !neg);
mutex_unlock(&trace_types_lock); mutex_unlock(&trace_types_lock);
mutex_unlock(&event_mutex);
/* /*
* If the first trailing whitespace is replaced with '\0' by strstrip, * If the first trailing whitespace is replaced with '\0' by strstrip,
...@@ -8076,9 +8082,11 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt, ...@@ -8076,9 +8082,11 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
if (val != 0 && val != 1) if (val != 0 && val != 1)
return -EINVAL; return -EINVAL;
mutex_lock(&event_mutex);
mutex_lock(&trace_types_lock); mutex_lock(&trace_types_lock);
ret = set_tracer_flag(tr, 1 << index, val); ret = set_tracer_flag(tr, 1 << index, val);
mutex_unlock(&trace_types_lock); mutex_unlock(&trace_types_lock);
mutex_unlock(&event_mutex);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -320,7 +320,8 @@ void trace_event_enable_cmd_record(bool enable) ...@@ -320,7 +320,8 @@ void trace_event_enable_cmd_record(bool enable)
struct trace_event_file *file; struct trace_event_file *file;
struct trace_array *tr; struct trace_array *tr;
mutex_lock(&event_mutex); lockdep_assert_held(&event_mutex);
do_for_each_event_file(tr, file) { do_for_each_event_file(tr, file) {
if (!(file->flags & EVENT_FILE_FL_ENABLED)) if (!(file->flags & EVENT_FILE_FL_ENABLED))
...@@ -334,7 +335,6 @@ void trace_event_enable_cmd_record(bool enable) ...@@ -334,7 +335,6 @@ void trace_event_enable_cmd_record(bool enable)
clear_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags); clear_bit(EVENT_FILE_FL_RECORDED_CMD_BIT, &file->flags);
} }
} while_for_each_event_file(); } while_for_each_event_file();
mutex_unlock(&event_mutex);
} }
void trace_event_enable_tgid_record(bool enable) void trace_event_enable_tgid_record(bool enable)
...@@ -342,7 +342,8 @@ void trace_event_enable_tgid_record(bool enable) ...@@ -342,7 +342,8 @@ void trace_event_enable_tgid_record(bool enable)
struct trace_event_file *file; struct trace_event_file *file;
struct trace_array *tr; struct trace_array *tr;
mutex_lock(&event_mutex); lockdep_assert_held(&event_mutex);
do_for_each_event_file(tr, file) { do_for_each_event_file(tr, file) {
if (!(file->flags & EVENT_FILE_FL_ENABLED)) if (!(file->flags & EVENT_FILE_FL_ENABLED))
continue; continue;
...@@ -356,7 +357,6 @@ void trace_event_enable_tgid_record(bool enable) ...@@ -356,7 +357,6 @@ void trace_event_enable_tgid_record(bool enable)
&file->flags); &file->flags);
} }
} while_for_each_event_file(); } while_for_each_event_file();
mutex_unlock(&event_mutex);
} }
static int __ftrace_event_enable_disable(struct trace_event_file *file, static int __ftrace_event_enable_disable(struct trace_event_file *file,
......
...@@ -1662,7 +1662,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir, ...@@ -1662,7 +1662,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,
parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0); parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);
return -EINVAL; return -EINVAL;
fail_mem: fail_mem:
kfree(filter); __free_filter(filter);
/* If any call succeeded, we still need to sync */ /* If any call succeeded, we still need to sync */
if (!fail) if (!fail)
tracepoint_synchronize_unregister(); tracepoint_synchronize_unregister();
......
...@@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data, ...@@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
strscpy(str_field, str_val, STR_VAR_LEN_MAX); strscpy(str_field, str_val, STR_VAR_LEN_MAX);
n_u64 += STR_VAR_LEN_MAX / sizeof(u64); n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
} else { } 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++; n_u64++;
} }
} }
......
...@@ -148,8 +148,8 @@ static int tracing_map_cmp_atomic64(void *val_a, void *val_b) ...@@ -148,8 +148,8 @@ static int tracing_map_cmp_atomic64(void *val_a, void *val_b)
#define DEFINE_TRACING_MAP_CMP_FN(type) \ #define DEFINE_TRACING_MAP_CMP_FN(type) \
static int tracing_map_cmp_##type(void *val_a, void *val_b) \ static int tracing_map_cmp_##type(void *val_a, void *val_b) \
{ \ { \
type a = *(type *)val_a; \ type a = (type)(*(u64 *)val_a); \
type b = *(type *)val_b; \ type b = (type)(*(u64 *)val_b); \
\ \
return (a > b) ? 1 : ((a < b) ? -1 : 0); \ return (a > b) ? 1 : ((a < b) ? -1 : 0); \
} }
......
...@@ -36,6 +36,7 @@ static int __init trace_printk_init(void) ...@@ -36,6 +36,7 @@ static int __init trace_printk_init(void)
/* Kick off printing in irq context */ /* Kick off printing in irq context */
irq_work_queue(&irqwork); irq_work_queue(&irqwork);
irq_work_sync(&irqwork);
trace_printk("This is a %s that will use trace_bprintk()\n", trace_printk("This is a %s that will use trace_bprintk()\n",
"static string"); "static string");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment