From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: Petri Latvala <adrinael@adrinael.net>,
Arkadiusz Hiler <arek@hiler.eu>,
Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
Chris Wilson <chris.p.wilson@linux.intel.com>
Subject: [igt-dev] [PATCH i-g-t 1/2] i915/perf: Stress opening of new perf streams against existing contexts
Date: Tue, 31 Jan 2023 10:17:30 +0100 [thread overview]
Message-ID: <20230131091731.5892-2-janusz.krzysztofik@linux.intel.com> (raw)
In-Reply-To: <20230131091731.5892-1-janusz.krzysztofik@linux.intel.com>
From: Chris Wilson <chris.p.wilson@linux.intel.com>
Try opening the perf stream while there is a flurry of activity on the
system, both new and old contexts. This will exercise the ability of the
driver to modify those contexts to work with perf.
References: https://gitlab.freedesktop.org/drm/intel/-/issues/6333
Signed-off-by: Chris Wilson <chris.p.wilson@linux.intel.com>
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
---
tests/i915/perf.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/tests/i915/perf.c b/tests/i915/perf.c
index dd1f1ac399..e33cacc443 100644
--- a/tests/i915/perf.c
+++ b/tests/i915/perf.c
@@ -4885,6 +4885,71 @@ test_whitelisted_registers_userspace_config(void)
i915_perf_remove_config(drm_fd, config_id);
}
+static void test_open_race(const struct intel_execution_engine2 *e, int timeout)
+{
+ int *done;
+
+ done = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+ igt_assert(done != MAP_FAILED);
+
+ igt_fork(child, 1) {
+ uint64_t properties[] = {
+ DRM_I915_PERF_PROP_SAMPLE_OA, true,
+ DRM_I915_PERF_PROP_OA_METRICS_SET, test_set->perf_oa_metrics_set,
+ DRM_I915_PERF_PROP_OA_FORMAT, test_set->perf_oa_format,
+ DRM_I915_PERF_PROP_OA_EXPONENT, oa_exp_1_millisec,
+ };
+ struct drm_i915_perf_open_param param = {
+ .flags = I915_PERF_FLAG_FD_CLOEXEC,
+ .num_properties = sizeof(properties) / 16,
+ .properties_ptr = to_user_pointer(properties),
+ };
+ unsigned long count = 0;
+
+ do {
+ __perf_close(__perf_open(drm_fd, ¶m, false));
+ count++;
+ } while (!READ_ONCE(*done));
+
+ igt_info("Completed %lu cycles\n", count);
+ }
+
+ for (int persistence = 0; persistence <= 1; persistence++) {
+ igt_fork(child, sysconf(_SC_NPROCESSORS_ONLN)) {
+ int i915 = gem_reopen_driver(drm_fd);
+
+ do {
+ igt_spin_t *spin;
+ uint64_t ahnd;
+ uint32_t ctx;
+
+ ctx = gem_context_create_for_engine(i915, e->class, e->instance);
+ gem_context_set_persistence(i915, ctx, persistence);
+
+ spin = __igt_spin_new(i915, ctx, .ahnd = ahnd);
+ for (int i = random() % 7; i--; ) {
+ if (random() & 1) {
+ igt_spin_end(spin);
+ gem_sync(i915, spin->handle);
+ igt_spin_reset(spin);
+ }
+ gem_execbuf(i915, &spin->execbuf);
+ }
+
+ gem_context_destroy(i915, ctx);
+ igt_spin_free(i915, spin);
+ put_ahnd(ahnd);
+ } while (!READ_ONCE(*done));
+ }
+ }
+
+ sleep(timeout);
+ *done = 1;
+ igt_waitchildren();
+
+ munmap(done, 4096);
+}
+
static unsigned
read_i915_module_ref(void)
{
@@ -5259,6 +5324,15 @@ igt_main
igt_subtest("whitelisted-registers-userspace-config")
test_whitelisted_registers_userspace_config();
+ igt_subtest_with_dynamic("open-race") {
+ const struct intel_execution_engine2 *e;
+
+ for_each_physical_engine(drm_fd, e)
+ if (e->class == I915_ENGINE_CLASS_RENDER)
+ igt_dynamic_f("%s", e->name)
+ test_open_race(e, 5);
+ }
+
igt_fixture {
/* leave sysctl options in their default state... */
write_u64_file("/proc/sys/dev/i915/oa_max_sample_rate", 100000);
--
2.25.1
next prev parent reply other threads:[~2023-01-31 9:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 9:17 [igt-dev] [PATCH i-g-t 0/2] tests/i915/perf: Add stress / race exercises Janusz Krzysztofik
2023-01-31 9:17 ` Janusz Krzysztofik [this message]
2023-01-31 11:59 ` [igt-dev] [PATCH i-g-t 1/2] i915/perf: Stress opening of new perf streams against existing contexts Kamil Konieczny
2023-01-31 14:14 ` Janusz Krzysztofik
2023-01-31 9:17 ` [igt-dev] [PATCH i-g-t 2/2] tests/i915/perf: Exercise barrier race Janusz Krzysztofik
2023-02-01 18:21 ` Kamil Konieczny
2023-02-01 19:16 ` Janusz Krzysztofik
2023-02-02 10:19 ` Kamil Konieczny
2023-01-31 11:16 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/i915/perf: Add stress / race exercises Patchwork
2023-01-31 15:08 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-01-31 16:19 ` [igt-dev] [PATCH i-g-t 0/2] " Dixit, Ashutosh
2023-01-31 16:55 ` Dixit, Ashutosh
2023-01-31 17:56 ` Janusz Krzysztofik
2023-01-31 17:36 ` Janusz Krzysztofik
2023-01-31 18:36 ` Dixit, Ashutosh
2023-02-01 15:51 ` Janusz Krzysztofik
2023-02-03 19:21 ` Umesh Nerlige Ramappa
2023-02-03 20:59 ` Janusz Krzysztofik
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=20230131091731.5892-2-janusz.krzysztofik@linux.intel.com \
--to=janusz.krzysztofik@linux.intel.com \
--cc=adrinael@adrinael.net \
--cc=arek@hiler.eu \
--cc=chris.p.wilson@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox