* [PATCH] ledtrig-cpu: kill useless mutex to fix sleep in atomic context
@ 2012-11-05 14:20 Nathan Lynch
2012-11-06 1:06 ` Bryan Wu
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Lynch @ 2012-11-05 14:20 UTC (permalink / raw)
To: linux-leds; +Cc: linux-kernel, miles.lane, cooloney
Seeing the following every time the CPU enters or leaves idle on a
Beagleboard:
BUG: sleeping function called from invalid context at kernel/mutex.c:269
in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/0
no locks held by swapper/0/0.
[<c001659c>] (unwind_backtrace+0x0/0xf8) from [<c05aaa7c>] (mutex_lock_nested+0x24/0x380)
[<c05aaa7c>] (mutex_lock_nested+0x24/0x380) from [<c043bd1c>] (ledtrig_cpu+0x38/0x88)
[<c043bd1c>] (ledtrig_cpu+0x38/0x88) from [<c000f4b0>] (cpu_idle+0xf4/0x120)
[<c000f4b0>] (cpu_idle+0xf4/0x120) from [<c07e47c8>] (start_kernel+0x2bc/0x30c)
Miles Lane has reported seeing similar splats during system suspend.
The mutex in struct led_trigger_cpu appears to have no function: it
resides in a per-cpu data structure which never changes after the
trigger is registered. So just remove it.
Reported-by: Miles Lane <miles.lane@gmail.com>
Signed-off-by: Nathan Lynch <ntl@pobox.com>
---
drivers/leds/ledtrig-cpu.c | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/drivers/leds/ledtrig-cpu.c b/drivers/leds/ledtrig-cpu.c
index b312056..4239b39 100644
--- a/drivers/leds/ledtrig-cpu.c
+++ b/drivers/leds/ledtrig-cpu.c
@@ -33,8 +33,6 @@
struct led_trigger_cpu {
char name[MAX_NAME_LEN];
struct led_trigger *_trig;
- struct mutex lock;
- int lock_is_inited;
};
static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig);
@@ -50,12 +48,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
{
struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig);
- /* mutex lock should be initialized before calling mutex_call() */
- if (!trig->lock_is_inited)
- return;
-
- mutex_lock(&trig->lock);
-
/* Locate the correct CPU LED */
switch (ledevt) {
case CPU_LED_IDLE_END:
@@ -75,8 +67,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
/* Will leave the LED as it is */
break;
}
-
- mutex_unlock(&trig->lock);
}
EXPORT_SYMBOL(ledtrig_cpu);
@@ -117,14 +107,9 @@ static int __init ledtrig_cpu_init(void)
for_each_possible_cpu(cpu) {
struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
- mutex_init(&trig->lock);
-
snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
- mutex_lock(&trig->lock);
led_trigger_register_simple(trig->name, &trig->_trig);
- trig->lock_is_inited = 1;
- mutex_unlock(&trig->lock);
}
register_syscore_ops(&ledtrig_cpu_syscore_ops);
@@ -142,15 +127,9 @@ static void __exit ledtrig_cpu_exit(void)
for_each_possible_cpu(cpu) {
struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
- mutex_lock(&trig->lock);
-
led_trigger_unregister_simple(trig->_trig);
trig->_trig = NULL;
memset(trig->name, 0, MAX_NAME_LEN);
- trig->lock_is_inited = 0;
-
- mutex_unlock(&trig->lock);
- mutex_destroy(&trig->lock);
}
unregister_syscore_ops(&ledtrig_cpu_syscore_ops);
--
1.7.11.7
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ledtrig-cpu: kill useless mutex to fix sleep in atomic context
2012-11-05 14:20 [PATCH] ledtrig-cpu: kill useless mutex to fix sleep in atomic context Nathan Lynch
@ 2012-11-06 1:06 ` Bryan Wu
0 siblings, 0 replies; 2+ messages in thread
From: Bryan Wu @ 2012-11-06 1:06 UTC (permalink / raw)
To: Nathan Lynch; +Cc: linux-leds, linux-kernel, miles.lane
On Mon, Nov 5, 2012 at 6:20 AM, Nathan Lynch <ntl@pobox.com> wrote:
> Seeing the following every time the CPU enters or leaves idle on a
> Beagleboard:
>
> BUG: sleeping function called from invalid context at kernel/mutex.c:269
> in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/0
> no locks held by swapper/0/0.
> [<c001659c>] (unwind_backtrace+0x0/0xf8) from [<c05aaa7c>] (mutex_lock_nested+0x24/0x380)
> [<c05aaa7c>] (mutex_lock_nested+0x24/0x380) from [<c043bd1c>] (ledtrig_cpu+0x38/0x88)
> [<c043bd1c>] (ledtrig_cpu+0x38/0x88) from [<c000f4b0>] (cpu_idle+0xf4/0x120)
> [<c000f4b0>] (cpu_idle+0xf4/0x120) from [<c07e47c8>] (start_kernel+0x2bc/0x30c)
>
> Miles Lane has reported seeing similar splats during system suspend.
>
> The mutex in struct led_trigger_cpu appears to have no function: it
> resides in a per-cpu data structure which never changes after the
> trigger is registered. So just remove it.
>
> Reported-by: Miles Lane <miles.lane@gmail.com>
> Signed-off-by: Nathan Lynch <ntl@pobox.com>
Thanks, I also think we probable don't need this locking for per CPU
data. But if I'm wrong please correct me.
I will merge this and send to Linus soon.
-Bryan
> ---
> drivers/leds/ledtrig-cpu.c | 21 ---------------------
> 1 file changed, 21 deletions(-)
>
> diff --git a/drivers/leds/ledtrig-cpu.c b/drivers/leds/ledtrig-cpu.c
> index b312056..4239b39 100644
> --- a/drivers/leds/ledtrig-cpu.c
> +++ b/drivers/leds/ledtrig-cpu.c
> @@ -33,8 +33,6 @@
> struct led_trigger_cpu {
> char name[MAX_NAME_LEN];
> struct led_trigger *_trig;
> - struct mutex lock;
> - int lock_is_inited;
> };
>
> static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig);
> @@ -50,12 +48,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
> {
> struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig);
>
> - /* mutex lock should be initialized before calling mutex_call() */
> - if (!trig->lock_is_inited)
> - return;
> -
> - mutex_lock(&trig->lock);
> -
> /* Locate the correct CPU LED */
> switch (ledevt) {
> case CPU_LED_IDLE_END:
> @@ -75,8 +67,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
> /* Will leave the LED as it is */
> break;
> }
> -
> - mutex_unlock(&trig->lock);
> }
> EXPORT_SYMBOL(ledtrig_cpu);
>
> @@ -117,14 +107,9 @@ static int __init ledtrig_cpu_init(void)
> for_each_possible_cpu(cpu) {
> struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
>
> - mutex_init(&trig->lock);
> -
> snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
>
> - mutex_lock(&trig->lock);
> led_trigger_register_simple(trig->name, &trig->_trig);
> - trig->lock_is_inited = 1;
> - mutex_unlock(&trig->lock);
> }
>
> register_syscore_ops(&ledtrig_cpu_syscore_ops);
> @@ -142,15 +127,9 @@ static void __exit ledtrig_cpu_exit(void)
> for_each_possible_cpu(cpu) {
> struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
>
> - mutex_lock(&trig->lock);
> -
> led_trigger_unregister_simple(trig->_trig);
> trig->_trig = NULL;
> memset(trig->name, 0, MAX_NAME_LEN);
> - trig->lock_is_inited = 0;
> -
> - mutex_unlock(&trig->lock);
> - mutex_destroy(&trig->lock);
> }
>
> unregister_syscore_ops(&ledtrig_cpu_syscore_ops);
> --
> 1.7.11.7
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-06 1:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 14:20 [PATCH] ledtrig-cpu: kill useless mutex to fix sleep in atomic context Nathan Lynch
2012-11-06 1:06 ` Bryan Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®