aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli Nieminen <suokkos@gmail.com>2010-04-01 08:44:58 -0400
committerDave Airlie <airlied@redhat.com>2010-04-05 21:35:45 -0400
commit0745866165598b067442c472911280527b08be3e (patch)
tree454900be36c969fe45554a47e733807d63be8b6f
parent1403b1a38e8b19a4cc17e2c158e278628943a436 (diff)
drm/ttm: Add debugfs output entry to pool allocator.
ttm_page_alloc_debugfs can be registered to output the state of pools. Debugfs file will output number of pages freed from the pool, number of pages in pool now and the lowes number of pages in pool since previous shrink. Signed-off-by: Pauli Nieminen <suokkos@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c45
-rw-r--r--include/drm/ttm/ttm_page_alloc.h4
2 files changed, 42 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index f46e40be0797..f82bf805903c 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -34,6 +34,7 @@
34#include <linux/spinlock.h> 34#include <linux/spinlock.h>
35#include <linux/highmem.h> 35#include <linux/highmem.h>
36#include <linux/mm_types.h> 36#include <linux/mm_types.h>
37#include <linux/module.h>
37#include <linux/mm.h> 38#include <linux/mm.h>
38 39
39#include <asm/atomic.h> 40#include <asm/atomic.h>
@@ -66,6 +67,9 @@ struct ttm_page_pool {
66 struct list_head list; 67 struct list_head list;
67 int gfp_flags; 68 int gfp_flags;
68 unsigned npages; 69 unsigned npages;
70 char *name;
71 unsigned long nfrees;
72 unsigned long nrefills;
69}; 73};
70 74
71struct ttm_pool_opts { 75struct ttm_pool_opts {
@@ -190,6 +194,7 @@ static void ttm_pool_update_free_locked(struct ttm_page_pool *pool,
190 unsigned freed_pages) 194 unsigned freed_pages)
191{ 195{
192 pool->npages -= freed_pages; 196 pool->npages -= freed_pages;
197 pool->nfrees += freed_pages;
193} 198}
194 199
195/** 200/**
@@ -263,7 +268,6 @@ restart:
263 } 268 }
264 } 269 }
265 270
266
267 /* remove range of pages from the pool */ 271 /* remove range of pages from the pool */
268 if (freed_pages) { 272 if (freed_pages) {
269 __list_del(&p->lru, &pool->list); 273 __list_del(&p->lru, &pool->list);
@@ -490,6 +494,7 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool,
490 494
491 if (!r) { 495 if (!r) {
492 list_splice(&new_pages, &pool->list); 496 list_splice(&new_pages, &pool->list);
497 ++pool->nrefills;
493 pool->npages += alloc_size; 498 pool->npages += alloc_size;
494 } else { 499 } else {
495 printk(KERN_ERR "[ttm] Failed to fill pool (%p).", pool); 500 printk(KERN_ERR "[ttm] Failed to fill pool (%p).", pool);
@@ -663,13 +668,15 @@ void ttm_put_pages(struct list_head *pages, unsigned page_count, int flags,
663 ttm_page_pool_free(pool, page_count); 668 ttm_page_pool_free(pool, page_count);
664} 669}
665 670
666static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, int flags) 671static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, int flags,
672 char *name)
667{ 673{
668 spin_lock_init(&pool->lock); 674 spin_lock_init(&pool->lock);
669 pool->fill_lock = false; 675 pool->fill_lock = false;
670 INIT_LIST_HEAD(&pool->list); 676 INIT_LIST_HEAD(&pool->list);
671 pool->npages = 0; 677 pool->npages = pool->nfrees = 0;
672 pool->gfp_flags = flags; 678 pool->gfp_flags = flags;
679 pool->name = name;
673} 680}
674 681
675int ttm_page_alloc_init(unsigned max_pages) 682int ttm_page_alloc_init(unsigned max_pages)
@@ -679,13 +686,15 @@ int ttm_page_alloc_init(unsigned max_pages)
679 686
680 printk(KERN_INFO "[ttm] Initializing pool allocator.\n"); 687 printk(KERN_INFO "[ttm] Initializing pool allocator.\n");
681 688
682 ttm_page_pool_init_locked(&_manager.wc_pool, GFP_HIGHUSER); 689 ttm_page_pool_init_locked(&_manager.wc_pool, GFP_HIGHUSER, "wc");
683 690
684 ttm_page_pool_init_locked(&_manager.uc_pool, GFP_HIGHUSER); 691 ttm_page_pool_init_locked(&_manager.uc_pool, GFP_HIGHUSER, "uc");
685 692
686 ttm_page_pool_init_locked(&_manager.wc_pool_dma32, GFP_USER | GFP_DMA32); 693 ttm_page_pool_init_locked(&_manager.wc_pool_dma32, GFP_USER | GFP_DMA32,
694 "wc dma");
687 695
688 ttm_page_pool_init_locked(&_manager.uc_pool_dma32, GFP_USER | GFP_DMA32); 696 ttm_page_pool_init_locked(&_manager.uc_pool_dma32, GFP_USER | GFP_DMA32,
697 "uc dma");
689 698
690 _manager.options.max_size = max_pages; 699 _manager.options.max_size = max_pages;
691 _manager.options.small = SMALL_ALLOCATION; 700 _manager.options.small = SMALL_ALLOCATION;
@@ -709,3 +718,25 @@ void ttm_page_alloc_fini()
709 for (i = 0; i < NUM_POOLS; ++i) 718 for (i = 0; i < NUM_POOLS; ++i)
710 ttm_page_pool_free(&_manager.pools[i], FREE_ALL_PAGES); 719 ttm_page_pool_free(&_manager.pools[i], FREE_ALL_PAGES);
711} 720}
721
722int ttm_page_alloc_debugfs(struct seq_file *m, void *data)
723{
724 struct ttm_page_pool *p;
725 unsigned i;
726 char *h[] = {"pool", "refills", "pages freed", "size"};
727 if (atomic_read(&_manager.page_alloc_inited) == 0) {
728 seq_printf(m, "No pool allocator running.\n");
729 return 0;
730 }
731 seq_printf(m, "%6s %12s %13s %8s\n",
732 h[0], h[1], h[2], h[3]);
733 for (i = 0; i < NUM_POOLS; ++i) {
734 p = &_manager.pools[i];
735
736 seq_printf(m, "%6s %12ld %13ld %8d\n",
737 p->name, p->nrefills,
738 p->nfrees, p->npages);
739 }
740 return 0;
741}
742EXPORT_SYMBOL(ttm_page_alloc_debugfs);
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
index 043d817b8164..8b091c309df4 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);
67 */ 67 */
68void ttm_page_alloc_fini(void); 68void ttm_page_alloc_fini(void);
69 69
70/**
71 * Output the state of pools to debugfs file
72 */
73extern int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
70#endif 74#endif