public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lktdm: Bring support for hardlockup, softlockup and hung task crashes
@ 2010-05-16  5:39 Frederic Weisbecker
  2010-05-16  9:36 ` Cyrill Gorcunov
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Weisbecker @ 2010-05-16  5:39 UTC (permalink / raw)
  To: Andrew Morton
  Cc: LKML, Frederic Weisbecker, Simon Kagstrom, Ingo Molnar,
	Andrew Morton, Don Zickus, Cyrill Gorcunov

This adds three new types of kernel "crashes" in the lkdtm
driver to trigger hardlockups, softlockups and task hung
states at will.

The two formers are useful to test the new generic lockup
detector and check its further regressions. The latter one
is a bonus to check the hung task detector regressions even
though it's not currently in rework.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Simon Kagstrom <simon.kagstrom@netinsight.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
---
 drivers/misc/lkdtm.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 31a9911..5bfb2a2 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -75,6 +75,9 @@ enum ctype {
 	UNALIGNED_LOAD_STORE_WRITE,
 	OVERWRITE_ALLOCATION,
 	WRITE_AFTER_FREE,
+	SOFTLOCKUP,
+	HARDLOCKUP,
+	HUNG_TASK,
 };
 
 static char* cp_name[] = {
@@ -99,6 +102,9 @@ static char* cp_type[] = {
 	"UNALIGNED_LOAD_STORE_WRITE",
 	"OVERWRITE_ALLOCATION",
 	"WRITE_AFTER_FREE",
+	"SOFTLOCKUP",
+	"HARDLOCKUP",
+	"HUNG_TASK",
 };
 
 static struct jprobe lkdtm;
@@ -320,6 +326,20 @@ static void lkdtm_do_action(enum ctype which)
 		memset(data, 0x78, len);
 		break;
 	}
+	case SOFTLOCKUP:
+		preempt_disable();
+		for (;;)
+			cpu_relax();
+		break;
+	case HARDLOCKUP:
+		local_irq_disable();
+		for (;;)
+			cpu_relax();
+		break;
+	case HUNG_TASK:
+		set_current_state(TASK_UNINTERRUPTIBLE);
+		schedule();
+		break;
 	case NONE:
 	default:
 		break;
-- 
1.6.2.3


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

* Re: [PATCH] lktdm: Bring support for hardlockup, softlockup and hung task crashes
  2010-05-16  5:39 [PATCH] lktdm: Bring support for hardlockup, softlockup and hung task crashes Frederic Weisbecker
@ 2010-05-16  9:36 ` Cyrill Gorcunov
  2010-05-16 10:35   ` Frederic Weisbecker
  0 siblings, 1 reply; 4+ messages in thread
From: Cyrill Gorcunov @ 2010-05-16  9:36 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Andrew Morton, LKML, Simon Kagstrom, Ingo Molnar, Don Zickus

On Sun, May 16, 2010 at 07:39:51AM +0200, Frederic Weisbecker wrote:
...  
>  static struct jprobe lkdtm;
> @@ -320,6 +326,20 @@ static void lkdtm_do_action(enum ctype which)
>  		memset(data, 0x78, len);
>  		break;
>  	}
> +	case SOFTLOCKUP:
> +		preempt_disable();
> +		for (;;)
> +			cpu_relax();
> +		break;
> +	case HARDLOCKUP:
> +		local_irq_disable();
> +		for (;;)
> +			cpu_relax();
> +		break;
> +	case HUNG_TASK:
> +		set_current_state(TASK_UNINTERRUPTIBLE);
> +		schedule();
> +		break;
>  	case NONE:
>  	default:
>  		break;

Looks good to me. Btw perhaps we may simplify it a bit:

	case HARDLOCKUP:
		local_irq_disable();
	case SOFTLOCKUP:
		preempt_disable();
		for (;;)
			cpu_relax();
		break;

since it'll save a few bytes. What do you think? Did I miss
something?

	-- Cyrill

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

* Re: [PATCH] lktdm: Bring support for hardlockup, softlockup and hung task crashes
  2010-05-16  9:36 ` Cyrill Gorcunov
@ 2010-05-16 10:35   ` Frederic Weisbecker
  2010-05-16 10:46     ` Cyrill Gorcunov
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Weisbecker @ 2010-05-16 10:35 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Andrew Morton, LKML, Simon Kagstrom, Ingo Molnar, Don Zickus

On Sun, May 16, 2010 at 01:36:36PM +0400, Cyrill Gorcunov wrote:
> On Sun, May 16, 2010 at 07:39:51AM +0200, Frederic Weisbecker wrote:
> ...  
> >  static struct jprobe lkdtm;
> > @@ -320,6 +326,20 @@ static void lkdtm_do_action(enum ctype which)
> >  		memset(data, 0x78, len);
> >  		break;
> >  	}
> > +	case SOFTLOCKUP:
> > +		preempt_disable();
> > +		for (;;)
> > +			cpu_relax();
> > +		break;
> > +	case HARDLOCKUP:
> > +		local_irq_disable();
> > +		for (;;)
> > +			cpu_relax();
> > +		break;
> > +	case HUNG_TASK:
> > +		set_current_state(TASK_UNINTERRUPTIBLE);
> > +		schedule();
> > +		break;
> >  	case NONE:
> >  	default:
> >  		break;
> 
> Looks good to me. Btw perhaps we may simplify it a bit:
> 
> 	case HARDLOCKUP:
> 		local_irq_disable();
> 	case SOFTLOCKUP:
> 		preempt_disable();
> 		for (;;)
> 			cpu_relax();
> 		break;
> 
> since it'll save a few bytes. What do you think? Did I miss
> something?


It would make the code a bit less clear in that people
might stick on the reason to disable preemption after disabling
irq, especially with a code that already does something rather
unusual ;)


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

* Re: [PATCH] lktdm: Bring support for hardlockup, softlockup and hung task crashes
  2010-05-16 10:35   ` Frederic Weisbecker
@ 2010-05-16 10:46     ` Cyrill Gorcunov
  0 siblings, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2010-05-16 10:46 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Andrew Morton, LKML, Simon Kagstrom, Ingo Molnar, Don Zickus

On Sun, May 16, 2010 at 12:35:08PM +0200, Frederic Weisbecker wrote:
...
> > Looks good to me. Btw perhaps we may simplify it a bit:
> > 
> > 	case HARDLOCKUP:
> > 		local_irq_disable();
> > 	case SOFTLOCKUP:
> > 		preempt_disable();
> > 		for (;;)
> > 			cpu_relax();
> > 		break;
> > 
> > since it'll save a few bytes. What do you think? Did I miss
> > something?
> 
> 
> It would make the code a bit less clear in that people
> might stick on the reason to disable preemption after disabling
> irq, especially with a code that already does something rather
> unusual ;)
> 

ok, convinced

	-- Cyrill

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

end of thread, other threads:[~2010-05-16 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-16  5:39 [PATCH] lktdm: Bring support for hardlockup, softlockup and hung task crashes Frederic Weisbecker
2010-05-16  9:36 ` Cyrill Gorcunov
2010-05-16 10:35   ` Frederic Weisbecker
2010-05-16 10:46     ` Cyrill Gorcunov

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