Commit e021c5f1 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-v6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull more tracing updates from Steven Rostedt:
 "Tracing fixes and clean ups:

   - Replace strlcpy() with strscpy()

   - Initialize the pipe cpumask to zero on allocation

   - Use within_module() instead of open coding it

   - Remove extra space in hwlat_detectory/mode output

   - Use LIST_HEAD() instead of open coding it

   - A bunch of clean ups and fixes for the cpumask filter

   - Set local da_mon_##name to static

   - Fix race in snapshot buffer between cpu write and swap"

* tag 'trace-v6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing/filters: Fix coding style issues
  tracing/filters: Change parse_pred() cpulist ternary into an if block
  tracing/filters: Fix double-free of struct filter_pred.mask
  tracing/filters: Fix error-handling of cpulist parsing buffer
  tracing: Zero the pipe cpumask on alloc to avoid spurious -EBUSY
  ftrace: Use LIST_HEAD to initialize clear_hash
  ftrace: Use within_module to check rec->ip within specified module.
  tracing: Replace strlcpy with strscpy in trace/events/task.h
  tracing: Fix race issue between cpu buffer write and swap
  tracing: Remove extra space at the end of hwlat_detector/mode
  rv: Set variable 'da_mon_##name' to static
parents 82c5561b cbb557ba
...@@ -262,7 +262,7 @@ static inline void da_monitor_destroy_##name(void) \ ...@@ -262,7 +262,7 @@ static inline void da_monitor_destroy_##name(void) \
/* \ /* \
* per-cpu monitor variables \ * per-cpu monitor variables \
*/ \ */ \
DEFINE_PER_CPU(struct da_monitor, da_mon_##name); \ static DEFINE_PER_CPU(struct da_monitor, da_mon_##name); \
\ \
/* \ /* \
* da_get_monitor_##name - return current CPU monitor address \ * da_get_monitor_##name - return current CPU monitor address \
......
...@@ -47,7 +47,7 @@ TRACE_EVENT(task_rename, ...@@ -47,7 +47,7 @@ TRACE_EVENT(task_rename,
TP_fast_assign( TP_fast_assign(
__entry->pid = task->pid; __entry->pid = task->pid;
memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN); memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
strlcpy(entry->newcomm, comm, TASK_COMM_LEN); strscpy(entry->newcomm, comm, TASK_COMM_LEN);
__entry->oom_score_adj = task->signal->oom_score_adj; __entry->oom_score_adj = task->signal->oom_score_adj;
), ),
......
...@@ -6779,8 +6779,7 @@ void ftrace_release_mod(struct module *mod) ...@@ -6779,8 +6779,7 @@ void ftrace_release_mod(struct module *mod)
last_pg = &ftrace_pages_start; last_pg = &ftrace_pages_start;
for (pg = ftrace_pages_start; pg; pg = *last_pg) { for (pg = ftrace_pages_start; pg; pg = *last_pg) {
rec = &pg->records[0]; rec = &pg->records[0];
if (within_module_core(rec->ip, mod) || if (within_module(rec->ip, mod)) {
within_module_init(rec->ip, mod)) {
/* /*
* As core pages are first, the first * As core pages are first, the first
* page should never be a module page. * page should never be a module page.
...@@ -6852,8 +6851,7 @@ void ftrace_module_enable(struct module *mod) ...@@ -6852,8 +6851,7 @@ void ftrace_module_enable(struct module *mod)
* not part of this module, then skip this pg, * not part of this module, then skip this pg,
* which the "break" will do. * which the "break" will do.
*/ */
if (!within_module_core(rec->ip, mod) && if (!within_module(rec->ip, mod))
!within_module_init(rec->ip, mod))
break; break;
/* Weak functions should still be ignored */ /* Weak functions should still be ignored */
...@@ -7142,9 +7140,7 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr) ...@@ -7142,9 +7140,7 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr)
struct dyn_ftrace key; struct dyn_ftrace key;
struct ftrace_mod_map *mod_map = NULL; struct ftrace_mod_map *mod_map = NULL;
struct ftrace_init_func *func, *func_next; struct ftrace_init_func *func, *func_next;
struct list_head clear_hash; LIST_HEAD(clear_hash);
INIT_LIST_HEAD(&clear_hash);
key.ip = start; key.ip = start;
key.flags = end; /* overload flags, as it is unsigned long */ key.flags = end; /* overload flags, as it is unsigned long */
......
...@@ -7599,6 +7599,11 @@ static int tracing_snapshot_open(struct inode *inode, struct file *file) ...@@ -7599,6 +7599,11 @@ static int tracing_snapshot_open(struct inode *inode, struct file *file)
return ret; return ret;
} }
static void tracing_swap_cpu_buffer(void *tr)
{
update_max_tr_single((struct trace_array *)tr, current, smp_processor_id());
}
static ssize_t static ssize_t
tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt, tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
loff_t *ppos) loff_t *ppos)
...@@ -7657,13 +7662,15 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt, ...@@ -7657,13 +7662,15 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
ret = tracing_alloc_snapshot_instance(tr); ret = tracing_alloc_snapshot_instance(tr);
if (ret < 0) if (ret < 0)
break; break;
local_irq_disable();
/* Now, we're going to swap */ /* Now, we're going to swap */
if (iter->cpu_file == RING_BUFFER_ALL_CPUS) if (iter->cpu_file == RING_BUFFER_ALL_CPUS) {
local_irq_disable();
update_max_tr(tr, current, smp_processor_id(), NULL); update_max_tr(tr, current, smp_processor_id(), NULL);
else local_irq_enable();
update_max_tr_single(tr, current, iter->cpu_file); } else {
local_irq_enable(); smp_call_function_single(iter->cpu_file, tracing_swap_cpu_buffer,
(void *)tr, 1);
}
break; break;
default: default:
if (tr->allocated_snapshot) { if (tr->allocated_snapshot) {
...@@ -9467,7 +9474,7 @@ static struct trace_array *trace_array_create(const char *name) ...@@ -9467,7 +9474,7 @@ static struct trace_array *trace_array_create(const char *name)
if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL)) if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
goto out_free_tr; goto out_free_tr;
if (!alloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL)) if (!zalloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL))
goto out_free_tr; goto out_free_tr;
tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS; tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS;
...@@ -10412,7 +10419,7 @@ __init static int tracer_alloc_buffers(void) ...@@ -10412,7 +10419,7 @@ __init static int tracer_alloc_buffers(void)
if (trace_create_savedcmd() < 0) if (trace_create_savedcmd() < 0)
goto out_free_temp_buffer; goto out_free_temp_buffer;
if (!alloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL)) if (!zalloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL))
goto out_free_savedcmd; goto out_free_savedcmd;
/* TODO: make the number of buffers hot pluggable with CPUS */ /* TODO: make the number of buffers hot pluggable with CPUS */
......
...@@ -1360,7 +1360,7 @@ int filter_assign_type(const char *type) ...@@ -1360,7 +1360,7 @@ int filter_assign_type(const char *type)
return FILTER_DYN_STRING; return FILTER_DYN_STRING;
if (strstr(type, "cpumask_t")) if (strstr(type, "cpumask_t"))
return FILTER_CPUMASK; return FILTER_CPUMASK;
} }
if (strstr(type, "__rel_loc") && strstr(type, "char")) if (strstr(type, "__rel_loc") && strstr(type, "char"))
return FILTER_RDYN_STRING; return FILTER_RDYN_STRING;
...@@ -1731,7 +1731,9 @@ static int parse_pred(const char *str, void *data, ...@@ -1731,7 +1731,9 @@ static int parse_pred(const char *str, void *data,
maskstart = i; maskstart = i;
/* Walk the cpulist until closing } */ /* Walk the cpulist until closing } */
for (; str[i] && str[i] != '}'; i++); for (; str[i] && str[i] != '}'; i++)
;
if (str[i] != '}') { if (str[i] != '}') {
parse_error(pe, FILT_ERR_MISSING_BRACE_CLOSE, pos + i); parse_error(pe, FILT_ERR_MISSING_BRACE_CLOSE, pos + i);
goto err_free; goto err_free;
...@@ -1744,17 +1746,23 @@ static int parse_pred(const char *str, void *data, ...@@ -1744,17 +1746,23 @@ static int parse_pred(const char *str, void *data,
/* Copy the cpulist between { and } */ /* Copy the cpulist between { and } */
tmp = kmalloc((i - maskstart) + 1, GFP_KERNEL); tmp = kmalloc((i - maskstart) + 1, GFP_KERNEL);
strscpy(tmp, str + maskstart, (i - maskstart) + 1); if (!tmp)
goto err_mem;
strscpy(tmp, str + maskstart, (i - maskstart) + 1);
pred->mask = kzalloc(cpumask_size(), GFP_KERNEL); pred->mask = kzalloc(cpumask_size(), GFP_KERNEL);
if (!pred->mask) if (!pred->mask) {
kfree(tmp);
goto err_mem; goto err_mem;
}
/* Now parse it */ /* Now parse it */
if (cpulist_parse(tmp, pred->mask)) { if (cpulist_parse(tmp, pred->mask)) {
kfree(tmp);
parse_error(pe, FILT_ERR_INVALID_CPULIST, pos + i); parse_error(pe, FILT_ERR_INVALID_CPULIST, pos + i);
goto err_free; goto err_free;
} }
kfree(tmp);
/* Move along */ /* Move along */
i++; i++;
...@@ -1767,6 +1775,7 @@ static int parse_pred(const char *str, void *data, ...@@ -1767,6 +1775,7 @@ static int parse_pred(const char *str, void *data,
if (single) { if (single) {
pred->val = cpumask_first(pred->mask); pred->val = cpumask_first(pred->mask);
kfree(pred->mask); kfree(pred->mask);
pred->mask = NULL;
} }
if (field->filter_type == FILTER_CPUMASK) { if (field->filter_type == FILTER_CPUMASK) {
...@@ -1775,13 +1784,17 @@ static int parse_pred(const char *str, void *data, ...@@ -1775,13 +1784,17 @@ static int parse_pred(const char *str, void *data,
FILTER_PRED_FN_CPUMASK; FILTER_PRED_FN_CPUMASK;
} else if (field->filter_type == FILTER_CPU) { } else if (field->filter_type == FILTER_CPU) {
if (single) { if (single) {
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op; if (pred->op == OP_BAND)
pred->op = OP_EQ;
pred->fn_num = FILTER_PRED_FN_CPU; pred->fn_num = FILTER_PRED_FN_CPU;
} else { } else {
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK; pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
} }
} else if (single) { } else if (single) {
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op; if (pred->op == OP_BAND)
pred->op = OP_EQ;
pred->fn_num = select_comparison_fn(pred->op, field->size, false); pred->fn_num = select_comparison_fn(pred->op, field->size, false);
if (pred->op == OP_NE) if (pred->op == OP_NE)
pred->not = 1; pred->not = 1;
......
...@@ -635,7 +635,7 @@ static int s_mode_show(struct seq_file *s, void *v) ...@@ -635,7 +635,7 @@ static int s_mode_show(struct seq_file *s, void *v)
else else
seq_printf(s, "%s", thread_mode_str[mode]); seq_printf(s, "%s", thread_mode_str[mode]);
if (mode != MODE_MAX) if (mode < MODE_MAX - 1) /* if mode is any but last */
seq_puts(s, " "); seq_puts(s, " ");
return 0; return 0;
......
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