Пример #1
0
/*
 * lpage_evict: Evict an lpage from physical memory.
 *
 * Synchronization: lock the lpage while accessing it. We come here
 * from the coremap and should have the global paging lock and should 
 * have pinned the physical page (see coremap.c:do_evict()). 
 * This is why we must not hold lpage locks while entering the coremap code.
 *
 * Similar to lpage_fault, the lpage lock should not be held while performing
 * the page out (if one is needed).
 */
void
lpage_evict(struct lpage *lp)
{
	paddr_t pa;
    off_t swapaddr;
    
	KASSERT(lock_do_i_hold(global_paging_lock));
	KASSERT(lp != NULL);
    lpage_lock(lp);
    swapaddr = lp->lp_swapaddr;
    pa = lp->lp_paddr & PAGE_FRAME;
	KASSERT(pa != INVALID_PADDR);
	if (LP_ISDIRTY(lp)) {
		lpage_unlock(lp);
		LP_CLEAR(lp, LPF_DIRTY);
		swap_pageout(pa, swapaddr);
		lpage_lock(lp);
	}
    lp->lp_paddr = INVALID_PADDR;
    lpage_unlock(lp);
}
Пример #2
0
/*
 * lpage_evict: Evict an lpage from physical memory.
 *
 * Synchronization: lock the lpage while accessing it. We come here
 * from the coremap and should have the global paging lock and should 
 * have pinned the physical page (see coremap.c:do_evict()). 
 * This is why we must not hold lpage locks while entering the coremap code.
 *
 * Similar to lpage_fault, the lpage lock should not be held while performing
 * the page out (if one is needed).
 */
void
lpage_evict(struct lpage *lp)
{

	paddr_t physical_address;
	off_t swap_address;

	// Lock the lpage while accessing it.
	KASSERT(lp != NULL);
	lpage_lock(lp);

	// Obtain the physical & swap address'
	physical_address = lp->lp_paddr & PAGE_FRAME;
	swap_address = lp->lp_swapaddr;

	// If the page is stored in RAM memory...
	if (physical_address != INVALID_PADDR) {
		DEBUG(DB_VM, "lpage_evict: Moving page from paddr 0x%x to swapaddr 0x%llx\n", physical_address, swap_address);

		// If page is dirty..
		if (LP_ISDIRTY(lp)) {
			// Move page into swapspace.
			lpage_unlock(lp);
			swap_pageout(physical_address, swap_address);
		  	LP_CLEAR(lp, LPF_DIRTY);
		  	lpage_lock(lp);
		}

		// Remove page from physical memory.
		lp->lp_paddr = INVALID_PADDR;
		lpage_unlock(lp);

	}
	else {
		lpage_unlock(lp);
	}

}