Avoid unnecessary object locking in vm_page_grab_pages_unlocked().
We were needlessly acquiring the object lock to call vm_page_grab_pages() even when all of the requested pages were looked up locklessly. Fix that, stop testing for count == 0 in vm_page_grab_pages(), and add assertions to help catch this kind of mistake. Reported by: cem Reviewed by: alc, cem, dougm, jeff Differential Revision: https://reviews.freebsd.org/D26304
This commit is contained in:
parent
ac07cdf8f7
commit
a2d704d19f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365275
@ -4724,12 +4724,11 @@ vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
|||||||
VM_OBJECT_ASSERT_WLOCKED(object);
|
VM_OBJECT_ASSERT_WLOCKED(object);
|
||||||
KASSERT(((u_int)allocflags >> VM_ALLOC_COUNT_SHIFT) == 0,
|
KASSERT(((u_int)allocflags >> VM_ALLOC_COUNT_SHIFT) == 0,
|
||||||
("vm_page_grap_pages: VM_ALLOC_COUNT() is not allowed"));
|
("vm_page_grap_pages: VM_ALLOC_COUNT() is not allowed"));
|
||||||
|
KASSERT(count > 0,
|
||||||
|
("vm_page_grab_pages: invalid page count %d", count));
|
||||||
vm_page_grab_check(allocflags);
|
vm_page_grab_check(allocflags);
|
||||||
|
|
||||||
pflags = vm_page_grab_pflags(allocflags);
|
pflags = vm_page_grab_pflags(allocflags);
|
||||||
if (count == 0)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
retrylookup:
|
retrylookup:
|
||||||
m = vm_radix_lookup_le(&object->rtree, pindex + i);
|
m = vm_radix_lookup_le(&object->rtree, pindex + i);
|
||||||
@ -4783,6 +4782,8 @@ vm_page_grab_pages_unlocked(vm_object_t object, vm_pindex_t pindex,
|
|||||||
int flags;
|
int flags;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
KASSERT(count > 0,
|
||||||
|
("vm_page_grab_pages_unlocked: invalid page count %d", count));
|
||||||
vm_page_grab_check(allocflags);
|
vm_page_grab_check(allocflags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4805,7 +4806,7 @@ vm_page_grab_pages_unlocked(vm_object_t object, vm_pindex_t pindex,
|
|||||||
vm_page_grab_release(m, allocflags);
|
vm_page_grab_release(m, allocflags);
|
||||||
pred = ma[i] = m;
|
pred = ma[i] = m;
|
||||||
}
|
}
|
||||||
if ((allocflags & VM_ALLOC_NOCREAT) != 0)
|
if (i == count || (allocflags & VM_ALLOC_NOCREAT) != 0)
|
||||||
return (i);
|
return (i);
|
||||||
count -= i;
|
count -= i;
|
||||||
VM_OBJECT_WLOCK(object);
|
VM_OBJECT_WLOCK(object);
|
||||||
|
Loading…
Reference in New Issue
Block a user