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>
Subject: [PATCH 07/14] tracing/kprobe: Wait for disabling all running kprobe handlers
Date: Mon, 22 Jul 2013 10:19:54 -0400	[thread overview]
Message-ID: <20130722142125.431384879@goodmis.org> (raw)
In-Reply-To: 20130722141947.972915744@goodmis.org

[-- Attachment #1: 0007-tracing-kprobe-Wait-for-disabling-all-running-kprobe.patch --]
[-- Type: text/plain, Size: 2211 bytes --]

From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Wait for disabling all running kprobe handlers when a kprobe
event is disabled, since the caller, trace_remove_event_call()
supposes that a removing event is disabled completely by
disabling the event.
With this change, ftrace can ensure that there is no running
event handlers after disabling it.

Link: http://lkml.kernel.org/r/20130709093526.20138.93100.stgit@mhiramat-M0-7522

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_kprobe.c |   23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index ae6ce83..3811487 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -243,11 +243,11 @@ find_event_file_link(struct trace_probe *tp, struct ftrace_event_file *file)
 static int
 disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
 {
+	struct event_file_link *link = NULL;
+	int wait = 0;
 	int ret = 0;
 
 	if (file) {
-		struct event_file_link *link;
-
 		link = find_event_file_link(tp, file);
 		if (!link) {
 			ret = -EINVAL;
@@ -255,10 +255,7 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
 		}
 
 		list_del_rcu(&link->list);
-		/* synchronize with kprobe_trace_func/kretprobe_trace_func */
-		synchronize_sched();
-		kfree(link);
-
+		wait = 1;
 		if (!list_empty(&tp->files))
 			goto out;
 
@@ -271,8 +268,22 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
 			disable_kretprobe(&tp->rp);
 		else
 			disable_kprobe(&tp->rp.kp);
+		wait = 1;
 	}
  out:
+	if (wait) {
+		/*
+		 * Synchronize with kprobe_trace_func/kretprobe_trace_func
+		 * to ensure disabled (all running handlers are finished).
+		 * This is not only for kfree(), but also the caller,
+		 * trace_remove_event_call() supposes it for releasing
+		 * event_call related objects, which will be accessed in
+		 * the kprobe_trace_func/kretprobe_trace_func.
+		 */
+		synchronize_sched();
+		kfree(link);	/* Ignored if link == NULL */
+	}
+
 	return ret;
 }
 
-- 
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 ` [PATCH 05/14] tracing/syscall: Avoid perf_trace_buf_*() if sys_data->perf_events " Steven Rostedt
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 ` Steven Rostedt [this message]
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=20130722142125.431384879@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=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