From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org Cc: igt-dev@lists.freedesktop.org Subject: [PATCH i-g-t] igt/gem_exec_capture: Capture many, many objects Date: Wed, 18 Jul 2018 10:32:25 +0100 [thread overview] Message-ID: <20180718093225.7881-1-chris@chris-wilson.co.uk> (raw) In-Reply-To: <20180718085841.31493-1-chris@chris-wilson.co.uk> Exercise O(N^2) behaviour in reading the error state, and push it to the extreme. Reported-by: Jason Ekstrand <jason@jlekstrand.net> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- tests/gem_exec_capture.c | 155 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 3 deletions(-) diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c index 2dc06ce43..de69da800 100644 --- a/tests/gem_exec_capture.c +++ b/tests/gem_exec_capture.c @@ -23,6 +23,7 @@ #include "igt.h" #include "igt_device.h" +#include "igt_rand.h" #include "igt_sysfs.h" #define LOCAL_OBJECT_CAPTURE (1 << 7) @@ -57,7 +58,7 @@ static void check_error_state(int dir, struct drm_i915_gem_exec_object2 *obj) igt_assert(found); } -static void __capture(int fd, int dir, unsigned ring, uint32_t target) +static void __capture1(int fd, int dir, unsigned ring, uint32_t target) { const int gen = intel_gen(intel_get_drm_devid(fd)); struct drm_i915_gem_exec_object2 obj[4]; @@ -167,10 +168,148 @@ static void capture(int fd, int dir, unsigned ring) uint32_t handle; handle = gem_create(fd, 4096); - __capture(fd, dir, ring, handle); + __capture1(fd, dir, ring, handle); gem_close(fd, handle); } +static void __captureN(int fd, int dir, unsigned ring, + unsigned int size, int count, unsigned int flags) +#define RANDOM 0x1 +{ + const int gen = intel_gen(intel_get_drm_devid(fd)); + struct drm_i915_gem_exec_object2 *obj; + struct drm_i915_gem_relocation_entry reloc[2]; + struct drm_i915_gem_execbuffer2 execbuf; + uint32_t *batch, *seqno; + int i; + + obj = calloc(count + 2, sizeof(*obj)); + igt_assert(obj); + + obj[0].handle = gem_create(fd, 4096); + for (i = 0; i < count; i++) { + obj[i + 1].handle = gem_create(fd, size); + obj[i + 1].flags = LOCAL_OBJECT_CAPTURE; + if (flags & RANDOM) { + uint32_t *ptr; + + ptr = gem_mmap__cpu(fd, obj[i + 1].handle, + 0, size, PROT_WRITE); + for (unsigned int n = 0; n < size / sizeof(*ptr); n++) + ptr[n] = hars_petruska_f54_1_random_unsafe(); + munmap(ptr, size); + } + } + + obj[count + 1].handle = gem_create(fd, 4096); + obj[count + 1].relocs_ptr = (uintptr_t)reloc; + obj[count + 1].relocation_count = ARRAY_SIZE(reloc); + + memset(reloc, 0, sizeof(reloc)); + reloc[0].target_handle = obj[count + 1].handle; /* recurse */ + reloc[0].presumed_offset = 0; + reloc[0].offset = 5*sizeof(uint32_t); + reloc[0].delta = 0; + reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; + reloc[0].write_domain = 0; + + reloc[1].target_handle = obj[0].handle; /* breadcrumb */ + reloc[1].presumed_offset = 0; + reloc[1].offset = sizeof(uint32_t); + reloc[1].delta = 0; + reloc[1].read_domains = I915_GEM_DOMAIN_RENDER; + reloc[1].write_domain = I915_GEM_DOMAIN_RENDER; + + seqno = gem_mmap__wc(fd, obj[0].handle, 0, 4096, PROT_READ); + gem_set_domain(fd, obj[0].handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + + batch = gem_mmap__cpu(fd, obj[count + 1].handle, 0, 4096, PROT_WRITE); + gem_set_domain(fd, obj[count + 1].handle, + I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); + + i = 0; + batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0); + if (gen >= 8) { + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 4) { + batch[++i] = 0; + batch[++i] = 0; + reloc[1].offset += sizeof(uint32_t); + } else { + batch[i]--; + batch[++i] = 0; + } + batch[++i] = 0xc0ffee; + if (gen < 3) + batch[++i] = MI_NOOP; + + batch[++i] = MI_BATCH_BUFFER_START; /* not crashed? try again! */ + if (gen >= 8) { + batch[i] |= 1 << 8 | 1; + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 6) { + batch[i] |= 1 << 8; + batch[++i] = 0; + } else { + batch[i] |= 2 << 6; + batch[++i] = 0; + if (gen < 4) { + batch[i] |= 1; + reloc[0].delta = 1; + } + } + munmap(batch, 4096); + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)obj; + execbuf.buffer_count = count + 2; + execbuf.flags = ring; + if (gen > 3 && gen < 6) + execbuf.flags |= I915_EXEC_SECURE; + gem_execbuf(fd, &execbuf); + + /* Wait for the request to start */ + while (*(volatile uint32_t *)seqno != 0xc0ffee) + igt_assert(gem_bo_busy(fd, obj[0].handle)); + munmap(seqno, 4096); + + igt_force_gpu_reset(fd); + + gem_sync(fd, obj[count + 1].handle); + gem_close(fd, obj[count + 1].handle); + for (i = 0; i < count; i++) + gem_close(fd, obj[i + 1].handle); + gem_close(fd, obj[0].handle); +} + +static void many(int fd, int dir, unsigned int flags) +{ + uint64_t ram, gtt; + unsigned long count; + char *error; + + gtt = (gem_aperture_size(fd) >> 20) / 4; + ram = intel_get_avail_ram_mb() / 4; + igt_debug("Available objects in GTT:%"PRIu64", RAM:%"PRIu64"\n", + gtt, ram); + + count = min(gtt, ram); + igt_require(count > 1); + + intel_require_memory(count, 2 << 20, CHECK_RAM); + + __captureN(fd, dir, 0, 2 << 20, count, flags); + + error = igt_sysfs_get(dir, "error"); + igt_sysfs_set(dir, "error", "Begone!"); + + igt_assert(error); + igt_debug("%s\n", error); +} + static void userptr(int fd, int dir) { uint32_t handle; @@ -179,7 +318,7 @@ static void userptr(int fd, int dir) igt_assert(posix_memalign(&ptr, 4096, 4096) == 0); igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0); - __capture(fd, dir, 0, handle); + __capture1(fd, dir, 0, handle); gem_close(fd, handle); free(ptr); @@ -236,6 +375,16 @@ igt_main } } + igt_subtest_f("many-zero") { + igt_require(gem_can_store_dword(fd, 0)); + many(fd, dir, 0); + } + + igt_subtest_f("many-random") { + igt_require(gem_can_store_dword(fd, 0)); + many(fd, dir, RANDOM); + } + /* And check we can read from different types of objects */ igt_subtest_f("userptr") { -- 2.18.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org Cc: igt-dev@lists.freedesktop.org Subject: [Intel-gfx] [PATCH i-g-t] igt/gem_exec_capture: Capture many, many objects Date: Wed, 18 Jul 2018 10:32:25 +0100 [thread overview] Message-ID: <20180718093225.7881-1-chris@chris-wilson.co.uk> (raw) In-Reply-To: <20180718085841.31493-1-chris@chris-wilson.co.uk> Exercise O(N^2) behaviour in reading the error state, and push it to the extreme. Reported-by: Jason Ekstrand <jason@jlekstrand.net> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- tests/gem_exec_capture.c | 155 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 3 deletions(-) diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c index 2dc06ce43..de69da800 100644 --- a/tests/gem_exec_capture.c +++ b/tests/gem_exec_capture.c @@ -23,6 +23,7 @@ #include "igt.h" #include "igt_device.h" +#include "igt_rand.h" #include "igt_sysfs.h" #define LOCAL_OBJECT_CAPTURE (1 << 7) @@ -57,7 +58,7 @@ static void check_error_state(int dir, struct drm_i915_gem_exec_object2 *obj) igt_assert(found); } -static void __capture(int fd, int dir, unsigned ring, uint32_t target) +static void __capture1(int fd, int dir, unsigned ring, uint32_t target) { const int gen = intel_gen(intel_get_drm_devid(fd)); struct drm_i915_gem_exec_object2 obj[4]; @@ -167,10 +168,148 @@ static void capture(int fd, int dir, unsigned ring) uint32_t handle; handle = gem_create(fd, 4096); - __capture(fd, dir, ring, handle); + __capture1(fd, dir, ring, handle); gem_close(fd, handle); } +static void __captureN(int fd, int dir, unsigned ring, + unsigned int size, int count, unsigned int flags) +#define RANDOM 0x1 +{ + const int gen = intel_gen(intel_get_drm_devid(fd)); + struct drm_i915_gem_exec_object2 *obj; + struct drm_i915_gem_relocation_entry reloc[2]; + struct drm_i915_gem_execbuffer2 execbuf; + uint32_t *batch, *seqno; + int i; + + obj = calloc(count + 2, sizeof(*obj)); + igt_assert(obj); + + obj[0].handle = gem_create(fd, 4096); + for (i = 0; i < count; i++) { + obj[i + 1].handle = gem_create(fd, size); + obj[i + 1].flags = LOCAL_OBJECT_CAPTURE; + if (flags & RANDOM) { + uint32_t *ptr; + + ptr = gem_mmap__cpu(fd, obj[i + 1].handle, + 0, size, PROT_WRITE); + for (unsigned int n = 0; n < size / sizeof(*ptr); n++) + ptr[n] = hars_petruska_f54_1_random_unsafe(); + munmap(ptr, size); + } + } + + obj[count + 1].handle = gem_create(fd, 4096); + obj[count + 1].relocs_ptr = (uintptr_t)reloc; + obj[count + 1].relocation_count = ARRAY_SIZE(reloc); + + memset(reloc, 0, sizeof(reloc)); + reloc[0].target_handle = obj[count + 1].handle; /* recurse */ + reloc[0].presumed_offset = 0; + reloc[0].offset = 5*sizeof(uint32_t); + reloc[0].delta = 0; + reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND; + reloc[0].write_domain = 0; + + reloc[1].target_handle = obj[0].handle; /* breadcrumb */ + reloc[1].presumed_offset = 0; + reloc[1].offset = sizeof(uint32_t); + reloc[1].delta = 0; + reloc[1].read_domains = I915_GEM_DOMAIN_RENDER; + reloc[1].write_domain = I915_GEM_DOMAIN_RENDER; + + seqno = gem_mmap__wc(fd, obj[0].handle, 0, 4096, PROT_READ); + gem_set_domain(fd, obj[0].handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + + batch = gem_mmap__cpu(fd, obj[count + 1].handle, 0, 4096, PROT_WRITE); + gem_set_domain(fd, obj[count + 1].handle, + I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); + + i = 0; + batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0); + if (gen >= 8) { + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 4) { + batch[++i] = 0; + batch[++i] = 0; + reloc[1].offset += sizeof(uint32_t); + } else { + batch[i]--; + batch[++i] = 0; + } + batch[++i] = 0xc0ffee; + if (gen < 3) + batch[++i] = MI_NOOP; + + batch[++i] = MI_BATCH_BUFFER_START; /* not crashed? try again! */ + if (gen >= 8) { + batch[i] |= 1 << 8 | 1; + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 6) { + batch[i] |= 1 << 8; + batch[++i] = 0; + } else { + batch[i] |= 2 << 6; + batch[++i] = 0; + if (gen < 4) { + batch[i] |= 1; + reloc[0].delta = 1; + } + } + munmap(batch, 4096); + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)obj; + execbuf.buffer_count = count + 2; + execbuf.flags = ring; + if (gen > 3 && gen < 6) + execbuf.flags |= I915_EXEC_SECURE; + gem_execbuf(fd, &execbuf); + + /* Wait for the request to start */ + while (*(volatile uint32_t *)seqno != 0xc0ffee) + igt_assert(gem_bo_busy(fd, obj[0].handle)); + munmap(seqno, 4096); + + igt_force_gpu_reset(fd); + + gem_sync(fd, obj[count + 1].handle); + gem_close(fd, obj[count + 1].handle); + for (i = 0; i < count; i++) + gem_close(fd, obj[i + 1].handle); + gem_close(fd, obj[0].handle); +} + +static void many(int fd, int dir, unsigned int flags) +{ + uint64_t ram, gtt; + unsigned long count; + char *error; + + gtt = (gem_aperture_size(fd) >> 20) / 4; + ram = intel_get_avail_ram_mb() / 4; + igt_debug("Available objects in GTT:%"PRIu64", RAM:%"PRIu64"\n", + gtt, ram); + + count = min(gtt, ram); + igt_require(count > 1); + + intel_require_memory(count, 2 << 20, CHECK_RAM); + + __captureN(fd, dir, 0, 2 << 20, count, flags); + + error = igt_sysfs_get(dir, "error"); + igt_sysfs_set(dir, "error", "Begone!"); + + igt_assert(error); + igt_debug("%s\n", error); +} + static void userptr(int fd, int dir) { uint32_t handle; @@ -179,7 +318,7 @@ static void userptr(int fd, int dir) igt_assert(posix_memalign(&ptr, 4096, 4096) == 0); igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0); - __capture(fd, dir, 0, handle); + __capture1(fd, dir, 0, handle); gem_close(fd, handle); free(ptr); @@ -236,6 +375,16 @@ igt_main } } + igt_subtest_f("many-zero") { + igt_require(gem_can_store_dword(fd, 0)); + many(fd, dir, 0); + } + + igt_subtest_f("many-random") { + igt_require(gem_can_store_dword(fd, 0)); + many(fd, dir, RANDOM); + } + /* And check we can read from different types of objects */ igt_subtest_f("userptr") { -- 2.18.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-07-18 9:32 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-18 8:58 [PATCH i-g-t] igt/gem_exec_capture: Capture many, many objects Chris Wilson 2018-07-18 8:58 ` [igt-dev] " Chris Wilson 2018-07-18 9:32 ` Chris Wilson [this message] 2018-07-18 9:32 ` [Intel-gfx] " Chris Wilson 2018-07-18 9:44 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork 2018-07-18 9:59 ` [igt-dev] ✓ Fi.CI.BAT: success for igt/gem_exec_capture: Capture many, many objects (rev2) Patchwork 2018-07-18 11:48 ` [igt-dev] ✗ Fi.CI.IGT: failure for igt/gem_exec_capture: Capture many, many objects Patchwork 2018-07-18 12:31 ` [igt-dev] ✓ Fi.CI.IGT: success for igt/gem_exec_capture: Capture many, many objects (rev2) Patchwork 2018-09-06 17:15 [PATCH i-g-t] igt/gem_exec_capture: Capture many, many objects Chris Wilson 2018-10-03 10:45 Chris Wilson
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=20180718093225.7881-1-chris@chris-wilson.co.uk \ --to=chris@chris-wilson.co.uk \ --cc=igt-dev@lists.freedesktop.org \ --cc=intel-gfx@lists.freedesktop.org \ /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: linkBe 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.