Jim Carter | 9 Dec 2003 07:27

[PATCH] apm.c, 2.4.20, set_cpus_allowed for CPU 0 on SMP

Using hyperthreading, and wanting to power off the CPU, when loading the
apm.o module I intermittently got the BUG() in function apm() of
./arch/i386/kernel/apm.c where it tries to migrate to CPU 0 and fails.

Shouldn't it call set_cpus_allowed() (in ./kernel/sched.c) instead of
just setting current->cpus_allowed and calling schedule()?  I didn't see
where schedule() notices that the task is on the wrong CPU, though I
could have missed it.

The attached patch makes this call, and it's unconditional, so that if
the thread starts out on CPU 0 but some ghost later tries to put it on
another CPU, it will stay on CPU 0.

Ten successive boot and "halt -p" pairs were successful in initializing
the module (of course for power-off only, due to SMP) and turning off
the power.  Before the patch I would have expected several failures --
seems like less than half, but enough to really mess up remote 
administration.  

Comments in the code say that some APM BIOSes need to be called by CPU 0
only.  There is no evidence that my BIOS does or does not require this.

Administrative details: The patch is relative to 2.4.20 from SuSE Linux
8.2, which is what the testing was done on.  The relevant code is
identical in pristine 2.4.23 sources.  Hardware is a Dell Dimension 4600
with a Pentium-4 processor (2.4 GHz, hyperthreading).  Kernel is
configured with SMP.

James F. Carter          Voice 310 825 2897    FAX 310 206 6673
UCLA-Mathnet;  6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
(Continue reading)

kuan2000@21cn.com | 16 Dec 2003 05:48
Favicon

(unknown)

-
To unsubscribe from this list: send the line "unsubscribe linux-laptop" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane