From patchwork Sun Mar 28 18:16:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Nieminen X-Patchwork-Id: 88797 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2SIHQpO016859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 28 Mar 2010 18:18:02 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nvx26-0005X3-A4; Sun, 28 Mar 2010 18:16:22 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nvx23-0005Wr-Qr for dri-devel@lists.sourceforge.net; Sun, 28 Mar 2010 18:16:19 +0000 Received-SPF: neutral (sfi-mx-1.v28.ch3.sourceforge.com: 213.243.153.188 is neither permitted nor denied by domain of gmail.com) client-ip=213.243.153.188; envelope-from=suokkos@gmail.com; helo=filtteri5.pp.htv.fi; Received: from filtteri5.pp.htv.fi ([213.243.153.188]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1Nvx22-00048S-FQ for dri-devel@lists.sourceforge.net; Sun, 28 Mar 2010 18:16:19 +0000 Received: from localhost (localhost [127.0.0.1]) by filtteri5.pp.htv.fi (Postfix) with ESMTP id DB6B65A60BE; Sun, 28 Mar 2010 21:16:10 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp5.welho.com ([213.243.153.39]) by localhost (filtteri5.pp.htv.fi [213.243.153.188]) (amavisd-new, port 10024) with ESMTP id 62M0e8L1ZE1e; Sun, 28 Mar 2010 21:16:10 +0300 (EEST) Received: from localhost.localdomain (cs181130083.pp.htv.fi [82.181.130.83]) by smtp5.welho.com (Postfix) with ESMTP id 7E59F5BC007; Sun, 28 Mar 2010 21:16:10 +0300 (EEST) From: Pauli Nieminen To: dri-devel@lists.sourceforge.net Subject: [PATCH 2/7] drm/ttm: Add debugfs output entry to pool allocator. Date: Sun, 28 Mar 2010 21:16:02 +0300 Message-Id: <1269800167-5291-2-git-send-email-suokkos@gmail.com> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1269800167-5291-1-git-send-email-suokkos@gmail.com> References: <1269800167-5291-1-git-send-email-suokkos@gmail.com> X-Spam-Score: 1.1 (+) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 1.2 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -0.1 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Nvx22-00048S-FQ X-BeenThere: dri-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 28 Mar 2010 18:18:03 +0000 (UTC) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 5029fd0..7b087ff 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,9 @@ struct ttm_page_pool { struct list_head list; int gfp_flags; unsigned npages; + char *name; + unsigned long nfrees; + unsigned long nrefills; }; struct ttm_pool_opts { @@ -190,6 +194,7 @@ static void ttm_pool_update_free_locked(struct ttm_page_pool *pool, unsigned freed_pages) { pool->npages -= freed_pages; + pool->nfrees += freed_pages; } /** @@ -257,7 +262,6 @@ restart: } } - /* remove range of pages from the pool */ if (freed_pages) { __list_del(&p->lru, &pool->list); @@ -484,6 +488,7 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool, if (!r) { list_splice(&new_pages, &pool->list); + ++pool->nrefills; pool->npages += alloc_size; } else { printk(KERN_ERR "[ttm] Failed to fill pool (%p).", pool); @@ -657,13 +662,15 @@ void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags, ttm_page_pool_free(pool, page_count); } -static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, int flags) +static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, int flags, + char *name) { spin_lock_init(&pool->lock); pool->fill_lock = false; INIT_LIST_HEAD(&pool->list); - pool->npages = 0; + pool->npages = pool->nfrees = 0; pool->gfp_flags = flags; + pool->name = name; } int ttm_page_alloc_init(unsigned max_pages) @@ -673,13 +680,15 @@ int ttm_page_alloc_init(unsigned max_pages) printk(KERN_INFO "[ttm] Initializing pool allocator.\n"); - ttm_page_pool_init_locked(&_manager.wc_pool, GFP_HIGHUSER); + ttm_page_pool_init_locked(&_manager.wc_pool, GFP_HIGHUSER, "wc"); - ttm_page_pool_init_locked(&_manager.uc_pool, GFP_HIGHUSER); + ttm_page_pool_init_locked(&_manager.uc_pool, GFP_HIGHUSER, "uc"); - ttm_page_pool_init_locked(&_manager.wc_pool_dma32, GFP_USER | GFP_DMA32); + ttm_page_pool_init_locked(&_manager.wc_pool_dma32, GFP_USER | GFP_DMA32, + "wc dma"); - ttm_page_pool_init_locked(&_manager.uc_pool_dma32, GFP_USER | GFP_DMA32); + ttm_page_pool_init_locked(&_manager.uc_pool_dma32, GFP_USER | GFP_DMA32, + "uc dma"); _manager.options.max_size = max_pages; _manager.options.small = SMALL_ALLOCATION; @@ -703,3 +712,25 @@ void ttm_page_alloc_fini() for (i = 0; i < NUM_POOLS; ++i) ttm_page_pool_free(&_manager.pools[i], FREE_ALL_PAGES); } + +int ttm_page_alloc_debugfs(struct seq_file *m, void *data) +{ + struct ttm_page_pool *p; + unsigned i; + char *h[] = {"pool", "refills", "pages freed", "size"}; + if (atomic_read(&_manager.page_alloc_inited) == 0) { + seq_printf(m, "No pool allocator running.\n"); + return 0; + } + seq_printf(m, "%6s %12s %13s %8s\n", + h[0], h[1], h[2], h[3]); + for (i = 0; i < NUM_POOLS; ++i) { + p = &_manager.pools[i]; + + seq_printf(m, "%6s %12ld %13ld %8d\n", + p->name, p->nrefills, + p->nfrees, p->npages); + } + return 0; +} +EXPORT_SYMBOL(ttm_page_alloc_debugfs); diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h index bdddd12..99bbe03 100644 --- a/include/drm/ttm/ttm_page_alloc.h +++ b/include/drm/ttm/ttm_page_alloc.h @@ -67,4 +67,8 @@ int ttm_page_alloc_init(unsigned max_pages); */ void ttm_page_alloc_fini(void); +/** + * Output the state of pools to debugfs file + */ +extern int ttm_page_alloc_debugfs(struct seq_file *m, void *data); #endif