linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][2.5] APM does unsafe conditional set_cpus_allowed
@ 2003-05-19 13:17 Zwane Mwaikambo
  0 siblings, 0 replies; only message in thread
From: Zwane Mwaikambo @ 2003-05-19 13:17 UTC (permalink / raw)
  To: Linux Kernel

kapmd does a conditional check in order to decide whether to set the 
task's cpu affinity mask. This can change during runtime, therefore we 
unconditionally set it. There is an early exit in set_cpus_allowed if the 
current processor is in the allowed mask anyway.

	Zwane

Index: linux-2.5-devel/arch/i386/kernel/apm.c
===================================================================
RCS file: /home/cvs/linux-2.5/arch/i386/kernel/apm.c,v
retrieving revision 1.52
diff -u -p -B -r1.52 apm.c
--- linux-2.5-devel/arch/i386/kernel/apm.c	15 May 2003 03:43:20 -0000	1.52
+++ linux-2.5-devel/arch/i386/kernel/apm.c	19 May 2003 12:14:05 -0000
@@ -512,9 +512,8 @@ static unsigned long apm_save_cpus(void)
 {
 	unsigned long x = current->cpus_allowed;
 	/* Some bioses don't like being called from CPU != 0 */
-	set_cpus_allowed(current, 1 << 0);
-	if (unlikely(smp_processor_id() != 0))
-		BUG();
+	set_cpus_allowed(current, 1UL << 0);
+	BUG_ON(smp_processor_id() != 0);
 	return x;
 }
 
@@ -914,11 +913,8 @@ static void apm_power_off(void)
 	 */
 #ifdef CONFIG_SMP
 	/* Some bioses don't like being called from CPU != 0 */
-	if (smp_processor_id() != 0) {
-		set_cpus_allowed(current, 1 << 0);
-		if (unlikely(smp_processor_id() != 0))
-			BUG();
-	}
+	set_cpus_allowed(current, 1UL << 0);
+	BUG_ON(smp_processor_id() != 0);
 #endif
 	if (apm_info.realmode_power_off)
 	{
@@ -1708,11 +1704,8 @@ static int apm(void *unused)
 	 * Some bioses don't like being called from CPU != 0.
 	 * Method suggested by Ingo Molnar.
 	 */
-	if (smp_processor_id() != 0) {
-		set_cpus_allowed(current, 1 << 0);
-		if (unlikely(smp_processor_id() != 0))
-			BUG();
-	}
+	set_cpus_allowed(current, 1UL << 0);
+	BUG_ON(smp_processor_id() != 0);
 #endif
 
 	if (apm_info.connection_version == 0) {
-- 
function.linuxpower.ca

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-19 13:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-19 13:17 [PATCH][2.5] APM does unsafe conditional set_cpus_allowed Zwane Mwaikambo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).