[Intel-gfx] [PATCH] First stab at doing wait accounting
Ben Gamari
bgamari.foss at gmail.com
Fri May 22 17:59:01 CEST 2009
---
drivers/gpu/drm/i915/i915_drv.h | 21 +++++++++++++++++++++
drivers/gpu/drm/i915/i915_gem.c | 14 +++++++++++++-
drivers/gpu/drm/i915/i915_gem_debugfs.c | 14 ++++++++++++++
3 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 9b149fe..1b59136 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -126,6 +126,24 @@ struct drm_i915_fence_reg {
struct drm_gem_object *obj;
};
+enum drm_i915_wait_srcs {
+ I915_WAITSRC_NEED_EVICTION,
+ I915_WAITSRC_NEED_FLUSH,
+ I915_WAITSRC_FLUSH_FOR_FENCE,
+ I915_WAITSRC_LAST
+};
+
+#ifdef WAIT_ACCOUNTING
+#define MIGHT_WAIT() struct timespec _wait_ts_begin, _wait_ts_end;
+#define BEGIN_WAIT() do_gettimeofday(&_wait_ts_begin);
+#define END_WAIT(src) do_gettimeofay(&_wait_ts_end); \
+ dev_priv->mm.wait_srcs[src] += wait_ts_end.tv_usec - wait_ts_begin.tv_usec;
+#else
+#define MIGHT_WAIT()
+#define BEGIN_WAIT()
+#define END_WAIT(src)
+#endif
+
typedef struct drm_i915_private {
struct drm_device *dev;
@@ -380,6 +398,9 @@ typedef struct drm_i915_private {
/* storage for physical objects */
struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
+
+ /* wait source accumulator */
+ long int wait_srcs[I915_WAITSRC_LAST];
} mm;
} drm_i915_private_t;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index b189b49..d6ebc9d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1939,12 +1939,15 @@ i915_gem_evict_something(struct drm_device *dev)
*/
if (!list_empty(&dev_priv->mm.request_list)) {
struct drm_i915_gem_request *request;
+ MIGHT_WAIT();
request = list_first_entry(&dev_priv->mm.request_list,
struct drm_i915_gem_request,
list);
+ BEGIN_WAIT();
ret = i915_wait_request(dev, request->seqno);
+ END_WAIT(I915_WAITSRC_EVICTION_FOR_OBJ);
if (ret)
break;
@@ -1964,15 +1967,19 @@ i915_gem_evict_something(struct drm_device *dev)
* will get moved to inactive.
*/
if (!list_empty(&dev_priv->mm.flushing_list)) {
+ MIGHT_WAIT();
+
obj_priv = list_first_entry(&dev_priv->mm.flushing_list,
struct drm_i915_gem_object,
list);
obj = obj_priv->obj;
-
+
+ BEGIN_WAIT();
i915_gem_flush(dev,
obj->write_domain,
obj->write_domain);
i915_add_request(dev, obj->write_domain);
+ END_WAIT(I915_WAITSRC_FLUSH_FOR_OBJ);
obj = NULL;
continue;
@@ -2238,7 +2245,10 @@ try_again:
* objects to finish before trying again.
*/
if (i == dev_priv->num_fence_regs) {
+ MIGHT_WAIT();
+
if (seqno == dev_priv->mm.next_gem_seqno) {
+
i915_gem_flush(dev,
I915_GEM_GPU_DOMAINS,
I915_GEM_GPU_DOMAINS);
@@ -2248,7 +2258,9 @@ try_again:
return -ENOMEM;
}
+ BEGIN_WAIT();
ret = i915_wait_request(dev, seqno);
+ END_WAIT(I915_WAITSRC_FLUSH_FOR_FENCE);
if (ret)
return ret;
goto try_again;
diff --git a/drivers/gpu/drm/i915/i915_gem_debugfs.c b/drivers/gpu/drm/i915/i915_gem_debugfs.c
index 986f108..d285845 100644
--- a/drivers/gpu/drm/i915/i915_gem_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_gem_debugfs.c
@@ -323,6 +323,19 @@ static int i915_ringbuffer_info(struct seq_file *m, void *data)
return 0;
}
+static int i915_wait_source_info(struct seq_file *m, void *data) {
+ struct drm_info_node *node = (struct drm_info_node *) m->private;
+ struct drm_device *dev = node->minor->dev;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+
+#define WAITSRC(SRC) seq_printf(m, "%s\t%ld\n", #SRC, dev_priv->mm.wait_srcs[I915_WAITSRC_##SRC])
+ WAITSRC(NEED_EVICTION);
+ WAITSRC(NEED_FLUSH);
+ WAITSRC(FLUSH_FOR_FENCE);
+#undef WAITSRC
+
+ return 0;
+}
static struct drm_info_list i915_gem_debugfs_list[] = {
{"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
@@ -336,6 +349,7 @@ static struct drm_info_list i915_gem_debugfs_list[] = {
{"i915_ringbuffer_data", i915_ringbuffer_data, 0},
{"i915_ringbuffer_info", i915_ringbuffer_info, 0},
{"i915_batchbuffers", i915_batchbuffer_info, 0},
+ {"i915_wait_sources", i915_wait_source_info, 0},
};
#define I915_GEM_DEBUGFS_ENTRIES ARRAY_SIZE(i915_gem_debugfs_list)
--
1.6.2.2
More information about the Intel-gfx
mailing list