public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH for tip][bugfix] ftrace: fix deadlock when setting set_ftrace_pid
@ 2009-03-06  6:29 KOSAKI Motohiro
  2009-03-06  6:57 ` Lai Jiangshan
  2009-03-06 11:09 ` [tip:tracing/ftrace] tracing: " KOSAKI Motohiro
  0 siblings, 2 replies; 4+ messages in thread
From: KOSAKI Motohiro @ 2009-03-06  6:29 UTC (permalink / raw)
  To: LKML, Steven Rostedt, Ingo Molnar; +Cc: kosaki.motohiro


Impact: fix deadlock bug

reproduce way:
	# cd /sys/kernel/debug/tracing
	# echo $$ > set_ftrace_pid

	then, console become hangup.

detail:
when writing set_ftracepid, kernel callstack is following

	ftrace_pid_write()
		mutex_lock(&ftrace_lock);
		ftrace_update_pid_func()
			mutex_lock(&ftrace_lock);
			mutex_unlock(&ftrace_lock);
		mutex_unlock(&ftrace_lock);

then, system alaways deadlock when ftrace_pid_write() is called.

In past days, ftrace_pid_write() use ftrace_start_lock, but
commit e6ea44e9b4c12325337cd1c06103cd515a1c02b2 consolidate
ftrace_start_lock to ftrace_lock.


Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 5a3a06b..0d3b393 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -218,10 +218,8 @@ static void ftrace_update_pid_func(void)
 {
 	ftrace_func_t func;
 
-	mutex_lock(&ftrace_lock);
-
 	if (ftrace_trace_function == ftrace_stub)
-		goto out;
+		return;
 
 	func = ftrace_trace_function;
 
@@ -238,9 +236,6 @@ static void ftrace_update_pid_func(void)
 #else
 	__ftrace_trace_function = func;
 #endif
-
- out:
-	mutex_unlock(&ftrace_lock);
 }
 
 /* set when tracing only a pid */



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH for tip][bugfix] ftrace: fix deadlock when setting set_ftrace_pid
  2009-03-06  6:29 [PATCH for tip][bugfix] ftrace: fix deadlock when setting set_ftrace_pid KOSAKI Motohiro
@ 2009-03-06  6:57 ` Lai Jiangshan
  2009-03-06 11:08   ` Ingo Molnar
  2009-03-06 11:09 ` [tip:tracing/ftrace] tracing: " KOSAKI Motohiro
  1 sibling, 1 reply; 4+ messages in thread
From: Lai Jiangshan @ 2009-03-06  6:57 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, Steven Rostedt, Ingo Molnar

KOSAKI Motohiro wrote:
> Impact: fix deadlock bug
> 
> reproduce way:
> 	# cd /sys/kernel/debug/tracing
> 	# echo $$ > set_ftrace_pid
> 
> 	then, console become hangup.
> 
> detail:
> when writing set_ftracepid, kernel callstack is following
> 
> 	ftrace_pid_write()
> 		mutex_lock(&ftrace_lock);
> 		ftrace_update_pid_func()
> 			mutex_lock(&ftrace_lock);
> 			mutex_unlock(&ftrace_lock);
> 		mutex_unlock(&ftrace_lock);
> 
> then, system alaways deadlock when ftrace_pid_write() is called.
> 
> In past days, ftrace_pid_write() use ftrace_start_lock, but
> commit e6ea44e9b4c12325337cd1c06103cd515a1c02b2 consolidate
> ftrace_start_lock to ftrace_lock.
> 
> 
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 5a3a06b..0d3b393 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -218,10 +218,8 @@ static void ftrace_update_pid_func(void)
>  {
>  	ftrace_func_t func;
>  
> -	mutex_lock(&ftrace_lock);
> -
>  	if (ftrace_trace_function == ftrace_stub)
> -		goto out;
> +		return;
>  
>  	func = ftrace_trace_function;
>  
> @@ -238,9 +236,6 @@ static void ftrace_update_pid_func(void)
>  #else
>  	__ftrace_trace_function = func;
>  #endif
> -
> - out:
> -	mutex_unlock(&ftrace_lock);
>  }
>  
>  /* set when tracing only a pid */
> 
> 

Reviewed-By: Lai Jiangshan <laijs@cn.fujitsu.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH for tip][bugfix] ftrace: fix deadlock when setting set_ftrace_pid
  2009-03-06  6:57 ` Lai Jiangshan
@ 2009-03-06 11:08   ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2009-03-06 11:08 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: KOSAKI Motohiro, LKML, Steven Rostedt


* Lai Jiangshan <laijs@cn.fujitsu.com> wrote:

> KOSAKI Motohiro wrote:
> > Impact: fix deadlock bug
> > 
> > reproduce way:
> > 	# cd /sys/kernel/debug/tracing
> > 	# echo $$ > set_ftrace_pid
> > 
> > 	then, console become hangup.
> > 
> > detail:
> > when writing set_ftracepid, kernel callstack is following
> > 
> > 	ftrace_pid_write()
> > 		mutex_lock(&ftrace_lock);
> > 		ftrace_update_pid_func()
> > 			mutex_lock(&ftrace_lock);
> > 			mutex_unlock(&ftrace_lock);
> > 		mutex_unlock(&ftrace_lock);
> > 
> > then, system alaways deadlock when ftrace_pid_write() is called.
> > 
> > In past days, ftrace_pid_write() use ftrace_start_lock, but
> > commit e6ea44e9b4c12325337cd1c06103cd515a1c02b2 consolidate
> > ftrace_start_lock to ftrace_lock.
> > 
> > 
> > Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> > ---
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > index 5a3a06b..0d3b393 100644
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -218,10 +218,8 @@ static void ftrace_update_pid_func(void)
> >  {
> >  	ftrace_func_t func;
> >  
> > -	mutex_lock(&ftrace_lock);
> > -
> >  	if (ftrace_trace_function == ftrace_stub)
> > -		goto out;
> > +		return;
> >  
> >  	func = ftrace_trace_function;
> >  
> > @@ -238,9 +236,6 @@ static void ftrace_update_pid_func(void)
> >  #else
> >  	__ftrace_trace_function = func;
> >  #endif
> > -
> > - out:
> > -	mutex_unlock(&ftrace_lock);
> >  }
> >  
> >  /* set when tracing only a pid */
> > 
> > 
> 
> Reviewed-By: Lai Jiangshan <laijs@cn.fujitsu.com>

Applied, thanks!

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:tracing/ftrace] tracing: fix deadlock when setting set_ftrace_pid
  2009-03-06  6:29 [PATCH for tip][bugfix] ftrace: fix deadlock when setting set_ftrace_pid KOSAKI Motohiro
  2009-03-06  6:57 ` Lai Jiangshan
@ 2009-03-06 11:09 ` KOSAKI Motohiro
  1 sibling, 0 replies; 4+ messages in thread
From: KOSAKI Motohiro @ 2009-03-06 11:09 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, srostedt, tglx, laijs, kosaki.motohiro,
	mingo

Commit-ID:  10dd3ebe213c31bff14b4dae3c5d32a76b1fad7c
Gitweb:     http://git.kernel.org/tip/10dd3ebe213c31bff14b4dae3c5d32a76b1fad7c
Author:     "KOSAKI Motohiro" <kosaki.motohiro@jp.fujitsu.com>
AuthorDate: Fri, 6 Mar 2009 15:29:04 +0900
Commit:     Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 6 Mar 2009 12:07:38 +0100

tracing: fix deadlock when setting set_ftrace_pid

Impact: fix deadlock while using set_ftrace_pid

Reproducer:

	# cd /sys/kernel/debug/tracing
	# echo $$ > set_ftrace_pid

	then, console becomes hung.

Details:

when writing set_ftracepid, kernel callstack is following

	ftrace_pid_write()
		mutex_lock(&ftrace_lock);
		ftrace_update_pid_func()
			mutex_lock(&ftrace_lock);
			mutex_unlock(&ftrace_lock);
		mutex_unlock(&ftrace_lock);

then, system always deadlocks when ftrace_pid_write() is called.

In past days, ftrace_pid_write() used ftrace_start_lock, but
commit e6ea44e9b4c12325337cd1c06103cd515a1c02b2 consolidated
ftrace_start_lock to ftrace_lock.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Steven Rostedt <srostedt@redhat.com>
LKML-Reference: <20090306151155.0778.A69D9226@jp.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/trace/ftrace.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index d7a06a0..d33d306 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -218,10 +218,8 @@ static void ftrace_update_pid_func(void)
 {
 	ftrace_func_t func;
 
-	mutex_lock(&ftrace_lock);
-
 	if (ftrace_trace_function == ftrace_stub)
-		goto out;
+		return;
 
 	func = ftrace_trace_function;
 
@@ -238,9 +236,6 @@ static void ftrace_update_pid_func(void)
 #else
 	__ftrace_trace_function = func;
 #endif
-
- out:
-	mutex_unlock(&ftrace_lock);
 }
 
 /* set when tracing only a pid */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-06 11:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-06  6:29 [PATCH for tip][bugfix] ftrace: fix deadlock when setting set_ftrace_pid KOSAKI Motohiro
2009-03-06  6:57 ` Lai Jiangshan
2009-03-06 11:08   ` Ingo Molnar
2009-03-06 11:09 ` [tip:tracing/ftrace] tracing: " KOSAKI Motohiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox