Add flag VM_ALLOC_NOWAIT for vm_page_grab() that prevents sleeping and

allows the function to fail.

Reviewed by:	kib, alc
Sponsored by:	Nginx, Inc.
This commit is contained in:
Gleb Smirnoff 2014-12-22 09:02:21 +00:00
parent 6ee80f259c
commit e3ed82bcf7
2 changed files with 5 additions and 0 deletions

View File

@ -2711,6 +2711,8 @@ retrylookup:
sleep = (allocflags & VM_ALLOC_IGN_SBUSY) != 0 ?
vm_page_xbusied(m) : vm_page_busied(m);
if (sleep) {
if ((allocflags & VM_ALLOC_NOWAIT) != 0)
return (NULL);
/*
* Reference the page before unlocking and
* sleeping so that the page daemon is less
@ -2738,6 +2740,8 @@ retrylookup:
}
m = vm_page_alloc(object, pindex, allocflags);
if (m == NULL) {
if ((allocflags & VM_ALLOC_NOWAIT) != 0)
return (NULL);
VM_OBJECT_WUNLOCK(object);
VM_WAIT;
VM_OBJECT_WLOCK(object);

View File

@ -405,6 +405,7 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
#define VM_ALLOC_IGN_SBUSY 0x1000 /* (g) Ignore shared busy flag */
#define VM_ALLOC_NODUMP 0x2000 /* (ag) don't include in dump */
#define VM_ALLOC_SBUSY 0x4000 /* (acg) Shared busy the page */
#define VM_ALLOC_NOWAIT 0x8000 /* (g) Do not sleep, return NULL */
#define VM_ALLOC_COUNT_SHIFT 16
#define VM_ALLOC_COUNT(count) ((count) << VM_ALLOC_COUNT_SHIFT)