From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/5] i915/pmu: Add helpers to convert ticks to ns
Date: Fri, 22 Sep 2023 14:52:29 -0700 [thread overview]
Message-ID: <20230922215233.2438200-2-umesh.nerlige.ramappa@intel.com> (raw)
In-Reply-To: <20230922215233.2438200-1-umesh.nerlige.ramappa@intel.com>
MTL is introducing a 2 new counters to read busyness in ticks rather
than nanoseconds:
(1) A counter that returns engine busyness in ticks (xxxx-busy-ticks)
(2) A counter that returns gt active time in ticks (total-active-ticks)
Busyness % = (delta-xxxx-busy-ticks * 100) / delta-total-active-ticks
At the same time it is deprecating the old busyness counter that would
require the kernel to convert the ticks to ns.
Current IGT modifications are not using total-active-ticks since that is
a larger change and more thought needs to go into incorporating that
into the tests. That will be part of a follow up series. For now, add
some helpers to the IGT tests to convert the ticks to ns.
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
tests/intel/perf_pmu.c | 69 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/tests/intel/perf_pmu.c b/tests/intel/perf_pmu.c
index c6e6a8b77..87078ad38 100644
--- a/tests/intel/perf_pmu.c
+++ b/tests/intel/perf_pmu.c
@@ -255,6 +255,72 @@ IGT_TEST_DESCRIPTION("Test the i915 pmu perf interface");
const double tolerance = 0.05f;
const unsigned long batch_duration_ns = 500e6;
+static bool busy_ticks_only;
+static uint32_t cs_ts_freq;
+
+static bool strendswith(const char *str, const char *endswith)
+{
+ unsigned int endlen = strlen(endswith);
+ unsigned int str_len = strlen(str);
+
+ if (str_len < endlen)
+ return false;
+
+ return strcmp(str + (str_len - endlen), endswith) == 0;
+}
+
+static bool pmu_supports_event(int i915, const char *event_end)
+{
+ struct dirent *dent;
+ bool found = false;
+ int pmu_fd;
+ DIR *d;
+
+ pmu_fd = igt_perf_events_dir(i915);
+ igt_require(pmu_fd >= 0);
+
+ d = fdopendir(dup(pmu_fd));
+ igt_assert(d);
+ rewinddir(d);
+
+ while ((dent = readdir(d)) != NULL) {
+ if (dent->d_type != DT_REG)
+ continue;
+
+ if (strendswith(dent->d_name, event_end)) {
+ found = true;
+ break;
+ }
+ }
+
+ closedir(d);
+ close(pmu_fd);
+
+ return found;
+}
+
+static bool pmu_supports_only_busy_ticks(int i915)
+{
+ return pmu_supports_event(i915, "-busy-ticks") &&
+ !pmu_supports_event(i915, "-busy");
+}
+
+static uint32_t
+cs_timestamp_frequency(int fd)
+{
+ struct drm_i915_getparam gp = {};
+ static uint32_t value;
+
+ if (value)
+ return value;
+
+ gp.param = I915_PARAM_CS_TIMESTAMP_FREQUENCY;
+ gp.value = (int *)(&value);
+
+ igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp), 0);
+
+ return value;
+}
char *drpc;
const char *no_debug_data = "\0";
@@ -2482,6 +2548,9 @@ igt_main
i915_for_each_gt(fd, tmp, gt)
num_gt++;
+
+ busy_ticks_only = pmu_supports_only_busy_ticks(fd);
+ cs_ts_freq = cs_timestamp_frequency(fd);
}
igt_describe("Verify i915 pmu dir exists and read all events");
--
2.38.1
next prev parent reply other threads:[~2023-09-22 21:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 21:52 [igt-dev] [PATCH i-g-t 0/5] Update IGT tests to support new engine busyness interface Umesh Nerlige Ramappa
2023-09-22 21:52 ` Umesh Nerlige Ramappa [this message]
2023-09-22 21:52 ` [igt-dev] [PATCH i-g-t 2/5] i915/pmu: Pass config directly to the init test Umesh Nerlige Ramappa
2023-09-22 21:52 ` [igt-dev] [PATCH i-g-t 3/5] i915/pmu: Switch to new busyness counter if old one is unavailable Umesh Nerlige Ramappa
2023-09-22 21:52 ` [igt-dev] [PATCH i-g-t 4/5] lib/i915: Export engine to gt mapping Umesh Nerlige Ramappa
2023-09-22 21:52 ` [igt-dev] [PATCH i-g-t 5/5] i915/pmu: Add a new test to use total_active_ticks for busyness Umesh Nerlige Ramappa
2023-09-22 22:18 ` Umesh Nerlige Ramappa
2023-09-22 22:58 ` [igt-dev] ✗ Fi.CI.BAT: failure for Update IGT tests to support new engine busyness interface Patchwork
2023-09-23 0:04 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
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=20230922215233.2438200-2-umesh.nerlige.ramappa@intel.com \
--to=umesh.nerlige.ramappa@intel.com \
--cc=igt-dev@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: 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