Lines Matching full:pages

36  * - Pool collects resently freed pages for reuse
38 * - doesn't track currently in use pages
55 * struct ttm_page_pool - Pool to reuse recently allocated uc/wc pages.
61 * @list: Pool of free uc/wc pages for fast reuse.
63 * @npages: Number of pages in pool.
96 * @free_interval: minimum number of jiffies between freeing pages from pool.
99 * some pages to free.
100 * @small_allocation: Limit in number of pages what is small allocation.
228 /* Convert kb to number of pages */
271 static int set_pages_array_wb(vm_page_t *pages, int addrinarray) in set_pages_array_wb() argument
277 pmap_page_set_memattr(pages[i], VM_MEMATTR_WRITE_BACK); in set_pages_array_wb()
282 static int set_pages_array_wc(vm_page_t *pages, int addrinarray) in set_pages_array_wc() argument
288 pmap_page_set_memattr(pages[i], VM_MEMATTR_WRITE_COMBINING); in set_pages_array_wc()
293 static int set_pages_array_uc(vm_page_t *pages, int addrinarray) in set_pages_array_uc() argument
299 pmap_page_set_memattr(pages[i], VM_MEMATTR_UNCACHEABLE); in set_pages_array_uc()
325 /* set memory back to wb and free the pages. */
326 static void ttm_pages_put(vm_page_t *pages, unsigned npages) in ttm_pages_put() argument
331 if (set_pages_array_wb(pages, npages)) in ttm_pages_put()
332 printf("[TTM] Failed to set %d pages to wb!\n", npages); in ttm_pages_put()
334 ttm_vm_page_free(pages[i]); in ttm_pages_put()
345 * Free pages from pool.
348 * number of pages in one go.
350 * @pool: to free the pages from
351 * @free_all: If set to true will free all pages in pool
377 /* remove range of pages from the pool */ in ttm_page_pool_free()
412 /* remove range of pages from the pool */ in ttm_page_pool_free()
430 /* Get good estimation how many pages are free in pools */
461 /* return estimated number of unused pages in pool */ in ttm_pool_mm_shrink()
478 static int ttm_set_pages_caching(vm_page_t *pages, in ttm_set_pages_caching() argument
485 r = set_pages_array_uc(pages, cpages); in ttm_set_pages_caching()
487 printf("[TTM] Failed to set %d pages to uc!\n", cpages); in ttm_set_pages_caching()
490 r = set_pages_array_wc(pages, cpages); in ttm_set_pages_caching()
492 printf("[TTM] Failed to set %d pages to wc!\n", cpages); in ttm_set_pages_caching()
501 * Free pages the pages that failed to change the caching state. If there is
502 * any pages that have changed their caching state already put them to the
505 static void ttm_handle_caching_state_failure(struct pglist *pages, in ttm_handle_caching_state_failure() argument
510 /* Failed pages have to be freed */ in ttm_handle_caching_state_failure()
512 TAILQ_REMOVE(pages, failed_pages[i], plinks.q); in ttm_handle_caching_state_failure()
518 * Allocate new pages with correct caching.
521 * pages returned in pages array.
523 static int ttm_alloc_new_pages(struct pglist *pages, int ttm_alloc_flags, in ttm_alloc_new_pages() argument
542 /* store already allocated pages in the pool after in ttm_alloc_new_pages()
548 ttm_handle_caching_state_failure(pages, in ttm_alloc_new_pages()
569 ttm_handle_caching_state_failure(pages, in ttm_alloc_new_pages()
578 TAILQ_INSERT_HEAD(pages, p, plinks.q); in ttm_alloc_new_pages()
584 ttm_handle_caching_state_failure(pages, in ttm_alloc_new_pages()
595 * Fill the given pool if there aren't enough pages and the requested number of
596 * pages is small.
606 * If pool doesn't have enough pages for the allocation new pages are in ttm_page_pool_fill_locked()
615 * pages in a pool we fill the pool up first. */ in ttm_page_pool_fill_locked()
638 /* If we have any pages left put them to the pool. */ in ttm_page_pool_fill_locked()
651 * Cut 'count' number of pages from the pool and put them on the return list.
653 * @return count of pages still required to fulfill the request.
656 struct pglist *pages, in ttm_page_pool_get_pages() argument
668 /* take all pages from the pool */ in ttm_page_pool_get_pages()
669 TAILQ_CONCAT(pages, &pool->list, plinks.q); in ttm_page_pool_get_pages()
677 TAILQ_INSERT_TAIL(pages, p, plinks.q); in ttm_page_pool_get_pages()
686 /* Put all pages in pages list to correct pool to wait for reuse */
687 static void ttm_put_pages(vm_page_t *pages, unsigned npages, int flags, in ttm_put_pages() argument
694 /* No pool for this memory type so free the pages */ in ttm_put_pages()
696 if (pages[i]) { in ttm_put_pages()
697 ttm_vm_page_free(pages[i]); in ttm_put_pages()
698 pages[i] = NULL; in ttm_put_pages()
706 if (pages[i]) { in ttm_put_pages()
707 TAILQ_INSERT_TAIL(&pool->list, pages[i], plinks.q); in ttm_put_pages()
708 pages[i] = NULL; in ttm_put_pages()
716 /* free at least NUM_PAGES_TO_ALLOC number of pages in ttm_put_pages()
727 * On success pages list will hold count number of correctly
728 * cached pages.
730 static int ttm_get_pages(vm_page_t *pages, unsigned npages, int flags, in ttm_get_pages() argument
740 /* No pool for cached pages */ in ttm_get_pages()
748 pages[r] = p; in ttm_get_pages()
756 /* First we take pages from the pool */ in ttm_get_pages()
761 pages[count++] = p; in ttm_get_pages()
764 /* clear the pages coming from the pool if requested */ in ttm_get_pages()
771 /* If pool didn't have enough pages allocate new one. */ in ttm_get_pages()
780 pages[count++] = p; in ttm_get_pages()
783 /* If there is any pages in the list put them back to in ttm_get_pages()
785 printf("[TTM] Failed to allocate extra pages for large request\n"); in ttm_get_pages()
786 ttm_put_pages(pages, count, flags, cstate); in ttm_get_pages()
856 ret = ttm_get_pages(&ttm->pages[i], 1, in ttm_pool_populate()
864 ret = ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], in ttm_pool_populate()
889 if (ttm->pages[i]) { in ttm_pool_unpopulate()
891 ttm->pages[i]); in ttm_pool_unpopulate()
892 ttm_put_pages(&ttm->pages[i], 1, in ttm_pool_unpopulate()
906 char *h[] = {"pool", "refills", "pages freed", "size"};