From patchwork Thu Aug 31 10:35:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 9931807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 155686016C for ; Thu, 31 Aug 2017 10:35:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06F72288F3 for ; Thu, 31 Aug 2017 10:35:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F03FD288F9; Thu, 31 Aug 2017 10:35:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9DDE2288F3 for ; Thu, 31 Aug 2017 10:35:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EAE956E6CA; Thu, 31 Aug 2017 10:35:40 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 94D4C6E6B8 for ; Thu, 31 Aug 2017 10:35:31 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Aug 2017 03:35:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,451,1498546800"; d="scan'208";a="146648099" Received: from delly.ld.intel.com ([10.103.239.215]) by fmsmga006.fm.intel.com with ESMTP; 31 Aug 2017 03:35:30 -0700 From: Lionel Landwerlin To: intel-gfx@lists.freedesktop.org Date: Thu, 31 Aug 2017 11:35:13 +0100 Message-Id: <20170831103515.21188-10-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170831103515.21188-1-lionel.g.landwerlin@intel.com> References: <20170831103515.21188-1-lionel.g.landwerlin@intel.com> Subject: [Intel-gfx] [PATCH i-g-t v5 09/11] tests/perf: estimate number of blocking/polling based on time spent X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Blocking & polling tests define an amount of time to spend in the test and then estimate the number of syscalls that should successfully return. The problem is that while running the test we might spend slightly more time than initiallly planned. This change estimates the number of syscalls based on time spent after the fact. Signed-off-by: Lionel Landwerlin Reviewed-by: Matthew Auld --- tests/perf.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tests/perf.c b/tests/perf.c index 24df7c2a..6c062d20 100644 --- a/tests/perf.c +++ b/tests/perf.c @@ -2372,7 +2372,8 @@ test_blocking(void) DRM_I915_PERF_PROP_OA_EXPONENT, oa_exponent, }; struct drm_i915_perf_open_param param = { - .flags = I915_PERF_FLAG_FD_CLOEXEC, + .flags = I915_PERF_FLAG_FD_CLOEXEC | + I915_PERF_FLAG_DISABLED, .num_properties = sizeof(properties) / 16, .properties_ptr = to_user_pointer(properties), }; @@ -2397,16 +2398,17 @@ test_blocking(void) */ int min_iterations = (test_duration_ns / (oa_period + 6000000ull)); - int64_t start; + int64_t start, end; int n = 0; stream_fd = __perf_open(drm_fd, ¶m); times(&start_times); - igt_debug("tick length = %dns, test duration = %"PRIu64"ns, min iter. = %d, max iter. = %d\n", + igt_debug("tick length = %dns, test duration = %"PRIu64"ns, min iter. = %d," + " estimated max iter. = %d, oa_period = %"PRIu64"ns\n", (int)tick_ns, test_duration_ns, - min_iterations, max_iterations); + min_iterations, max_iterations, oa_period); /* In the loop we perform blocking polls while the HW is sampling at * ~25Hz, with the expectation that we spend most of our time blocked @@ -2425,8 +2427,13 @@ test_blocking(void) * floor(real_stime)). * * We Loop for 1000 x tick_ns so one tick corresponds to 0.1% + * + * Also enable the stream just before poll/read to minimize + * the error delta. */ - for (start = get_time(); (get_time() - start) < test_duration_ns; /* nop */) { + start = get_time(); + do_ioctl(stream_fd, I915_PERF_IOCTL_ENABLE, 0); + for (/* nop */; ((end = get_time()) - start) < test_duration_ns; /* nop */) { struct drm_i915_perf_record_header *header; bool timer_report_read = false; bool non_timer_report_read = false; @@ -2468,6 +2475,12 @@ test_blocking(void) n++; } + /* Updated the maximum of iterations based on the time spent + * in the loop. + */ + max_iterations = (end - start) / oa_period + 1; + igt_debug("adjusted max iter. = %d\n", max_iterations); + times(&end_times); /* Using nanosecond units is fairly silly here, given the tick in- @@ -2524,6 +2537,7 @@ test_polling(void) }; struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC | + I915_PERF_FLAG_DISABLED | I915_PERF_FLAG_FD_NONBLOCK, .num_properties = sizeof(properties) / 16, .properties_ptr = to_user_pointer(properties), @@ -2548,7 +2562,7 @@ test_polling(void) * to check for data and giving some time to read(). */ int min_iterations = (test_duration_ns / (oa_period + 6000000ull)); - int64_t start; + int64_t start, end; int n = 0; stream_fd = __perf_open(drm_fd, ¶m); @@ -2576,8 +2590,13 @@ test_polling(void) * floor(real_stime)). * * We Loop for 1000 x tick_ns so one tick corresponds to 0.1% + * + * Also enable the stream just before poll/read to minimize + * the error delta. */ - for (start = get_time(); (get_time() - start) < test_duration_ns; /* nop */) { + start = get_time(); + do_ioctl(stream_fd, I915_PERF_IOCTL_ENABLE, 0); + for (/* nop */; ((end = get_time()) - start) < test_duration_ns; /* nop */) { struct pollfd pollfd = { .fd = stream_fd, .events = POLLIN }; struct drm_i915_perf_record_header *header; bool timer_report_read = false; @@ -2625,8 +2644,7 @@ test_polling(void) if (header->type == DRM_I915_PERF_RECORD_SAMPLE) { uint32_t *report = (void *)(header + 1); - if (oa_report_is_periodic(oa_exponent, - report)) + if (oa_report_is_periodic(oa_exponent, report)) timer_report_read = true; else non_timer_report_read = true; @@ -2650,6 +2668,12 @@ test_polling(void) n++; } + /* Updated the maximum of iterations based on the time spent + * in the loop. + */ + max_iterations = (end - start) / oa_period + 1; + igt_debug("adjusted max iter. = %d\n", max_iterations); + times(&end_times); /* Using nanosecond units is fairly silly here, given the tick in-