Skip to contentSkip to conversation

ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

PATCH New Santosh Shilimkar 2 participants 5 messages Mar 16, 2010 – Mar 20, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

This patch fixes the preempt leak in the cpuidle path invoked from cpu-hotplug
log:

BUG: scheduling while atomic: swapper/0/0x00000002
<d>Modules linked in:
Backtrace:
[<c0024f90>] (dump_backtrace+0x0/0x110) from [<c01762c4>] (dump_stack+0x18/0x1c)
 r7:c0218cc4 r6:c0341f00 r5:c7836000 r4:00000000
[<c01762ac>] (dump_stack+0x0/0x1c) from [<c003d94c>] (__schedule_bug+0x60/0x70)
[<c003d8ec>] (__schedule_bug+0x0/0x70) from [<c0176914>] (schedule+0x98/0x7b8)
 r5:c7836000 r4:c7836000
[<c017687c>] (schedule+0x0/0x7b8) from [<c00228c4>] (cpu_idle+0xb4/0xd4)
# [<c0022810>] (cpu_idle+0x0/0xd4) from [<c01744e8>] (secondary_start_kernel+0xe0/0xf0)
 r5:c7836000 r4:c020a220
[<c0174408>] (secondary_start_kernel+0x0/0xf0) from [<c0031150>] (set_cpu_power_state+0x40/0x44)
 r7:c0218cc4 r6:00000001 r5:00000001 r4:c7836000

Backtrace aborted due to bad frame pointer <c7837fbc>

Cc Catalin Marinas <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/kernel/smp.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/kernel/smp.c +1 -0
index 57162af..2a42d22 100644
@@ -226,6 +226,7 @@ void __ref cpu_die(void)
 	 * actual CPU shutdown procedure is at least platform (if not
 	 * CPU) specific
 	 */
+	preempt_enable_no_resched();
 	platform_cpu_die(cpu);
 
 	/*
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 1/1 ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

Quoted 16 lines · Santosh Shilimkar

This patch fixes the preempt leak in the cpuidle path invoked from cpu-hotplug
log:

BUG: scheduling while atomic: swapper/0/0x00000002
<d>Modules linked in:
Backtrace:
[<c0024f90>] (dump_backtrace+0x0/0x110) from [<c01762c4>] (dump_stack+0x18/0x1c)
 r7:c0218cc4 r6:c0341f00 r5:c7836000 r4:00000000
[<c01762ac>] (dump_stack+0x0/0x1c) from [<c003d94c>] (__schedule_bug+0x60/0x70)
[<c003d8ec>] (__schedule_bug+0x0/0x70) from [<c0176914>] (schedule+0x98/0x7b8)
 r5:c7836000 r4:c7836000
[<c017687c>] (schedule+0x0/0x7b8) from [<c00228c4>] (cpu_idle+0xb4/0xd4)
# [<c0022810>] (cpu_idle+0x0/0xd4) from [<c01744e8>] (secondary_start_kernel+0xe0/0xf0)
 r5:c7836000 r4:c020a220
[<c0174408>] (secondary_start_kernel+0x0/0xf0) from [<c0031150>] (set_cpu_power_state+0x40/0x44)
 r7:c0218cc4 r6:00000001 r5:00000001 r4:c7836000
Quoted 1 line

Backtrace aborted due to bad frame pointer <c7837fbc>

Can you describe the conditions which leads up to this please?

#2 lore raw

PATCH 1/1 ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

Quoted 26 lines

-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Wednesday, March 17, 2010 2:20 AM
To: Shilimkar, Santosh
Cc: linux-arm-kernel at lists.infradead.org; Catalin Marinas
Subject: Re: [PATCH] ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

Quoted 16 lines · Santosh Shilimkar

This patch fixes the preempt leak in the cpuidle path invoked from cpu-hotplug
log:

BUG: scheduling while atomic: swapper/0/0x00000002
<d>Modules linked in:
Backtrace:
[<c0024f90>] (dump_backtrace+0x0/0x110) from [<c01762c4>] (dump_stack+0x18/0x1c)
 r7:c0218cc4 r6:c0341f00 r5:c7836000 r4:00000000
[<c01762ac>] (dump_stack+0x0/0x1c) from [<c003d94c>] (__schedule_bug+0x60/0x70)
[<c003d8ec>] (__schedule_bug+0x0/0x70) from [<c0176914>] (schedule+0x98/0x7b8)
 r5:c7836000 r4:c7836000
[<c017687c>] (schedule+0x0/0x7b8) from [<c00228c4>] (cpu_idle+0xb4/0xd4)
# [<c0022810>] (cpu_idle+0x0/0xd4) from [<c01744e8>] (secondary_start_kernel+0xe0/0xf0)
 r5:c7836000 r4:c020a220
[<c0174408>] (secondary_start_kernel+0x0/0xf0) from [<c0031150>] (set_cpu_power_state+0x40/0x44)
 r7:c0218cc4 r6:00000001 r5:00000001 r4:c7836000
Quoted 1 line

Backtrace aborted due to bad frame pointer <c7837fbc>

Quoted 1 line

Can you describe the conditions which leads up to this please?

On SMP kernel with PREEMPT enabled, if you try to offline the CPU using hot-plug and then bring it back(online), you will get this dump. Since CPU is taken out from idle thread, the process shown is 2.

Regards,
Santosh

#3 lore raw

PATCH 1/1 ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

Quoted 3 lines · Santosh

On SMP kernel with PREEMPT enabled, if you try to offline the CPU using hot-plug and then bring it back(online), you will get this dump. Since CPU is taken out from idle thread, the process shown is 2.

Hmm, I don't think this is how we should be solving this problem. x86 calls init_idle() on the idle task when it's re-used, and this resets the preempt count amongst other things. So maybe we want to do this instead in the __cpu_up path:

	if (!idle) {
		idle = fork_idle(cpu);
		if (IS_ERR(idle)) {
			printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
			return PTR_ERR(idle);
		}
		ci->idle = idle;

- }
+ } else {
+ init_idle(idle);
+ }

#4 lore raw

PATCH 1/1 ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

Quoted 24 lines

-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Friday, March 19, 2010 5:43 PM
To: Shilimkar, Santosh
Cc: linux-arm-kernel at lists.infradead.org; Catalin Marinas
Subject: Re: [PATCH] ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002"

Quoted 3 lines · Santosh

On SMP kernel with PREEMPT enabled, if you try to offline the CPU using hot-plug and then bring it back(online), you will get this dump. Since CPU is taken out from idle thread, the process shown is 2.

Hmm, I don't think this is how we should be solving this problem. x86 calls init_idle() on the idle task when it's re-used, and this resets the preempt count amongst other things. So maybe we want to do this instead in the __cpu_up path:

	if (!idle) {
		idle = fork_idle(cpu);
		if (IS_ERR(idle)) {
			printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
			return PTR_ERR(idle);
		}
		ci->idle = idle;

Review

Quoted 4 lines
(quoted diff) +3 -1
-	}
+	} else {
+		init_idle(idle);
+	}

This doesn't fix the dump. Will have look at this in more details on the same lines as you suggested.

- Santosh