Skip to content

Commit b29c830

Browse files
committed
Merge tag 'trace-3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing update from Steven Rostedt: "This batch of changes is mostly clean ups and small bug fixes. The only real feature that was added this release is from Namhyung Kim, who introduced "set_graph_notrace" filter that lets you run the function graph tracer and not trace particular functions and their call chain. Tom Zanussi added some updates to the ftrace multibuffer tracing that made it more consistent with the top level tracing. One of the fixes for perf function tracing required an API change in RCU; the addition of "rcu_is_watching()". As Paul McKenney is pushing that change in this release too, he gave me a branch that included all the changes to get that working, and I pulled that into my tree in order to complete the perf function tracing fix" * tag 'trace-3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Add rcu annotation for syscall trace descriptors tracing: Do not use signed enums with unsigned long long in fgragh output tracing: Remove unused function ftrace_off_permanent() tracing: Do not assign filp->private_data to freed memory tracing: Add helper function tracing_is_disabled() tracing: Open tracer when ftrace_dump_on_oops is used tracing: Add support for SOFT_DISABLE to syscall events tracing: Make register/unregister_ftrace_command __init tracing: Update event filters for multibuffer recordmcount.pl: Add support for __fentry__ ftrace: Have control op function callback only trace when RCU is watching rcu: Do not trace rcu_is_watching() functions ftrace/x86: skip over the breakpoint for ftrace caller trace/trace_stat: use rbtree postorder iteration helper instead of opencoding ftrace: Add set_graph_notrace filter ftrace: Narrow down the protected area of graph_lock ftrace: Introduce struct ftrace_graph_data ftrace: Get rid of ftrace_graph_filter_enabled tracing: Fix potential out-of-bounds in trace_get_user() tracing: Show more exact help information about snapshot
2 parents 0bde729 + 3a81a52 commit b29c830

23 files changed

Lines changed: 564 additions & 230 deletions

‎arch/x86/kernel/ftrace.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
248248
return ret;
249249
}
250250

251+
static int is_ftrace_caller(unsigned long ip)
252+
{
253+
if (ip == (unsigned long)(&ftrace_call) ||
254+
ip == (unsigned long)(&ftrace_regs_call))
255+
return 1;
256+
257+
return 0;
258+
}
259+
251260
/*
252261
* A breakpoint was added to the code address we are about to
253262
* modify, and this is the handle that will just skip over it.
@@ -257,10 +266,13 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
257266
*/
258267
int ftrace_int3_handler(struct pt_regs *regs)
259268
{
269+
unsigned long ip;
270+
260271
if (WARN_ON_ONCE(!regs))
261272
return 0;
262273

263-
if (!ftrace_location(regs->ip - 1))
274+
ip = regs->ip - 1;
275+
if (!ftrace_location(ip) && !is_ftrace_caller(ip))
264276
return 0;
265277

266278
regs->ip += MCOUNT_INSN_SIZE - 1;

‎include/linux/ftrace.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,11 @@ static inline int ftrace_force_update(void) { return 0; }
533533
static inline void ftrace_disable_daemon(void) { }
534534
static inline void ftrace_enable_daemon(void) { }
535535
static inline void ftrace_release_mod(struct module *mod) {}
536-
static inline int register_ftrace_command(struct ftrace_func_command *cmd)
536+
static inline __init int register_ftrace_command(struct ftrace_func_command *cmd)
537537
{
538538
return -EINVAL;
539539
}
540-
static inline int unregister_ftrace_command(char *cmd_name)
540+
static inline __init int unregister_ftrace_command(char *cmd_name)
541541
{
542542
return -EINVAL;
543543
}
@@ -721,6 +721,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
721721
extern char __irqentry_text_start[];
722722
extern char __irqentry_text_end[];
723723

724+
#define FTRACE_NOTRACE_DEPTH 65536
724725
#define FTRACE_RETFUNC_DEPTH 50
725726
#define FTRACE_RETSTACK_ALLOC_SIZE 32
726727
extern int register_ftrace_graph(trace_func_graph_ret_t retfunc,

‎include/linux/ftrace_event.h‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ enum {
202202
TRACE_EVENT_FL_NO_SET_FILTER_BIT,
203203
TRACE_EVENT_FL_IGNORE_ENABLE_BIT,
204204
TRACE_EVENT_FL_WAS_ENABLED_BIT,
205+
TRACE_EVENT_FL_USE_CALL_FILTER_BIT,
205206
};
206207

207208
/*
@@ -213,13 +214,15 @@ enum {
213214
* WAS_ENABLED - Set and stays set when an event was ever enabled
214215
* (used for module unloading, if a module event is enabled,
215216
* it is best to clear the buffers that used it).
217+
* USE_CALL_FILTER - For ftrace internal events, don't use file filter
216218
*/
217219
enum {
218220
TRACE_EVENT_FL_FILTERED = (1 << TRACE_EVENT_FL_FILTERED_BIT),
219221
TRACE_EVENT_FL_CAP_ANY = (1 << TRACE_EVENT_FL_CAP_ANY_BIT),
220222
TRACE_EVENT_FL_NO_SET_FILTER = (1 << TRACE_EVENT_FL_NO_SET_FILTER_BIT),
221223
TRACE_EVENT_FL_IGNORE_ENABLE = (1 << TRACE_EVENT_FL_IGNORE_ENABLE_BIT),
222224
TRACE_EVENT_FL_WAS_ENABLED = (1 << TRACE_EVENT_FL_WAS_ENABLED_BIT),
225+
TRACE_EVENT_FL_USE_CALL_FILTER = (1 << TRACE_EVENT_FL_USE_CALL_FILTER_BIT),
223226
};
224227

225228
struct ftrace_event_call {
@@ -238,6 +241,7 @@ struct ftrace_event_call {
238241
* bit 2: failed to apply filter
239242
* bit 3: ftrace internal event (do not enable)
240243
* bit 4: Event was enabled by module
244+
* bit 5: use call filter rather than file filter
241245
*/
242246
int flags; /* static flags of different events */
243247

@@ -253,6 +257,8 @@ struct ftrace_subsystem_dir;
253257
enum {
254258
FTRACE_EVENT_FL_ENABLED_BIT,
255259
FTRACE_EVENT_FL_RECORDED_CMD_BIT,
260+
FTRACE_EVENT_FL_FILTERED_BIT,
261+
FTRACE_EVENT_FL_NO_SET_FILTER_BIT,
256262
FTRACE_EVENT_FL_SOFT_MODE_BIT,
257263
FTRACE_EVENT_FL_SOFT_DISABLED_BIT,
258264
};
@@ -261,20 +267,25 @@ enum {
261267
* Ftrace event file flags:
262268
* ENABLED - The event is enabled
263269
* RECORDED_CMD - The comms should be recorded at sched_switch
270+
* FILTERED - The event has a filter attached
271+
* NO_SET_FILTER - Set when filter has error and is to be ignored
264272
* SOFT_MODE - The event is enabled/disabled by SOFT_DISABLED
265273
* SOFT_DISABLED - When set, do not trace the event (even though its
266274
* tracepoint may be enabled)
267275
*/
268276
enum {
269277
FTRACE_EVENT_FL_ENABLED = (1 << FTRACE_EVENT_FL_ENABLED_BIT),
270278
FTRACE_EVENT_FL_RECORDED_CMD = (1 << FTRACE_EVENT_FL_RECORDED_CMD_BIT),
279+
FTRACE_EVENT_FL_FILTERED = (1 << FTRACE_EVENT_FL_FILTERED_BIT),
280+
FTRACE_EVENT_FL_NO_SET_FILTER = (1 << FTRACE_EVENT_FL_NO_SET_FILTER_BIT),
271281
FTRACE_EVENT_FL_SOFT_MODE = (1 << FTRACE_EVENT_FL_SOFT_MODE_BIT),
272282
FTRACE_EVENT_FL_SOFT_DISABLED = (1 << FTRACE_EVENT_FL_SOFT_DISABLED_BIT),
273283
};
274284

275285
struct ftrace_event_file {
276286
struct list_head list;
277287
struct ftrace_event_call *event_call;
288+
struct event_filter *filter;
278289
struct dentry *dir;
279290
struct trace_array *tr;
280291
struct ftrace_subsystem_dir *system;
@@ -310,12 +321,16 @@ struct ftrace_event_file {
310321

311322
#define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */
312323

313-
extern void destroy_preds(struct ftrace_event_call *call);
324+
extern void destroy_preds(struct ftrace_event_file *file);
325+
extern void destroy_call_preds(struct ftrace_event_call *call);
314326
extern int filter_match_preds(struct event_filter *filter, void *rec);
315-
extern int filter_current_check_discard(struct ring_buffer *buffer,
316-
struct ftrace_event_call *call,
317-
void *rec,
318-
struct ring_buffer_event *event);
327+
328+
extern int filter_check_discard(struct ftrace_event_file *file, void *rec,
329+
struct ring_buffer *buffer,
330+
struct ring_buffer_event *event);
331+
extern int call_filter_check_discard(struct ftrace_event_call *call, void *rec,
332+
struct ring_buffer *buffer,
333+
struct ring_buffer_event *event);
319334

320335
enum {
321336
FILTER_OTHER = 0,

‎include/linux/kernel.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ void tracing_snapshot_alloc(void);
501501

502502
extern void tracing_start(void);
503503
extern void tracing_stop(void);
504-
extern void ftrace_off_permanent(void);
505504

506505
static inline __printf(1, 2)
507506
void ____trace_printk_check_format(const char *fmt, ...)
@@ -639,7 +638,6 @@ extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
639638
#else
640639
static inline void tracing_start(void) { }
641640
static inline void tracing_stop(void) { }
642-
static inline void ftrace_off_permanent(void) { }
643641
static inline void trace_dump_stack(int skip) { }
644642

645643
static inline void tracing_on(void) { }

‎include/linux/syscalls.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
120120
.class = &event_class_syscall_enter, \
121121
.event.funcs = &enter_syscall_print_funcs, \
122122
.data = (void *)&__syscall_meta_##sname,\
123-
.flags = TRACE_EVENT_FL_CAP_ANY, \
123+
.flags = TRACE_EVENT_FL_CAP_ANY, \
124124
}; \
125125
static struct ftrace_event_call __used \
126126
__attribute__((section("_ftrace_events"))) \
@@ -134,7 +134,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
134134
.class = &event_class_syscall_exit, \
135135
.event.funcs = &exit_syscall_print_funcs, \
136136
.data = (void *)&__syscall_meta_##sname,\
137-
.flags = TRACE_EVENT_FL_CAP_ANY, \
137+
.flags = TRACE_EVENT_FL_CAP_ANY, \
138138
}; \
139139
static struct ftrace_event_call __used \
140140
__attribute__((section("_ftrace_events"))) \

‎include/trace/ftrace.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,8 @@ static inline notrace int ftrace_get_offsets_##call( \
437437
* { <assign>; } <-- Here we assign the entries by the __field and
438438
* __array macros.
439439
*
440-
* if (!filter_current_check_discard(buffer, event_call, entry, event))
441-
* trace_nowake_buffer_unlock_commit(buffer,
442-
* event, irq_flags, pc);
440+
* if (!filter_check_discard(ftrace_file, entry, buffer, event))
441+
* trace_buffer_unlock_commit(buffer, event, irq_flags, pc);
443442
* }
444443
*
445444
* static struct trace_event ftrace_event_type_<call> = {
@@ -553,7 +552,7 @@ ftrace_raw_event_##call(void *__data, proto) \
553552
\
554553
{ assign; } \
555554
\
556-
if (!filter_current_check_discard(buffer, event_call, entry, event)) \
555+
if (!filter_check_discard(ftrace_file, entry, buffer, event)) \
557556
trace_buffer_unlock_commit(buffer, event, irq_flags, pc); \
558557
}
559558
/*

‎kernel/rcu/tiny.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(rcu_irq_enter);
181181
/*
182182
* Test whether RCU thinks that the current CPU is idle.
183183
*/
184-
bool __rcu_is_watching(void)
184+
bool notrace __rcu_is_watching(void)
185185
{
186186
return rcu_dynticks_nesting;
187187
}

‎kernel/rcu/tree.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void rcu_nmi_exit(void)
664664
* rcu_is_watching(), the caller of __rcu_is_watching() must have at
665665
* least disabled preemption.
666666
*/
667-
bool __rcu_is_watching(void)
667+
bool notrace __rcu_is_watching(void)
668668
{
669669
return atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1;
670670
}
@@ -675,7 +675,7 @@ bool __rcu_is_watching(void)
675675
* If the current CPU is in its idle loop and is neither in an interrupt
676676
* or NMI handler, return true.
677677
*/
678-
bool rcu_is_watching(void)
678+
bool notrace rcu_is_watching(void)
679679
{
680680
int ret;
681681

0 commit comments

Comments
 (0)