Skip to content

Commit e021c5f

Browse files
committed
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
2 parents 82c5561 + cbb557b commit e021c5f

File tree

6 files changed

+39
-23
lines changed

6 files changed

+39
-23
lines changed

include/rv/da_monitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static inline void da_monitor_destroy_##name(void) \
262262
/* \
263263
* per-cpu monitor variables \
264264
*/ \
265-
DEFINE_PER_CPU(struct da_monitor, da_mon_##name); \
265+
static DEFINE_PER_CPU(struct da_monitor, da_mon_##name); \
266266
\
267267
/* \
268268
* da_get_monitor_##name - return current CPU monitor address \

include/trace/events/task.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ TRACE_EVENT(task_rename,
4747
TP_fast_assign(
4848
__entry->pid = task->pid;
4949
memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
50-
strlcpy(entry->newcomm, comm, TASK_COMM_LEN);
50+
strscpy(entry->newcomm, comm, TASK_COMM_LEN);
5151
__entry->oom_score_adj = task->signal->oom_score_adj;
5252
),
5353

kernel/trace/ftrace.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6779,8 +6779,7 @@ void ftrace_release_mod(struct module *mod)
67796779
last_pg = &ftrace_pages_start;
67806780
for (pg = ftrace_pages_start; pg; pg = *last_pg) {
67816781
rec = &pg->records[0];
6782-
if (within_module_core(rec->ip, mod) ||
6783-
within_module_init(rec->ip, mod)) {
6782+
if (within_module(rec->ip, mod)) {
67846783
/*
67856784
* As core pages are first, the first
67866785
* page should never be a module page.
@@ -6852,8 +6851,7 @@ void ftrace_module_enable(struct module *mod)
68526851
* not part of this module, then skip this pg,
68536852
* which the "break" will do.
68546853
*/
6855-
if (!within_module_core(rec->ip, mod) &&
6856-
!within_module_init(rec->ip, mod))
6854+
if (!within_module(rec->ip, mod))
68576855
break;
68586856

68596857
/* Weak functions should still be ignored */
@@ -7142,9 +7140,7 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr)
71427140
struct dyn_ftrace key;
71437141
struct ftrace_mod_map *mod_map = NULL;
71447142
struct ftrace_init_func *func, *func_next;
7145-
struct list_head clear_hash;
7146-
7147-
INIT_LIST_HEAD(&clear_hash);
7143+
LIST_HEAD(clear_hash);
71487144

71497145
key.ip = start;
71507146
key.flags = end; /* overload flags, as it is unsigned long */

kernel/trace/trace.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7599,6 +7599,11 @@ static int tracing_snapshot_open(struct inode *inode, struct file *file)
75997599
return ret;
76007600
}
76017601

7602+
static void tracing_swap_cpu_buffer(void *tr)
7603+
{
7604+
update_max_tr_single((struct trace_array *)tr, current, smp_processor_id());
7605+
}
7606+
76027607
static ssize_t
76037608
tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
76047609
loff_t *ppos)
@@ -7657,13 +7662,15 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
76577662
ret = tracing_alloc_snapshot_instance(tr);
76587663
if (ret < 0)
76597664
break;
7660-
local_irq_disable();
76617665
/* Now, we're going to swap */
7662-
if (iter->cpu_file == RING_BUFFER_ALL_CPUS)
7666+
if (iter->cpu_file == RING_BUFFER_ALL_CPUS) {
7667+
local_irq_disable();
76637668
update_max_tr(tr, current, smp_processor_id(), NULL);
7664-
else
7665-
update_max_tr_single(tr, current, iter->cpu_file);
7666-
local_irq_enable();
7669+
local_irq_enable();
7670+
} else {
7671+
smp_call_function_single(iter->cpu_file, tracing_swap_cpu_buffer,
7672+
(void *)tr, 1);
7673+
}
76677674
break;
76687675
default:
76697676
if (tr->allocated_snapshot) {
@@ -9467,7 +9474,7 @@ static struct trace_array *trace_array_create(const char *name)
94679474
if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
94689475
goto out_free_tr;
94699476

9470-
if (!alloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL))
9477+
if (!zalloc_cpumask_var(&tr->pipe_cpumask, GFP_KERNEL))
94719478
goto out_free_tr;
94729479

94739480
tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS;
@@ -10412,7 +10419,7 @@ __init static int tracer_alloc_buffers(void)
1041210419
if (trace_create_savedcmd() < 0)
1041310420
goto out_free_temp_buffer;
1041410421

10415-
if (!alloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL))
10422+
if (!zalloc_cpumask_var(&global_trace.pipe_cpumask, GFP_KERNEL))
1041610423
goto out_free_savedcmd;
1041710424

1041810425
/* TODO: make the number of buffers hot pluggable with CPUS */

kernel/trace/trace_events_filter.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ int filter_assign_type(const char *type)
13601360
return FILTER_DYN_STRING;
13611361
if (strstr(type, "cpumask_t"))
13621362
return FILTER_CPUMASK;
1363-
}
1363+
}
13641364

13651365
if (strstr(type, "__rel_loc") && strstr(type, "char"))
13661366
return FILTER_RDYN_STRING;
@@ -1731,7 +1731,9 @@ static int parse_pred(const char *str, void *data,
17311731
maskstart = i;
17321732

17331733
/* Walk the cpulist until closing } */
1734-
for (; str[i] && str[i] != '}'; i++);
1734+
for (; str[i] && str[i] != '}'; i++)
1735+
;
1736+
17351737
if (str[i] != '}') {
17361738
parse_error(pe, FILT_ERR_MISSING_BRACE_CLOSE, pos + i);
17371739
goto err_free;
@@ -1744,17 +1746,23 @@ static int parse_pred(const char *str, void *data,
17441746

17451747
/* Copy the cpulist between { and } */
17461748
tmp = kmalloc((i - maskstart) + 1, GFP_KERNEL);
1747-
strscpy(tmp, str + maskstart, (i - maskstart) + 1);
1749+
if (!tmp)
1750+
goto err_mem;
17481751

1752+
strscpy(tmp, str + maskstart, (i - maskstart) + 1);
17491753
pred->mask = kzalloc(cpumask_size(), GFP_KERNEL);
1750-
if (!pred->mask)
1754+
if (!pred->mask) {
1755+
kfree(tmp);
17511756
goto err_mem;
1757+
}
17521758

17531759
/* Now parse it */
17541760
if (cpulist_parse(tmp, pred->mask)) {
1761+
kfree(tmp);
17551762
parse_error(pe, FILT_ERR_INVALID_CPULIST, pos + i);
17561763
goto err_free;
17571764
}
1765+
kfree(tmp);
17581766

17591767
/* Move along */
17601768
i++;
@@ -1767,6 +1775,7 @@ static int parse_pred(const char *str, void *data,
17671775
if (single) {
17681776
pred->val = cpumask_first(pred->mask);
17691777
kfree(pred->mask);
1778+
pred->mask = NULL;
17701779
}
17711780

17721781
if (field->filter_type == FILTER_CPUMASK) {
@@ -1775,13 +1784,17 @@ static int parse_pred(const char *str, void *data,
17751784
FILTER_PRED_FN_CPUMASK;
17761785
} else if (field->filter_type == FILTER_CPU) {
17771786
if (single) {
1778-
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
1787+
if (pred->op == OP_BAND)
1788+
pred->op = OP_EQ;
1789+
17791790
pred->fn_num = FILTER_PRED_FN_CPU;
17801791
} else {
17811792
pred->fn_num = FILTER_PRED_FN_CPU_CPUMASK;
17821793
}
17831794
} else if (single) {
1784-
pred->op = pred->op == OP_BAND ? OP_EQ : pred->op;
1795+
if (pred->op == OP_BAND)
1796+
pred->op = OP_EQ;
1797+
17851798
pred->fn_num = select_comparison_fn(pred->op, field->size, false);
17861799
if (pred->op == OP_NE)
17871800
pred->not = 1;

kernel/trace/trace_hwlat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static int s_mode_show(struct seq_file *s, void *v)
635635
else
636636
seq_printf(s, "%s", thread_mode_str[mode]);
637637

638-
if (mode != MODE_MAX)
638+
if (mode < MODE_MAX - 1) /* if mode is any but last */
639639
seq_puts(s, " ");
640640

641641
return 0;

0 commit comments

Comments
 (0)