Page MenuHomeFreeBSD

vm_page_grab_pages: fetch page ranges
ClosedPublic

Authored by dougm on Thu, May 8, 6:23 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 28, 6:42 PM
Unknown Object (File)
Wed, May 28, 6:05 PM
Unknown Object (File)
Tue, May 27, 7:59 PM
Unknown Object (File)
Tue, May 13, 7:43 AM
Unknown Object (File)
Mon, May 12, 2:52 PM
Unknown Object (File)
Mon, May 12, 2:43 PM
Unknown Object (File)
Mon, May 12, 8:53 AM
Unknown Object (File)
Fri, May 9, 3:56 AM
Subscribers

Details

Summary

Define an iterator based function for reading a range of consecutive, non-NULL leaves from a pctrie. Adapt it to vm pages. Use it in vm_page_grab_pages to fetch more than one page at a time.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dougm requested review of this revision.Thu, May 8, 6:23 AM
dougm created this revision.
markj added inline comments.
sys/vm/vm_page.c
5199

Not directly related to this diff, but I believe this zeroing is redundant when the page is freshly allocated. vm_page_alloc_iter(VM_ALLOC_ZERO) will have already zeroed it.

Can we exploit this to simplify control flow a bit? I wonder if the loop body could be written like this:

ahead = vm_radix_iter_lookup_range(&pages, pindex + i, &ma[i], count - i);
if (ahead > 0) {
    for (int j = 0; j < ahead; j++) {
        m = ma[i + j];
        if (!vm_page_tryacquire(...)) {
            ...
        }
        if (vm_page_none_valid(m) && (allocflags & VM_ALLOC_ZERO) != 0) {
            pmap_zero_page(m);
            vm_page_valid(m);
        }
        vm_page_grab_release(m, allocflags);
    }
    i += ahead;
} else {
    if ((allocflags & VM_ALLOC_NOCREAT) != 0)
        break;
    ...
    vm_page_grab_release(m, allocflags);
    i++;
}
This revision is now accepted and ready to land.Thu, May 8, 2:20 PM
sys/vm/vm_page.c
5199

Hrm, sorry, I misremembered. Apparently only the noobj flavour of vm_page_alloc() handles zeroing, so my comment is invalid.

sys/vm/vm_page.c
2142

This goto should no longer exist. It is a leftover from VM_ALLOC_NOOBJ that should have been eliminated when the _noobj functions were introduced. vm_page_alloc_contig*() has this right.

sys/vm/vm_page.c
3556–3575

If this function is being inlined, then I am tempted to suggest that the iterator be passed in and only reset in cases where we actually release the object lock and sleep.

sys/vm/vm_page.c
5189–5192

I would recommend a comment here saying that vm_page_alloc_iter handled the reset.

sys/vm/vm_page.c
2407

Isn't this assignment now pointless?

This revision was automatically updated to reflect the committed changes.