All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Hideo AOKI <haoki@redhat.com>, Takahiro Yasui <tyasui@redhat.com>
Subject: [PATCH -mm] markers: avoid call_rcu_sched if old is NULL
Date: Tue, 08 Jul 2008 16:28:53 -0400	[thread overview]
Message-ID: <4873CE05.2030001@redhat.com> (raw)

Introduce marker_entry_free_old() and check old pointer is NULL before
setting call_rcu_sched(), because marker_entry_remove/add_probe() can
return NULL.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
---
 kernel/marker.c |   29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

Mathieu, I think this might be a bug. Tracepoint also has
same bug...

Index: 2.6.26-rc8-mm1/kernel/marker.c
===================================================================
--- 2.6.26-rc8-mm1.orig/kernel/marker.c	2008-07-07 11:42:04.000000000 -0400
+++ 2.6.26-rc8-mm1/kernel/marker.c	2008-07-07 11:42:04.000000000 -0400
@@ -201,6 +201,17 @@ static void free_old_closure(struct rcu_
 	entry->rcu_pending = 0;
 }

+static void marker_entry_free_old(struct marker_entry *entry, void *old)
+{
+	if (!old)
+		return;
+	entry->oldptr = old;
+	entry->rcu_pending = 1;
+	/* write rcu_pending before calling the RCU callback */
+	smp_wmb();
+	call_rcu_sched(&entry->rcu, free_old_closure);
+}
+
 static void debug_print_probes(struct marker_entry *entry)
 {
 	int i;
@@ -666,11 +677,7 @@ int marker_probe_register(const char *na
 	mutex_lock(&markers_mutex);
 	entry = get_marker(name);
 	WARN_ON(!entry);
-	entry->oldptr = old;
-	entry->rcu_pending = 1;
-	/* write rcu_pending before calling the RCU callback */
-	smp_wmb();
-	call_rcu_sched(&entry->rcu, free_old_closure);
+	marker_entry_free_old(entry, old);
 end:
 	mutex_unlock(&markers_mutex);
 	return ret;
@@ -709,11 +716,7 @@ int marker_probe_unregister(const char *
 	entry = get_marker(name);
 	if (!entry)
 		goto end;
-	entry->oldptr = old;
-	entry->rcu_pending = 1;
-	/* write rcu_pending before calling the RCU callback */
-	smp_wmb();
-	call_rcu_sched(&entry->rcu, free_old_closure);
+	marker_entry_free_old(entry, old);
 	remove_marker(name);	/* Ignore busy error message */
 	ret = 0;
 end:
@@ -787,11 +790,7 @@ int marker_probe_unregister_private_data
 	mutex_lock(&markers_mutex);
 	entry = get_marker_from_private_data(probe, probe_private);
 	WARN_ON(!entry);
-	entry->oldptr = old;
-	entry->rcu_pending = 1;
-	/* write rcu_pending before calling the RCU callback */
-	smp_wmb();
-	call_rcu_sched(&entry->rcu, free_old_closure);
+	marker_entry_free_old(entry, old);
 	remove_marker(entry->name);	/* Ignore busy error message */
 end:
 	mutex_unlock(&markers_mutex);
-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


             reply	other threads:[~2008-07-08 20:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-08 20:28 Masami Hiramatsu [this message]
2008-07-09  3:02 ` [PATCH -mm] markers: avoid call_rcu_sched if old is NULL Mathieu Desnoyers
2008-07-09  4:25   ` Mathieu Desnoyers
2008-07-11 19:18   ` Andrew Morton
2008-07-13  4:28     ` Mathieu Desnoyers

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=4873CE05.2030001@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=haoki@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=tyasui@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.