sys/vm/vm_page.c
/*
 * vm_page_cache
 *
 * Put the specified page onto the page cache queue (if appropriate).
 *
 * The page must be busy, and this routine will release the busy and
 * possibly even free the page.
 */
vm_page_cache
Put the specified page onto the page cache queue (if appropriate).

The page must be busy, and this routine will release the busy and
possibly even free the page.
vm_page_cache Put the specified page onto the page cache queue ( if appropriate ) . The page must be busy and this routine will release the busy and possibly even free the page .
void
vm_page_cache(vm_page_t m)
{
	if ((m->flags & (PG_UNQUEUED | PG_NEED_COMMIT | PG_FICTITIOUS)) ||
	    (m->busy_count & PBUSY_MASK) ||
	    m->wire_count || m->hold_count) {
		vm_page_wakeup(m);
		return;
	}
	if ((m->queue - m->pc) == PQ_CACHE) {
		if (m->flags & (PG_MAPPED | PG_WRITEABLE))
			pmap_mapped_sync(m);
		KKASSERT((m->flags & PG_MAPPED) == 0);
		vm_page_wakeup(m);
		return;
	}
#if 0
	if (m->dirty) {
		panic("vm_page_cache: caching a dirty page, pindex: %ld",
			(long)m->pindex);
	}
#endif
	vm_page_protect(m, VM_PROT_NONE);
	pmap_mapped_sync(m);
	if ((m->flags & (PG_UNQUEUED | PG_MAPPED)) ||
	    (m->busy_count & PBUSY_MASK) ||
	    m->wire_count || m->hold_count) {
		vm_page_wakeup(m);
	} else if (m->dirty || (m->flags & PG_NEED_COMMIT)) {
		vm_page_deactivate(m);
		vm_page_wakeup(m);
	} else {
		_vm_page_and_queue_spin_lock(m);
		_vm_page_rem_queue_spinlocked(m);
		_vm_page_add_queue_spinlocked(m, PQ_CACHE + m->pc, 0);
		_vm_page_and_queue_spin_unlock(m);
		vm_page_wakeup(m);
		vm_page_free_wakeup();
	}
}
void vm_page_cache ( vm_page_t m ) { if ( ( m -> flags & ( PG_UNQUEUED | PG_NEED_COMMIT | PG_FICTITIOUS ) ) || ( m -> busy_count & PBUSY_MASK ) || m -> wire_count || m -> hold_count ) { vm_page_wakeup ( m ) ; return ; } if ( ( m -> queue - m -> pc ) == PQ_CACHE ) { if ( m -> flags & ( PG_MAPPED | PG_WRITEABLE ) ) pmap_mapped_sync ( m ) ; KKASSERT ( ( m -> flags & PG_MAPPED ) == 0 ) ; vm_page_wakeup ( m ) ; return ; } #if 0 if ( m -> dirty ) { panic ( " " , ( long ) m -> pindex ) ; } #endif vm_page_protect ( m , VM_PROT_NONE ) ; pmap_mapped_sync ( m ) ; if ( ( m -> flags & ( PG_UNQUEUED | PG_MAPPED ) ) || ( m -> busy_count & PBUSY_MASK ) || m -> wire_count || m -> hold_count ) { vm_page_wakeup ( m ) ; } else if ( m -> dirty || ( m -> flags & PG_NEED_COMMIT ) ) { vm_page_deactivate ( m ) ; vm_page_wakeup ( m ) ; } else { _vm_page_and_queue_spin_lock ( m ) ; _vm_page_rem_queue_spinlocked ( m ) ; _vm_page_add_queue_spinlocked ( m , PQ_CACHE + m -> pc , 0 ) ; _vm_page_and_queue_spin_unlock ( m ) ; vm_page_wakeup ( m ) ; vm_page_free_wakeup ( ) ; } }
vm_page_cache
 Put the specified page onto the page cache queue (if appropriate).
vm_page_cache Put the specified page onto the page cache queue ( if appropriate ) .
/*
	 * Not suitable for the cache
	 */ /*
	 * Already in the cache (and thus not mapped)
	 */ /*
	 * REMOVED - it is possible for dirty to get set at any time as
	 *	     long as the page is still mapped and writeable.
	 *
	 * Caller is required to test m->dirty, but note that the act of
	 * removing the page from its maps can cause it to become dirty
	 * on an SMP system due to another cpu running in usermode.
	 */ /*
	 * Remove all pmaps and indicate that the page is not
	 * writeable or mapped.  Our vm_page_protect() call may
	 * have blocked (especially w/ VM_PROT_NONE), so recheck
	 * everything.
	 */