public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 3/9] lib/perf: Fix data types and general tidy
Date: Tue, 10 Oct 2017 10:30:02 +0100	[thread overview]
Message-ID: <20171010093008.22804-4-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20171010093008.22804-1-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Configuration and format are uint64_t in the perf API.

Tidy some other details as well.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/igt_perf.c | 40 +++++++++++++++++++---------------------
 lib/igt_perf.h |  4 ++--
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/lib/igt_perf.c b/lib/igt_perf.c
index 961a858af9e3..208474302fcc 100644
--- a/lib/igt_perf.c
+++ b/lib/igt_perf.c
@@ -9,49 +9,47 @@
 
 uint64_t i915_type_id(void)
 {
-	char buf[1024];
-	int fd, n;
-
-	fd = open("/sys/bus/event_source/devices/i915/type", 0);
-	if (fd < 0) {
-		n = -1;
-	} else {
-		n = read(fd, buf, sizeof(buf)-1);
-		close(fd);
-	}
-	if (n < 0)
+	char buf[64];
+	ssize_t ret;
+	int fd;
+
+	fd = open("/sys/bus/event_source/devices/i915/type", O_RDONLY);
+	if (fd < 0)
+		return 0;
+
+	ret = read(fd, buf, sizeof(buf) - 1);
+	close(fd);
+	if (ret < 1)
 		return 0;
 
-	buf[n] = '\0';
-	return strtoull(buf, 0, 0);
+	buf[ret] = '\0';
+
+	return strtoull(buf, NULL, 0);
 }
 
-static int _perf_open(int config, int group, int format)
+static int _perf_open(uint64_t config, int group, uint64_t format)
 {
-	struct perf_event_attr attr;
-
-	memset(&attr, 0, sizeof (attr));
+	struct perf_event_attr attr = { };
 
 	attr.type = i915_type_id();
 	if (attr.type == 0)
 		return -ENOENT;
 
-	attr.config = config;
-
 	if (group >= 0)
 		format &= ~PERF_FORMAT_GROUP;
 
 	attr.read_format = format;
+	attr.config = config;
 
 	return perf_event_open(&attr, -1, 0, group, 0);
 }
 
-int perf_i915_open(int config)
+int perf_i915_open(uint64_t config)
 {
 	return _perf_open(config, -1, PERF_FORMAT_TOTAL_TIME_ENABLED);
 }
 
-int perf_i915_open_group(int config, int group)
+int perf_i915_open_group(uint64_t config, int group)
 {
 	return _perf_open(config, group,
 			  PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_GROUP);
diff --git a/lib/igt_perf.h b/lib/igt_perf.h
index 8e674c3a3755..cc10cb300aaf 100644
--- a/lib/igt_perf.h
+++ b/lib/igt_perf.h
@@ -62,7 +62,7 @@ perf_event_open(struct perf_event_attr *attr,
 }
 
 uint64_t i915_type_id(void);
-int perf_i915_open(int config);
-int perf_i915_open_group(int config, int group);
+int perf_i915_open(uint64_t config);
+int perf_i915_open_group(uint64_t config, int group);
 
 #endif /* I915_PERF_H */
-- 
2.9.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-10-10  9:30 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10  9:29 [PATCH v4 i-g-t 0/7] IGT PMU support Tvrtko Ursulin
2017-10-10  9:30 ` [PATCH i-g-t 1/9] intel-gpu-overlay: Move local perf implementation to a library Tvrtko Ursulin
2017-11-21 19:34   ` [PATCH i-g-t v3 " Tvrtko Ursulin
2017-10-10  9:30 ` [PATCH i-g-t 2/9] intel-gpu-overlay: Consolidate perf PMU access to library Tvrtko Ursulin
2017-10-10 12:21   ` Chris Wilson
2017-10-10  9:30 ` Tvrtko Ursulin [this message]
2017-10-10 12:22   ` [PATCH i-g-t 3/9] lib/perf: Fix data types and general tidy Chris Wilson
2017-10-10  9:30 ` [PATCH i-g-t 4/9] intel-gpu-overlay: Fix interrupts PMU readout Tvrtko Ursulin
2017-10-10 12:23   ` Chris Wilson
2017-10-10 14:17     ` [PATCH i-g-t v2 " Tvrtko Ursulin
2017-10-10  9:30 ` [PATCH i-g-t 5/9] intel-gpu-overlay: Catch-up to new i915 PMU Tvrtko Ursulin
2017-11-21 18:20   ` Tvrtko Ursulin
2017-10-10  9:30 ` [PATCH i-g-t 6/9] intel-gpu-overlay: Use RAPL PMU for power reading Tvrtko Ursulin
2017-10-10 11:30   ` [PATCH i-g-t v2 " Tvrtko Ursulin
2017-10-10 12:05     ` [PATCH i-g-t v3 " Tvrtko Ursulin
2017-10-10 12:25       ` Chris Wilson
2017-11-21 19:35       ` [PATCH i-g-t v4 " Tvrtko Ursulin
2017-10-10  9:30 ` [PATCH i-g-t 7/9] tests/perf_pmu: Tests for i915 PMU API Tvrtko Ursulin
2017-10-10 12:37   ` Chris Wilson
2017-10-10 13:38     ` Tvrtko Ursulin
2017-10-10 13:46       ` Chris Wilson
2017-10-10 14:17         ` [PATCH i-g-t v6 " Tvrtko Ursulin
2017-10-10 16:39           ` Chris Wilson
2017-10-11 12:54             ` [PATCH i-g-t v7 " Tvrtko Ursulin
2017-11-21 11:50               ` Chris Wilson
2017-11-21 18:21               ` [PATCH i-g-t v8 " Tvrtko Ursulin
2017-11-21 19:36                 ` [PATCH i-g-t v9 " Tvrtko Ursulin
2017-10-10  9:30 ` [PATCH i-g-t 8/9] gem_wsim: Busy stats balancers Tvrtko Ursulin
2017-11-21 19:37   ` [PATCH i-g-t v3 " Tvrtko Ursulin
2017-10-10  9:30 ` [PATCH i-g-t 9/9] media-bench.pl: Add busy balancers to the list Tvrtko Ursulin
2017-11-21 11:51   ` Chris Wilson
2017-10-10  9:42 ` ✗ Fi.CI.BAT: failure for IGT PMU support (rev7) Patchwork
2017-10-10 12:06 ` ✓ Fi.CI.BAT: success for IGT PMU support (rev8) Patchwork
2017-10-10 13:48 ` ✓ Fi.CI.BAT: success for IGT PMU support (rev9) Patchwork
2017-10-10 15:19 ` ✗ Fi.CI.IGT: failure for IGT PMU support (rev8) Patchwork
2017-10-10 18:42 ` ✓ Fi.CI.BAT: success for IGT PMU support (rev11) Patchwork
2017-10-11  1:28 ` ✓ Fi.CI.IGT: " Patchwork
2017-10-11 14:09 ` ✓ Fi.CI.BAT: success for IGT PMU support (rev12) Patchwork
2017-10-11 20:16 ` ✗ Fi.CI.IGT: failure " Patchwork
2017-11-22 11:41 ` ✓ Fi.CI.BAT: success for IGT PMU support (rev18) Patchwork
2017-11-22 11:57   ` Tvrtko Ursulin
2017-11-22 12:47     ` Petri Latvala
2017-11-22 14:31 ` ✓ Fi.CI.IGT: " Patchwork
2017-11-22 14:39   ` Petri Latvala
2017-11-22 14:50     ` Petri Latvala
2017-11-22 17:09     ` Tvrtko Ursulin

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=20171010093008.22804-4-tvrtko.ursulin@linux.intel.com \
    --to=tursulin@ursulin.net \
    --cc=Intel-gfx@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