Modify vm_page_grab_pages() to handle VM_ALLOC_NOWAIT.
This will allow its use in sendfile_swapin(). Reviewed by: alc, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D11942
This commit is contained in:
parent
6921451dab
commit
9df950b35d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=322405
@ -2746,7 +2746,7 @@ vfs_vmio_extend(struct buf *bp, int desiredpages, int size)
|
||||
* deadlocks once allocbuf() is called after
|
||||
* pages are vfs_busy_pages().
|
||||
*/
|
||||
vm_page_grab_pages(obj,
|
||||
(void)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,
|
||||
|
@ -1248,7 +1248,7 @@ pmap_pinit(pmap_t pm)
|
||||
CPU_ZERO(&pm->pm_active);
|
||||
|
||||
VM_OBJECT_WLOCK(pm->pm_tsb_obj);
|
||||
vm_page_grab_pages(pm->pm_tsb_obj, 0, VM_ALLOC_NORMAL |
|
||||
(void)vm_page_grab_pages(pm->pm_tsb_obj, 0, VM_ALLOC_NORMAL |
|
||||
VM_ALLOC_NOBUSY | VM_ALLOC_WIRED | VM_ALLOC_ZERO, ma, TSB_PAGES);
|
||||
VM_OBJECT_WUNLOCK(pm->pm_tsb_obj);
|
||||
for (i = 0; i < TSB_PAGES; i++)
|
||||
|
@ -391,7 +391,7 @@ vm_thread_new(struct thread *td, int pages)
|
||||
* page of stack.
|
||||
*/
|
||||
VM_OBJECT_WLOCK(ksobj);
|
||||
vm_page_grab_pages(ksobj, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY |
|
||||
(void)vm_page_grab_pages(ksobj, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY |
|
||||
VM_ALLOC_WIRED, ma, pages);
|
||||
for (i = 0; i < pages; i++)
|
||||
ma[i]->valid = VM_PAGE_BITS_ALL;
|
||||
@ -568,7 +568,7 @@ vm_thread_swapin(struct thread *td)
|
||||
pages = td->td_kstack_pages;
|
||||
ksobj = td->td_kstack_obj;
|
||||
VM_OBJECT_WLOCK(ksobj);
|
||||
vm_page_grab_pages(ksobj, 0, VM_ALLOC_NORMAL | VM_ALLOC_WIRED, ma,
|
||||
(void)vm_page_grab_pages(ksobj, 0, VM_ALLOC_NORMAL | VM_ALLOC_WIRED, ma,
|
||||
pages);
|
||||
for (int i = 0; i < pages;) {
|
||||
int j, a, count, rv;
|
||||
|
@ -3173,13 +3173,15 @@ vm_page_grab(vm_object_t object, vm_pindex_t pindex, int allocflags)
|
||||
* optional allocation flags:
|
||||
* VM_ALLOC_IGN_SBUSY do not sleep on soft busy pages
|
||||
* VM_ALLOC_NOBUSY do not exclusive busy the page
|
||||
* VM_ALLOC_NOWAIT do not sleep
|
||||
* VM_ALLOC_SBUSY set page to sbusy state
|
||||
* VM_ALLOC_WIRED wire the pages
|
||||
* VM_ALLOC_ZERO zero and validate any invalid pages
|
||||
*
|
||||
* This routine may sleep.
|
||||
* If VM_ALLOC_NOWAIT is not specified, this routine may sleep. Otherwise, it
|
||||
* may return a partial prefix of the requested range.
|
||||
*/
|
||||
void
|
||||
int
|
||||
vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
||||
vm_page_t *ma, int count)
|
||||
{
|
||||
@ -3197,7 +3199,7 @@ vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
||||
(allocflags & VM_ALLOC_IGN_SBUSY) != 0,
|
||||
("vm_page_grab_pages: VM_ALLOC_SBUSY/IGN_SBUSY mismatch"));
|
||||
if (count == 0)
|
||||
return;
|
||||
return (0);
|
||||
i = 0;
|
||||
retrylookup:
|
||||
m = vm_page_lookup(object, pindex + i);
|
||||
@ -3206,6 +3208,8 @@ vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
||||
sleep = (allocflags & VM_ALLOC_IGN_SBUSY) != 0 ?
|
||||
vm_page_xbusied(m) : vm_page_busied(m);
|
||||
if (sleep) {
|
||||
if ((allocflags & VM_ALLOC_NOWAIT) != 0)
|
||||
break;
|
||||
/*
|
||||
* Reference the page before unlocking and
|
||||
* sleeping so that the page daemon is less
|
||||
@ -3233,6 +3237,8 @@ vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
||||
m = vm_page_alloc(object, pindex + i, (allocflags &
|
||||
~VM_ALLOC_IGN_SBUSY) | VM_ALLOC_COUNT(count - i));
|
||||
if (m == NULL) {
|
||||
if ((allocflags & VM_ALLOC_NOWAIT) != 0)
|
||||
break;
|
||||
VM_OBJECT_WUNLOCK(object);
|
||||
VM_WAIT;
|
||||
VM_OBJECT_WLOCK(object);
|
||||
@ -3247,6 +3253,7 @@ vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
||||
ma[i] = m;
|
||||
m = vm_page_next(m);
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -419,7 +419,7 @@ vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa);
|
||||
#define VM_ALLOC_IGN_SBUSY 0x1000 /* (gp) Ignore shared busy flag */
|
||||
#define VM_ALLOC_NODUMP 0x2000 /* (ag) don't include in dump */
|
||||
#define VM_ALLOC_SBUSY 0x4000 /* (acgp) Shared busy the page */
|
||||
#define VM_ALLOC_NOWAIT 0x8000 /* (g) Do not sleep, return NULL */
|
||||
#define VM_ALLOC_NOWAIT 0x8000 /* (gp) Do not sleep */
|
||||
#define VM_ALLOC_COUNT_SHIFT 16
|
||||
#define VM_ALLOC_COUNT(count) ((count) << VM_ALLOC_COUNT_SHIFT)
|
||||
|
||||
@ -470,7 +470,7 @@ vm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,
|
||||
vm_paddr_t boundary, vm_memattr_t memattr);
|
||||
vm_page_t vm_page_alloc_freelist(int, int);
|
||||
vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int);
|
||||
void vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
||||
int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,
|
||||
vm_page_t *ma, int count);
|
||||
int vm_page_try_to_free (vm_page_t);
|
||||
void vm_page_deactivate (vm_page_t);
|
||||
|
Loading…
Reference in New Issue
Block a user