Skip to contentSkip to conversation

i915/perf: Correct the logic of finding i915 pmu event path

igt-dev NAK Terrence Xu 4 participants 5 messages Apr 10, 2020 – Apr 14, 2020 Library code

lore
Share & tools
lore
#0 lore raw

Hardcoded i915 PMU event path /sys/bus/event_source/devices/i915 isn't always correct when vGPU isn't on BDF 0:2.0 in virtualization environment.

e.g. It will show as sys/bus/event_source/devices/i915-0000:00:03.0 when vGPU is on BDF 0:3.0.

Refine the path name so that intel_gpu_top can find the correct adapter.

---
 lib/igt_perf.c        | 15 ++++++++++++++-
 tools/intel_gpu_top.c | 16 +++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)
lib/igt_perf.c +14 -1
index 418c1c188..3531209b3 100644
@@ -7,6 +7,7 @@
 #include <sys/stat.h>
 #include <sys/sysinfo.h>
 #include <sys/sysmacros.h>
+#include <dirent.h>
 
 #include "igt_perf.h"
 
@@ -75,11 +76,23 @@ uint64_t i915_perf_type_id(int i915)
 uint64_t igt_perf_type_id(const char *device)
 {
 	char buf[64];
+	char dev[64];
 	ssize_t ret;
 	int fd;
+	DIR *dir;
+	struct dirent *dent;
+
+	dir = opendir("/sys/bus/event_source/devices/");
+
+	while ((dent = readdir(dir))) {
+		if (!(strncmp(dent->d_name, device, strlen(device)))) {
+			strcpy(dev, dent->d_name);
+			break;
+		}
+	}
 
 	snprintf(buf, sizeof(buf),
-		 "/sys/bus/event_source/devices/%s/type", device);
+		 "/sys/bus/event_source/devices/%s/type", dev);
 
 	fd = open(buf, O_RDONLY);
 	if (fd < 0)
tools/intel_gpu_top.c +15 -1
index 8197482dd..065c40bba 100644
@@ -170,11 +170,13 @@ static int engine_cmp(const void *__a, const void *__b)
 
 static struct engines *discover_engines(void)
 {
-	const char *sysfs_root = "/sys/devices/i915/events";
+	const char *sysfs_root = "/sys/bus/event_source/devices/";
 	struct engines *engines;
 	struct dirent *dent;
 	int ret = 0;
 	DIR *d;
+	char dev[64];
+	char eve[64];
 
 	engines = malloc(sizeof(struct engines));
 	if (!engines)
@@ -184,7 +186,19 @@ static struct engines *discover_engines(void)
 
 	engines->num_engines = 0;
 
+
 	d = opendir(sysfs_root);
+	while ((dent = readdir(d))) {
+
+		if (!(strncmp(dent->d_name, "i915", 4))) {
+			strcpy(dev, dent->d_name);
+			break;
+		}
+	}
+
+	sprintf(eve, "%s%s/events", sysfs_root, dev);
+
+	d = opendir(eve);
 	if (!d)
 		return NULL;
 
Signature · 6 lines
2.17.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

Quoting Terrence Xu (2020-04-10 11:20:46)

Quoted 28 lines

Hardcoded i915 PMU event path /sys/bus/event_source/devices/i915 isn't always correct when vGPU isn't on BDF 0:2.0 in virtualization environment.

e.g. It will show as sys/bus/event_source/devices/i915-0000:00:03.0 when vGPU is on BDF 0:3.0.

Refine the path name so that intel_gpu_top can find the correct adapter.

---
 lib/igt_perf.c        | 15 ++++++++++++++-
 tools/intel_gpu_top.c | 16 +++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)
lib/igt_perf.c +1 -0
index 418c1c188..3531209b3 100644
@@ -7,6 +7,7 @@
 #include <sys/stat.h>
 #include <sys/sysinfo.h>
 #include <sys/sysmacros.h>
+#include <dirent.h>
 
 #include "igt_perf.h"
 

lib/igt_perf.c uint64_t i915_perf_type_id(int i915) · line 85

Quoted 10 lines
lib/igt_perf.c +5 -0
@@ -75,11 +76,23 @@ uint64_t i915_perf_type_id(int i915)
 uint64_t igt_perf_type_id(const char *device)
 {
        char buf[64];
+       char dev[64];
        ssize_t ret;
        int fd;
+       DIR *dir;
+       struct dirent *dent;
+
+       dir = opendir("/sys/bus/event_source/devices/");

Nak, this is passed the explicit device to use.

i915_perf_type_id() takes the device fd and expands it to the pmu device name.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw
Quoted 44 lines

-----Original Message-----
From: Chris Wilson <[email protected]>
Quoting Terrence Xu (2020-04-10 11:20:46)

Quoted 28 lines

Hardcoded i915 PMU event path /sys/bus/event_source/devices/i915 isn't always correct when vGPU isn't on BDF 0:2.0 in virtualization environment.

e.g. It will show as sys/bus/event_source/devices/i915-0000:00:03.0 when vGPU is on BDF 0:3.0.

Refine the path name so that intel_gpu_top can find the correct adapter.

---
 lib/igt_perf.c        | 15 ++++++++++++++-
 tools/intel_gpu_top.c | 16 +++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)
lib/igt_perf.c index renamed from lib/igt_perf.c +0 -0

418c1c188..3531209b3 100644

lib/igt_perf.c +1 -0
@@ -7,6 +7,7 @@
 #include <sys/stat.h>
 #include <sys/sysinfo.h>
 #include <sys/sysmacros.h>
+#include <dirent.h>
 
 #include "igt_perf.h"
 

lib/igt_perf.c uint64_t i915_perf_type_id(int i915) uint64_t · line 84

Quoted 9 lines
lib/igt_perf.c +5 -0
@@ -75,11 +76,23 @@ uint64_t i915_perf_type_id(int i915)  uint64_t
 igt_perf_type_id(const char *device)  {
        char buf[64];
+       char dev[64];
        ssize_t ret;
        int fd;
+       DIR *dir;
+       struct dirent *dent;
+
+       dir = opendir("/sys/bus/event_source/devices/");

Nak, this is passed the explicit device to use.

Quoted 2 lines

i915_perf_type_id() takes the device fd and expands it to the pmu device name. -Chris

[Xu, Terrence] Thanks for your quick response! Do you think we can use perf_i915_open_group() instead of perf_igfx_open_group() in intel_gpu_top when open pmu? Since i915_perf_type_id() can provide the right i915 pmu.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

+ Ayaz

Quoted 44 lines · Terrence
Quoted 44 lines

-----Original Message-----
From: Chris Wilson <[email protected]>
Quoting Terrence Xu (2020-04-10 11:20:46)

Quoted 28 lines

Hardcoded i915 PMU event path /sys/bus/event_source/devices/i915 isn't always correct when vGPU isn't on BDF 0:2.0 in virtualization environment.

e.g. It will show as sys/bus/event_source/devices/i915-0000:00:03.0 when vGPU is on BDF 0:3.0.

Refine the path name so that intel_gpu_top can find the correct adapter.

---
  lib/igt_perf.c        | 15 ++++++++++++++-
  tools/intel_gpu_top.c | 16 +++++++++++++++-
  2 files changed, 29 insertions(+), 2 deletions(-)
lib/igt_perf.c index renamed from lib/igt_perf.c +0 -0

418c1c188..3531209b3 100644

lib/igt_perf.c +1 -0
@@ -7,6 +7,7 @@
  #include <sys/stat.h>
  #include <sys/sysinfo.h>
  #include <sys/sysmacros.h>
+#include <dirent.h>
 
  #include "igt_perf.h"
 

lib/igt_perf.c uint64_t i915_perf_type_id(int i915) uint64_t · line 84

Quoted 9 lines
lib/igt_perf.c +5 -0
@@ -75,11 +76,23 @@ uint64_t i915_perf_type_id(int i915)  uint64_t
 igt_perf_type_id(const char *device)  {
         char buf[64];
+       char dev[64];
         ssize_t ret;
         int fd;
+       DIR *dir;
+       struct dirent *dent;
+
+       dir = opendir("/sys/bus/event_source/devices/");

Nak, this is passed the explicit device to use.

Quoted 3 lines
Quoted 2 lines

i915_perf_type_id() takes the device fd and expands it to the pmu device name. -Chris

[Xu, Terrence] Thanks for your quick response! Do you think we can use perf_i915_open_group() instead of perf_igfx_open_group() in intel_gpu_top when open pmu? Since i915_perf_type_id() can provide the right i915 pmu.

Ayaz has a patch series in progress which should fix this.

Apart that it would think of 0000:00:03.0 as a discrete GPU but perhaps that would be okay for now, since only difference would be omission or RAPL (power) data which is probably correct for virtualization.

Regards,

Tvrtko
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for i915/perf: Correct the logic of finding i915 pmu event path

In reply to Terrence Xu
== Series Details ==

== Series Details ==

Series: i915/perf: Correct the logic of finding i915 pmu event path
URL : https://patchwork.freedesktop.org/series/75794/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8289 -> IGTPW_4444
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_4444 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_4444, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4444/index.html

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_4444:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@execlists:
- fi-skl-lmem: [PASS][1] -> [DMESG-WARN][2] +1 similar issue
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8289/fi-skl-lmem/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4444/fi-skl-lmem/igt@i915_selftest@[email protected]

Known issues
------------

Here are the changes found in IGTPW_4444 that come from known issues:

### IGT changes ###

#### Possible fixes ####

* igt@kms_flip@basic-flip-vs-wf_vblank:
- fi-skl-lmem: [DMESG-WARN][3] -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8289/fi-skl-lmem/igt@kms_flip@basic-flip-vs-wf_vblank.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4444/fi-skl-lmem/igt@kms_flip@basic-flip-vs-wf_vblank.html

#### Warnings ####

* igt@i915_pm_rpm@module-reload:
- fi-kbl-x1275: [FAIL][5] ([i915#62] / [i915#95]) -> [SKIP][6] ([fdo#109271])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8289/fi-kbl-x1275/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4444/fi-kbl-x1275/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#62]: https://gitlab.freedesktop.org/drm/intel/issues/62
[i915#666]: https://gitlab.freedesktop.org/drm/intel/issues/666
[i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95

Participating hosts (52 -> 46)
------------------------------

Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_5586 -> IGTPW_4444

CI-20190529: 20190529
CI_DRM_8289: 81e3d7ff72672b6aeadbf9c0b9cc514cec9c889d @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_4444: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4444/index.html
IGT_5586: 29fad328e6a1b105c8d688cafe19b1b5c19ad0c8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_4444/index.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev