On Sun, Mar 23, 2014 at 19:45, Miod Vallat wrote:
> The current logic is borrowed from FreeBSD, about 15 years ago, and goes
> like this:
> - for MADV_RANDOM areas, do not try to fault any other page.
> - for MADV_NORMAL areas, try to fault the 3 preceding pages and the 4
> following pages.
> - for MADV_SEQUENTIAL areas (which do not exist unless explicit
> madvise() calls are performed), try to fault the 8 preceding pages and
> the 7 following pages.
Back faulting, particularly in the case of sequential advice, seems
strange. But we can fiddle with that later.
> + if (uvmexp.pageshift <= 14) {
> + npages = 1 << (14 - uvmexp.pageshift);
> + KASSERT(npages <= UVM_MAXRANGE / 2);
> +
> + uvmadvice[UVM_ADV_NORMAL].nforw = npages;
> + uvmadvice[UVM_ADV_NORMAL].nback = npages - 1;
> + }
> +
> + if (uvmexp.pageshift <= 15) {
> + npages = 1 << (15 - uvmexp.pageshift);
> + KASSERT(npages <= UVM_MAXRANGE / 2);
> +
> + uvmadvice[UVM_ADV_SEQUENTIAL].nforw = npages - 1;
> + uvmadvice[UVM_ADV_SEQUENTIAL].nback = npages;
> + }
> +}
These calculations strike me as weird. Also, I think there's a bug.
nback should always be the -1 value, right? Oh, wait, it was like
that. Even stranger.
The following would be much more clear to me. The point is to fault in
a constant amount of data in bytes, no? Make that explicit.
uvmadvice[NORMAL].nforw = 16384 / PAGESIZE;
uvmadvice[NORMAL].nback = 12288 / PAGESIZE;
uvmadvice[SEQ].nforw = 32768 / PAGESIZE;
uvmadvice[SEQ].nback = 28672 / PAGESIZE;
That replicates the existing code, more or less.