Skip to contentSkip to conversation

lktdm: Bring support for hardlockup, softlockup and hung task crashes

PATCH In review Frederic Weisbecker 2 participants 4 messages May 16, 2010 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lktdm: Bring support for hardlockup, softlockup and hung task crashes

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.

Cc Simon Kagstrom <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Don Zickus <[email protected]>
Cc Cyrill Gorcunov <[email protected]>
---
 drivers/misc/lkdtm.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/misc/lkdtm.c +20 -0
index 31a9911..5bfb2a2 100644
@@ -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;
Signature · 1 line
1.6.2.3
#1 lore raw

On Sun, May 16, 2010 at 07:39:51AM +0200, Frederic Weisbecker wrote:
...

Quoted 12 lines

static struct jprobe lkdtm;

drivers/misc/lkdtm.c +7 -0
@@ -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();

drivers/misc/lkdtm.c static void lkdtm_do_action(enum ctype which) · line 345

Quoted 10 lines
drivers/misc/lkdtm.c +7 -0
+		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

#2 lore raw
Quoted 35 lines · Cyrill Gorcunov

On Sun, May 16, 2010 at 07:39:51AM +0200, Frederic Weisbecker wrote:
...

Quoted 12 lines

static struct jprobe lkdtm;

drivers/misc/lkdtm.c +7 -0
@@ -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();

drivers/misc/lkdtm.c static void lkdtm_do_action(enum ctype which) · line 345

Quoted 10 lines
drivers/misc/lkdtm.c +7 -0
+		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;
Quoted 2 lines

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 ;)

#3 lore raw

On Sun, May 16, 2010 at 12:35:08PM +0200, Frederic Weisbecker wrote:
...

Quoted 10 lines
Quoted 10 lines

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;
Quoted 9 lines
Quoted 2 lines

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