Mesa (master): iris: Push heavy memchecker code to DEBUG

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Mar 22 17:38:22 UTC 2019


Module: Mesa
Branch: master
Commit: db99d02fce1951fc6364aea206fff84ae4c08e2d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=db99d02fce1951fc6364aea206fff84ae4c08e2d

Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Nov 21 11:12:11 2018 +0000

iris: Push heavy memchecker code to DEBUG

Invoking VALGRIND_CHECK_MEM_IS_DEFINED pulls in enough code to convince
gcc to not inline __gen_uint and results in a lot of packing code ending
up out-of-line with lots of stack copying. To ameliorate this, only
insert the check inside the packer if DEBUG is defined and instead
perform the validation checking before submitting the batch to the
kernel. This should give accurate results if --trace-origins=yes is
used, and failing that we can recompile in full debug mode to check on
insertion.

Improve drawoverhead baseline by 25% with a default build with
valgrind-dev installed (with effectively no loss of vg coverage).

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/gallium/drivers/iris/iris_batch.c | 12 ++++++++++++
 src/gallium/drivers/iris/iris_state.c |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c
index ce6fa99b1ad..556422c38bc 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -51,6 +51,14 @@
 #include <errno.h>
 #include <xf86drm.h>
 
+#if HAVE_VALGRIND
+#include <valgrind.h>
+#include <memcheck.h>
+#define VG(x) x
+#else
+#define VG(x)
+#endif
+
 #define FILE_DEBUG_FLAG DEBUG_BUFMGR
 
 /* Terminating the batch takes either 4 bytes for MI_BATCH_BUFFER_END
@@ -408,6 +416,7 @@ iris_chain_to_new_batch(struct iris_batch *batch)
    /* We only support chaining a single time. */
    assert(batch->bo == batch->exec_bos[0]);
 
+   VG(void *map = batch->map);
    uint32_t *cmd = batch->map_next;
    uint64_t *addr = batch->map_next + 4;
    batch->map_next += 12;
@@ -420,6 +429,8 @@ iris_chain_to_new_batch(struct iris_batch *batch)
    /* Emit MI_BATCH_BUFFER_START to chain to another batch. */
    *cmd = (0x31 << 23) | (1 << 8) | (3 - 2);
    *addr = batch->bo->gtt_offset;
+
+   VG(VALGRIND_CHECK_MEM_IS_DEFINED(map, batch->primary_batch_size));
 }
 
 /**
@@ -434,6 +445,7 @@ iris_finish_batch(struct iris_batch *batch)
    map[0] = (0xA << 23);
 
    batch->map_next += 4;
+   VG(VALGRIND_CHECK_MEM_IS_DEFINED(batch->map, iris_batch_bytes_used(batch)));
 
    if (batch->bo == batch->exec_bos[0])
       batch->primary_batch_size = iris_batch_bytes_used(batch);
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index e5f231158fc..4ab3662da7b 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -77,7 +77,7 @@
 #include <valgrind.h>
 #include <memcheck.h>
 #define VG(x) x
-#ifndef NDEBUG
+#ifdef DEBUG
 #define __gen_validate_value(x) VALGRIND_CHECK_MEM_IS_DEFINED(&(x), sizeof(x))
 #endif
 #else




More information about the mesa-commit mailing list