pg = uvm_pagealloc_pgfl(&uvm.page_free[free_list], try1, try2, &color); if (pg != NULL)
pgfl = &uvm.page_free[free_list]; if ((pg = TAILQ_FIRST((freeq = &pgfl->pgfl_queues[try1]))) != NULL || (pg = TAILQ_FIRST((freeq = &pgfl->pgfl_queues[try2]))) != NULL)
uvm_pagealloc_strat(obj, off, anon, flags, strat, free_list)	struct uvm_object *obj;	voff_t off;	int flags;	struct vm_anon *anon;	int strat, free_list;{	int lcv, try1, try2, s, zeroit = 0, color;	struct vm_page *pg;	boolean_t use_reserve;	KASSERT(obj == NULL || anon == NULL);	KASSERT(off == trunc_page(off));	LOCK_ASSERT(obj == NULL || simple_lock_held(&obj->vmobjlock));	LOCK_ASSERT(anon == NULL || simple_lock_held(&anon->an_lock));	s = uvm_lock_fpageq();	/*	 * This implements a global round-robin page coloring	 * algorithm.	 *	 * XXXJRT: Should we make the `nextcolor' per-cpu?	 * XXXJRT: What about virtually-indexed caches?	 */	color = uvm.page_free_nextcolor;	/*	 * check to see if we need to generate some free pages waking	 * the pagedaemon.	 */	UVM_KICK_PDAEMON();	/*	 * fail if any of these conditions is true:	 * [1]  there really are no free pages, or	 * [2]  only kernel "reserved" pages remain and	 *        the page isn't being allocated to a kernel object.	 * [3]  only pagedaemon "reserved" pages remain and	 *        the requestor isn't the pagedaemon.	 */	use_reserve = (flags & UVM_PGA_USERESERVE) ||		(obj && UVM_OBJ_IS_KERN_OBJECT(obj));	if ((uvmexp.free <= uvmexp.reserve_kernel && !use_reserve) ||	    (uvmexp.free <= uvmexp.reserve_pagedaemon &&	     !(use_reserve && (curproc == uvm.pagedaemon_proc ||				curproc == syncerproc))))		goto fail;#if PGFL_NQUEUES != 2#error uvm_pagealloc_strat needs to be updated#endif	/*	 * If we want a zero'd page, try the ZEROS queue first, otherwise	 * we try the UNKNOWN queue first.	 */	if (flags & UVM_PGA_ZERO) {		try1 = PGFL_ZEROS;		try2 = PGFL_UNKNOWN;	} else {		try1 = PGFL_UNKNOWN;		try2 = PGFL_ZEROS;	} again:	switch (strat) {	case UVM_PGA_STRAT_NORMAL:		/* Check all freelists in descending priority order. */		for (lcv = 0; lcv < VM_NFREELIST; lcv++) {			pg = uvm_pagealloc_pgfl(&uvm.page_free[lcv],			    try1, try2, &color);			if (pg != NULL)				goto gotit;		}		/* No pages free! */		goto fail;	case UVM_PGA_STRAT_ONLY:	case UVM_PGA_STRAT_FALLBACK:		/* Attempt to allocate from the specified free list. */		KASSERT(free_list >= 0 && free_list < VM_NFREELIST);		pg = uvm_pagealloc_pgfl(&uvm.page_free[free_list],		    try1, try2, &color);		if (pg != NULL)			goto gotit;		/* Fall back, if possible. */		if (strat == UVM_PGA_STRAT_FALLBACK) {			strat = UVM_PGA_STRAT_NORMAL;			goto again;		}		/* No pages free! */		goto fail;	default:		panic("uvm_pagealloc_strat: bad strat %d", strat);		/* NOTREACHED */	} gotit:	/*	 * We now know which color we actually allocated from; set	 * the next color accordingly.	 */	uvm.page_free_nextcolor = (color + 1) & uvmexp.colormask;	/*	 * update allocation statistics and remember if we have to	 * zero the page	 */	if (flags & UVM_PGA_ZERO) {		if (pg->flags & PG_ZERO) {			uvmexp.pga_zerohit++;			zeroit = 0;		} else {			uvmexp.pga_zeromiss++;			zeroit = 1;		}	}	uvm_unlock_fpageq(s);		/* unlock free page queue */	pg->offset = off;	pg->uobject = obj;	pg->uanon = anon;	pg->flags = PG_BUSY|PG_CLEAN|PG_FAKE;	pg->version++;	if (anon) {		anon->u.an_page = pg;		pg->pqflags = PQ_ANON;		uvmexp.anonpages++;	} else {		if (obj)			uvm_pageinsert(pg);		pg->pqflags = 0;	}#if defined(UVM_PAGE_TRKOWN)	pg->owner_tag = NULL;#endif	UVM_PAGE_OWN(pg, "new alloc");	if (flags & UVM_PGA_ZERO) {		/*		 * A zero'd page is not clean.  If we got a page not already		 * zero'd, then we have to zero it ourselves.		 */		pg->flags &= ~PG_CLEAN;		if (zeroit)			pmap_zero_page(VM_PAGE_TO_PHYS(pg));	}	return(pg); fail:	uvm_unlock_fpageq(s);	return (NULL);}