From: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 4/4] tests/perf: add new tests for configurable OA buffer size
Date: Wed, 10 Oct 2018 17:57:47 +0100 [thread overview]
Message-ID: <20181010165747.23667-5-lionel.g.landwerlin@intel.com> (raw)
In-Reply-To: <20181010165747.23667-1-lionel.g.landwerlin@intel.com>
Verify that the buffer fills up within the expected time based of a
given size and also that invalid sizes are rejected.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
tests/perf.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 103 insertions(+), 9 deletions(-)
diff --git a/tests/perf.c b/tests/perf.c
index ab3aed35..6a6001d5 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -2334,11 +2334,31 @@ test_polling(void)
__perf_close(stream_fd);
}
+static int
+find_oa_exponent_for_buffer_fill_time(size_t oa_buf_size, size_t report_size, uint64_t fill_time_ns)
+{
+ size_t n_reports = oa_buf_size / report_size;
+
+ for (int e = 1; e < 32; e++) {
+ if (fill_time_ns < oa_exponent_to_ns(e) * n_reports)
+ return e;
+ }
+
+ igt_assert(!"reached");
+ return -1;
+}
+
static void
-test_buffer_fill(void)
+test_buffer_fill(bool program_size, size_t oa_buf_size)
{
- /* ~5 micro second period */
- int oa_exponent = max_oa_exponent_for_period_lte(5000);
+ size_t report_size = get_oa_format(test_oa_format).size;
+ /*
+ * Select an exponent that guarantees that the buffer fills up
+ * in about 25ms. Otherwise the nanosleep might be too short
+ * which makes the test unreliable.
+ */
+ int oa_exponent = find_oa_exponent_for_buffer_fill_time(oa_buf_size, report_size,
+ 25 * 1000 * 1000UL);
uint64_t oa_period = oa_exponent_to_ns(oa_exponent);
uint64_t properties[] = {
/* Include OA reports in samples */
@@ -2348,18 +2368,18 @@ test_buffer_fill(void)
DRM_I915_PERF_PROP_OA_METRICS_SET, test_metric_set_id,
DRM_I915_PERF_PROP_OA_FORMAT, test_oa_format,
DRM_I915_PERF_PROP_OA_EXPONENT, oa_exponent,
+ DRM_I915_PERF_PROP_OA_BUFFER_SIZE, oa_buf_size,
};
struct drm_i915_perf_open_param param = {
.flags = I915_PERF_FLAG_FD_CLOEXEC,
- .num_properties = sizeof(properties) / 16,
+ .num_properties = program_size ?
+ (ARRAY_SIZE(properties) / 2) : ((ARRAY_SIZE(properties) / 2) - 1),
.properties_ptr = to_user_pointer(properties),
};
struct drm_i915_perf_record_header *header;
int buf_size = 65536 * (256 + sizeof(struct drm_i915_perf_record_header));
uint8_t *buf = malloc(buf_size);
int len;
- size_t oa_buf_size = DEFAULT_OA_BUF_SIZE;
- size_t report_size = get_oa_format(test_oa_format).size;
int n_full_oa_reports = oa_buf_size / report_size;
uint64_t fill_duration = n_full_oa_reports * oa_period;
@@ -2396,8 +2416,9 @@ test_buffer_fill(void)
do_ioctl(stream_fd, I915_PERF_IOCTL_DISABLE, 0);
- igt_debug("fill_duration = %"PRIu64"ns, oa_exponent = %u\n",
- fill_duration, oa_exponent);
+ igt_debug("fill_duration = %"PRIu64"ns/%"PRIu64"us/%"PRIu64"ms, oa_exponent = %u, buf_size = %lu\n",
+ fill_duration, fill_duration / 1000, fill_duration / 1000000,
+ oa_exponent, oa_buf_size);
do_ioctl(stream_fd, I915_PERF_IOCTL_ENABLE, 0);
@@ -2477,6 +2498,35 @@ test_buffer_fill(void)
__perf_close(stream_fd);
}
+static void
+test_invalid_buffer_size()
+{
+ uint64_t properties[] = {
+ /* Include OA reports in samples */
+ DRM_I915_PERF_PROP_SAMPLE_OA, true,
+
+ /* OA unit configuration */
+ DRM_I915_PERF_PROP_OA_METRICS_SET, test_metric_set_id,
+ DRM_I915_PERF_PROP_OA_FORMAT, test_oa_format,
+ DRM_I915_PERF_PROP_OA_EXPONENT, max_oa_exponent_for_period_lte(5000),
+ DRM_I915_PERF_PROP_OA_BUFFER_SIZE, 0 /* updated below */,
+ };
+ struct drm_i915_perf_open_param param = {
+ .flags = I915_PERF_FLAG_FD_CLOEXEC,
+ .num_properties = ARRAY_SIZE(properties) / 2,
+ .properties_ptr = to_user_pointer(properties),
+ };
+
+ properties[ARRAY_SIZE(properties) - 1] = DEFAULT_OA_BUF_SIZE + 1;
+ do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m, EINVAL);
+
+ properties[ARRAY_SIZE(properties) - 1] = 0xffffffff;
+ do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m, EINVAL);
+
+ properties[ARRAY_SIZE(properties) - 1] = 0xffffffffffffffff;
+ do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m, EINVAL);
+}
+
static void
test_enable_disable(void)
{
@@ -4079,6 +4129,32 @@ test_sysctl_defaults(void)
igt_assert_eq(max_freq, 100000);
}
+static bool
+kernel_supports_open_option(int fd, uint64_t option, uint64_t value)
+{
+ uint64_t properties[] = {
+ /* Intentionally wrong handle */
+ DRM_I915_PERF_PROP_CTX_HANDLE, UINT64_MAX,
+
+ DRM_I915_PERF_PROP_SAMPLE_OA, true,
+ DRM_I915_PERF_PROP_OA_METRICS_SET, test_metric_set_id,
+ DRM_I915_PERF_PROP_OA_FORMAT, test_oa_format,
+ DRM_I915_PERF_PROP_OA_EXPONENT, max_oa_exponent_for_period_lte(5000),
+ option, value,
+ };
+ struct drm_i915_perf_open_param param = {
+ .flags = I915_PERF_FLAG_FD_CLOEXEC,
+ .num_properties = ARRAY_SIZE(properties) / 2,
+ .properties_ptr = to_user_pointer(properties),
+ };
+ int ret;
+
+ ret = igt_ioctl(fd, DRM_IOCTL_I915_PERF_OPEN, ¶m);
+ assert(ret == -1);
+
+ return errno == ENOENT;
+}
+
igt_main
{
igt_skip_on_simulation();
@@ -4152,7 +4228,25 @@ igt_main
}
igt_subtest("buffer-fill")
- test_buffer_fill();
+ test_buffer_fill(false, DEFAULT_OA_BUF_SIZE);
+
+ igt_subtest("buffer-fill-sized") {
+ size_t size = 128 * 1024; /* Smallest HW supported size. */
+ const size_t max_size = DEFAULT_OA_BUF_SIZE;
+
+ igt_require(kernel_supports_open_option(drm_fd, DRM_I915_PERF_PROP_OA_BUFFER_SIZE, 0));
+
+ while (size <= max_size) {
+ test_buffer_fill(true, size);
+ size *= 2;
+ }
+ }
+
+ igt_subtest("invalid-buffer-size") {
+ igt_require(kernel_supports_open_option(drm_fd, DRM_I915_PERF_PROP_OA_BUFFER_SIZE, 0));
+
+ test_invalid_buffer_size();
+ }
igt_subtest("disabled-read-error")
test_disabled_read_error();
--
2.19.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-10-10 16:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 16:57 [igt-dev] [PATCH i-g-t 0/4] tests/perf: add support for new oa buffer size parameter Lionel Landwerlin
2018-10-10 16:57 ` [igt-dev] [PATCH i-g-t 1/4] include: bump drm uAPI headers Lionel Landwerlin
2018-10-10 16:57 ` [igt-dev] [PATCH i-g-t 2/4] tests/perf: buffer-fill: drop load helper usage Lionel Landwerlin
2018-10-10 16:57 ` [igt-dev] [PATCH i-g-t 3/4] tests/perf: rename MAX_OA_BUFFER_SIZE Lionel Landwerlin
2018-10-10 16:57 ` Lionel Landwerlin [this message]
2018-10-10 17:12 ` [igt-dev] [PATCH i-g-t 4/4] tests/perf: add new tests for configurable OA buffer size Chris Wilson
2018-10-10 17:38 ` Lionel Landwerlin
2018-10-10 17:50 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/perf: add support for new oa buffer size parameter Patchwork
2018-10-10 23:56 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=20181010165747.23667-5-lionel.g.landwerlin@intel.com \
--to=lionel.g.landwerlin@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