Skip to content

Commit

Permalink
Merge tag 'trace-v4.4' 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 tracking updates from Steven Rostedt:
 "Most of the changes are clean ups and small fixes.  Some of them have
  stable tags to them.  I searched through my INBOX just as the merge
  window opened and found lots of patches to pull.  I ran them through
  all my tests and they were in linux-next for a few days.

  Features added this release:
  ----------------------------

   - Module globbing.  You can now filter function tracing to several
     modules.  # echo '*:mod:*snd*' > set_ftrace_filter (Dmitry Safonov)

   - Tracer specific options are now visible even when the tracer is not
     active.  It was rather annoying that you can only see and modify
     tracer options after enabling the tracer.  Now they are in the
     options/ directory even when the tracer is not active.  Although
     they are still only visible when the tracer is active in the
     trace_options file.

   - Trace options are now per instance (although some of the tracer
     specific options are global)

   - New tracefs file: set_event_pid.  If any pid is added to this file,
     then all events in the instance will filter out events that are not
     part of this pid.  sched_switch and sched_wakeup events handle next
     and the wakee pids"

* tag 'trace-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (68 commits)
  tracefs: Fix refcount imbalance in start_creating()
  tracing: Put back comma for empty fields in boot string parsing
  tracing: Apply tracer specific options from kernel command line.
  tracing: Add some documentation about set_event_pid
  ring_buffer: Remove unneeded smp_wmb() before wakeup of reader benchmark
  tracing: Allow dumping traces without tracking trace started cpus
  ring_buffer: Fix more races when terminating the producer in the benchmark
  ring_buffer: Do no not complete benchmark reader too early
  tracing: Remove redundant TP_ARGS redefining
  tracing: Rename max_stack_lock to stack_trace_max_lock
  tracing: Allow arch-specific stack tracer
  recordmcount: arm64: Replace the ignored mcount call into nop
  recordmcount: Fix endianness handling bug for nop_mcount
  tracepoints: Fix documentation of RCU lockdep checks
  tracing: ftrace_event_is_function() can return boolean
  tracing: is_legal_op() can return boolean
  ring-buffer: rb_event_is_commit() can return boolean
  ring-buffer: rb_per_cpu_empty() can return boolean
  ring_buffer: ring_buffer_empty{cpu}() can return boolean
  ring-buffer: rb_is_reader_page() can return boolean
  ...
  • Loading branch information
torvalds committed Nov 6, 2015
2 parents 7c623ca + d227c3a commit 22402cd
Show file tree
Hide file tree
Showing 39 changed files with 1,787 additions and 943 deletions.
18 changes: 18 additions & 0 deletions Documentation/trace/events.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,24 @@ prev_pid == 0
# cat sched_wakeup/filter
common_pid == 0

5.4 PID filtering
-----------------

The set_event_pid file in the same directory as the top events directory
exists, will filter all events from tracing any task that does not have the
PID listed in the set_event_pid file.

# cd /sys/kernel/debug/tracing
# echo $$ > set_event_pid
# echo 1 > events/enabled

Will only trace events for the current task.

To add more PIDs without losing the PIDs already included, use '>>'.

# echo 123 244 1 >> set_event_pid


6. Event triggers
=================

Expand Down
23 changes: 23 additions & 0 deletions Documentation/trace/ftrace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ of ftrace. Here is a list of some of the key files:

Have the function tracer only trace a single thread.

set_event_pid:

Have the events only trace a task with a PID listed in this file.
Note, sched_switch and sched_wake_up will also trace events
listed in this file.

set_graph_function:

Set a "trigger" function where tracing should start
Expand Down Expand Up @@ -2437,6 +2443,23 @@ The following commands are supported:

echo '!writeback*:mod:ext3' >> set_ftrace_filter

Mod command supports module globbing. Disable tracing for all
functions except a specific module:

echo '!*:mod:!ext3' >> set_ftrace_filter

Disable tracing for all modules, but still trace kernel:

echo '!*:mod:*' >> set_ftrace_filter

Enable filter only for kernel:

echo '*write*:mod:!*' >> set_ftrace_filter

Enable filter for module globbing:

echo '*write*:mod:*snd*' >> set_ftrace_filter

- traceon/traceoff
These commands turn tracing on and off when the specified
functions are hit. The parameter determines how many times the
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,25 +556,29 @@ void ftrace_replace_code(int enable)
run_sync();

report = "updating code";
count = 0;

for_ftrace_rec_iter(iter) {
rec = ftrace_rec_iter_record(iter);

ret = add_update(rec, enable);
if (ret)
goto remove_breakpoints;
count++;
}

run_sync();

report = "removing breakpoints";
count = 0;

for_ftrace_rec_iter(iter) {
rec = ftrace_rec_iter_record(iter);

ret = finish_update(rec, enable);
if (ret)
goto remove_breakpoints;
count++;
}

run_sync();
Expand Down
6 changes: 5 additions & 1 deletion fs/tracefs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,12 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
dput(dentry);
dentry = ERR_PTR(-EEXIST);
}
if (IS_ERR(dentry))

if (IS_ERR(dentry)) {
mutex_unlock(&parent->d_inode->i_mutex);
simple_release_fs(&tracefs_mount, &tracefs_mount_count);
}

return dentry;
}

Expand Down
11 changes: 11 additions & 0 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,18 @@ static inline void ftrace_kill(void) { }
#endif /* CONFIG_FUNCTION_TRACER */

#ifdef CONFIG_STACK_TRACER

#define STACK_TRACE_ENTRIES 500

struct stack_trace;

extern unsigned stack_trace_index[];
extern struct stack_trace stack_trace_max;
extern unsigned long stack_trace_max_size;
extern arch_spinlock_t stack_trace_max_lock;

extern int stack_tracer_enabled;
void stack_trace_print(void);
int
stack_trace_sysctl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
Expand Down
4 changes: 2 additions & 2 deletions include/linux/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
}
#endif

int ring_buffer_empty(struct ring_buffer *buffer);
int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
bool ring_buffer_empty(struct ring_buffer *buffer);
bool ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);

void ring_buffer_record_disable(struct ring_buffer *buffer);
void ring_buffer_record_enable(struct ring_buffer *buffer);
Expand Down
20 changes: 13 additions & 7 deletions include/linux/trace_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,12 @@ struct ring_buffer_event *
trace_current_buffer_lock_reserve(struct ring_buffer **current_buffer,
int type, unsigned long len,
unsigned long flags, int pc);
void trace_current_buffer_unlock_commit(struct ring_buffer *buffer,
struct ring_buffer_event *event,
unsigned long flags, int pc);
void trace_buffer_unlock_commit(struct ring_buffer *buffer,
void trace_buffer_unlock_commit(struct trace_array *tr,
struct ring_buffer *buffer,
struct ring_buffer_event *event,
unsigned long flags, int pc);
void trace_buffer_unlock_commit_regs(struct ring_buffer *buffer,
void trace_buffer_unlock_commit_regs(struct trace_array *tr,
struct ring_buffer *buffer,
struct ring_buffer_event *event,
unsigned long flags, int pc,
struct pt_regs *regs);
Expand Down Expand Up @@ -329,6 +328,7 @@ enum {
EVENT_FILE_FL_SOFT_DISABLED_BIT,
EVENT_FILE_FL_TRIGGER_MODE_BIT,
EVENT_FILE_FL_TRIGGER_COND_BIT,
EVENT_FILE_FL_PID_FILTER_BIT,
};

/*
Expand All @@ -342,6 +342,7 @@ enum {
* tracepoint may be enabled)
* TRIGGER_MODE - When set, invoke the triggers associated with the event
* TRIGGER_COND - When set, one or more triggers has an associated filter
* PID_FILTER - When set, the event is filtered based on pid
*/
enum {
EVENT_FILE_FL_ENABLED = (1 << EVENT_FILE_FL_ENABLED_BIT),
Expand All @@ -352,6 +353,7 @@ enum {
EVENT_FILE_FL_SOFT_DISABLED = (1 << EVENT_FILE_FL_SOFT_DISABLED_BIT),
EVENT_FILE_FL_TRIGGER_MODE = (1 << EVENT_FILE_FL_TRIGGER_MODE_BIT),
EVENT_FILE_FL_TRIGGER_COND = (1 << EVENT_FILE_FL_TRIGGER_COND_BIT),
EVENT_FILE_FL_PID_FILTER = (1 << EVENT_FILE_FL_PID_FILTER_BIT),
};

struct trace_event_file {
Expand Down Expand Up @@ -430,6 +432,8 @@ extern enum event_trigger_type event_triggers_call(struct trace_event_file *file
extern void event_triggers_post_call(struct trace_event_file *file,
enum event_trigger_type tt);

bool trace_event_ignore_this_pid(struct trace_event_file *trace_file);

/**
* trace_trigger_soft_disabled - do triggers and test if soft disabled
* @file: The file pointer of the event to test
Expand All @@ -449,6 +453,8 @@ trace_trigger_soft_disabled(struct trace_event_file *file)
event_triggers_call(file, NULL);
if (eflags & EVENT_FILE_FL_SOFT_DISABLED)
return true;
if (eflags & EVENT_FILE_FL_PID_FILTER)
return trace_event_ignore_this_pid(file);
}
return false;
}
Expand Down Expand Up @@ -508,7 +514,7 @@ event_trigger_unlock_commit(struct trace_event_file *file,
enum event_trigger_type tt = ETT_NONE;

if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
trace_buffer_unlock_commit(buffer, event, irq_flags, pc);
trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc);

if (tt)
event_triggers_post_call(file, tt);
Expand Down Expand Up @@ -540,7 +546,7 @@ event_trigger_unlock_commit_regs(struct trace_event_file *file,
enum event_trigger_type tt = ETT_NONE;

if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
trace_buffer_unlock_commit_regs(buffer, event,
trace_buffer_unlock_commit_regs(file->tr, buffer, event,
irq_flags, pc, regs);

if (tt)
Expand Down
39 changes: 32 additions & 7 deletions include/linux/tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct notifier_block;
struct tracepoint_func {
void *func;
void *data;
int prio;
};

struct tracepoint {
Expand All @@ -42,9 +43,14 @@ struct trace_enum_map {
unsigned long enum_value;
};

#define TRACEPOINT_DEFAULT_PRIO 10

extern int
tracepoint_probe_register(struct tracepoint *tp, void *probe, void *data);
extern int
tracepoint_probe_register_prio(struct tracepoint *tp, void *probe, void *data,
int prio);
extern int
tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data);
extern void
for_each_kernel_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
Expand Down Expand Up @@ -111,7 +117,18 @@ extern void syscall_unregfunc(void);
#define TP_ARGS(args...) args
#define TP_CONDITION(args...) args

#ifdef CONFIG_TRACEPOINTS
/*
* Individual subsystem my have a separate configuration to
* enable their tracepoints. By default, this file will create
* the tracepoints if CONFIG_TRACEPOINT is defined. If a subsystem
* wants to be able to disable its tracepoints from being created
* it can define NOTRACE before including the tracepoint headers.
*/
#if defined(CONFIG_TRACEPOINTS) && !defined(NOTRACE)
#define TRACEPOINTS_ENABLED
#endif

#ifdef TRACEPOINTS_ENABLED

/*
* it_func[0] is never NULL because there is at least one element in the array
Expand Down Expand Up @@ -167,10 +184,11 @@ extern void syscall_unregfunc(void);
* structure. Force alignment to the same alignment as the section start.
*
* When lockdep is enabled, we make sure to always do the RCU portions of
* the tracepoint code, regardless of whether tracing is on or we match the
* condition. This lets us find RCU issues triggered with tracepoints even
* when this tracepoint is off. This code has no purpose other than poking
* RCU a bit.
* the tracepoint code, regardless of whether tracing is on. However,
* don't check if the condition is false, due to interaction with idle
* instrumentation. This lets us find RCU issues triggered with tracepoints
* even when this tracepoint is off. This code has no purpose other than
* poking RCU a bit.
*/
#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
extern struct tracepoint __tracepoint_##name; \
Expand All @@ -196,6 +214,13 @@ extern void syscall_unregfunc(void);
(void *)probe, data); \
} \
static inline int \
register_trace_prio_##name(void (*probe)(data_proto), void *data,\
int prio) \
{ \
return tracepoint_probe_register_prio(&__tracepoint_##name, \
(void *)probe, data, prio); \
} \
static inline int \
unregister_trace_##name(void (*probe)(data_proto), void *data) \
{ \
return tracepoint_probe_unregister(&__tracepoint_##name,\
Expand Down Expand Up @@ -234,7 +259,7 @@ extern void syscall_unregfunc(void);
#define EXPORT_TRACEPOINT_SYMBOL(name) \
EXPORT_SYMBOL(__tracepoint_##name)

#else /* !CONFIG_TRACEPOINTS */
#else /* !TRACEPOINTS_ENABLED */
#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
static inline void trace_##name(proto) \
{ } \
Expand Down Expand Up @@ -266,7 +291,7 @@ extern void syscall_unregfunc(void);
#define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
#define EXPORT_TRACEPOINT_SYMBOL(name)

#endif /* CONFIG_TRACEPOINTS */
#endif /* TRACEPOINTS_ENABLED */

#ifdef CONFIG_TRACING
/**
Expand Down
2 changes: 1 addition & 1 deletion include/trace/define_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
#undef DECLARE_TRACE
#define DECLARE_TRACE(name, proto, args)

#ifdef CONFIG_EVENT_TRACING
#ifdef TRACEPOINTS_ENABLED
#include <trace/trace_events.h>
#include <trace/perf.h>
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/trace/events/gpio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#undef TRACE_SYSTEM
#define TRACE_SYSTEM gpio

#ifndef CONFIG_TRACING_EVENTS_GPIO
#define NOTRACE
#endif

#if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_GPIO_H

Expand Down
Loading

0 comments on commit 22402cd

Please sign in to comment.