Hi,

I've noticed some strange and unneeded CPU switching
lately (who hasn't) and have come up with a simple
fix.

It consists of replacing these lines (at 315 in sched.c):

                /* Give a largish advantage to the same processor... */
                /* (this is equivalent to penalizing other processors) */
                if (p->processor == this_cpu)
                        weight += PROC_CHANGE_PENALTY;

With:
                if (p->processor != this_cpu) {
                        weight -= PROC_CHANGE_PENALTY;
                        return weight;
                }

It works because now the weight value for processes on other
CPUs can drop below 0 so the process on this CPU will remain
here even if it's timeslice is over. The reason it didn't work
before is that the 'local' process didn't get it's bonus when
it's time slice was over, effectively abolishing the CPU change
penalty every DEF_PRIORITY/smp_num_cpus...

The return is there so we don't do the weight += p->priority
trick (which would undoubtedly return us to fast-switching
behaviour).

No diff this time since I'm too lazy to check out a clean
kernel tree and I have to install Linux to two headless
machines (using a headless, PPP-using boot-floppy).

cheers,

Rik -- the flu hits, the flu hits, the flu hits -- MORE
+-------------------------------------------------------------------+
| Linux memory management tour guide.        [EMAIL PROTECTED] |
| Scouting Vries cubscout leader.      http://www.phys.uu.nl/~riel/ |
+-------------------------------------------------------------------+


-
Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/mentre/smp-faq/
To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]

Reply via email to