History

Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/core

Ingo Molnar committed 14 years ago

Commit 09bda442 parents d1e169d 47b0edc15 files · +118 −44Browse files

Unified · Split

15 files
  1. Documentation/trace/ftrace.txt +7 −0
  2. arch/x86/kernel/process.c +12 −12
  3. drivers/cpuidle/cpuidle.c +4 −4
  4. include/linux/ftrace.h +2 −2
  5. include/linux/interrupt.h +1 −6
  6. include/linux/tracepoint.h +18 −4
  7. include/trace/events/power.h +2 −0
  8. include/trace/events/printk.h +41 −0
  9. kernel/irq/chip.c +2 −0
  10. kernel/printk.c +5 −0
  11. kernel/softirq.c +6 −0
  12. kernel/trace/ftrace.c +10 −7
  13. kernel/trace/trace.c +3 −3
  14. kernel/trace/trace_events_filter.c +3 −4
  15. kernel/trace/trace_syscalls.c +2 −2
Documentation/trace/ftrace.txt+7−0
@@ -226,6 +226,13 @@ Here is the list of current tracers that may be configured. · 225 unmodified lines
226226 Traces and records the max latency that it takes for
227227 the highest priority task to get scheduled after
228228 it has been woken up.
229+ Traces all tasks as an average developer would expect.
230+
231+ "wakeup_rt"
232+
233+ Traces and records the max latency that it takes for just
234+ RT tasks (as the current "wakeup" does). This is useful
235+ for those interested in wake up timings of RT tasks.
229236
230237 "hw-branch-tracer"
231238
arch/x86/kernel/process.c+12−12
@@ -377,8 +377,8 @@ static inline int hlt_use_halt(void) · 376 unmodified lines
377377 void default_idle(void)
378378 {
379379 if (hlt_use_halt()) {
380− trace_power_start(POWER_CSTATE, 1, smp_processor_id());
381− trace_cpu_idle(1, smp_processor_id());
380+ trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
381+ trace_cpu_idle_rcuidle(1, smp_processor_id());
382382 current_thread_info()->status &= ~TS_POLLING;
383383 /*
384384 * TS_POLLING-cleared state must be visible before we
@@ -391,8 +391,8 @@ void default_idle(void) · 6 unmodified lines
391391 else
392392 local_irq_enable();
393393 current_thread_info()->status |= TS_POLLING;
394− trace_power_end(smp_processor_id());
395− trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
394+ trace_power_end_rcuidle(smp_processor_id());
395+ trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
396396 } else {
397397 local_irq_enable();
398398 /* loop is done by the caller */
@@ -450,8 +450,8 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait); · 51 unmodified lines
450450 static void mwait_idle(void)
451451 {
452452 if (!need_resched()) {
453− trace_power_start(POWER_CSTATE, 1, smp_processor_id());
454− trace_cpu_idle(1, smp_processor_id());
453+ trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
454+ trace_cpu_idle_rcuidle(1, smp_processor_id());
455455 if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
456456 clflush((void *)&current_thread_info()->flags);
457457
@@ -461,8 +461,8 @@ static void mwait_idle(void) · 3 unmodified lines
461461 __sti_mwait(0, 0);
462462 else
463463 local_irq_enable();
464− trace_power_end(smp_processor_id());
465− trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
464+ trace_power_end_rcuidle(smp_processor_id());
465+ trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
466466 } else
467467 local_irq_enable();
468468 }
@@ -474,13 +474,13 @@ static void mwait_idle(void) · 5 unmodified lines
474474 */
475475 static void poll_idle(void)
476476 {
477− trace_power_start(POWER_CSTATE, 0, smp_processor_id());
478− trace_cpu_idle(0, smp_processor_id());
477+ trace_power_start_rcuidle(POWER_CSTATE, 0, smp_processor_id());
478+ trace_cpu_idle_rcuidle(0, smp_processor_id());
479479 local_irq_enable();
480480 while (!need_resched())
481481 cpu_relax();
482− trace_power_end(smp_processor_id());
483− trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
482+ trace_power_end_rcuidle(smp_processor_id());
483+ trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
484484 }
485485
486486 /*
drivers/cpuidle/cpuidle.c+4−4
@@ -94,13 +94,13 @@ int cpuidle_idle_call(void) · 93 unmodified lines
9494
9595 target_state = &drv->states[next_state];
9696
97− trace_power_start(POWER_CSTATE, next_state, dev->cpu);
98− trace_cpu_idle(next_state, dev->cpu);
97+ trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu);
98+ trace_cpu_idle_rcuidle(next_state, dev->cpu);
9999
100100 entered_state = target_state->enter(dev, drv, next_state);
101101
102− trace_power_end(dev->cpu);
103− trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);
102+ trace_power_end_rcuidle(dev->cpu);
103+ trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu);
104104
105105 if (entered_state >= 0) {
106106 /* Update cpuidle counters */
include/linux/ftrace.h+2−2
@@ -178,9 +178,9 @@ struct dyn_ftrace { · 177 unmodified lines
178178 };
179179
180180 int ftrace_force_update(void);
181−void ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
181+int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
182182 int len, int reset);
183−void ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
183+int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
184184 int len, int reset);
185185 void ftrace_set_global_filter(unsigned char *buf, int len, int reset);
186186 void ftrace_set_global_notrace(unsigned char *buf, int len, int reset);
include/linux/interrupt.h+1−6
@@ -20,7 +20,6 @@ · 19 unmodified lines
2020 #include <linux/atomic.h>
2121 #include <asm/ptrace.h>
2222 #include <asm/system.h>
23−#include <trace/events/irq.h>
2423
2524 /*
2625 * These correspond to the IORESOURCE_IRQ_* defines in
@@ -456,11 +455,7 @@ asmlinkage void do_softirq(void); · 429 unmodified lines
456455 asmlinkage void __do_softirq(void);
457456 extern void open_softirq(int nr, void (*action)(struct softirq_action *));
458457 extern void softirq_init(void);
459−static inline void __raise_softirq_irqoff(unsigned int nr)
460−{
461− trace_softirq_raise(nr);
462− or_softirq_pending(1UL << nr);
463−}
458+extern void __raise_softirq_irqoff(unsigned int nr);
464459
465460 extern void raise_softirq_irqoff(unsigned int nr);
466461 extern void raise_softirq(unsigned int nr);
include/linux/tracepoint.h+18−4
@@ -114,7 +114,7 @@ static inline void tracepoint_synchronize_unregister(void) · 113 unmodified lines
114114 * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just
115115 * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto".
116116 */
117−#define __DO_TRACE(tp, proto, args, cond) \
117+#define __DO_TRACE(tp, proto, args, cond, prercu, postrcu) \
118118 do { \
119119 struct tracepoint_func *it_func_ptr; \
120120 void *it_func; \
@@ -122,6 +122,7 @@ static inline void tracepoint_synchronize_unregister(void) · 1 unmodified line
122122 \
123123 if (!(cond)) \
124124 return; \
125+ prercu; \
125126 rcu_read_lock_sched_notrace(); \
126127 it_func_ptr = rcu_dereference_sched((tp)->funcs); \
127128 if (it_func_ptr) { \
@@ -132,6 +133,7 @@ static inline void tracepoint_synchronize_unregister(void) · 4 unmodified lines
132133 } while ((++it_func_ptr)->func); \
133134 } \
134135 rcu_read_unlock_sched_notrace(); \
136+ postrcu; \
135137 } while (0)
136138
137139 /*
@@ -139,7 +141,7 @@ static inline void tracepoint_synchronize_unregister(void) · 1 unmodified line
139141 * not add unwanted padding between the beginning of the section and the
140142 * structure. Force alignment to the same alignment as the section start.
141143 */
142−#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
144+#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
143145 extern struct tracepoint __tracepoint_##name; \
144146 static inline void trace_##name(proto) \
145147 { \
@@ -147,7 +149,17 @@ static inline void tracepoint_synchronize_unregister(void) · 1 unmodified line
147149 __DO_TRACE(&__tracepoint_##name, \
148150 TP_PROTO(data_proto), \
149151 TP_ARGS(data_args), \
150− TP_CONDITION(cond)); \
152+ TP_CONDITION(cond),,); \
153+ } \
154+ static inline void trace_##name##_rcuidle(proto) \
155+ { \
156+ if (static_branch(&__tracepoint_##name.key)) \
157+ __DO_TRACE(&__tracepoint_##name, \
158+ TP_PROTO(data_proto), \
159+ TP_ARGS(data_args), \
160+ TP_CONDITION(cond), \
161+ rcu_idle_exit(), \
162+ rcu_idle_enter()); \
151163 } \
152164 static inline int \
153165 register_trace_##name(void (*probe)(data_proto), void *data) \
@@ -190,9 +202,11 @@ static inline void tracepoint_synchronize_unregister(void) · 36 unmodified lines
190202 EXPORT_SYMBOL(__tracepoint_##name)
191203
192204 #else /* !CONFIG_TRACEPOINTS */
193−#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
205+#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
194206 static inline void trace_##name(proto) \
195207 { } \
208+ static inline void trace_##name##_rcuidle(proto) \
209+ { } \
196210 static inline int \
197211 register_trace_##name(void (*probe)(data_proto), \
198212 void *data) \
include/trace/events/power.h+2−0
@@ -151,6 +151,8 @@ enum { · 150 unmodified lines
151151 events get removed */
152152 static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
153153 static inline void trace_power_end(u64 cpuid) {};
154+static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
155+static inline void trace_power_end_rcuidle(u64 cpuid) {};
154156 static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
155157 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
156158
include/trace/events/printk.h+41−0
@@ -0,0 +1,41 @@
1+#undef TRACE_SYSTEM
2+#define TRACE_SYSTEM printk
3+
4+#if !defined(_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ)
5+#define _TRACE_PRINTK_H
6+
7+#include <linux/tracepoint.h>
8+
9+TRACE_EVENT_CONDITION(console,
10+ TP_PROTO(const char *log_buf, unsigned start, unsigned end,
11+ unsigned log_buf_len),
12+
13+ TP_ARGS(log_buf, start, end, log_buf_len),
14+
15+ TP_CONDITION(start != end),
16+
17+ TP_STRUCT__entry(
18+ __dynamic_array(char, msg, end - start + 1)
19+ ),
20+
21+ TP_fast_assign(
22+ if ((start & (log_buf_len - 1)) > (end & (log_buf_len - 1))) {
23+ memcpy(__get_dynamic_array(msg),
24+ log_buf + (start & (log_buf_len - 1)),
25+ log_buf_len - (start & (log_buf_len - 1)));
26+ memcpy((char *)__get_dynamic_array(msg) +
27+ log_buf_len - (start & (log_buf_len - 1)),
28+ log_buf, end & (log_buf_len - 1));
29+ } else
30+ memcpy(__get_dynamic_array(msg),
31+ log_buf + (start & (log_buf_len - 1)),
32+ end - start);
33+ ((char *)__get_dynamic_array(msg))[end - start] = 0;
34+ ),
35+
36+ TP_printk("%s", __get_str(msg))
37+);
38+#endif /* _TRACE_PRINTK_H */
39+
40+/* This part must be outside protection */
41+#include <trace/define_trace.h>
kernel/irq/chip.c+2−0
@@ -16,6 +16,8 @@ · 15 unmodified lines
1616 #include <linux/interrupt.h>
1717 #include <linux/kernel_stat.h>
1818
19+#include <trace/events/irq.h>
20+
1921 #include "internals.h"
2022
2123 /**
kernel/printk.c+5−0
@@ -44,6 +44,9 @@ · 43 unmodified lines
4444
4545 #include <asm/uaccess.h>
4646
47+#define CREATE_TRACE_POINTS
48+#include <trace/events/printk.h>
49+
4750 /*
4851 * Architectures can override it:
4952 */
@@ -542,6 +545,8 @@ MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to" · 492 unmodified lines
542545 static void _call_console_drivers(unsigned start,
543546 unsigned end, int msg_log_level)
544547 {
548+ trace_console(&LOG_BUF(0), start, end, log_buf_len);
549+
545550 if ((msg_log_level < console_loglevel || ignore_loglevel) &&
546551 console_drivers && start != end) {
547552 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
kernel/softirq.c+6−0
@@ -385,6 +385,12 @@ void raise_softirq(unsigned int nr) · 384 unmodified lines
385385 local_irq_restore(flags);
386386 }
387387
388+void __raise_softirq_irqoff(unsigned int nr)
389+{
390+ trace_softirq_raise(nr);
391+ or_softirq_pending(1UL << nr);
392+}
393+
388394 void open_softirq(int nr, void (*action)(struct softirq_action *))
389395 {
390396 softirq_vec[nr].action = action;
kernel/trace/ftrace.c+10−7
@@ -1129,7 +1129,7 @@ static struct ftrace_hash *alloc_ftrace_hash(int size_bits) · 1128 unmodified lines
11291129 return NULL;
11301130
11311131 size = 1 << size_bits;
1132− hash->buckets = kzalloc(sizeof(*hash->buckets) * size, GFP_KERNEL);
1132+ hash->buckets = kcalloc(size, sizeof(*hash->buckets), GFP_KERNEL);
11331133
11341134 if (!hash->buckets) {
11351135 kfree(hash);
@@ -3146,8 +3146,10 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len, · 2010 unmodified lines
31463146 mutex_lock(&ftrace_regex_lock);
31473147 if (reset)
31483148 ftrace_filter_reset(hash);
3149− if (buf)
3150− ftrace_match_records(hash, buf, len);
3149+ if (buf && !ftrace_match_records(hash, buf, len)) {
3150+ ret = -EINVAL;
3151+ goto out_regex_unlock;
3152+ }
31513153
31523154 mutex_lock(&ftrace_lock);
31533155 ret = ftrace_hash_move(ops, enable, orig_hash, hash);
@@ -3157,6 +3159,7 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len, · 3 unmodified lines
31573159
31583160 mutex_unlock(&ftrace_lock);
31593161
3162+ out_regex_unlock:
31603163 mutex_unlock(&ftrace_regex_lock);
31613164
31623165 free_ftrace_hash(hash);
@@ -3173,10 +3176,10 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len, · 10 unmodified lines
31733176 * Filters denote which functions should be enabled when tracing is enabled.
31743177 * If @buf is NULL and reset is set, all functions will be enabled for tracing.
31753178 */
3176−void ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
3179+int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
31773180 int len, int reset)
31783181 {
3179− ftrace_set_regex(ops, buf, len, reset, 1);
3182+ return ftrace_set_regex(ops, buf, len, reset, 1);
31803183 }
31813184 EXPORT_SYMBOL_GPL(ftrace_set_filter);
31823185
@@ -3191,10 +3194,10 @@ EXPORT_SYMBOL_GPL(ftrace_set_filter); · 8 unmodified lines
31913194 * is enabled. If @buf is NULL and reset is set, all functions will be enabled
31923195 * for tracing.
31933196 */
3194−void ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
3197+int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
31953198 int len, int reset)
31963199 {
3197− ftrace_set_regex(ops, buf, len, reset, 0);
3200+ return ftrace_set_regex(ops, buf, len, reset, 0);
31983201 }
31993202 EXPORT_SYMBOL_GPL(ftrace_set_notrace);
32003203 /**
kernel/trace/trace.c+3−3
@@ -2764,12 +2764,12 @@ static const char readme_msg[] = · 2763 unmodified lines
27642764 "tracing mini-HOWTO:\n\n"
27652765 "# mount -t debugfs nodev /sys/kernel/debug\n\n"
27662766 "# cat /sys/kernel/debug/tracing/available_tracers\n"
2767− "wakeup preemptirqsoff preemptoff irqsoff function sched_switch nop\n\n"
2767+ "wakeup wakeup_rt preemptirqsoff preemptoff irqsoff function nop\n\n"
27682768 "# cat /sys/kernel/debug/tracing/current_tracer\n"
27692769 "nop\n"
2770− "# echo sched_switch > /sys/kernel/debug/tracing/current_tracer\n"
2770+ "# echo wakeup > /sys/kernel/debug/tracing/current_tracer\n"
27712771 "# cat /sys/kernel/debug/tracing/current_tracer\n"
2772− "sched_switch\n"
2772+ "wakeup\n"
27732773 "# cat /sys/kernel/debug/tracing/trace_options\n"
27742774 "noprint-parent nosym-offset nosym-addr noverbose\n"
27752775 "# echo print-parent > /sys/kernel/debug/tracing/trace_options\n"
kernel/trace/trace_events_filter.c+3−4
@@ -685,7 +685,7 @@ find_event_field(struct ftrace_event_call *call, char *name) · 684 unmodified lines
685685
686686 static int __alloc_pred_stack(struct pred_stack *stack, int n_preds)
687687 {
688− stack->preds = kzalloc(sizeof(*stack->preds)*(n_preds + 1), GFP_KERNEL);
688+ stack->preds = kcalloc(n_preds + 1, sizeof(*stack->preds), GFP_KERNEL);
689689 if (!stack->preds)
690690 return -ENOMEM;
691691 stack->index = n_preds;
@@ -826,8 +826,7 @@ static int __alloc_preds(struct event_filter *filter, int n_preds) · 134 unmodified lines
826826 if (filter->preds)
827827 __free_preds(filter);
828828
829− filter->preds =
830− kzalloc(sizeof(*filter->preds) * n_preds, GFP_KERNEL);
829+ filter->preds = kcalloc(n_preds, sizeof(*filter->preds), GFP_KERNEL);
831830
832831 if (!filter->preds)
833832 return -ENOMEM;
@@ -1486,7 +1485,7 @@ static int fold_pred(struct filter_pred *preds, struct filter_pred *root) · 652 unmodified lines
14861485 children = count_leafs(preds, &preds[root->left]);
14871486 children += count_leafs(preds, &preds[root->right]);
14881487
1489− root->ops = kzalloc(sizeof(*root->ops) * children, GFP_KERNEL);
1488+ root->ops = kcalloc(children, sizeof(*root->ops), GFP_KERNEL);
14901489 if (!root->ops)
14911490 return -ENOMEM;
14921491
kernel/trace/trace_syscalls.c+2−2
@@ -468,8 +468,8 @@ int __init init_ftrace_syscalls(void) · 467 unmodified lines
468468 unsigned long addr;
469469 int i;
470470
471− syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
472− NR_syscalls, GFP_KERNEL);
471+ syscalls_metadata = kcalloc(NR_syscalls, sizeof(*syscalls_metadata),
472+ GFP_KERNEL);
473473 if (!syscalls_metadata) {
474474 WARN_ON(1);
475475 return -ENOMEM;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t