Skip to contentSkip to conversation

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

PATCH Superseded Santosh Shilimkar 3 participants 7 messages Apr 17, 2010 – Apr 18, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH v2 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. The fix is suggested by Russell King and is based on x86 idea of calling init_idle() on the idle task when it's re-used which also resets the preempt count amongst other things

dump:

BUG: scheduling while atomic: swapper/0/0x00000002
Modules linked in:
Backtrace:
[<c0024f90>] (dump_backtrace+0x0/0x110) from [<c0173bc4>] (dump_stack+0x18/0x1c)
 r7:c02149e4 r6:c033df00 r5:c7836000 r4:00000000
[<c0173bac>] (dump_stack+0x0/0x1c) from [<c003b4f0>] (__schedule_bug+0x60/0x70)
[<c003b490>] (__schedule_bug+0x0/0x70) from [<c0174214>] (schedule+0x98/0x7b8)
 r5:c7836000 r4:c7836000
[<c017417c>] (schedule+0x0/0x7b8) from [<c00228c4>] (cpu_idle+0xb4/0xd4)
# [<c0022810>] (cpu_idle+0x0/0xd4) from [<c0171dd8>] (secondary_start_kernel+0xe0/0xf0)
 r5:c7836000 r4:c0205f40
[<c0171cf8>] (secondary_start_kernel+0x0/0xf0) from [<c002d57c>] (prm_rmw_mod_reg_bits+0x88/0xa4)
 r7:c02149e4 r6:00000001 r5:00000001 r4:c7836000

Backtrace aborted due to bad frame pointer <c7837fbc>

Cc Russell King <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Sundar R IYER <[email protected]>
---
 arch/arm/kernel/smp.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/kernel/smp.c +7 -1
index 57162af..3e14629 100644
@@ -86,8 +86,14 @@ int __cpuinit __cpu_up(unsigned int cpu)
 			return PTR_ERR(idle);
 		}
 		ci->idle = idle;
+	} else {
+		/*
+		 * Since idle thread getting re-used, call
+		 * init_idle() to set up the idle thread for given
+		 * CPU. Additionally it also resets the preempt count
+		 */
+		init_idle(idle, cpu);
 	}
-
 	/*
 	 * Allocate initial page tables to allow the new CPU to
 	 * enable the MMU safely.  This essentially means a set
Signature · 1 line
1.6.0.4
#1 lore raw

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

Hello Santosh,

Quoted 34 lines · Santosh Shilimkar

This patch fixes the preempt leak in the cpuidle path invoked from cpu-hotplug. The fix is suggested by Russell King and is based on x86 idea of calling init_idle() on the idle task when it's re-used which also resets the preempt count amongst other things

dump:

BUG: scheduling while atomic: swapper/0/0x00000002
Modules linked in:
Backtrace:
[<c0024f90>] (dump_backtrace+0x0/0x110) from [<c0173bc4>] (dump_stack+0x18/0x1c)
  r7:c02149e4 r6:c033df00 r5:c7836000 r4:00000000
[<c0173bac>] (dump_stack+0x0/0x1c) from [<c003b4f0>] (__schedule_bug+0x60/0x70)
[<c003b490>] (__schedule_bug+0x0/0x70) from [<c0174214>] (schedule+0x98/0x7b8)
  r5:c7836000 r4:c7836000
[<c017417c>] (schedule+0x0/0x7b8) from [<c00228c4>] (cpu_idle+0xb4/0xd4)
# [<c0022810>] (cpu_idle+0x0/0xd4) from [<c0171dd8>] (secondary_start_kernel+0xe0/0xf0)
  r5:c7836000 r4:c0205f40
[<c0171cf8>] (secondary_start_kernel+0x0/0xf0) from [<c002d57c>] (prm_rmw_mod_reg_bits+0x88/0xa4)
  r7:c02149e4 r6:00000001 r5:00000001 r4:c7836000

Backtrace aborted due to bad frame pointer<c7837fbc>

Cc Russell King<[email protected]>
Cc Catalin Marinas<[email protected]>
Cc Sundar R IYER<[email protected]>
---
  arch/arm/kernel/smp.c |    8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/kernel/smp.c +0 -0
index 57162af..3e14629 100644

arch/arm/kernel/smp.c int __cpuinit __cpu_up(unsigned int cpu) · line 95

Quoted 10 lines
arch/arm/kernel/smp.c +7 -0
@@ -86,8 +86,14 @@ int __cpuinit __cpu_up(unsigned int cpu)
  			return PTR_ERR(idle);
  		}
  		ci->idle = idle;
+	} else {
+		/*
+		 * Since idle thread getting re-used, call
+		 * init_idle() to set up the idle thread for given
+		 * CPU. Additionally it also resets the preempt count
+		 */
+		init_idle(idle, cpu);

Since Sundar was the first to suggest this fix, shouldn't his SOB be included as well instead of CC ? Or did I miss a mail thread ?

Regards,
Philby

#2 lore raw

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

Quoted 49 lines

-----Original Message-----
From: Philby John [mailto:pjohn at mvista.com]
Sent: Saturday, April 17, 2010 3:22 PM
To: Shilimkar, Santosh
Cc: linux-arm-kernel at lists.infradead.org; Russell King; Sundar R IYER; Catalin Marinas
Subject: Re: [PATCH v2] ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002

Hello Santosh,

Quoted 39 lines · Santosh Shilimkar

This patch fixes the preempt leak in the cpuidle path invoked from cpu-hotplug. The fix is suggested by Russell King and is based on x86 idea of calling init_idle() on the idle task when it's re-used which also resets the preempt count amongst other things

dump:

BUG: scheduling while atomic: swapper/0/0x00000002
Modules linked in:
Backtrace:
[<c0024f90>] (dump_backtrace+0x0/0x110) from [<c0173bc4>] (dump_stack+0x18/0x1c)
  r7:c02149e4 r6:c033df00 r5:c7836000 r4:00000000
[<c0173bac>] (dump_stack+0x0/0x1c) from [<c003b4f0>] (__schedule_bug+0x60/0x70)
[<c003b490>] (__schedule_bug+0x0/0x70) from [<c0174214>] (schedule+0x98/0x7b8)
  r5:c7836000 r4:c7836000
[<c017417c>] (schedule+0x0/0x7b8) from [<c00228c4>] (cpu_idle+0xb4/0xd4)
# [<c0022810>] (cpu_idle+0x0/0xd4) from [<c0171dd8>] (secondary_start_kernel+0xe0/0xf0)
  r5:c7836000 r4:c0205f40
[<c0171cf8>] (secondary_start_kernel+0x0/0xf0) from [<c002d57c>] (prm_rmw_mod_reg_bits+0x88/0xa4)
  r7:c02149e4 r6:00000001 r5:00000001 r4:c7836000

Backtrace aborted due to bad frame pointer<c7837fbc>

Cc Russell King<[email protected]>
Cc Catalin Marinas<[email protected]>
Cc Sundar R IYER<[email protected]>
---
  arch/arm/kernel/smp.c |    8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/kernel/smp.c +2 -0
index 57162af..3e14629 100644
@@ -86,8 +86,14 @@ int __cpuinit __cpu_up(unsigned int cpu)
  			return PTR_ERR(idle);
  		}
  		ci->idle = idle;
+	} else {
+		/*
Quoted 8 lines

arch/arm/kernel/smp.c int __cpuinit __cpu_up(unsigned int cpu) · line 95

Quoted 5 lines
arch/arm/kernel/smp.c +5 -0
+		 * Since idle thread getting re-used, call
+		 * init_idle() to set up the idle thread for given
+		 * CPU. Additionally it also resets the preempt count
+		 */
+		init_idle(idle, cpu);

Since Sundar was the first to suggest this fix, shouldn't his SOB be included as well instead of CC ? Or did I miss a mail thread ?

Probably you missed the initial thread. Russell suggested this some time back and top of my alternate patch and not Sundar.

Since he was interested in the fix I added Cc. Adding SOB is no problem really but just to be clear on the thread.

Regards,
Santosh

#3 lore raw

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

Quoted 57 lines · Santosh
Quoted 49 lines

-----Original Message-----
From: Philby John [mailto:pjohn at mvista.com]
Sent: Saturday, April 17, 2010 3:22 PM
To: Shilimkar, Santosh
Cc: linux-arm-kernel at lists.infradead.org; Russell King; Sundar R IYER; Catalin Marinas
Subject: Re: [PATCH v2] ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002

Hello Santosh,

Quoted 39 lines · Santosh Shilimkar

This patch fixes the preempt leak in the cpuidle path invoked from cpu-hotplug. The fix is suggested by Russell King and is based on x86 idea of calling init_idle() on the idle task when it's re-used which also resets the preempt count amongst other things

dump:

BUG: scheduling while atomic: swapper/0/0x00000002
Modules linked in:
Backtrace:
[<c0024f90>] (dump_backtrace+0x0/0x110) from [<c0173bc4>] (dump_stack+0x18/0x1c)
   r7:c02149e4 r6:c033df00 r5:c7836000 r4:00000000
[<c0173bac>] (dump_stack+0x0/0x1c) from [<c003b4f0>] (__schedule_bug+0x60/0x70)
[<c003b490>] (__schedule_bug+0x0/0x70) from [<c0174214>] (schedule+0x98/0x7b8)
   r5:c7836000 r4:c7836000
[<c017417c>] (schedule+0x0/0x7b8) from [<c00228c4>] (cpu_idle+0xb4/0xd4)
# [<c0022810>] (cpu_idle+0x0/0xd4) from [<c0171dd8>] (secondary_start_kernel+0xe0/0xf0)
   r5:c7836000 r4:c0205f40
[<c0171cf8>] (secondary_start_kernel+0x0/0xf0) from [<c002d57c>] (prm_rmw_mod_reg_bits+0x88/0xa4)
   r7:c02149e4 r6:00000001 r5:00000001 r4:c7836000

Backtrace aborted due to bad frame pointer<c7837fbc>

Cc Russell King<[email protected]>
Cc Catalin Marinas<[email protected]>
Cc Sundar R IYER<[email protected]>
---
   arch/arm/kernel/smp.c |    8 +++++++-
   1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/kernel/smp.c +2 -0
index 57162af..3e14629 100644
@@ -86,8 +86,14 @@ int __cpuinit __cpu_up(unsigned int cpu)
   			return PTR_ERR(idle);
   		}
   		ci->idle = idle;
+	} else {
+		/*
Quoted 8 lines

arch/arm/kernel/smp.c int __cpuinit __cpu_up(unsigned int cpu) · line 95

Quoted 5 lines
arch/arm/kernel/smp.c +5 -0
+		 * Since idle thread getting re-used, call
+		 * init_idle() to set up the idle thread for given
+		 * CPU. Additionally it also resets the preempt count
+		 */
+		init_idle(idle, cpu);

Since Sundar was the first to suggest this fix, shouldn't his SOB be included as well instead of CC ? Or did I miss a mail thread ?

Quoted 2 lines

Probably you missed the initial thread. Russell suggested this some time back and top of my alternate patch and not Sundar.

Ah! ok. Sorry for the fuss.

Regards,
Philby

#4 lore raw

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

In reply to Philby John
Quoted 2 lines · Philby John

Since Sundar was the first to suggest this fix, shouldn't his SOB be included as well instead of CC ? Or did I miss a mail thread ?

I think you need to review what qualifies for a SOB line. A SOB line effectively means you're certifying one of the conditions given in the developer certificate of origin. If you're not doing that, you must not use SOB.

In any case, as Santosh points out, it was myself who originally suggested this approach. However, I really can't be bothered to try and find my email as people insist on using email clients which break threading.

#5 lore raw

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

In reply to Santosh Shilimkar

arch/arm/kernel/smp.c int __cpuinit __cpu_up(unsigned int cpu) · line 93

Quoted 4 lines · Santosh Shilimkar
arch/arm/kernel/smp.c +4 -0
+		/*
+		 * Since idle thread getting re-used, call
+		 * init_idle() to set up the idle thread for given
+		 * CPU. Additionally it also resets the preempt count

"Since this idle thread is being re-used, call init_idle() to reinitialize the thread structure."

I don't think we need to mention the preempt count explicitly because that's a detail of reinitializing the thread structure.

#6 lore raw

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

Quoted 16 lines

-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Sunday, April 18, 2010 12:04 AM
To: Shilimkar, Santosh
Cc: linux-arm-kernel at lists.infradead.org; Catalin Marinas; Sundar R IYER
Subject: Re: [PATCH v2] ARM: Fix "BUG: scheduling while atomic: swapper/0/0x00000002

arch/arm/kernel/smp.c int __cpuinit __cpu_up(unsigned int cpu) · line 93

Quoted 4 lines · Santosh Shilimkar
arch/arm/kernel/smp.c +4 -0
+		/*
+		 * Since idle thread getting re-used, call
+		 * init_idle() to set up the idle thread for given
+		 * CPU. Additionally it also resets the preempt count

"Since this idle thread is being re-used, call init_idle() to reinitialize the thread structure."

Quoted 2 lines

I don't think we need to mention the preempt count explicitly because that's a detail of reinitializing the thread structure.

Ok.
Will fix the description and if you are ok can submit to patch system

Regards,
Santosh