Skip to contentSkip to conversation

tracing/core: another fixes

PATCH In review Frederic Weisbecker 2 participants 4 messages May 27, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tracing/core: another fixes

Hi,

Here are two another fixes for ftrace, on top of tracing/core.

Thanks,
Frederic.

The following changes since commit c2adae0970ca1db8adb92fb56ae3bcabd916e8bd:
Steven Rostedt (1):
tracing: convert irq events to use __print_symbolic

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/core

Heiko Carstens (1):
trace: disable preemption before taking raw spinlocks

Zhaolei (1):
ftrace: don't convert function's local variable name in macro

 include/trace/ftrace.h |   20 ++++++++++----------
 kernel/trace/trace.c   |    2 ++
 2 files changed, 12 insertions(+), 10 deletions(-)
#1 lore raw

PATCH 1/2 trace: disable preemption before taking raw spinlocks

From: Heiko Carstens <[email protected]>

s390 code uses smp_processor_id() in __raw_spin_lock() code which reveals that a (raw) spinlock is taken without preemption disabled. This can potentially deadlock.

To fix this explicitly disable and enable preemption.

BUG: using smp_processor_id() in preemptible [00000000] code: cat/2278
caller is trace_find_cmdline+0x40/0xfc
CPU: 0 Not tainted 2.6.30-rc7-dirty #39
Process cat (pid: 2278, task: 000000003faedb68, ksp: 000000003b33b988)
000000003b33b988 000000003b33bae0 0000000000000002 0000000000000000
       000000003b33bb80 000000003b33baf8 000000003b33baf8 00000000000175d6
       0000000000000001 000000003b33b988 000000003f9b0000 000000000000000b
       000000000000000c 000000003b33bb40 000000003b33bae0 0000000000000000
       0000000000000000 00000000000175d6 000000003b33bae0 000000003b33bb28
Call Trace:
([<00000000000174b2>] show_trace+0x112/0x170)
 [<0000000000017582>] show_stack+0x72/0x100
 [<0000000000441538>] dump_stack+0xc8/0xd8
 [<000000000025c350>] debug_smp_processor_id+0x114/0x130
 [<00000000000bf0e4>] trace_find_cmdline+0x40/0xfc
 [<00000000000c35d4>] trace_print_context+0x58/0xac
 [<00000000000bb676>] print_trace_line+0x416/0x470
 [<00000000000bc8fe>] s_show+0x4e/0x428
 [<000000000013834e>] seq_read+0x36a/0x5d4
 [<0000000000112a78>] vfs_read+0xc8/0x174
 [<0000000000112c58>] SyS_read+0x74/0xc4
 [<000000000002c7ae>] sysc_noemu+0x10/0x16
 [<000002000012436c>] 0x2000012436c
1 lock held by cat/2278:
 #0:  (&p->lock){+.+.+.}, at: [<0000000000138056>] seq_read+0x72/0x5d4

[ Impact: fix preempt-unsafe raw spinlock ]

---
 kernel/trace/trace.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/trace/trace.c +2 -0
index 02d32ba..a3a8a87 100644
@@ -808,6 +808,7 @@ void trace_find_cmdline(int pid, char comm[])
 		return;
 	}
 
+	preempt_disable();
 	__raw_spin_lock(&trace_cmdline_lock);
 	map = map_pid_to_cmdline[pid];
 	if (map != NO_CMDLINE_MAP)
@@ -816,6 +817,7 @@ void trace_find_cmdline(int pid, char comm[])
 		strcpy(comm, "<...>");
 
 	__raw_spin_unlock(&trace_cmdline_lock);
+	preempt_enable();
 }
 
 void tracing_record_cmdline(struct task_struct *tsk)
Signature · 1 line
1.6.2.3
#2 lore raw

PATCH 2/2 ftrace: don't convert function's local variable name in macro

In reply to Frederic Weisbecker

From: Zhaolei <[email protected]>

"call" is an argument of macro, but it is also used as a local variable name of function in macro.
We should keep this local variable name distinct from any CPP macro parameter name if both are in the same macro scope, although it hasn't caused any problem yet.

[ Impact: robustify macro ]

---
 include/trace/ftrace.h |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
include/trace/ftrace.h +10 -10
index 87fc227..b4ec83a 100644
@@ -397,19 +397,19 @@ static void ftrace_profile_##call(proto)				\
 	perf_tpcounter_event(event_##call.id);				\
 }									\
 									\
-static int ftrace_profile_enable_##call(struct ftrace_event_call *call) \
+static int ftrace_profile_enable_##call(struct ftrace_event_call *event_call) \
 {									\
 	int ret = 0;							\
 									\
-	if (!atomic_inc_return(&call->profile_count))			\
+	if (!atomic_inc_return(&event_call->profile_count))		\
 		ret = register_trace_##call(ftrace_profile_##call);	\
 									\
 	return ret;							\
 }									\
 									\
-static void ftrace_profile_disable_##call(struct ftrace_event_call *call) \
+static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
 {									\
-	if (atomic_add_negative(-1, &call->profile_count))		\
+	if (atomic_add_negative(-1, &event_call->profile_count))	\
 		unregister_trace_##call(ftrace_profile_##call);		\
 }
 
@@ -433,9 +433,9 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *call) \
 #define __array(type, item, len)
 
 #undef __string
-#define __string(item, src)						       \
-	__str_offsets.item = __str_size +				       \
-			     offsetof(typeof(*entry), __str_data);	       \
+#define __string(item, src)						\
+	__str_offsets.item = __str_size +				\
+			     offsetof(typeof(*entry), __str_data);	\
 	__str_size += strlen(src) + 1;
 
 #undef __assign_str
@@ -451,8 +451,8 @@ static struct ftrace_event_call event_##call;				\
 									\
 static void ftrace_raw_event_##call(proto)				\
 {									\
-	struct ftrace_str_offsets_##call __maybe_unused __str_offsets;  \
-	struct ftrace_event_call *call = &event_##call;			\
+	struct ftrace_str_offsets_##call __maybe_unused __str_offsets;	\
+	struct ftrace_event_call *event_call = &event_##call;		\
 	struct ring_buffer_event *event;				\
 	struct ftrace_raw_##call *entry;				\
 	unsigned long irq_flags;					\
@@ -473,7 +473,7 @@ static void ftrace_raw_event_##call(proto)				\
 									\
 	assign;								\
 									\
-	if (!filter_current_check_discard(call, entry, event))		\
+	if (!filter_current_check_discard(event_call, entry, event))	\
 		trace_nowake_buffer_unlock_commit(event, irq_flags, pc); \
 }									\
 									\
Signature · 1 line
1.6.2.3
#3 lore raw
In reply to Frederic Weisbecker
Quoted 18 lines · Frederic Weisbecker

Hi,

Here are two another fixes for ftrace, on top of tracing/core.

Thanks,
Frederic.

The following changes since commit c2adae0970ca1db8adb92fb56ae3bcabd916e8bd:
Steven Rostedt (1):
tracing: convert irq events to use __print_symbolic

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git tracing/core

Heiko Carstens (1):
trace: disable preemption before taking raw spinlocks

Quoted 6 lines

Zhaolei (1):
ftrace: don't convert function's local variable name in macro

 include/trace/ftrace.h |   20 ++++++++++----------
 kernel/trace/trace.c   |    2 ++
 2 files changed, 12 insertions(+), 10 deletions(-)

Pulled, thanks Frederic!

Ingo