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@whitecape.org>
This commit is contained in:
Chris Wilson 2018-11-21 11:12:11 +00:00 committed by Kenneth Graunke
parent 87f865aab3
commit db99d02fce
2 changed files with 13 additions and 1 deletions

View file

@ -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);

View file

@ -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