Fix to swap_out()

From: Espiritu, Civ Kenneth (EspiritK@mcguire.af.mil)
Date: Tue Apr 18 2000 - 07:37:24 EST


Hi,

I'm taking a little break from Redcode (Corewar) programming and
decided to look a little at Linux's internals.

>From a BSD guru:
     * To locate pages to swap out, it takes a pass through the task list.
       Ostensibly it locates the task with the largest RSS to then try to
       swap pages out from rather then select pages that are not in use.
       From my read of the code, it also botches this badly.

I also looked at the code and it didn't look too nice. The offending
line is 365, where we pick the largest Resident Size Set (RSS) to swap
first.

A fix would be to pick tasks to page which don't page fault alot by
calculating a page fault rate over the task's lifespan. If the system
inadvertently pages something that it shouldn't there is feedback
from p->maj_flt which will make the task less likely to be swapped
out in future swap attempts.

An optimization to the fix would be to remove the +1 in the denominator
 if p->maj_flt was initialized to 1 when the task is first created (I think
in
/kernel/fork.c).

What are your thoughts on this fix?

Ken Espiritu

from /mm/vmscan.c (2.3.99-pre5)

363 /* Refresh swap_cnt? */
364 if (assign == 1)
365 mm->swap_cnt = mm->rss;
366 if (mm->swap_cnt > max_cnt) {
367 max_cnt = mm->swap_cnt;
368 best = mm;
369 pid = p->pid;
370 }

Fix:
365 mm->swap_cnt =
(jiffies-p->start_time)/(p->maj_flt+1);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 23 2000 - 21:00:13 EST