From owner-svn-src-all@FreeBSD.ORG Tue Feb 3 13:45:07 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 72BE541E; Tue, 3 Feb 2015 13:45:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5F132E3F; Tue, 3 Feb 2015 13:45:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t13Dj7fC060242; Tue, 3 Feb 2015 13:45:07 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t13Dj6wp060238; Tue, 3 Feb 2015 13:45:06 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502031345.t13Dj6wp060238@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 3 Feb 2015 13:45:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278153 - head/sys/dev/drm2/ttm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Feb 2015 13:45:07 -0000 Author: kib Date: Tue Feb 3 13:45:06 2015 New Revision: 278153 URL: https://svnweb.freebsd.org/changeset/base/278153 Log: If the vm_page_alloc_contig() failed in the ttm page allocators, do what other callers of vm_page_alloc_contig() do, retry after vm_pageout_grow_cache(). Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/drm2/ttm/ttm_bo.c head/sys/dev/drm2/ttm/ttm_page_alloc.c Modified: head/sys/dev/drm2/ttm/ttm_bo.c ============================================================================== --- head/sys/dev/drm2/ttm/ttm_bo.c Tue Feb 3 13:43:03 2015 (r278152) +++ head/sys/dev/drm2/ttm/ttm_bo.c Tue Feb 3 13:45:06 2015 (r278153) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define TTM_ASSERT_LOCKED(param) #define TTM_DEBUG(fmt, arg...) @@ -1489,15 +1490,23 @@ int ttm_bo_global_init(struct drm_global container_of(ref, struct ttm_bo_global_ref, ref); struct ttm_bo_global *glob = ref->object; int ret; + int tries; sx_init(&glob->device_list_mutex, "ttmdlm"); mtx_init(&glob->lru_lock, "ttmlru", NULL, MTX_DEF); glob->mem_glob = bo_ref->mem_glob; + tries = 0; +retry: glob->dummy_read_page = vm_page_alloc_contig(NULL, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ, 1, 0, VM_MAX_ADDRESS, PAGE_SIZE, 0, VM_MEMATTR_UNCACHEABLE); if (unlikely(glob->dummy_read_page == NULL)) { + if (tries < 1) { + vm_pageout_grow_cache(tries, 0, VM_MAX_ADDRESS); + tries++; + goto retry; + } ret = -ENOMEM; goto out_no_drp; } Modified: head/sys/dev/drm2/ttm/ttm_page_alloc.c ============================================================================== --- head/sys/dev/drm2/ttm/ttm_page_alloc.c Tue Feb 3 13:43:03 2015 (r278152) +++ head/sys/dev/drm2/ttm/ttm_page_alloc.c Tue Feb 3 13:45:06 2015 (r278153) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define NUM_PAGES_TO_ALLOC (PAGE_SIZE/sizeof(vm_page_t)) #define SMALL_ALLOCATION 16 @@ -460,6 +461,14 @@ static void ttm_handle_caching_state_fai } } +static vm_paddr_t +ttm_alloc_high_bound(int ttm_alloc_flags) +{ + + return ((ttm_alloc_flags & TTM_PAGE_FLAG_DMA32) ? 0xffffffff : + VM_MAX_ADDRESS); +} + /** * Allocate new pages with correct caching. * @@ -475,6 +484,7 @@ static int ttm_alloc_new_pages(struct pg unsigned i, cpages, aflags; unsigned max_cpages = min(count, (unsigned)(PAGE_SIZE/sizeof(vm_page_t))); + int tries; aflags = VM_ALLOC_NORMAL | VM_ALLOC_WIRED | VM_ALLOC_NOOBJ | ((ttm_alloc_flags & TTM_PAGE_FLAG_ZERO_ALLOC) != 0 ? @@ -485,11 +495,18 @@ static int ttm_alloc_new_pages(struct pg M_WAITOK | M_ZERO); for (i = 0, cpages = 0; i < count; ++i) { + tries = 0; +retry: p = vm_page_alloc_contig(NULL, 0, aflags, 1, 0, - (ttm_alloc_flags & TTM_PAGE_FLAG_DMA32) ? 0xffffffff : - VM_MAX_ADDRESS, PAGE_SIZE, 0, - ttm_caching_state_to_vm(cstate)); + ttm_alloc_high_bound(ttm_alloc_flags), + PAGE_SIZE, 0, ttm_caching_state_to_vm(cstate)); if (!p) { + if (tries < 3) { + vm_pageout_grow_cache(tries, 0, + ttm_alloc_high_bound(ttm_alloc_flags)); + tries++; + goto retry; + } printf("[TTM] Unable to get page %u\n", i); /* store already allocated pages in the pool after @@ -691,6 +708,7 @@ static int ttm_get_pages(vm_page_t *page int gfp_flags, aflags; unsigned count; int r; + int tries; aflags = VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | ((flags & TTM_PAGE_FLAG_ZERO_ALLOC) != 0 ? VM_ALLOC_ZERO : 0); @@ -698,11 +716,18 @@ static int ttm_get_pages(vm_page_t *page /* No pool for cached pages */ if (pool == NULL) { for (r = 0; r < npages; ++r) { + tries = 0; +retry: p = vm_page_alloc_contig(NULL, 0, aflags, 1, 0, - (flags & TTM_PAGE_FLAG_DMA32) ? 0xffffffff : - VM_MAX_ADDRESS, PAGE_SIZE, + ttm_alloc_high_bound(flags), PAGE_SIZE, 0, ttm_caching_state_to_vm(cstate)); if (!p) { + if (tries < 3) { + vm_pageout_grow_cache(tries, 0, + ttm_alloc_high_bound(flags)); + tries++; + goto retry; + } printf("[TTM] Unable to allocate page\n"); return -ENOMEM; }