Subject: Re: Strange VM behaviour
To: None <thorpej@zembu.com>
From: Lennart Augustsson <lennart@mail.augustsson.net>
List: tech-kern
Date: 02/20/2001 01:17:55
This is a multi-part message in MIME format.
--------------7AC39D1E7C5650320A904733
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Jason R Thorpe wrote:

> On Sat, Feb 17, 2001 at 10:12:50AM -0500, Lennart Augustsson wrote:
>
>  > every time:
>  > extent_free
>  > uvm_swap_free
>  > uvm_anon_dropswap
>
> It would be nice to put a breakpoint at uvm_anon_dropswap and see if it's
> getting into extent_free many times, or if it's really looping in extent_free.

I did a little more than that.  I put in some calls to microtime() in amap_wipeout()
and I also counted the number of calls to uvm_swap_free() which does one
call to extent_free().  With the test program below the time to do an amap_wipeout()
gets larger the longer the program has run.  If I let my test program run for a
minute or so it takes about 2.5s to do the amap_wipeout(), but the number of calls
to uvm_swap_free() is pretty much the same.  Here are some figures:

amap_wipeout: 1521523 usec, 28123 calls
amap_wipeout: 2528250 usec, 28903 calls


The test program allocates a large chunk of memory (about 115M running
single user on my 128M machine).  It has a "window" of 60M which it slowly
slides up and down the allocated memory.  Within that window it does pretty
random accesses all over.  If you want to use it you should adjust the SIZE
value so the there will be about 5M of swapping (you'll understand what I mean
when you run it).  Let the program run for a minute or so and then just hit ^C.

(I must say that the behaviour of the paging activity for this program surprises
in general.)

    -- Lennart


--------------7AC39D1E7C5650320A904733
Content-Type: text/plain; charset=us-ascii;
 name="big.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="big.c"

#include <stdio.h>
#include <stdlib.h>


#define M (1024*1024)
#define SIZE (115*M)
#define WINDOW (60*M)

#define LOOP 4
#define ILOOP 100000
#define INCR 10007

int
main(int argc, char **argv)
{
	char *mem = malloc(SIZE);
	int i, j, k, a;

	if (mem == 0) {
		printf("no memory\n");
		exit(1);
	}
	a = 0;
	for (i = 0; i < LOOP; i++) {
		for (j = 0; j < SIZE - WINDOW; j += M) {
			printf("at %d M\n", j / M);
			for (k = 0; k < ILOOP; k++) {
				mem[j+a]++;
				a += INCR;
				if (a > WINDOW)
					a -= WINDOW;
			}
		}
		for (; j >= 0; j -= M) {
			printf("at %d M\n", j / M);
			for (k = 0; k < ILOOP; k++) {
				mem[j+a]++;
				a += INCR;
				if (a > WINDOW)
					a -= WINDOW;
			}
		}
	}
	printf("done\n");
}

--------------7AC39D1E7C5650320A904733--