From: Pauli Nieminen <suokkos@gmail.com>
To: dri-devel@lists.sourceforge.net
Subject: [PATCH 2/7] drm/ttm: Add debugfs output entry to pool allocator.
Date: Thu, 1 Apr 2010 15:44:58 +0300 [thread overview]
Message-ID: <1270125903-6004-2-git-send-email-suokkos@gmail.com> (raw)
In-Reply-To: <1270125903-6004-1-git-send-email-suokkos@gmail.com>
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>
---
drivers/gpu/drm/ttm/ttm_page_alloc.c | 45 ++++++++++++++++++++++++++++-----
include/drm/ttm/ttm_page_alloc.h | 4 +++
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 f46e40b..f82bf80 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -34,6 +34,7 @@
#include <linux/spinlock.h>
#include <linux/highmem.h>
#include <linux/mm_types.h>
+#include <linux/module.h>
#include <linux/mm.h>
#include <asm/atomic.h>
@@ -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;
}
/**
@@ -263,7 +268,6 @@ restart:
}
}
-
/* remove range of pages from the pool */
if (freed_pages) {
__list_del(&p->lru, &pool->list);
@@ -490,6 +494,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);
@@ -663,13 +668,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)
@@ -679,13 +686,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;
@@ -709,3 +718,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 043d817..8b091c3 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
--
1.7.0
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
next prev parent reply other threads:[~2010-04-01 12:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-01 12:44 [PATCH 1/7] drm/ttm: add pool wc/uc page allocator V3 Pauli Nieminen
2010-04-01 12:44 ` Pauli Nieminen [this message]
2010-04-01 12:44 ` [PATCH 3/7] drm/radeon/kms: Add ttm page pool debugfs file Pauli Nieminen
2010-04-01 12:45 ` [PATCH 4/7] drm/nouveau: " Pauli Nieminen
2010-04-01 12:45 ` [PATCH 5/7] arch/x86: Add array variants for setting memory to wc caching Pauli Nieminen
2010-05-18 9:34 ` Dave Airlie
2010-05-18 16:43 ` H. Peter Anvin
2010-05-18 20:54 ` Venkatesh Pallipadi
2010-04-01 12:45 ` [PATCH 6/7] drm/ttm: Use set_pages_array_wc instead of set_memory_wc Pauli Nieminen
2010-04-01 12:45 ` [PATCH 7/7] drm/ttm: Add sysfs interface to control pool allocator Pauli Nieminen
2010-04-01 13:00 ` [PATCH 1/7] drm/ttm: add pool wc/uc page allocator V3 Jerome Glisse
-- strict thread matches above, loose matches on Subject: below --
2010-03-28 18:16 [PATCH 1/7] drm/ttm: add pool wc/uc page allocator V2 Pauli Nieminen
2010-03-28 18:16 ` [PATCH 2/7] drm/ttm: Add debugfs output entry to pool allocator Pauli Nieminen
2010-03-24 22:36 drm/ttm: Pool allocator simplification and sysfs interface Pauli Nieminen
2010-03-24 22:36 ` [PATCH 1/7] drm/ttm: add pool wc/uc page allocator Pauli Nieminen
2010-03-24 22:36 ` [PATCH 2/7] drm/ttm: Add debugfs output entry to pool allocator Pauli Nieminen
2010-03-17 20:49 [PATCH 0/7] drm/ttm: Pool allocator Pauli Nieminen
2010-03-17 20:50 ` [PATCH 1/7] drm/ttm: add pool wc/uc page allocator Pauli Nieminen
2010-03-17 20:50 ` [PATCH 2/7] drm/ttm: Add debugfs output entry to pool allocator Pauli Nieminen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1270125903-6004-2-git-send-email-suokkos@gmail.com \
--to=suokkos@gmail.com \
--cc=dri-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.