diff options
author | Alan Cox <alc@FreeBSD.org> | 2017-08-09 04:23:04 +0000 |
---|---|---|
committer | Alan Cox <alc@FreeBSD.org> | 2017-08-09 04:23:04 +0000 |
commit | 5471caf6f18d41463535aa9a94df1dd575440990 (patch) | |
tree | 29b3f4c8aab7236b15725e53a281afdd1573d974 /sys/kern/vfs_bio.c | |
parent | 29a263df942976235d5d831fd919ef9d40e238d8 (diff) | |
download | src-5471caf6f18d41463535aa9a94df1dd575440990.tar.gz src-5471caf6f18d41463535aa9a94df1dd575440990.zip |
Introduce vm_page_grab_pages(), which is intended to replace loops calling
vm_page_grab() on consecutive page indices. Besides simplifying the code
in the caller, vm_page_grab_pages() allows for batching optimizations.
For example, the current implementation replaces calls to vm_page_lookup()
on consecutive page indices by cheaper calls to vm_page_next().
Reviewed by: kib, markj
Tested by: pho (an earlier version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D11926
Notes
Notes:
svn path=/head/; revision=322296
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r-- | sys/kern/vfs_bio.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 20069d566a25..cb376abbb098 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -2735,7 +2735,7 @@ vfs_vmio_extend(struct buf *bp, int desiredpages, int size) */ obj = bp->b_bufobj->bo_object; VM_OBJECT_WLOCK(obj); - while (bp->b_npages < desiredpages) { + if (bp->b_npages < desiredpages) { /* * We must allocate system pages since blocking * here could interfere with paging I/O, no @@ -2746,14 +2746,12 @@ vfs_vmio_extend(struct buf *bp, int desiredpages, int size) * deadlocks once allocbuf() is called after * pages are vfs_busy_pages(). */ - m = vm_page_grab(obj, OFF_TO_IDX(bp->b_offset) + bp->b_npages, - VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM | - VM_ALLOC_WIRED | VM_ALLOC_IGN_SBUSY | - VM_ALLOC_COUNT(desiredpages - bp->b_npages)); - if (m->valid == 0) - bp->b_flags &= ~B_CACHE; - bp->b_pages[bp->b_npages] = m; - ++bp->b_npages; + vm_page_grab_pages(obj, + OFF_TO_IDX(bp->b_offset) + bp->b_npages, + VM_ALLOC_SYSTEM | VM_ALLOC_IGN_SBUSY | + VM_ALLOC_NOBUSY | VM_ALLOC_WIRED, + &bp->b_pages[bp->b_npages], desiredpages - bp->b_npages); + bp->b_npages = desiredpages; } /* |