From patchwork Tue Jan 31 09:17:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13122582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53A8FC636CD for ; Tue, 31 Jan 2023 09:18:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5E9410E32B; Tue, 31 Jan 2023 09:18:01 +0000 (UTC) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id C889010E31A; Tue, 31 Jan 2023 09:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675156675; x=1706692675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J9LbdSjmVWg07qkWZYdKzd1aZNthp1vZOLxnmY3ObGY=; b=Jgw+wi6jCT7iIbPLpxq/kypD0Xrf38QqKIjTPF53grlB8xUyKx1SAcDb XxzfjeEcB6pMz1jsiPr2wr6SHkRiDH54SkMwom+cYauHoAd1G+vFYZ2eV lhSw80j4nA1tctZY/jFEOJnn/UgSLh6dGOc82e28iSPEWXsLm4QL40W/d 9cuAtX0N10RDGJC/WA6aAr3igMpihtEiy7OtcQaDGebU0z4yIcQunHBfS 2istplKyDRmTUsWtg+g8Ibx59zXNrXwRr/mgztGDFZ32E4bsgaKELSQzH aa1hV8wwRAgRMwgixh1113tpYMqwA6rpaYi2AjeQ773a0eHiGbdAkc2A3 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="390154150" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="390154150" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 01:17:55 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="909837944" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="909837944" Received: from khernet-mobl.ger.corp.intel.com (HELO jkrzyszt-mobl1.ger.corp.intel.com) ([10.213.18.238]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 01:17:52 -0800 From: Janusz Krzysztofik To: Petri Latvala , Arkadiusz Hiler , Kamil Konieczny Date: Tue, 31 Jan 2023 10:17:30 +0100 Message-Id: <20230131091731.5892-2-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131091731.5892-1-janusz.krzysztofik@linux.intel.com> References: <20230131091731.5892-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/2] i915/perf: Stress opening of new perf streams against existing contexts X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Chris Wilson Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Chris Wilson 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 Signed-off-by: Janusz Krzysztofik Cc: Andi Shyti --- 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); From patchwork Tue Jan 31 09:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13122581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FFE5C38142 for ; Tue, 31 Jan 2023 09:18:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6458C10E31A; Tue, 31 Jan 2023 09:18:00 +0000 (UTC) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B703E10E32B; Tue, 31 Jan 2023 09:17:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675156678; x=1706692678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tzciVk8LP4p/TqsIOEeeJ/RvfEhNpsVE6QdphgFsalc=; b=a3diXOs9fxKOd+E6iqPVvfrnbI0d+WeIiNvtpUrL94iyRCa0UoVC35Oy Xn4+na9vfoxxYrikqvz28QcGrze8Rf8NDwTpRqXE/0Zjr+Cr73QBzrY1L ijwlIUU43Ltz//q5ZZcfMpDNMxqkdakIbmC2YtkFaNo5HMvo3DjbWfTbk Uzo0QByCkn0eJ7efbb6rVViVx6EyEm/4gmVbojs+sMGaYXfKcnAAwB1Ll plyRpTHhbe7hSPCkh4QqBsbzoKBKH6uj17N0oIDNHJDJc9wJd85cflH1o FgAQpxqYiPU1WbJK8hEbDJICi5c3Hg+6yPhkM2Y6gjlAjm/MZSBqIDjvD w==; X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="390154169" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="390154169" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 01:17:58 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="909837963" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="909837963" Received: from khernet-mobl.ger.corp.intel.com (HELO jkrzyszt-mobl1.ger.corp.intel.com) ([10.213.18.238]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 01:17:55 -0800 From: Janusz Krzysztofik To: Petri Latvala , Arkadiusz Hiler , Kamil Konieczny Date: Tue, 31 Jan 2023 10:17:31 +0100 Message-Id: <20230131091731.5892-3-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230131091731.5892-1-janusz.krzysztofik@linux.intel.com> References: <20230131091731.5892-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/2] tests/i915/perf: Exercise barrier race X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Chris Wilson Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add a new subtest focused on exercising interaction between perf open / close operations, which replace active barriers with perf requests, and concurrent barrier preallocate / acquire operations performed during context first pin / last unpin. References: https://gitlab.freedesktop.org/drm/intel/-/issues/6333 Signed-off-by: Janusz Krzysztofik Cc: Chris Wilson --- tests/i915/perf.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/tests/i915/perf.c b/tests/i915/perf.c index e33cacc443..11a3ec21ab 100644 --- a/tests/i915/perf.c +++ b/tests/i915/perf.c @@ -39,6 +39,7 @@ #include #include "i915/gem.h" +#include "i915/gem_create.h" #include "i915/perf.h" #include "igt.h" #include "igt_perf.h" @@ -4885,7 +4886,27 @@ 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) +static void gem_exec_nop(int i915, const struct intel_execution_engine2 *e) +{ + const uint32_t bbe = MI_BATCH_BUFFER_END; + struct drm_i915_gem_exec_object2 obj = { }; + struct drm_i915_gem_execbuffer2 execbuf = { + .buffers_ptr = to_user_pointer(&obj), + .buffer_count = 1, + }; + + obj.handle = gem_create(i915, 4096); + gem_write(i915, obj.handle, 0, &bbe, sizeof(bbe)); + + execbuf.flags = e->flags; + gem_execbuf(i915, &execbuf); + + gem_sync(i915, obj.handle); + gem_close(i915, obj.handle); +} + +static void test_open_race(const struct intel_execution_engine2 *e, int timeout, + bool use_spin) { int *done; @@ -4926,6 +4947,12 @@ static void test_open_race(const struct intel_execution_engine2 *e, int timeout) ctx = gem_context_create_for_engine(i915, e->class, e->instance); gem_context_set_persistence(i915, ctx, persistence); + if (!use_spin) { + gem_exec_nop(i915, e); + gem_context_destroy(i915, ctx); + continue; + } + spin = __igt_spin_new(i915, ctx, .ahnd = ahnd); for (int i = random() % 7; i--; ) { if (random() & 1) { @@ -5330,7 +5357,17 @@ igt_main 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); + test_open_race(e, 5, true); + } + + igt_describe("Exercise perf open/close against intensive barrier preallocate/acquire"); + igt_subtest_with_dynamic("barrier-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, false); } igt_fixture {