diff options
-rw-r--r-- | include/trace/ftrace.h | 33 | ||||
-rw-r--r-- | include/trace/syscall.h | 15 | ||||
-rw-r--r-- | kernel/fork.c | 2 | ||||
-rw-r--r-- | kernel/tracepoint.c | 26 | ||||
-rw-r--r-- | samples/trace_events/trace-events-sample.h | 3 |
5 files changed, 63 insertions, 16 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 0fd06fef9fac..26b4f2e13275 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -44,6 +44,12 @@ | |||
44 | #undef __field_ext | 44 | #undef __field_ext |
45 | #define __field_ext(type, item, filter_type) type item; | 45 | #define __field_ext(type, item, filter_type) type item; |
46 | 46 | ||
47 | #undef __field_struct | ||
48 | #define __field_struct(type, item) type item; | ||
49 | |||
50 | #undef __field_struct_ext | ||
51 | #define __field_struct_ext(type, item, filter_type) type item; | ||
52 | |||
47 | #undef __array | 53 | #undef __array |
48 | #define __array(type, item, len) type item[len]; | 54 | #define __array(type, item, len) type item[len]; |
49 | 55 | ||
@@ -122,6 +128,12 @@ | |||
122 | #undef __field_ext | 128 | #undef __field_ext |
123 | #define __field_ext(type, item, filter_type) | 129 | #define __field_ext(type, item, filter_type) |
124 | 130 | ||
131 | #undef __field_struct | ||
132 | #define __field_struct(type, item) | ||
133 | |||
134 | #undef __field_struct_ext | ||
135 | #define __field_struct_ext(type, item, filter_type) | ||
136 | |||
125 | #undef __array | 137 | #undef __array |
126 | #define __array(type, item, len) | 138 | #define __array(type, item, len) |
127 | 139 | ||
@@ -315,9 +327,21 @@ static struct trace_event_functions ftrace_event_type_funcs_##call = { \ | |||
315 | if (ret) \ | 327 | if (ret) \ |
316 | return ret; | 328 | return ret; |
317 | 329 | ||
330 | #undef __field_struct_ext | ||
331 | #define __field_struct_ext(type, item, filter_type) \ | ||
332 | ret = trace_define_field(event_call, #type, #item, \ | ||
333 | offsetof(typeof(field), item), \ | ||
334 | sizeof(field.item), \ | ||
335 | 0, filter_type); \ | ||
336 | if (ret) \ | ||
337 | return ret; | ||
338 | |||
318 | #undef __field | 339 | #undef __field |
319 | #define __field(type, item) __field_ext(type, item, FILTER_OTHER) | 340 | #define __field(type, item) __field_ext(type, item, FILTER_OTHER) |
320 | 341 | ||
342 | #undef __field_struct | ||
343 | #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER) | ||
344 | |||
321 | #undef __array | 345 | #undef __array |
322 | #define __array(type, item, len) \ | 346 | #define __array(type, item, len) \ |
323 | do { \ | 347 | do { \ |
@@ -379,6 +403,12 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \ | |||
379 | #undef __field_ext | 403 | #undef __field_ext |
380 | #define __field_ext(type, item, filter_type) | 404 | #define __field_ext(type, item, filter_type) |
381 | 405 | ||
406 | #undef __field_struct | ||
407 | #define __field_struct(type, item) | ||
408 | |||
409 | #undef __field_struct_ext | ||
410 | #define __field_struct_ext(type, item, filter_type) | ||
411 | |||
382 | #undef __array | 412 | #undef __array |
383 | #define __array(type, item, len) | 413 | #define __array(type, item, len) |
384 | 414 | ||
@@ -550,6 +580,9 @@ static inline notrace int ftrace_get_offsets_##call( \ | |||
550 | #undef __field | 580 | #undef __field |
551 | #define __field(type, item) | 581 | #define __field(type, item) |
552 | 582 | ||
583 | #undef __field_struct | ||
584 | #define __field_struct(type, item) | ||
585 | |||
553 | #undef __array | 586 | #undef __array |
554 | #define __array(type, item, len) | 587 | #define __array(type, item, len) |
555 | 588 | ||
diff --git a/include/trace/syscall.h b/include/trace/syscall.h index fed853f3d7aa..9674145e2f6a 100644 --- a/include/trace/syscall.h +++ b/include/trace/syscall.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/tracepoint.h> | 4 | #include <linux/tracepoint.h> |
5 | #include <linux/unistd.h> | 5 | #include <linux/unistd.h> |
6 | #include <linux/ftrace_event.h> | 6 | #include <linux/ftrace_event.h> |
7 | #include <linux/thread_info.h> | ||
7 | 8 | ||
8 | #include <asm/ptrace.h> | 9 | #include <asm/ptrace.h> |
9 | 10 | ||
@@ -32,4 +33,18 @@ struct syscall_metadata { | |||
32 | struct ftrace_event_call *exit_event; | 33 | struct ftrace_event_call *exit_event; |
33 | }; | 34 | }; |
34 | 35 | ||
36 | #if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) | ||
37 | static inline void syscall_tracepoint_update(struct task_struct *p) | ||
38 | { | ||
39 | if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) | ||
40 | set_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT); | ||
41 | else | ||
42 | clear_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT); | ||
43 | } | ||
44 | #else | ||
45 | static inline void syscall_tracepoint_update(struct task_struct *p) | ||
46 | { | ||
47 | } | ||
48 | #endif | ||
49 | |||
35 | #endif /* _TRACE_SYSCALL_H */ | 50 | #endif /* _TRACE_SYSCALL_H */ |
diff --git a/kernel/fork.c b/kernel/fork.c index d2799d1fc952..6a13c46cd87d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1487,7 +1487,9 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1487 | 1487 | ||
1488 | total_forks++; | 1488 | total_forks++; |
1489 | spin_unlock(¤t->sighand->siglock); | 1489 | spin_unlock(¤t->sighand->siglock); |
1490 | syscall_tracepoint_update(p); | ||
1490 | write_unlock_irq(&tasklist_lock); | 1491 | write_unlock_irq(&tasklist_lock); |
1492 | |||
1491 | proc_fork_connector(p); | 1493 | proc_fork_connector(p); |
1492 | cgroup_post_fork(p); | 1494 | cgroup_post_fork(p); |
1493 | if (clone_flags & CLONE_THREAD) | 1495 | if (clone_flags & CLONE_THREAD) |
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 33cbd8c203f8..3490407dc7b7 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c | |||
@@ -492,33 +492,29 @@ static int sys_tracepoint_refcount; | |||
492 | 492 | ||
493 | void syscall_regfunc(void) | 493 | void syscall_regfunc(void) |
494 | { | 494 | { |
495 | unsigned long flags; | 495 | struct task_struct *p, *t; |
496 | struct task_struct *g, *t; | ||
497 | 496 | ||
498 | if (!sys_tracepoint_refcount) { | 497 | if (!sys_tracepoint_refcount) { |
499 | read_lock_irqsave(&tasklist_lock, flags); | 498 | read_lock(&tasklist_lock); |
500 | do_each_thread(g, t) { | 499 | for_each_process_thread(p, t) { |
501 | /* Skip kernel threads. */ | 500 | set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); |
502 | if (t->mm) | 501 | } |
503 | set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); | 502 | read_unlock(&tasklist_lock); |
504 | } while_each_thread(g, t); | ||
505 | read_unlock_irqrestore(&tasklist_lock, flags); | ||
506 | } | 503 | } |
507 | sys_tracepoint_refcount++; | 504 | sys_tracepoint_refcount++; |
508 | } | 505 | } |
509 | 506 | ||
510 | void syscall_unregfunc(void) | 507 | void syscall_unregfunc(void) |
511 | { | 508 | { |
512 | unsigned long flags; | 509 | struct task_struct *p, *t; |
513 | struct task_struct *g, *t; | ||
514 | 510 | ||
515 | sys_tracepoint_refcount--; | 511 | sys_tracepoint_refcount--; |
516 | if (!sys_tracepoint_refcount) { | 512 | if (!sys_tracepoint_refcount) { |
517 | read_lock_irqsave(&tasklist_lock, flags); | 513 | read_lock(&tasklist_lock); |
518 | do_each_thread(g, t) { | 514 | for_each_process_thread(p, t) { |
519 | clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); | 515 | clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); |
520 | } while_each_thread(g, t); | 516 | } |
521 | read_unlock_irqrestore(&tasklist_lock, flags); | 517 | read_unlock(&tasklist_lock); |
522 | } | 518 | } |
523 | } | 519 | } |
524 | #endif | 520 | #endif |
diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 6af373236d73..4b0113f73ee9 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h | |||
@@ -56,7 +56,8 @@ | |||
56 | * struct: This defines the way the data will be stored in the ring buffer. | 56 | * struct: This defines the way the data will be stored in the ring buffer. |
57 | * There are currently two types of elements. __field and __array. | 57 | * There are currently two types of elements. __field and __array. |
58 | * a __field is broken up into (type, name). Where type can be any | 58 | * a __field is broken up into (type, name). Where type can be any |
59 | * type but an array. | 59 | * primitive type (integer, long or pointer). __field_struct() can |
60 | * be any static complex data value (struct, union, but not an array). | ||
60 | * For an array. there are three fields. (type, name, size). The | 61 | * For an array. there are three fields. (type, name, size). The |
61 | * type of elements in the array, the name of the field and the size | 62 | * type of elements in the array, the name of the field and the size |
62 | * of the array. | 63 | * of the array. |