ARM: MM: bugfix: initialize spinlock for init_mm.context
PATCH v2 1/1 ARM: MM: bugfix: initialize spinlock for init_mm.context
init_mm used at kernel/sched.c:idle_task_exit() has spin_lock (init_mm.context.id_lock) that is not initialized when spin_lock/unlock is called at an ARM machine. Note that mm_struct.context.id_lock is usually initialized except for the instance of init_mm at linux/arch/arm/mm/context.c
Not initializing this spinlock incurs "BUG: pinlock bad magic" warning when spinlock debug is enabled. We have observed such instances when testing PM in S5PC210 machines.
--
changes
v2: fixed incorrect initializer parameter (list_lock -> id_lock) --- arch/arm/include/asm/mmu.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/include/asm/mmu.h +4 -0
@@ -13,6 +13,10 @@ typedef struct {#ifdef CONFIG_CPU_HAS_ASID #define ASID (mm) ((mm)->context.id & 255) + +/* init_mm.context.id_lock should be initialized. */ +#define INIT_MM_CONTEXT (name) \ + .context.id_lock = __SPIN_LOCK_UNLOCKED(name.context.id_lock),#else #define ASID (mm) (0)#endif
Signature · 1 line
1.6.3.3
PATCH v2 1/1 ARM: MM: bugfix: initialize spinlock for init_mm.context
Quoted 4 lines · MyungJoo Ham
init_mmused at kernel/sched.c:idle_task_exit() hasspin_lock(init_mm.context.id_lock) that is not initialized when spin_lock/unlock is called at an ARM machine. Note that mm_struct.context.id_lock is
usually
Quoted 1 line
initialized except for the instance of
init_mmat
linux/arch/arm/mm/context.c
Quoted 2 lines
Not initializing this spinlock incurs "BUG: pinlock bad magic" warning
when
spinlock?
Quoted 1 line
spinlock debug is enabled. We have observed such instances when testing PM
in
Quoted 27 lines
S5PC210 machines.
Signed-off-by MyungJoo Ham <[email protected]>Signed-off-by Kyungmin Park <[email protected]>--
changesv2: fixed incorrect initializer parameter (list_lock -> id_lock) --- arch/arm/include/asm/mmu.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)arch/arm/include/asm/mmu.h +4
-0@@ -13,6 +13,10 @@ typedef struct {#ifdef CONFIG_CPU_HAS_ASID #define ASID (mm) ((mm)->context.id & 255) + +/* init_mm.context.id_lock should be initialized. */ +#define INIT_MM_CONTEXT (name) \ + .context.id_lock = __SPIN_LOCK_UNLOCKED(name.context.id_lock),#else #define ASID (mm) (0)
Quoted 2 lines
#endif
--
Also, happened following warning without this patch when hotplug.
[root at Samsung ~]# echo 0 > /sys/devices/system/cpu/cpu1/online
BUG: spinlock bad magic on CPU#1, swapper/0 lock: 802fee10, .magic: 00000000, .owner: swapper/0, .owner_cpu: 1 [<8002e250>] (unwind_backtrace+0x0/0xec) from [<80163038>] (do_raw_spin_unlock+0x20/0xc0) [<80163038>] (do_raw_spin_unlock+0x20/0xc0) from [<80219420>] (_raw_spin_unlock_irqrestore+0xc/0x38) [<80219420>] (_raw_spin_unlock_irqrestore+0xc/0x38) from [<800319a8>] (set_mm_context+0x94/0xb4) [<800319a8>] (set_mm_context+0x94/0xb4) from [<80031ac4>] (__new_context+0x9c/0xb4) [<80031ac4>] (__new_context+0x9c/0xb4) from [<800443dc>] (idle_task_exit+0xe0/0x140) [<800443dc>] (idle_task_exit+0xe0/0x140) from [<80211dd8>] (cpu_die+0x14/0x44) [<80211dd8>] (cpu_die+0x14/0x44) from [<80029878>] (cpu_idle+0x54/0xd0) [<80029878>] (cpu_idle+0x54/0xd0) from [<40008080>] (0x40008080)
CPU1: shutdown
[root at Samsung ~]# OK
In my opinion, this stuff should be sent to Russell's tree with Catalin's ack.
Catalin, is still valid your ack?
Thanks.
Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.
PATCH v2 1/1 ARM: MM: bugfix: initialize spinlock for init_mm.context
In reply to MyungJoo HamQuoted 5 lines · MyungJoo Ham
init_mmused at kernel/sched.c:idle_task_exit() hasspin_lock(init_mm.context.id_lock) that is not initialized when spin_lock/unlock is called at an ARM machine. Note that mm_struct.context.id_lock is usually initialized except for the instance ofinit_mmatlinux/arch/arm/mm/context.c
Quoted 7 lines
Not initializing this spinlock incurs "BUG: pinlock bad magic" warning when spinlock debug is enabled. We have observed such instances when testing PM in S5PC210 machines.
Signed-off-by MyungJoo Ham <[email protected]>Signed-off-by Kyungmin Park <[email protected]>