FreeBSD/sys/dev/drm2/ttm/ttm_page_alloc.c
/* Put all pages in pages list to correct pool to wait for reuse */
Put all pages in pages list to correct pool to wait for reuse
Put all pages in pages list to correct pool to wait for reuse
static void ttm_put_pages(vm_page_t *pages, unsigned npages, int flags,
			  enum ttm_caching_state cstate)
{
	struct ttm_page_pool *pool = ttm_get_pool(flags, cstate);
	unsigned i;
	if (pool == NULL) {
		for (i = 0; i < npages; i++) {
			if (pages[i]) {
				ttm_vm_page_free(pages[i]);
				pages[i] = NULL;
			}
		}
		return;
	}
	mtx_lock(&pool->lock);
	for (i = 0; i < npages; i++) {
		if (pages[i]) {
			TAILQ_INSERT_TAIL(&pool->list, pages[i], plinks.q);
			pages[i] = NULL;
			pool->npages++;
		}
	}
	npages = 0;
	if (pool->npages > _manager->options.max_size) {
		npages = pool->npages - _manager->options.max_size;
		if (npages < NUM_PAGES_TO_ALLOC)
			npages = NUM_PAGES_TO_ALLOC;
	}
	mtx_unlock(&pool->lock);
	if (npages)
		ttm_page_pool_free(pool, npages);
}
static void ttm_put_pages ( vm_page_t * pages , unsigned npages , int flags , enum ttm_caching_state cstate ) { struct ttm_page_pool * pool = ttm_get_pool ( flags , cstate ) ; unsigned i ; if ( pool == NULL ) { for ( i = 0 ; i < npages ; i ++ ) { if ( pages [ i ] ) { ttm_vm_page_free ( pages [ i ] ) ; pages [ i ] = NULL ; } } return ; } mtx_lock ( & pool -> lock ) ; for ( i = 0 ; i < npages ; i ++ ) { if ( pages [ i ] ) { TAILQ_INSERT_TAIL ( & pool -> list , pages [ i ] , plinks . q ) ; pages [ i ] = NULL ; pool -> npages ++ ; } } npages = 0 ; if ( pool -> npages > _manager -> options . max_size ) { npages = pool -> npages - _manager -> options . max_size ; if ( npages < NUM_PAGES_TO_ALLOC ) npages = NUM_PAGES_TO_ALLOC ; } mtx_unlock ( & pool -> lock ) ; if ( npages ) ttm_page_pool_free ( pool , npages ) ; }
Put all pages in pages list to correct pool to wait for reuse
Put all pages in pages list to correct pool to wait for reuse
/* No pool for this memory type so free the pages */ /* Check that we don't go over the pool limit */ /* free at least NUM_PAGES_TO_ALLOC number of pages
		 * to reduce calls to set_memory_wb */