Skip to content

Commit 7eb6952

Browse files
committed
Merge tag 'trace-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: "Not much changes for the 3.12 merge window. The major tracing changes are still in flux, and will have to wait for 3.13. The changes for 3.12 are mostly clean ups and minor fixes. H Peter Anvin added a check to x86_32 static function tracing that helps a small segment of the kernel community. Oleg Nesterov had a few changes from 3.11, but were mostly clean ups and not worth pushing in the -rc time frame. Li Zefan had small clean up with annotating a raw_init with __init. I fixed a slight race in updating function callbacks, but the race is so small and the bug that happens when it occurs is so minor it's not even worth pushing to stable. The only real enhancement is from Alexander Z Lam that made the tracing_cpumask work for trace buffer instances, instead of them all sharing a global cpumask" * tag 'trace-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: ftrace/rcu: Do not trace debug_lockdep_rcu_enabled() x86-32, ftrace: Fix static ftrace when early microcode is enabled ftrace: Fix a slight race in modifying what function callback gets traced tracing: Make tracing_cpumask available for all instances tracing: Kill the !CONFIG_MODULES code in trace_events.c tracing: Don't pass file_operations array to event_create_dir() tracing: Kill trace_create_file_ops() and friends tracing/syscalls: Annotate raw_init function with __init
2 parents 300893b + a0a5a05 commit 7eb6952

7 files changed

Lines changed: 68 additions & 209 deletions

File tree

‎arch/x86/kernel/entry_32.S‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,9 @@ ftrace_restore_flags:
11761176
#else /* ! CONFIG_DYNAMIC_FTRACE */
11771177

11781178
ENTRY(mcount)
1179+
cmpl $__PAGE_OFFSET, %esp
1180+
jb ftrace_stub /* Paging not enabled yet? */
1181+
11791182
cmpl $0, function_trace_stop
11801183
jne ftrace_stub
11811184

‎kernel/rcupdate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct lockdep_map rcu_sched_lock_map =
122122
STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_sched", &rcu_sched_lock_key);
123123
EXPORT_SYMBOL_GPL(rcu_sched_lock_map);
124124

125-
int debug_lockdep_rcu_enabled(void)
125+
int notrace debug_lockdep_rcu_enabled(void)
126126
{
127127
return rcu_scheduler_active && debug_locks &&
128128
current->lockdep_recursion == 0;

‎kernel/trace/ftrace.c‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,12 +1978,27 @@ int __weak ftrace_arch_code_modify_post_process(void)
19781978

19791979
void ftrace_modify_all_code(int command)
19801980
{
1981+
int update = command & FTRACE_UPDATE_TRACE_FUNC;
1982+
1983+
/*
1984+
* If the ftrace_caller calls a ftrace_ops func directly,
1985+
* we need to make sure that it only traces functions it
1986+
* expects to trace. When doing the switch of functions,
1987+
* we need to update to the ftrace_ops_list_func first
1988+
* before the transition between old and new calls are set,
1989+
* as the ftrace_ops_list_func will check the ops hashes
1990+
* to make sure the ops are having the right functions
1991+
* traced.
1992+
*/
1993+
if (update)
1994+
ftrace_update_ftrace_func(ftrace_ops_list_func);
1995+
19811996
if (command & FTRACE_UPDATE_CALLS)
19821997
ftrace_replace_code(1);
19831998
else if (command & FTRACE_DISABLE_CALLS)
19841999
ftrace_replace_code(0);
19852000

1986-
if (command & FTRACE_UPDATE_TRACE_FUNC)
2001+
if (update && ftrace_trace_function != ftrace_ops_list_func)
19872002
ftrace_update_ftrace_func(ftrace_trace_function);
19882003

19892004
if (command & FTRACE_START_FUNC_RET)

‎kernel/trace/trace.c‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,11 +3165,6 @@ static const struct file_operations show_traces_fops = {
31653165
.llseek = seq_lseek,
31663166
};
31673167

3168-
/*
3169-
* Only trace on a CPU if the bitmask is set:
3170-
*/
3171-
static cpumask_var_t tracing_cpumask;
3172-
31733168
/*
31743169
* The tracer itself will not take this lock, but still we want
31753170
* to provide a consistent cpumask to user-space:
@@ -3186,11 +3181,12 @@ static ssize_t
31863181
tracing_cpumask_read(struct file *filp, char __user *ubuf,
31873182
size_t count, loff_t *ppos)
31883183
{
3184+
struct trace_array *tr = file_inode(filp)->i_private;
31893185
int len;
31903186

31913187
mutex_lock(&tracing_cpumask_update_lock);
31923188

3193-
len = cpumask_scnprintf(mask_str, count, tracing_cpumask);
3189+
len = cpumask_scnprintf(mask_str, count, tr->tracing_cpumask);
31943190
if (count - len < 2) {
31953191
count = -EINVAL;
31963192
goto out_err;
@@ -3208,7 +3204,7 @@ static ssize_t
32083204
tracing_cpumask_write(struct file *filp, const char __user *ubuf,
32093205
size_t count, loff_t *ppos)
32103206
{
3211-
struct trace_array *tr = filp->private_data;
3207+
struct trace_array *tr = file_inode(filp)->i_private;
32123208
cpumask_var_t tracing_cpumask_new;
32133209
int err, cpu;
32143210

@@ -3228,12 +3224,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
32283224
* Increase/decrease the disabled counter if we are
32293225
* about to flip a bit in the cpumask:
32303226
*/
3231-
if (cpumask_test_cpu(cpu, tracing_cpumask) &&
3227+
if (cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
32323228
!cpumask_test_cpu(cpu, tracing_cpumask_new)) {
32333229
atomic_inc(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled);
32343230
ring_buffer_record_disable_cpu(tr->trace_buffer.buffer, cpu);
32353231
}
3236-
if (!cpumask_test_cpu(cpu, tracing_cpumask) &&
3232+
if (!cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
32373233
cpumask_test_cpu(cpu, tracing_cpumask_new)) {
32383234
atomic_dec(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled);
32393235
ring_buffer_record_enable_cpu(tr->trace_buffer.buffer, cpu);
@@ -3242,7 +3238,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
32423238
arch_spin_unlock(&ftrace_max_lock);
32433239
local_irq_enable();
32443240

3245-
cpumask_copy(tracing_cpumask, tracing_cpumask_new);
3241+
cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new);
32463242

32473243
mutex_unlock(&tracing_cpumask_update_lock);
32483244
free_cpumask_var(tracing_cpumask_new);
@@ -3256,9 +3252,10 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
32563252
}
32573253

32583254
static const struct file_operations tracing_cpumask_fops = {
3259-
.open = tracing_open_generic,
3255+
.open = tracing_open_generic_tr,
32603256
.read = tracing_cpumask_read,
32613257
.write = tracing_cpumask_write,
3258+
.release = tracing_release_generic_tr,
32623259
.llseek = generic_file_llseek,
32633260
};
32643261

@@ -5938,6 +5935,11 @@ static int new_instance_create(const char *name)
59385935
if (!tr->name)
59395936
goto out_free_tr;
59405937

5938+
if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
5939+
goto out_free_tr;
5940+
5941+
cpumask_copy(tr->tracing_cpumask, cpu_all_mask);
5942+
59415943
raw_spin_lock_init(&tr->start_lock);
59425944

59435945
tr->current_trace = &nop_trace;
@@ -5969,6 +5971,7 @@ static int new_instance_create(const char *name)
59695971
out_free_tr:
59705972
if (tr->trace_buffer.buffer)
59715973
ring_buffer_free(tr->trace_buffer.buffer);
5974+
free_cpumask_var(tr->tracing_cpumask);
59725975
kfree(tr->name);
59735976
kfree(tr);
59745977

@@ -6098,6 +6101,9 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
60986101
{
60996102
int cpu;
61006103

6104+
trace_create_file("tracing_cpumask", 0644, d_tracer,
6105+
tr, &tracing_cpumask_fops);
6106+
61016107
trace_create_file("trace_options", 0644, d_tracer,
61026108
tr, &tracing_iter_fops);
61036109

@@ -6147,9 +6153,6 @@ static __init int tracer_init_debugfs(void)
61476153

61486154
init_tracer_debugfs(&global_trace, d_tracer);
61496155

6150-
trace_create_file("tracing_cpumask", 0644, d_tracer,
6151-
&global_trace, &tracing_cpumask_fops);
6152-
61536156
trace_create_file("available_tracers", 0444, d_tracer,
61546157
&global_trace, &show_traces_fops);
61556158

@@ -6371,7 +6374,7 @@ __init static int tracer_alloc_buffers(void)
63716374
if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
63726375
goto out;
63736376

6374-
if (!alloc_cpumask_var(&tracing_cpumask, GFP_KERNEL))
6377+
if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL))
63756378
goto out_free_buffer_mask;
63766379

63776380
/* Only allocate trace_printk buffers if a trace_printk exists */
@@ -6386,7 +6389,7 @@ __init static int tracer_alloc_buffers(void)
63866389
ring_buf_size = 1;
63876390

63886391
cpumask_copy(tracing_buffer_mask, cpu_possible_mask);
6389-
cpumask_copy(tracing_cpumask, cpu_all_mask);
6392+
cpumask_copy(global_trace.tracing_cpumask, cpu_all_mask);
63906393

63916394
raw_spin_lock_init(&global_trace.start_lock);
63926395

@@ -6441,7 +6444,7 @@ __init static int tracer_alloc_buffers(void)
64416444
#ifdef CONFIG_TRACER_MAX_TRACE
64426445
free_percpu(global_trace.max_buffer.data);
64436446
#endif
6444-
free_cpumask_var(tracing_cpumask);
6447+
free_cpumask_var(global_trace.tracing_cpumask);
64456448
out_free_buffer_mask:
64466449
free_cpumask_var(tracing_buffer_mask);
64476450
out:

‎kernel/trace/trace.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ struct trace_array {
206206
struct dentry *event_dir;
207207
struct list_head systems;
208208
struct list_head events;
209+
cpumask_var_t tracing_cpumask; /* only trace on set CPUs */
209210
int ref;
210211
};
211212

0 commit comments

Comments
 (0)