diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-06-17 13:02:11 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-07-18 21:31:28 -0400 |
commit | cd92bf61d6d70bd3eb33b46d600e3f3eb9c5778a (patch) | |
tree | 7f02ec47e54b3fa2a139a21bbcfed90318de79d3 | |
parent | 421c7860c6e1989da3962fafdd6699316c9f8e20 (diff) |
tracing/perf: Move the PERF_MAX_TRACE_SIZE check into perf_trace_buf_prepare()
Every perf_trace_buf_prepare() caller does
WARN_ONCE(size > PERF_MAX_TRACE_SIZE, message) and "message" is
almost the same.
Shift this WARN_ONCE() into perf_trace_buf_prepare(). This changes
the meaning of _ONCE, but I think this is fine.
- 4947014 2932448 10104832 17984294 1126b26 vmlinux
+ 4948422 2932448 10104832 17985702 11270a6 vmlinux
on my build.
Link: http://lkml.kernel.org/r/20130617170211.GA19813@redhat.com
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | include/trace/ftrace.h | 4 | ||||
-rw-r--r-- | kernel/trace/trace_event_perf.c | 4 | ||||
-rw-r--r-- | kernel/trace/trace_kprobe.c | 6 | ||||
-rw-r--r-- | kernel/trace/trace_syscalls.c | 12 | ||||
-rw-r--r-- | kernel/trace/trace_uprobe.c | 2 |
5 files changed, 4 insertions, 24 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index d615f78cc6b6..41a6643e2136 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -670,10 +670,6 @@ perf_trace_##call(void *__data, proto) \ | |||
670 | sizeof(u64)); \ | 670 | sizeof(u64)); \ |
671 | __entry_size -= sizeof(u32); \ | 671 | __entry_size -= sizeof(u32); \ |
672 | \ | 672 | \ |
673 | if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE, \ | ||
674 | "profile buffer not large enough")) \ | ||
675 | return; \ | ||
676 | \ | ||
677 | entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \ | 673 | entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare( \ |
678 | __entry_size, event_call->event.type, &__regs, &rctx); \ | 674 | __entry_size, event_call->event.type, &__regs, &rctx); \ |
679 | if (!entry) \ | 675 | if (!entry) \ |
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c index 12df5573086e..80c36bcf66e8 100644 --- a/kernel/trace/trace_event_perf.c +++ b/kernel/trace/trace_event_perf.c | |||
@@ -236,6 +236,10 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type, | |||
236 | 236 | ||
237 | BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long)); | 237 | BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long)); |
238 | 238 | ||
239 | if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, | ||
240 | "perf buffer not large enough")) | ||
241 | return NULL; | ||
242 | |||
239 | pc = preempt_count(); | 243 | pc = preempt_count(); |
240 | 244 | ||
241 | *rctxp = perf_swevent_get_recursion_context(); | 245 | *rctxp = perf_swevent_get_recursion_context(); |
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 7ed6976493c8..ae6ce835b023 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -1087,9 +1087,6 @@ kprobe_perf_func(struct trace_probe *tp, struct pt_regs *regs) | |||
1087 | __size = sizeof(*entry) + tp->size + dsize; | 1087 | __size = sizeof(*entry) + tp->size + dsize; |
1088 | size = ALIGN(__size + sizeof(u32), sizeof(u64)); | 1088 | size = ALIGN(__size + sizeof(u32), sizeof(u64)); |
1089 | size -= sizeof(u32); | 1089 | size -= sizeof(u32); |
1090 | if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, | ||
1091 | "profile buffer not large enough")) | ||
1092 | return; | ||
1093 | 1090 | ||
1094 | entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); | 1091 | entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); |
1095 | if (!entry) | 1092 | if (!entry) |
@@ -1120,9 +1117,6 @@ kretprobe_perf_func(struct trace_probe *tp, struct kretprobe_instance *ri, | |||
1120 | __size = sizeof(*entry) + tp->size + dsize; | 1117 | __size = sizeof(*entry) + tp->size + dsize; |
1121 | size = ALIGN(__size + sizeof(u32), sizeof(u64)); | 1118 | size = ALIGN(__size + sizeof(u32), sizeof(u64)); |
1122 | size -= sizeof(u32); | 1119 | size -= sizeof(u32); |
1123 | if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, | ||
1124 | "profile buffer not large enough")) | ||
1125 | return; | ||
1126 | 1120 | ||
1127 | entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); | 1121 | entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); |
1128 | if (!entry) | 1122 | if (!entry) |
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index ac0085777fbd..8fd03657bc7d 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c | |||
@@ -575,10 +575,6 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id) | |||
575 | size = ALIGN(size + sizeof(u32), sizeof(u64)); | 575 | size = ALIGN(size + sizeof(u32), sizeof(u64)); |
576 | size -= sizeof(u32); | 576 | size -= sizeof(u32); |
577 | 577 | ||
578 | if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, | ||
579 | "perf buffer not large enough")) | ||
580 | return; | ||
581 | |||
582 | rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size, | 578 | rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size, |
583 | sys_data->enter_event->event.type, regs, &rctx); | 579 | sys_data->enter_event->event.type, regs, &rctx); |
584 | if (!rec) | 580 | if (!rec) |
@@ -652,14 +648,6 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret) | |||
652 | size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64)); | 648 | size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64)); |
653 | size -= sizeof(u32); | 649 | size -= sizeof(u32); |
654 | 650 | ||
655 | /* | ||
656 | * Impossible, but be paranoid with the future | ||
657 | * How to put this check outside runtime? | ||
658 | */ | ||
659 | if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, | ||
660 | "exit event has grown above perf buffer size")) | ||
661 | return; | ||
662 | |||
663 | rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size, | 651 | rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size, |
664 | sys_data->exit_event->event.type, regs, &rctx); | 652 | sys_data->exit_event->event.type, regs, &rctx); |
665 | if (!rec) | 653 | if (!rec) |
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index d5d0cd368a56..a23d2d71188e 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c | |||
@@ -818,8 +818,6 @@ static void uprobe_perf_print(struct trace_uprobe *tu, | |||
818 | 818 | ||
819 | size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu)); | 819 | size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu)); |
820 | size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32); | 820 | size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32); |
821 | if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough")) | ||
822 | return; | ||
823 | 821 | ||
824 | preempt_disable(); | 822 | preempt_disable(); |
825 | head = this_cpu_ptr(call->perf_events); | 823 | head = this_cpu_ptr(call->perf_events); |