FreeBSD/sys/dev/drm2/ttm/ttm_page_alloc.c
/**
 * Fill the given pool if there aren't enough pages and the requested number of
 * pages is small.
 */
Fill the given pool if there aren't enough pages and the requested number of
pages is small.
Fill the given pool if there aren ' t enough pages and the requested number of pages is small .
static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool,
    int ttm_flags, enum ttm_caching_state cstate, unsigned count)
{
	vm_page_t p;
	int r;
	unsigned cpages = 0;
	if (pool->fill_lock)
		return;
	pool->fill_lock = true;
	if (count < _manager->options.small
		&& count > pool->npages) {
		struct pglist new_pages;
		unsigned alloc_size = _manager->options.alloc_size;
		mtx_unlock(&pool->lock);
		TAILQ_INIT(&new_pages);
		r = ttm_alloc_new_pages(&new_pages, pool->ttm_page_alloc_flags,
		    ttm_flags, cstate, alloc_size);
		mtx_lock(&pool->lock);
		if (!r) {
			TAILQ_CONCAT(&pool->list, &new_pages, plinks.q);
			++pool->nrefills;
			pool->npages += alloc_size;
		} else {
			printf("[TTM] Failed to fill pool (%p)\n", pool);
			TAILQ_FOREACH(p, &pool->list, plinks.q) {
				++cpages;
			}
			TAILQ_CONCAT(&pool->list, &new_pages, plinks.q);
			pool->npages += cpages;
		}
	}
	pool->fill_lock = false;
}
static void ttm_page_pool_fill_locked ( struct ttm_page_pool * pool , int ttm_flags , enum ttm_caching_state cstate , unsigned count ) { vm_page_t p ; int r ; unsigned cpages = 0 ; if ( pool -> fill_lock ) return ; pool -> fill_lock = true ; if ( count < _manager -> options . small && count > pool -> npages ) { struct pglist new_pages ; unsigned alloc_size = _manager -> options . alloc_size ; mtx_unlock ( & pool -> lock ) ; TAILQ_INIT ( & new_pages ) ; r = ttm_alloc_new_pages ( & new_pages , pool -> ttm_page_alloc_flags , ttm_flags , cstate , alloc_size ) ; mtx_lock ( & pool -> lock ) ; if ( ! r ) { TAILQ_CONCAT ( & pool -> list , & new_pages , plinks . q ) ; ++ pool -> nrefills ; pool -> npages += alloc_size ; } else { printf ( " \n " , pool ) ; TAILQ_FOREACH ( p , & pool -> list , plinks . q ) { ++ cpages ; } TAILQ_CONCAT ( & pool -> list , & new_pages , plinks . q ) ; pool -> npages += cpages ; } } pool -> fill_lock = false ; }
Fill the given pool if there aren't enough pages and the requested number of
 pages is small.
Fill the given pool if there aren ' t enough pages and the requested number of pages is small .
/**
	 * Only allow one pool fill operation at a time.
	 * If pool doesn't have enough pages for the allocation new pages are
	 * allocated from outside of pool.
	 */ /* If allocation request is small and there are not enough
	 * pages in a pool we fill the pool up first. */ /**
		 * Can't change page caching if in irqsave context. We have to
		 * drop the pool->lock.
		 */ /* If we have any pages left put them to the pool. */