public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: rostedt@goodmis.org, Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>,
	systemtap <systemtap@sources.redhat.com>,
	DLE <dle-develop@lists.sourceforge.net>,
	Jim Keniston <jkenisto@us.ibm.com>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Andi Kleen <ak@linux.intel.com>,
	Christoph Hellwig <hch@infradead.org>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Jason Baron <jbaron@redhat.com>,
	"K.Prasad" <prasad@linux.vnet.ibm.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	Li Zefan <lizf@cn.fujitsu.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Tom Zanussi <tzanussi@gmail.com>
Subject: [PATCH tracing/kprobes 2/6] ftrace: Fix trace_add_event_call() to initialize list take 2
Date: Wed, 16 Sep 2009 11:42:55 -0400	[thread overview]
Message-ID: <4AB1077F.6020107@redhat.com> (raw)
In-Reply-To: <1253111371.20020.198.camel@gandalf.stny.rr.com>

Steven Rostedt wrote:
> On Wed, 2009-09-16 at 10:17 -0400, Masami Hiramatsu wrote:
>> Steven Rostedt wrote:
> 
>>>> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
>>>> index ba34920..38e82a5 100644
>>>> --- a/kernel/trace/trace_events.c
>>>> +++ b/kernel/trace/trace_events.c
>>>> @@ -1009,10 +1009,14 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
>>>>   	if (!d_events)
>>>>   		return -ENOENT;
>>>>
>>>> +	INIT_LIST_HEAD(&call->list);
>>>
>>> The INIT_LIST_HEAD is not needed here. The list_add will assign it.
>>
>> Without initializing it, list debugging code warns always :-)
>> Please see, __list_add()@lib/list_debug.c
> 
> /me looks
> 
> from: include/linux/list.h
> 
> static inline void list_add(struct list_head *new, struct list_head *head)
> {
> 	__list_add(new, head, head->next);
> }
> 
> from: lib/list_debug.c
> 
> void __list_add(struct list_head *new,
> 			      struct list_head *prev,
> 			      struct list_head *next)
> {
> 	WARN(next->prev != prev,
> 		"list_add corruption. next->prev should be "
> 		"prev (%p), but was %p. (next=%p).\n",
> 		prev, next->prev, next);
> 	WARN(prev->next != next,
> 		"list_add corruption. prev->next should be "
> 		"next (%p), but was %p. (prev=%p).\n",
> 		next, prev->next, prev);
> 	next->prev = new;
> 	new->next = next;
> 	new->prev = prev;
> 	prev->next = new;
> }
> 
> What you pass in is:
> 
>          list_add(&call->list,&ftrace_events);
> 
> new =&call->list;
> prev =&ftrace_events->prev;
> next =&ftrace_events->next;
> 
> The above code never tests "new". The INIT_LIST_HEAD is useless.

Oh, I see, I misunderstood. Thank you for pointing it out. :)
Here, I updated the patch.

---
ftrace: Fix trace_add_event_call() to initialize list

From: Masami Hiramatsu <mhiramat@redhat.com>

Handle failuer path in trace_add_event_call() for fixing below bug
which occurred when I tried to add invalid event twice.

Could not create debugfs 'kmalloc' directory
Failed to register kprobe event: kmalloc
Faild to register probe event(-1)
------------[ cut here ]------------
WARNING: at /home/mhiramat/ksrc/random-tracing/lib/list_debug.c:26
__list_add+0x27/0x5c()
Hardware name:
list_add corruption. next->prev should be prev (c07d78cc), but was
00001000. (next=d854236c).
Modules linked in: sunrpc uinput virtio_net virtio_balloon i2c_piix4 pcspkr
i2c_core virtio_blk virtio_pci virtio_ring virtio [last unloaded:
scsi_wait_scan]
Pid: 1394, comm: tee Not tainted 2.6.31-rc9 #51
Call Trace:
 [<c0438424>] warn_slowpath_common+0x65/0x7c
 [<c05371b3>] ? __list_add+0x27/0x5c
 [<c043846f>] warn_slowpath_fmt+0x24/0x27
 [<c05371b3>] __list_add+0x27/0x5c
 [<c047f050>] list_add+0xa/0xc
 [<c047f8f5>] trace_add_event_call+0x60/0x97
 [<c0483133>] command_trace_probe+0x42c/0x51b
 [<c044a1b3>] ? remove_wait_queue+0x22/0x27
 [<c042a9c0>] ? __wake_up+0x32/0x3b
 [<c04832f6>] probes_write+0xd4/0x10a
 [<c0483222>] ? probes_write+0x0/0x10a
 [<c04b27a9>] vfs_write+0x80/0xdf
 [<c04b289c>] sys_write+0x3b/0x5d
 [<c0670d41>] syscall_call+0x7/0xb
---[ end trace 2b962b5dc1fdc07d ]---

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
---

 kernel/trace/trace_events.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index ba34920..83cc2c0 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1010,9 +1010,12 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
 		return -ENOENT;

 	list_add(&call->list, &ftrace_events);
-	return event_create_dir(call, d_events, &ftrace_event_id_fops,
+	ret = event_create_dir(call, d_events, &ftrace_event_id_fops,
 				&ftrace_enable_fops, &ftrace_event_filter_fops,
 				&ftrace_event_format_fops);
+	if (ret < 0)
+		list_del(&call->list);
+	return ret;
 }

 /* Add an additional event_call dynamically */


-- 
Masami Hiramatsu

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

e-mail: mhiramat@redhat.com


  reply	other threads:[~2009-09-16 15:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-14 20:48 [PATCH tracing/kprobes 0/6] tracing/kprobes: kprobe-based event tracer update and perf support Masami Hiramatsu
2009-09-14 20:48 ` [PATCH tracing/kprobes 1/6] tracing/kprobes: Fix trace_probe registration order Masami Hiramatsu
2009-10-17 10:00   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 2/6] ftrace: Fix trace_add_event_call() to initialize list Masami Hiramatsu
2009-09-15 23:51   ` Steven Rostedt
2009-09-16 14:17     ` Masami Hiramatsu
2009-09-16 14:29       ` Steven Rostedt
2009-09-16 15:42         ` Masami Hiramatsu [this message]
2009-09-16 15:43           ` [PATCH tracing/kprobes 2/6] ftrace: Fix trace_add_event_call() to initialize list take 2 Steven Rostedt
2009-10-17 10:01           ` [tip:perf/probes] ftrace: Fix trace_add_event_call() to initialize list tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 3/6] ftrace: Fix trace_remove_event_call() to lock trace_event_mutex Masami Hiramatsu
2009-09-16  3:17   ` Steven Rostedt
2009-09-16  4:05     ` Frederic Weisbecker
2009-09-16  4:54       ` Ananth N Mavinakayanahalli
2009-09-16  5:33         ` Frederic Weisbecker
2009-09-16 14:31     ` Masami Hiramatsu
2009-10-17 10:01   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 4/6] tracing/kprobes: Add probe handler dispatcher for support perf and ftrace Masami Hiramatsu
2009-10-17 10:01   ` [tip:perf/probes] tracing/kprobes: Add probe handler dispatcher to support perf and ftrace concurrent use tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 5/6] tracing/kprobes: Fix profiling alignment for perf_counter buffer Masami Hiramatsu
2009-10-17 10:01   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 6/6] tracing/kprobes: Disable kprobe events by default Masami Hiramatsu
2009-10-17 10:01   ` [tip:perf/probes] tracing/kprobes: Disable kprobe events by default after creation tip-bot for Masami Hiramatsu
2009-09-17  2:39 ` [PATCH tracing/kprobes 0/6] tracing/kprobes: kprobe-based event tracer update and perf support Frederic Weisbecker
2009-09-17 17:32   ` Masami Hiramatsu

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=4AB1077F.6020107@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=ananth@in.ibm.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jbaron@redhat.com \
    --cc=jkenisto@us.ibm.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=systemtap@sources.redhat.com \
    --cc=tzanussi@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox