Skip to contentSkip to conversation

removing interruptible_sleep_on in

PATCH In review Tom 'spot' Callaway 2 participants 3 messages Jan 13, 2004 – Jan 29, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 removing interruptible_sleep_on in

Fedora Core 2's 2.6.1 kernel package is patching interruptible_sleep_on (and sleep_on) as deprecated. This causes
sparc64 to stop building, since it uses interruptible_sleep_on in arch/sparc64/kernel/power.c. I made a best effort to fix this in the attached patch, feedback is appreciated.

~spot
---
Tom "spot" Callaway <tcallawa(a)redhat*com> LCA, RHCE Red Hat Sales Engineer || Aurora SPARC Linux Project Leader

"The author's mathematical treatment of the conception of purpose is novel and highly ingenious, but heretical and, so far as the present social order is concerned, dangerous and potentially subversive. Not to be published." -- Aldous Huxley's "Brave New World"

arch/sparc64/kernel/power.c renamed from arch/sparc64/kernel/power.c.BAD +6 -1
@@ -69,13 +69,16 @@
 {
 	static char *envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
 	char *argv[] = { "/sbin/shutdown", "-h", "now", NULL };
+	DECLARE_WAITQUEUE(wait, current);
+	add_wait_queue(&powerd_wait, &wait);
+	set_current_state(TASK_INTERRUPTIBLE);
 
 	daemonize("powerd");
 
 again:
 	while (button_pressed == 0) {
 		flush_signals(current);
-		interruptible_sleep_on(&powerd_wait);
+		schedule();
 	}
 
 	/* Ok, down we go... */
@@ -84,6 +87,8 @@
 		button_pressed = 0;
 		goto again;
 	}
+	remove_wait_queue(&powerd_wait, &wait);
+	set_current_state(TASK_RUNNING);
 	return 0;
 }
 
#1 lore raw
Quoted 5 lines · On Tue, 13 Jan 2004 22:40:03 -0600 "Tom 'spot' Callaway" <[email protected]>…

Fedora Core 2's 2.6.1 kernel package is patching interruptible_sleep_on (and sleep_on) as deprecated. This causes
sparc64 to stop building, since it uses interruptible_sleep_on in arch/sparc64/kernel/power.c. I made a best effort to fix this in the attached patch, feedback is appreciated.

I will review this and fix it up if needed tomorrow.

Thanks Tom.

#2 lore raw
In reply to Tom 'spot' Callaway
Quoted 5 lines · On Tue, 13 Jan 2004 22:40:03 -0600 "Tom 'spot' Callaway" <[email protected]>…

Fedora Core 2's 2.6.1 kernel package is patching interruptible_sleep_on (and sleep_on) as deprecated. This causes
sparc64 to stop building, since it uses interruptible_sleep_on in arch/sparc64/kernel/power.c. I made a best effort to fix this in the attached patch, feedback is appreciated.

I did things slightly differently to make sure there were no subtle races, this is what I'll push to Linus.

Thanks Tom.

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1507 -> 1.1508
# arch/sparc64/kernel/power.c 1.14 -> 1.15
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/01/29 davem@cheetah.(none) 1.1508
# [SPARC64]: Remove interruptible_sleep_on() usage, with help from Tom Callaway. # --------------------------------------------
#

arch/sparc64/kernel/power.c +10 -2
diff -Nru a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c
@@ -69,18 +69,26 @@
 {
 	static char *envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
 	char *argv[] = { "/sbin/shutdown", "-h", "now", NULL };
+	DECLARE_WAITQUEUE(wait, current);
 
 	daemonize("powerd");
 
+	add_wait_queue(&powerd_wait, &wait);
 again:
-	while (button_pressed = 0) {
+	for (;;) {
+		set_task_state(current, TASK_INTERRUPTIBLE);
+		if (button_pressed)
+			break;
 		flush_signals(current);
-		interruptible_sleep_on(&powerd_wait);
+		schedule();
 	}
+	__set_current_state(TASK_RUNNING);
+	remove_wait_queue(&powerd_wait, &wait);
 
 	/* Ok, down we go... */
 	if (execve("/sbin/shutdown", argv, envp) < 0) {
 		printk("powerd: shutdown execution failed\n");
+		add_wait_queue(&powerd_wait, &wait);
 		button_pressed = 0;
 		goto again;
 	}