diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/ftrace_event.h | 10 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 1 | ||||
-rw-r--r-- | include/linux/marker.h | 221 | ||||
-rw-r--r-- | include/linux/module.h | 11 | ||||
-rw-r--r-- | include/linux/syscalls.h | 24 | ||||
-rw-r--r-- | include/trace/ftrace.h | 111 |
6 files changed, 79 insertions, 299 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index bd099ba82ccc..4ec5e67e18cf 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/ring_buffer.h> | 4 | #include <linux/ring_buffer.h> |
5 | #include <linux/trace_seq.h> | 5 | #include <linux/trace_seq.h> |
6 | #include <linux/percpu.h> | 6 | #include <linux/percpu.h> |
7 | #include <linux/hardirq.h> | ||
7 | 8 | ||
8 | struct trace_array; | 9 | struct trace_array; |
9 | struct tracer; | 10 | struct tracer; |
@@ -130,10 +131,15 @@ struct ftrace_event_call { | |||
130 | void *data; | 131 | void *data; |
131 | 132 | ||
132 | atomic_t profile_count; | 133 | atomic_t profile_count; |
133 | int (*profile_enable)(struct ftrace_event_call *); | 134 | int (*profile_enable)(void); |
134 | void (*profile_disable)(struct ftrace_event_call *); | 135 | void (*profile_disable)(void); |
135 | }; | 136 | }; |
136 | 137 | ||
138 | #define FTRACE_MAX_PROFILE_SIZE 2048 | ||
139 | |||
140 | extern char *trace_profile_buf; | ||
141 | extern char *trace_profile_buf_nmi; | ||
142 | |||
137 | #define MAX_FILTER_PRED 32 | 143 | #define MAX_FILTER_PRED 32 |
138 | #define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */ | 144 | #define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */ |
139 | 145 | ||
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 4af56036a6bf..b7bbb5ddd7ae 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/preempt.h> | 17 | #include <linux/preempt.h> |
18 | #include <linux/marker.h> | ||
19 | #include <linux/msi.h> | 18 | #include <linux/msi.h> |
20 | #include <asm/signal.h> | 19 | #include <asm/signal.h> |
21 | 20 | ||
diff --git a/include/linux/marker.h b/include/linux/marker.h deleted file mode 100644 index b85e74ca782f..000000000000 --- a/include/linux/marker.h +++ /dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | #ifndef _LINUX_MARKER_H | ||
2 | #define _LINUX_MARKER_H | ||
3 | |||
4 | /* | ||
5 | * Code markup for dynamic and static tracing. | ||
6 | * | ||
7 | * See Documentation/marker.txt. | ||
8 | * | ||
9 | * (C) Copyright 2006 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | ||
10 | * | ||
11 | * This file is released under the GPLv2. | ||
12 | * See the file COPYING for more details. | ||
13 | */ | ||
14 | |||
15 | #include <stdarg.h> | ||
16 | #include <linux/types.h> | ||
17 | |||
18 | struct module; | ||
19 | struct marker; | ||
20 | |||
21 | /** | ||
22 | * marker_probe_func - Type of a marker probe function | ||
23 | * @probe_private: probe private data | ||
24 | * @call_private: call site private data | ||
25 | * @fmt: format string | ||
26 | * @args: variable argument list pointer. Use a pointer to overcome C's | ||
27 | * inability to pass this around as a pointer in a portable manner in | ||
28 | * the callee otherwise. | ||
29 | * | ||
30 | * Type of marker probe functions. They receive the mdata and need to parse the | ||
31 | * format string to recover the variable argument list. | ||
32 | */ | ||
33 | typedef void marker_probe_func(void *probe_private, void *call_private, | ||
34 | const char *fmt, va_list *args); | ||
35 | |||
36 | struct marker_probe_closure { | ||
37 | marker_probe_func *func; /* Callback */ | ||
38 | void *probe_private; /* Private probe data */ | ||
39 | }; | ||
40 | |||
41 | struct marker { | ||
42 | const char *name; /* Marker name */ | ||
43 | const char *format; /* Marker format string, describing the | ||
44 | * variable argument list. | ||
45 | */ | ||
46 | char state; /* Marker state. */ | ||
47 | char ptype; /* probe type : 0 : single, 1 : multi */ | ||
48 | /* Probe wrapper */ | ||
49 | void (*call)(const struct marker *mdata, void *call_private, ...); | ||
50 | struct marker_probe_closure single; | ||
51 | struct marker_probe_closure *multi; | ||
52 | const char *tp_name; /* Optional tracepoint name */ | ||
53 | void *tp_cb; /* Optional tracepoint callback */ | ||
54 | } __attribute__((aligned(8))); | ||
55 | |||
56 | #ifdef CONFIG_MARKERS | ||
57 | |||
58 | #define _DEFINE_MARKER(name, tp_name_str, tp_cb, format) \ | ||
59 | static const char __mstrtab_##name[] \ | ||
60 | __attribute__((section("__markers_strings"))) \ | ||
61 | = #name "\0" format; \ | ||
62 | static struct marker __mark_##name \ | ||
63 | __attribute__((section("__markers"), aligned(8))) = \ | ||
64 | { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \ | ||
65 | 0, 0, marker_probe_cb, { __mark_empty_function, NULL},\ | ||
66 | NULL, tp_name_str, tp_cb } | ||
67 | |||
68 | #define DEFINE_MARKER(name, format) \ | ||
69 | _DEFINE_MARKER(name, NULL, NULL, format) | ||
70 | |||
71 | #define DEFINE_MARKER_TP(name, tp_name, tp_cb, format) \ | ||
72 | _DEFINE_MARKER(name, #tp_name, tp_cb, format) | ||
73 | |||
74 | /* | ||
75 | * Note : the empty asm volatile with read constraint is used here instead of a | ||
76 | * "used" attribute to fix a gcc 4.1.x bug. | ||
77 | * Make sure the alignment of the structure in the __markers section will | ||
78 | * not add unwanted padding between the beginning of the section and the | ||
79 | * structure. Force alignment to the same alignment as the section start. | ||
80 | * | ||
81 | * The "generic" argument controls which marker enabling mechanism must be used. | ||
82 | * If generic is true, a variable read is used. | ||
83 | * If generic is false, immediate values are used. | ||
84 | */ | ||
85 | #define __trace_mark(generic, name, call_private, format, args...) \ | ||
86 | do { \ | ||
87 | DEFINE_MARKER(name, format); \ | ||
88 | __mark_check_format(format, ## args); \ | ||
89 | if (unlikely(__mark_##name.state)) { \ | ||
90 | (*__mark_##name.call) \ | ||
91 | (&__mark_##name, call_private, ## args);\ | ||
92 | } \ | ||
93 | } while (0) | ||
94 | |||
95 | #define __trace_mark_tp(name, call_private, tp_name, tp_cb, format, args...) \ | ||
96 | do { \ | ||
97 | void __check_tp_type(void) \ | ||
98 | { \ | ||
99 | register_trace_##tp_name(tp_cb); \ | ||
100 | } \ | ||
101 | DEFINE_MARKER_TP(name, tp_name, tp_cb, format); \ | ||
102 | __mark_check_format(format, ## args); \ | ||
103 | (*__mark_##name.call)(&__mark_##name, call_private, \ | ||
104 | ## args); \ | ||
105 | } while (0) | ||
106 | |||
107 | extern void marker_update_probe_range(struct marker *begin, | ||
108 | struct marker *end); | ||
109 | |||
110 | #define GET_MARKER(name) (__mark_##name) | ||
111 | |||
112 | #else /* !CONFIG_MARKERS */ | ||
113 | #define DEFINE_MARKER(name, tp_name, tp_cb, format) | ||
114 | #define __trace_mark(generic, name, call_private, format, args...) \ | ||
115 | __mark_check_format(format, ## args) | ||
116 | #define __trace_mark_tp(name, call_private, tp_name, tp_cb, format, args...) \ | ||
117 | do { \ | ||
118 | void __check_tp_type(void) \ | ||
119 | { \ | ||
120 | register_trace_##tp_name(tp_cb); \ | ||
121 | } \ | ||
122 | __mark_check_format(format, ## args); \ | ||
123 | } while (0) | ||
124 | static inline void marker_update_probe_range(struct marker *begin, | ||
125 | struct marker *end) | ||
126 | { } | ||
127 | #define GET_MARKER(name) | ||
128 | #endif /* CONFIG_MARKERS */ | ||
129 | |||
130 | /** | ||
131 | * trace_mark - Marker using code patching | ||
132 | * @name: marker name, not quoted. | ||
133 | * @format: format string | ||
134 | * @args...: variable argument list | ||
135 | * | ||
136 | * Places a marker using optimized code patching technique (imv_read()) | ||
137 | * to be enabled when immediate values are present. | ||
138 | */ | ||
139 | #define trace_mark(name, format, args...) \ | ||
140 | __trace_mark(0, name, NULL, format, ## args) | ||
141 | |||
142 | /** | ||
143 | * _trace_mark - Marker using variable read | ||
144 | * @name: marker name, not quoted. | ||
145 | * @format: format string | ||
146 | * @args...: variable argument list | ||
147 | * | ||
148 | * Places a marker using a standard memory read (_imv_read()) to be | ||
149 | * enabled. Should be used for markers in code paths where instruction | ||
150 | * modification based enabling is not welcome. (__init and __exit functions, | ||
151 | * lockdep, some traps, printk). | ||
152 | */ | ||
153 | #define _trace_mark(name, format, args...) \ | ||
154 | __trace_mark(1, name, NULL, format, ## args) | ||
155 | |||
156 | /** | ||
157 | * trace_mark_tp - Marker in a tracepoint callback | ||
158 | * @name: marker name, not quoted. | ||
159 | * @tp_name: tracepoint name, not quoted. | ||
160 | * @tp_cb: tracepoint callback. Should have an associated global symbol so it | ||
161 | * is not optimized away by the compiler (should not be static). | ||
162 | * @format: format string | ||
163 | * @args...: variable argument list | ||
164 | * | ||
165 | * Places a marker in a tracepoint callback. | ||
166 | */ | ||
167 | #define trace_mark_tp(name, tp_name, tp_cb, format, args...) \ | ||
168 | __trace_mark_tp(name, NULL, tp_name, tp_cb, format, ## args) | ||
169 | |||
170 | /** | ||
171 | * MARK_NOARGS - Format string for a marker with no argument. | ||
172 | */ | ||
173 | #define MARK_NOARGS " " | ||
174 | |||
175 | /* To be used for string format validity checking with gcc */ | ||
176 | static inline void __printf(1, 2) ___mark_check_format(const char *fmt, ...) | ||
177 | { | ||
178 | } | ||
179 | |||
180 | #define __mark_check_format(format, args...) \ | ||
181 | do { \ | ||
182 | if (0) \ | ||
183 | ___mark_check_format(format, ## args); \ | ||
184 | } while (0) | ||
185 | |||
186 | extern marker_probe_func __mark_empty_function; | ||
187 | |||
188 | extern void marker_probe_cb(const struct marker *mdata, | ||
189 | void *call_private, ...); | ||
190 | |||
191 | /* | ||
192 | * Connect a probe to a marker. | ||
193 | * private data pointer must be a valid allocated memory address, or NULL. | ||
194 | */ | ||
195 | extern int marker_probe_register(const char *name, const char *format, | ||
196 | marker_probe_func *probe, void *probe_private); | ||
197 | |||
198 | /* | ||
199 | * Returns the private data given to marker_probe_register. | ||
200 | */ | ||
201 | extern int marker_probe_unregister(const char *name, | ||
202 | marker_probe_func *probe, void *probe_private); | ||
203 | /* | ||
204 | * Unregister a marker by providing the registered private data. | ||
205 | */ | ||
206 | extern int marker_probe_unregister_private_data(marker_probe_func *probe, | ||
207 | void *probe_private); | ||
208 | |||
209 | extern void *marker_get_private_data(const char *name, marker_probe_func *probe, | ||
210 | int num); | ||
211 | |||
212 | /* | ||
213 | * marker_synchronize_unregister must be called between the last marker probe | ||
214 | * unregistration and the first one of | ||
215 | * - the end of module exit function | ||
216 | * - the free of any resource used by the probes | ||
217 | * to ensure the code and data are valid for any possibly running probes. | ||
218 | */ | ||
219 | #define marker_synchronize_unregister() synchronize_sched() | ||
220 | |||
221 | #endif | ||
diff --git a/include/linux/module.h b/include/linux/module.h index f8f92d015efe..1c755b2f937d 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/stringify.h> | 15 | #include <linux/stringify.h> |
16 | #include <linux/kobject.h> | 16 | #include <linux/kobject.h> |
17 | #include <linux/moduleparam.h> | 17 | #include <linux/moduleparam.h> |
18 | #include <linux/marker.h> | ||
19 | #include <linux/tracepoint.h> | 18 | #include <linux/tracepoint.h> |
20 | 19 | ||
21 | #include <asm/local.h> | 20 | #include <asm/local.h> |
@@ -327,10 +326,6 @@ struct module | |||
327 | /* The command line arguments (may be mangled). People like | 326 | /* The command line arguments (may be mangled). People like |
328 | keeping pointers to this stuff */ | 327 | keeping pointers to this stuff */ |
329 | char *args; | 328 | char *args; |
330 | #ifdef CONFIG_MARKERS | ||
331 | struct marker *markers; | ||
332 | unsigned int num_markers; | ||
333 | #endif | ||
334 | #ifdef CONFIG_TRACEPOINTS | 329 | #ifdef CONFIG_TRACEPOINTS |
335 | struct tracepoint *tracepoints; | 330 | struct tracepoint *tracepoints; |
336 | unsigned int num_tracepoints; | 331 | unsigned int num_tracepoints; |
@@ -535,8 +530,6 @@ int unregister_module_notifier(struct notifier_block * nb); | |||
535 | 530 | ||
536 | extern void print_modules(void); | 531 | extern void print_modules(void); |
537 | 532 | ||
538 | extern void module_update_markers(void); | ||
539 | |||
540 | extern void module_update_tracepoints(void); | 533 | extern void module_update_tracepoints(void); |
541 | extern int module_get_iter_tracepoints(struct tracepoint_iter *iter); | 534 | extern int module_get_iter_tracepoints(struct tracepoint_iter *iter); |
542 | 535 | ||
@@ -651,10 +644,6 @@ static inline void print_modules(void) | |||
651 | { | 644 | { |
652 | } | 645 | } |
653 | 646 | ||
654 | static inline void module_update_markers(void) | ||
655 | { | ||
656 | } | ||
657 | |||
658 | static inline void module_update_tracepoints(void) | 647 | static inline void module_update_tracepoints(void) |
659 | { | 648 | { |
660 | } | 649 | } |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index a8e37821cc60..7d9803cbb20f 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -100,33 +100,25 @@ struct perf_counter_attr; | |||
100 | 100 | ||
101 | #ifdef CONFIG_EVENT_PROFILE | 101 | #ifdef CONFIG_EVENT_PROFILE |
102 | #define TRACE_SYS_ENTER_PROFILE(sname) \ | 102 | #define TRACE_SYS_ENTER_PROFILE(sname) \ |
103 | static int prof_sysenter_enable_##sname(struct ftrace_event_call *event_call) \ | 103 | static int prof_sysenter_enable_##sname(void) \ |
104 | { \ | 104 | { \ |
105 | int ret = 0; \ | 105 | return reg_prof_syscall_enter("sys"#sname); \ |
106 | if (!atomic_inc_return(&event_enter_##sname.profile_count)) \ | ||
107 | ret = reg_prof_syscall_enter("sys"#sname); \ | ||
108 | return ret; \ | ||
109 | } \ | 106 | } \ |
110 | \ | 107 | \ |
111 | static void prof_sysenter_disable_##sname(struct ftrace_event_call *event_call)\ | 108 | static void prof_sysenter_disable_##sname(void) \ |
112 | { \ | 109 | { \ |
113 | if (atomic_add_negative(-1, &event_enter_##sname.profile_count)) \ | 110 | unreg_prof_syscall_enter("sys"#sname); \ |
114 | unreg_prof_syscall_enter("sys"#sname); \ | ||
115 | } | 111 | } |
116 | 112 | ||
117 | #define TRACE_SYS_EXIT_PROFILE(sname) \ | 113 | #define TRACE_SYS_EXIT_PROFILE(sname) \ |
118 | static int prof_sysexit_enable_##sname(struct ftrace_event_call *event_call) \ | 114 | static int prof_sysexit_enable_##sname(void) \ |
119 | { \ | 115 | { \ |
120 | int ret = 0; \ | 116 | return reg_prof_syscall_exit("sys"#sname); \ |
121 | if (!atomic_inc_return(&event_exit_##sname.profile_count)) \ | ||
122 | ret = reg_prof_syscall_exit("sys"#sname); \ | ||
123 | return ret; \ | ||
124 | } \ | 117 | } \ |
125 | \ | 118 | \ |
126 | static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \ | 119 | static void prof_sysexit_disable_##sname(void) \ |
127 | { \ | 120 | { \ |
128 | if (atomic_add_negative(-1, &event_exit_##sname.profile_count)) \ | 121 | unreg_prof_syscall_exit("sys"#sname); \ |
129 | unreg_prof_syscall_exit("sys"#sname); \ | ||
130 | } | 122 | } |
131 | 123 | ||
132 | #define TRACE_SYS_ENTER_PROFILE_INIT(sname) \ | 124 | #define TRACE_SYS_ENTER_PROFILE_INIT(sname) \ |
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 72a3b437b829..a0361cb69769 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -382,20 +382,14 @@ static inline int ftrace_get_offsets_##call( \ | |||
382 | * | 382 | * |
383 | * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later | 383 | * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later |
384 | * | 384 | * |
385 | * static int ftrace_profile_enable_<call>(struct ftrace_event_call *event_call) | 385 | * static int ftrace_profile_enable_<call>(void) |
386 | * { | 386 | * { |
387 | * int ret = 0; | 387 | * return register_trace_<call>(ftrace_profile_<call>); |
388 | * | ||
389 | * if (!atomic_inc_return(&event_call->profile_count)) | ||
390 | * ret = register_trace_<call>(ftrace_profile_<call>); | ||
391 | * | ||
392 | * return ret; | ||
393 | * } | 388 | * } |
394 | * | 389 | * |
395 | * static void ftrace_profile_disable_<call>(struct ftrace_event_call *event_call) | 390 | * static void ftrace_profile_disable_<call>(void) |
396 | * { | 391 | * { |
397 | * if (atomic_add_negative(-1, &event->call->profile_count)) | 392 | * unregister_trace_<call>(ftrace_profile_<call>); |
398 | * unregister_trace_<call>(ftrace_profile_<call>); | ||
399 | * } | 393 | * } |
400 | * | 394 | * |
401 | */ | 395 | */ |
@@ -405,20 +399,14 @@ static inline int ftrace_get_offsets_##call( \ | |||
405 | \ | 399 | \ |
406 | static void ftrace_profile_##call(proto); \ | 400 | static void ftrace_profile_##call(proto); \ |
407 | \ | 401 | \ |
408 | static int ftrace_profile_enable_##call(struct ftrace_event_call *event_call) \ | 402 | static int ftrace_profile_enable_##call(void) \ |
409 | { \ | 403 | { \ |
410 | int ret = 0; \ | 404 | return register_trace_##call(ftrace_profile_##call); \ |
411 | \ | ||
412 | if (!atomic_inc_return(&event_call->profile_count)) \ | ||
413 | ret = register_trace_##call(ftrace_profile_##call); \ | ||
414 | \ | ||
415 | return ret; \ | ||
416 | } \ | 405 | } \ |
417 | \ | 406 | \ |
418 | static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\ | 407 | static void ftrace_profile_disable_##call(void) \ |
419 | { \ | 408 | { \ |
420 | if (atomic_add_negative(-1, &event_call->profile_count)) \ | 409 | unregister_trace_##call(ftrace_profile_##call); \ |
421 | unregister_trace_##call(ftrace_profile_##call); \ | ||
422 | } | 410 | } |
423 | 411 | ||
424 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) | 412 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) |
@@ -660,11 +648,12 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ | |||
660 | * struct ftrace_raw_##call *entry; | 648 | * struct ftrace_raw_##call *entry; |
661 | * u64 __addr = 0, __count = 1; | 649 | * u64 __addr = 0, __count = 1; |
662 | * unsigned long irq_flags; | 650 | * unsigned long irq_flags; |
651 | * struct trace_entry *ent; | ||
663 | * int __entry_size; | 652 | * int __entry_size; |
664 | * int __data_size; | 653 | * int __data_size; |
654 | * int __cpu | ||
665 | * int pc; | 655 | * int pc; |
666 | * | 656 | * |
667 | * local_save_flags(irq_flags); | ||
668 | * pc = preempt_count(); | 657 | * pc = preempt_count(); |
669 | * | 658 | * |
670 | * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args); | 659 | * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args); |
@@ -675,25 +664,34 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ | |||
675 | * sizeof(u64)); | 664 | * sizeof(u64)); |
676 | * __entry_size -= sizeof(u32); | 665 | * __entry_size -= sizeof(u32); |
677 | * | 666 | * |
678 | * do { | 667 | * // Protect the non nmi buffer |
679 | * char raw_data[__entry_size]; <- allocate our sample in the stack | 668 | * // This also protects the rcu read side |
680 | * struct trace_entry *ent; | 669 | * local_irq_save(irq_flags); |
670 | * __cpu = smp_processor_id(); | ||
671 | * | ||
672 | * if (in_nmi()) | ||
673 | * raw_data = rcu_dereference(trace_profile_buf_nmi); | ||
674 | * else | ||
675 | * raw_data = rcu_dereference(trace_profile_buf); | ||
676 | * | ||
677 | * if (!raw_data) | ||
678 | * goto end; | ||
681 | * | 679 | * |
682 | * zero dead bytes from alignment to avoid stack leak to userspace: | 680 | * raw_data = per_cpu_ptr(raw_data, __cpu); |
683 | * | 681 | * |
684 | * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; | 682 | * //zero dead bytes from alignment to avoid stack leak to userspace: |
685 | * entry = (struct ftrace_raw_<call> *)raw_data; | 683 | * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; |
686 | * ent = &entry->ent; | 684 | * entry = (struct ftrace_raw_<call> *)raw_data; |
687 | * tracing_generic_entry_update(ent, irq_flags, pc); | 685 | * ent = &entry->ent; |
688 | * ent->type = event_call->id; | 686 | * tracing_generic_entry_update(ent, irq_flags, pc); |
687 | * ent->type = event_call->id; | ||
689 | * | 688 | * |
690 | * <tstruct> <- do some jobs with dynamic arrays | 689 | * <tstruct> <- do some jobs with dynamic arrays |
691 | * | 690 | * |
692 | * <assign> <- affect our values | 691 | * <assign> <- affect our values |
693 | * | 692 | * |
694 | * perf_tpcounter_event(event_call->id, __addr, __count, entry, | 693 | * perf_tpcounter_event(event_call->id, __addr, __count, entry, |
695 | * __entry_size); <- submit them to perf counter | 694 | * __entry_size); <- submit them to perf counter |
696 | * } while (0); | ||
697 | * | 695 | * |
698 | * } | 696 | * } |
699 | */ | 697 | */ |
@@ -716,11 +714,13 @@ static void ftrace_profile_##call(proto) \ | |||
716 | struct ftrace_raw_##call *entry; \ | 714 | struct ftrace_raw_##call *entry; \ |
717 | u64 __addr = 0, __count = 1; \ | 715 | u64 __addr = 0, __count = 1; \ |
718 | unsigned long irq_flags; \ | 716 | unsigned long irq_flags; \ |
717 | struct trace_entry *ent; \ | ||
719 | int __entry_size; \ | 718 | int __entry_size; \ |
720 | int __data_size; \ | 719 | int __data_size; \ |
720 | char *raw_data; \ | ||
721 | int __cpu; \ | ||
721 | int pc; \ | 722 | int pc; \ |
722 | \ | 723 | \ |
723 | local_save_flags(irq_flags); \ | ||
724 | pc = preempt_count(); \ | 724 | pc = preempt_count(); \ |
725 | \ | 725 | \ |
726 | __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ | 726 | __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \ |
@@ -728,23 +728,38 @@ static void ftrace_profile_##call(proto) \ | |||
728 | sizeof(u64)); \ | 728 | sizeof(u64)); \ |
729 | __entry_size -= sizeof(u32); \ | 729 | __entry_size -= sizeof(u32); \ |
730 | \ | 730 | \ |
731 | do { \ | 731 | if (WARN_ONCE(__entry_size > FTRACE_MAX_PROFILE_SIZE, \ |
732 | char raw_data[__entry_size]; \ | 732 | "profile buffer not large enough")) \ |
733 | struct trace_entry *ent; \ | 733 | return; \ |
734 | \ | ||
735 | local_irq_save(irq_flags); \ | ||
736 | __cpu = smp_processor_id(); \ | ||
734 | \ | 737 | \ |
735 | *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; \ | 738 | if (in_nmi()) \ |
736 | entry = (struct ftrace_raw_##call *)raw_data; \ | 739 | raw_data = rcu_dereference(trace_profile_buf_nmi); \ |
737 | ent = &entry->ent; \ | 740 | else \ |
738 | tracing_generic_entry_update(ent, irq_flags, pc); \ | 741 | raw_data = rcu_dereference(trace_profile_buf); \ |
739 | ent->type = event_call->id; \ | ||
740 | \ | 742 | \ |
741 | tstruct \ | 743 | if (!raw_data) \ |
744 | goto end; \ | ||
742 | \ | 745 | \ |
743 | { assign; } \ | 746 | raw_data = per_cpu_ptr(raw_data, __cpu); \ |
744 | \ | 747 | \ |
745 | perf_tpcounter_event(event_call->id, __addr, __count, entry,\ | 748 | *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; \ |
749 | entry = (struct ftrace_raw_##call *)raw_data; \ | ||
750 | ent = &entry->ent; \ | ||
751 | tracing_generic_entry_update(ent, irq_flags, pc); \ | ||
752 | ent->type = event_call->id; \ | ||
753 | \ | ||
754 | tstruct \ | ||
755 | \ | ||
756 | { assign; } \ | ||
757 | \ | ||
758 | perf_tpcounter_event(event_call->id, __addr, __count, entry, \ | ||
746 | __entry_size); \ | 759 | __entry_size); \ |
747 | } while (0); \ | 760 | \ |
761 | end: \ | ||
762 | local_irq_restore(irq_flags); \ | ||
748 | \ | 763 | \ |
749 | } | 764 | } |
750 | 765 | ||