Skip to contentSkip to conversation

windfarm got signal

PATCH New Johannes Berg 5 participants 11 messages Jun 20, 2006 – Jun 27, 2006 Linux for power macintosh

lore
Share & tools
lore
#0 lore raw

Hey,

after cpu hotplug I decided to write some fake suspend routines for ppc64 that always fail to see what all the drivers would say... The first thing I saw was during the phase where all threads are stopped, that windfarm got a signal!

Shortly after that, the fans were revved up fully but I guess that's expected if the wf control loop exits.

So now I'm trying to see *why* it got a signal there. Any ideas? Is that expected with pm and windfarm just does the wrong thing there by taking the signal as a reason to exit the control thread?

[code in question is windfarm_core.c:wf_thread_func]

johannes

#1 lore raw
Quoted 7 lines · Johannes Berg

Hey,

after cpu hotplug I decided to write some fake suspend routines for ppc64 that always fail to see what all the drivers would say... The first thing I saw was during the phase where all threads are stopped, that windfarm got a signal!

Quoted 8 lines

Shortly after that, the fans were revved up fully but I guess that's expected if the wf control loop exits.

So now I'm trying to see *why* it got a signal there. Any ideas? Is that expected with pm and windfarm just does the wrong thing there by taking the signal as a reason to exit the control thread?

[code in question is windfarm_core.c:wf_thread_func]

I think it's the way the freezer works ... it sends a pseudo signal to all kernel threads who are then supposed to do something like test for PF_FREEZE or something like that.

Ben.

#2 lore raw
Quoted 15 lines · Benjamin Herrenschmidt
Quoted 14 lines · Johannes Berg

Hey,

after cpu hotplug I decided to write some fake suspend routines for ppc64 that always fail to see what all the drivers would say... The first thing I saw was during the phase where all threads are stopped, that windfarm got a signal!

Shortly after that, the fans were revved up fully but I guess that's expected if the wf control loop exits.

So now I'm trying to see *why* it got a signal there. Any ideas? Is that expected with pm and windfarm just does the wrong thing there by taking the signal as a reason to exit the control thread?

Quoted 5 lines
Quoted 1 line

[code in question is windfarm_core.c:wf_thread_func]

I think it's the way the freezer works ... it sends a pseudo signal to all kernel threads who are then supposed to do something like test for PF_FREEZE or something like that.

Yes. More precisely, they are supposed to use try_to_freeze().

Please see Documentation/power/kernel_threads.txt.

Greetings,
Rafael

#3 lore raw
Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines

I think it's the way the freezer works ... it sends a pseudo signal to all kernel threads who are then supposed to do something like test for PF_FREEZE or something like that.

Yes. More precisely, they are supposed to use try_to_freeze().

Please see Documentation/power/kernel_threads.txt.

Thanks, I'll look and submit a patch. It does try_to_freeze() but also checks for pending signals.

johannes

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#4 lore raw
Quoted 2 lines · Johannes Berg

Thanks, I'll look and submit a patch. It does try_to_freeze() but also checks for pending signals.

Ah. The code is just in the wrong order:
while (!kthread_should_stop()) {
try_to_freeze();
...
schedule_timeout_interruptible(...);
if (signal_pending())

    break;
}

Would it be correct to just move the try_to_freeze() before the signal_pending() statement?

johannes

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#5 lore raw

Hi.

Quoted 10 lines · Johannes Berg
Quoted 2 lines · Johannes Berg

Thanks, I'll look and submit a patch. It does try_to_freeze() but also checks for pending signals.

Ah. The code is just in the wrong order:
while (!kthread_should_stop()) {
try_to_freeze();
...
schedule_timeout_interruptible(...);
if (signal_pending())

Quoted 5 lines
    break;
}

Would it be correct to just move the try_to_freeze() before the signal_pending() statement?

Hmm. Will kthread_should_stop() be set if it should really exit? If so, perhaps you can just remove the signal_pending() check. Otherwise, you'd want to change the signal_pending() test to something like the "if (signal_pending() && !try_to_freeze())" to avoid any possibility of a race. (In this case, you should be able to remove the try_to_freeze() from above).

Regards,

Nigel

Signature · 4 lines
Nigel, Michelle and Alisdair Cunningham
5 Mitchell Street
Cobden 3266
Victoria, Australia
#6 lore raw
In reply to Johannes Berg
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Johannes Berg

Thanks, I'll look and submit a patch. It does try_to_freeze() but also checks for pending signals.

Ah. The code is just in the wrong order:

The code should be

while (!kthread_should_stop()) {
try_to_freeze();
...
schedule_timeout_interruptible(...);
}

That is, I think we just don't care about the signal stuff.

Care to do a new patch ?

Cheers,
Ben.

#7 lore raw

PATCH 1/1 fix windfarm core thread wrt. signal handling

This patch removes the signal_pending() from the windfarm core thread loop as it isn't necessary and messes up when there actually *is* a signal pending because we should enter the freezer.

drivers/macintosh/windfarm_core.c +0 -6
index ab3faa7..c05a838 100644
@@ -116,12 +116,6 @@ static int wf_thread_func(void *data)
 		delay = next - jiffies;
 		if (delay <= HZ)
 			schedule_timeout_interruptible(delay);
-
-		/* there should be no signal, but oh well */
-		if (signal_pending(current)) {
-			printk(KERN_WARNING "windfarm: thread got sigl !\n");
-			break;
-		}
 	}
 
 	DBG("wf: thread stopped\n");
Acked-by on v1 1/1
#8 lore raw

Re: [PATCH] fix windfarm core thread wrt. signal handling

Quoted 5 lines · Johannes Berg

This patch removes the signal_pending() from the windfarm core thread loop as it isn't necessary and messes up when there actually *is* a signal pending because we should enter the freezer.

Quoted 18 lines
drivers/macintosh/windfarm_core.c +0 -6
index ab3faa7..c05a838 100644
@@ -116,12 +116,6 @@ static int wf_thread_func(void *data)
 		delay = next - jiffies;
 		if (delay <= HZ)
 			schedule_timeout_interruptible(delay);
-
-		/* there should be no signal, but oh well */
-		if (signal_pending(current)) {
-			printk(KERN_WARNING "windfarm: thread got sigl !\n");
-			break;
-		}
 	}
 
 	DBG("wf: thread stopped\n");
#9 lore raw
In reply to Johannes Berg

Hi!

Quoted 5 lines

after cpu hotplug I decided to write some fake suspend routines for ppc64 that always fail to see what all the drivers would say... The first thing I saw was during the phase where all threads are stopped, that windfarm got a signal!

Quoted 8 lines

Shortly after that, the fans were revved up fully but I guess that's expected if the wf control loop exits.

So now I'm trying to see *why* it got a signal there. Any ideas? Is that expected with pm and windfarm just does the wrong thing there by taking the signal as a reason to exit the control thread?

[code in question is windfarm_core.c:wf_thread_func]

See kernel/power/process.c

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         
#10 lore raw

PATCH 1/1 windfarm: proper try_to_freeze / signal_pending handling

In reply to Johannes Berg

This seems to work for me:
---
This patch makes windfarm handle signal_pending()/try_to_freeze() better.

drivers/macintosh/windfarm_core.c +2 -4
@@ -93,8 +93,6 @@ static int wf_thread_func(void *data)
 	DBG("wf: thread started\n");
 
 	while(!kthread_should_stop()) {
-		try_to_freeze();
-
 		if (time_after_eq(jiffies, next)) {
 			wf_notify(WF_EVENT_TICK, NULL);
 			if (wf_overtemp) {
@@ -117,8 +115,8 @@ static int wf_thread_func(void *data)
 		if (delay <= HZ)
 			schedule_timeout_interruptible(delay);
 
-		/* there should be no signal, but oh well */
-		if (signal_pending(current)) {
+		/* there should be no non-suspend signal, but oh well */
+		if (signal_pending(current) && !try_to_freeze()) {
 			printk(KERN_WARNING "windfarm: thread got sigl !\n");
 			break;
 		}