Skip to content

Commit

Permalink
Merge tag 'trace-3.12' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/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
  • Loading branch information
torvalds committed Sep 9, 2013
2 parents 300893b + a0a5a05 commit 7eb6952
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 209 deletions.
3 changes: 3 additions & 0 deletions arch/x86/kernel/entry_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,9 @@ ftrace_restore_flags:
#else /* ! CONFIG_DYNAMIC_FTRACE */

ENTRY(mcount)
cmpl $__PAGE_OFFSET, %esp
jb ftrace_stub /* Paging not enabled yet? */

cmpl $0, function_trace_stop
jne ftrace_stub

Expand Down
2 changes: 1 addition & 1 deletion kernel/rcupdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct lockdep_map rcu_sched_lock_map =
STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_sched", &rcu_sched_lock_key);
EXPORT_SYMBOL_GPL(rcu_sched_lock_map);

int debug_lockdep_rcu_enabled(void)
int notrace debug_lockdep_rcu_enabled(void)
{
return rcu_scheduler_active && debug_locks &&
current->lockdep_recursion == 0;
Expand Down
17 changes: 16 additions & 1 deletion kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1978,12 +1978,27 @@ int __weak ftrace_arch_code_modify_post_process(void)

void ftrace_modify_all_code(int command)
{
int update = command & FTRACE_UPDATE_TRACE_FUNC;

/*
* If the ftrace_caller calls a ftrace_ops func directly,
* we need to make sure that it only traces functions it
* expects to trace. When doing the switch of functions,
* we need to update to the ftrace_ops_list_func first
* before the transition between old and new calls are set,
* as the ftrace_ops_list_func will check the ops hashes
* to make sure the ops are having the right functions
* traced.
*/
if (update)
ftrace_update_ftrace_func(ftrace_ops_list_func);

if (command & FTRACE_UPDATE_CALLS)
ftrace_replace_code(1);
else if (command & FTRACE_DISABLE_CALLS)
ftrace_replace_code(0);

if (command & FTRACE_UPDATE_TRACE_FUNC)
if (update && ftrace_trace_function != ftrace_ops_list_func)
ftrace_update_ftrace_func(ftrace_trace_function);

if (command & FTRACE_START_FUNC_RET)
Expand Down
37 changes: 20 additions & 17 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3165,11 +3165,6 @@ static const struct file_operations show_traces_fops = {
.llseek = seq_lseek,
};

/*
* Only trace on a CPU if the bitmask is set:
*/
static cpumask_var_t tracing_cpumask;

/*
* The tracer itself will not take this lock, but still we want
* to provide a consistent cpumask to user-space:
Expand All @@ -3186,11 +3181,12 @@ static ssize_t
tracing_cpumask_read(struct file *filp, char __user *ubuf,
size_t count, loff_t *ppos)
{
struct trace_array *tr = file_inode(filp)->i_private;
int len;

mutex_lock(&tracing_cpumask_update_lock);

len = cpumask_scnprintf(mask_str, count, tracing_cpumask);
len = cpumask_scnprintf(mask_str, count, tr->tracing_cpumask);
if (count - len < 2) {
count = -EINVAL;
goto out_err;
Expand All @@ -3208,7 +3204,7 @@ static ssize_t
tracing_cpumask_write(struct file *filp, const char __user *ubuf,
size_t count, loff_t *ppos)
{
struct trace_array *tr = filp->private_data;
struct trace_array *tr = file_inode(filp)->i_private;
cpumask_var_t tracing_cpumask_new;
int err, cpu;

Expand All @@ -3228,12 +3224,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
* Increase/decrease the disabled counter if we are
* about to flip a bit in the cpumask:
*/
if (cpumask_test_cpu(cpu, tracing_cpumask) &&
if (cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
!cpumask_test_cpu(cpu, tracing_cpumask_new)) {
atomic_inc(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled);
ring_buffer_record_disable_cpu(tr->trace_buffer.buffer, cpu);
}
if (!cpumask_test_cpu(cpu, tracing_cpumask) &&
if (!cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
cpumask_test_cpu(cpu, tracing_cpumask_new)) {
atomic_dec(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled);
ring_buffer_record_enable_cpu(tr->trace_buffer.buffer, cpu);
Expand All @@ -3242,7 +3238,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
arch_spin_unlock(&ftrace_max_lock);
local_irq_enable();

cpumask_copy(tracing_cpumask, tracing_cpumask_new);
cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new);

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

static const struct file_operations tracing_cpumask_fops = {
.open = tracing_open_generic,
.open = tracing_open_generic_tr,
.read = tracing_cpumask_read,
.write = tracing_cpumask_write,
.release = tracing_release_generic_tr,
.llseek = generic_file_llseek,
};

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

if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
goto out_free_tr;

cpumask_copy(tr->tracing_cpumask, cpu_all_mask);

raw_spin_lock_init(&tr->start_lock);

tr->current_trace = &nop_trace;
Expand Down Expand Up @@ -5969,6 +5971,7 @@ static int new_instance_create(const char *name)
out_free_tr:
if (tr->trace_buffer.buffer)
ring_buffer_free(tr->trace_buffer.buffer);
free_cpumask_var(tr->tracing_cpumask);
kfree(tr->name);
kfree(tr);

Expand Down Expand Up @@ -6098,6 +6101,9 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
{
int cpu;

trace_create_file("tracing_cpumask", 0644, d_tracer,
tr, &tracing_cpumask_fops);

trace_create_file("trace_options", 0644, d_tracer,
tr, &tracing_iter_fops);

Expand Down Expand Up @@ -6147,9 +6153,6 @@ static __init int tracer_init_debugfs(void)

init_tracer_debugfs(&global_trace, d_tracer);

trace_create_file("tracing_cpumask", 0644, d_tracer,
&global_trace, &tracing_cpumask_fops);

trace_create_file("available_tracers", 0444, d_tracer,
&global_trace, &show_traces_fops);

Expand Down Expand Up @@ -6371,7 +6374,7 @@ __init static int tracer_alloc_buffers(void)
if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
goto out;

if (!alloc_cpumask_var(&tracing_cpumask, GFP_KERNEL))
if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL))
goto out_free_buffer_mask;

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

cpumask_copy(tracing_buffer_mask, cpu_possible_mask);
cpumask_copy(tracing_cpumask, cpu_all_mask);
cpumask_copy(global_trace.tracing_cpumask, cpu_all_mask);

raw_spin_lock_init(&global_trace.start_lock);

Expand Down Expand Up @@ -6441,7 +6444,7 @@ __init static int tracer_alloc_buffers(void)
#ifdef CONFIG_TRACER_MAX_TRACE
free_percpu(global_trace.max_buffer.data);
#endif
free_cpumask_var(tracing_cpumask);
free_cpumask_var(global_trace.tracing_cpumask);
out_free_buffer_mask:
free_cpumask_var(tracing_buffer_mask);
out:
Expand Down
1 change: 1 addition & 0 deletions kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct trace_array {
struct dentry *event_dir;
struct list_head systems;
struct list_head events;
cpumask_var_t tracing_cpumask; /* only trace on set CPUs */
int ref;
};

Expand Down
Loading

0 comments on commit 7eb6952

Please sign in to comment.