From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: Riana Tauro <riana.tauro@intel.com>
Cc: igt-dev@lists.freedesktop.org, tvrtko.ursulin@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t v2] tests/i915/perf_pmu: Add a basic perf_pmu test
Date: Fri, 3 Feb 2023 11:20:00 -0800 [thread overview]
Message-ID: <Y91eYOfdMN3PIRdB@orsosgc001.jf.intel.com> (raw)
In-Reply-To: <20230201043903.1847377-1-riana.tauro@intel.com>
On Wed, Feb 01, 2023 at 10:09:03AM +0530, Riana Tauro wrote:
>add a test that verifies the i915 pmu directory and
>reads all the events
>
>v2 : use igt_assert_eq instead of igt_assert
> check errno after loop (Umesh)
>
>Signed-off-by: Riana Tauro <riana.tauro@intel.com>
lgtm,
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>---
> lib/igt_perf.c | 11 +++++++++++
> lib/igt_perf.h | 1 +
> tests/i915/perf_pmu.c | 32 ++++++++++++++++++++++++++++++++
> 3 files changed, 44 insertions(+)
>
>diff --git a/lib/igt_perf.c b/lib/igt_perf.c
>index 11c91c5f..ffe078ad 100644
>--- a/lib/igt_perf.c
>+++ b/lib/igt_perf.c
>@@ -1,5 +1,6 @@
> #include <errno.h>
> #include <fcntl.h>
>+#include <limits.h>
> #include <stdint.h>
> #include <stdlib.h>
> #include <string.h>
>@@ -98,6 +99,16 @@ uint64_t igt_perf_type_id(const char *device)
> return strtoull(buf, NULL, 0);
> }
>
>+int igt_perf_events_dir(int i915)
>+{
>+ char buf[80];
>+ char path[PATH_MAX];
>+
>+ i915_perf_device(i915, buf, sizeof(buf));
>+ snprintf(path, sizeof(path), "/sys/bus/event_source/devices/%s/events", buf);
>+ return open(path, O_RDONLY);
>+}
>+
> static int
> _perf_open(uint64_t type, uint64_t config, int group, uint64_t format)
> {
>diff --git a/lib/igt_perf.h b/lib/igt_perf.h
>index 672bfea6..4d86e31a 100644
>--- a/lib/igt_perf.h
>+++ b/lib/igt_perf.h
>@@ -54,6 +54,7 @@ perf_event_open(struct perf_event_attr *attr,
> }
>
> uint64_t igt_perf_type_id(const char *device);
>+int igt_perf_events_dir(int i915);
> int igt_perf_open(uint64_t type, uint64_t config);
> int igt_perf_open_group(uint64_t type, uint64_t config, int group);
>
>diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
>index f363db2b..c1779fc9 100644
>--- a/tests/i915/perf_pmu.c
>+++ b/tests/i915/perf_pmu.c
>@@ -2132,6 +2132,34 @@ static void test_unload(unsigned int num_engines)
> igt_assert_eq(__igt_i915_driver_unload(NULL), 0);
> }
>
>+static void pmu_read(int i915)
>+{
>+ char val[128];
>+ int pmu_fd;
>+ struct dirent *de;
>+ DIR *dir;
>+
>+ pmu_fd = igt_perf_events_dir(i915);
>+ igt_require(pmu_fd >= 0);
>+
>+ dir = fdopendir(dup(pmu_fd));
>+ igt_assert(dir);
>+ rewinddir(dir);
>+
>+ errno = 0;
>+ while ((de = readdir(dir))) {
>+ if (de->d_type != DT_REG)
>+ continue;
>+
>+ igt_assert_eq(igt_sysfs_scanf(pmu_fd, de->d_name, "%127s", val), 1);
>+ igt_debug("'%s': %s\n", de->d_name, val);
>+ }
>+
>+ igt_assert_eq(errno, 0);
>+ closedir(dir);
>+ close(pmu_fd);
>+}
>+
> #define test_each_engine(T, i915, ctx, e) \
> igt_subtest_with_dynamic(T) for_each_ctx_engine(i915, ctx, e) \
> igt_dynamic_f("%s", e->name)
>@@ -2167,6 +2195,10 @@ igt_main
> igt_require(num_engines);
> }
>
>+ igt_describe("Verify i915 pmu dir exists and read all events");
>+ igt_subtest("pmu-read")
>+ pmu_read(fd);
>+
> /**
> * Test invalid access via perf API is rejected.
> */
>--
>2.39.0
>
prev parent reply other threads:[~2023-02-03 19:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 4:39 [igt-dev] [PATCH i-g-t v2] tests/i915/perf_pmu: Add a basic perf_pmu test Riana Tauro
2023-02-01 5:12 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/i915/perf_pmu: Add a basic perf_pmu test (rev2) Patchwork
2023-02-01 6:49 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-02-03 19:20 ` Umesh Nerlige Ramappa [this message]
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=Y91eYOfdMN3PIRdB@orsosgc001.jf.intel.com \
--to=umesh.nerlige.ramappa@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=riana.tauro@intel.com \
--cc=tvrtko.ursulin@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