Re: Fairness in love and swapping

Michael O'Reilly (
27 Feb 1998 10:56:01 +0800

"Stephen C. Tweedie" <> writes:
> > What we really need is that some mechanism that actually determines
> > in the first and last case that the system is thrashing like hell,
> > and that "swapping" (as opposed to paging) is becoming a required
> > strategy.
> True. Any takers for this? :)

That should be fairly easy. A stab. If the MIN(page in rate, page out
rate) over the last 30 seconds(?) is greater than X, and there are
more than 2(?) processes involved, then start swapping (instead of

Taking a relatively long baseline means that you need a lot of paging
to trigger. Taking the min of in/out means that it isn't just a
growing process, but something with a working set that's larger than
available ram. Taking the dispertion means that you ignore just one
process running out of ram.


The tricky bit there is working out how many processes are
involved. Maybe something as simple as a circular log N elements long
that records the last PID associated with the last page out/in.

This is cheap for the page case, and then you can regularly poll the
rates to check.

int pid_log[N];
int pid_log_next;


pid_log[pid_log_next] = pid;
pid_log_next = (pid_log_next+1)&(N-1);



age page rates;
dispertion = number of different PID's in log;

if MIN(page_rate_in, page_rate_out) > blah &&
dispertion > 3) {
swapping = 1;
} else {
swapping = 0;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to