public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 05/14] tracing/syscall: Avoid perf_trace_buf_*() if sys_data->perf_events is empty
Date: Mon, 22 Jul 2013 10:19:52 -0400	[thread overview]
Message-ID: <20130722142124.870071281@goodmis.org> (raw)
In-Reply-To: 20130722141947.972915744@goodmis.org

[-- Attachment #1: 0005-tracing-syscall-Avoid-perf_trace_buf_-if-sys_data-pe.patch --]
[-- Type: text/plain, Size: 2169 bytes --]

From: Oleg Nesterov <oleg@redhat.com>

perf_trace_buf_prepare() + perf_trace_buf_submit(head, task => NULL)
make no sense if hlist_empty(head). Change perf_syscall_enter/exit()
to check sys_data->{enter,exit}_event->perf_events beforehand.

Link: http://lkml.kernel.org/r/20130617170207.GA19806@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>
---
 kernel/trace/trace_syscalls.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 0611562..ac00857 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -566,6 +566,10 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 	if (!sys_data)
 		return;
 
+	head = this_cpu_ptr(sys_data->enter_event->perf_events);
+	if (hlist_empty(head))
+		return;
+
 	/* get the size after alignment with the u32 buffer size field */
 	size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec);
 	size = ALIGN(size + sizeof(u32), sizeof(u64));
@@ -583,8 +587,6 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 	rec->nr = syscall_nr;
 	syscall_get_arguments(current, regs, 0, sys_data->nb_args,
 			       (unsigned long *)&rec->args);
-
-	head = this_cpu_ptr(sys_data->enter_event->perf_events);
 	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
 }
 
@@ -642,6 +644,10 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 	if (!sys_data)
 		return;
 
+	head = this_cpu_ptr(sys_data->exit_event->perf_events);
+	if (hlist_empty(head))
+		return;
+
 	/* We can probably do that at build time */
 	size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
@@ -661,8 +667,6 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 
 	rec->nr = syscall_nr;
 	rec->ret = syscall_get_return_value(current, regs);
-
-	head = this_cpu_ptr(sys_data->exit_event->perf_events);
 	perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
 }
 
-- 
1.7.10.4



  parent reply	other threads:[~2013-07-22 14:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 14:19 [PATCH 00/14] [GIT PULL] tracing: fixes, clean ups and optimizations Steven Rostedt
2013-07-22 14:19 ` [PATCH 01/14] tracing: Use correct config guard CONFIG_STACK_TRACER Steven Rostedt
2013-07-22 14:19 ` [PATCH 02/14] tracing: Use trace_seq_puts()/trace_seq_putc() where possible Steven Rostedt
2013-07-22 14:19 ` [PATCH 03/14] tracing: Typo fix on ring buffer comments Steven Rostedt
2013-07-22 14:19 ` [PATCH 04/14] tracing/function: Avoid perf_trace_buf_*() if event_function.perf_events is empty Steven Rostedt
2013-07-22 14:19 ` Steven Rostedt [this message]
2013-07-22 14:19 ` [PATCH 06/14] tracing/perf: Move the PERF_MAX_TRACE_SIZE check into perf_trace_buf_prepare() Steven Rostedt
2013-07-22 14:19 ` [PATCH 07/14] tracing/kprobe: Wait for disabling all running kprobe handlers Steven Rostedt
2013-07-22 14:19 ` [PATCH 08/14] tracing: Fix error handling to ensure instances can always be removed Steven Rostedt
2013-07-22 14:19 ` [PATCH 09/14] tracing: Miscellaneous fixes for trace_array ref counting Steven Rostedt
2013-07-22 14:19 ` [PATCH 10/14] tracing: Add ref_data to function and fgraph tracer structs Steven Rostedt
2013-07-22 14:19 ` [PATCH 11/14] tracing: Simplify the iteration logic in f_start/f_next Steven Rostedt
2013-07-22 14:19 ` [PATCH 12/14] tracing: Do not (ab)use trace_seq in event_id_read() Steven Rostedt
2013-07-22 14:20 ` [PATCH 13/14] tracing: Kill trace_array->waiter Steven Rostedt
2013-07-22 14:20 ` [PATCH 14/14] tracing: Kill the unbalanced tr->ref++ in tracing_buffers_open() Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130722142124.870071281@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox