From patchwork Fri Mar 9 11:54:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10270471 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 6178C60594 for ; Fri, 9 Mar 2018 11:54:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E14729D7B for ; Fri, 9 Mar 2018 11:54:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3210B29DD3; Fri, 9 Mar 2018 11:54:27 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 8C46129D7B for ; Fri, 9 Mar 2018 11:54:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2793F6EBAD; Fri, 9 Mar 2018 11:54:26 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BBD96EBA7 for ; Fri, 9 Mar 2018 11:54:24 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id q83so3423290wme.5 for ; Fri, 09 Mar 2018 03:54:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+rJXe2OoE1HY5PWQnWtQsLbutsu0depWO81bo5mQrrY=; b=FvQ7sRUc2CVIhEhxTinTmwIT/SBoF7xSx29Q5nCG474t34V+Oda8zdoenRGV0M9mNy HbQ11oY9mOEUU6nurqo7gfzRb9fRGPa9exeKLZ8aDzYviGDm2n00MNHV/MfDPtdQihkG 954JjgtpvXqaXEmHXivj8y69B+RqYZuhEM5S89Cly0HiMhtAgoaK/yNZvnpI0r5MVgx4 tDg9uHqxbJtKyJVLE5tNGM4JL6H9ChWmJexzDn+9x60iFjXyP1q9VH7U+wlelo4o9l0T wmua6qVZ1M13LsXy+NWzxdZ7CfPMKiV7p93O/xHtsB9Apfzjv2gugjIUzFzvW50KpJjH FBIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+rJXe2OoE1HY5PWQnWtQsLbutsu0depWO81bo5mQrrY=; b=QRwdxOD6JxjjqfcHHMhukZd6xk+j4RzGj9DpjFTm/EVyaJYk1Xgo6FwbqfTAKbj8zM ve8lRPr0TY/c/OWlRRP5Tb8Z1RzE5S8c1hsSDoJNvd6/l0hY3Sr8aNT16MnU1imiCnyn wD6Bsd3A3v8hq+YFDRKm3pmq+hN6qForlK8EUKvsi7G+BRLSw8lu6QYR3Tsr205O32bn S7VTLuIdy/+TYistIbADA3gRZAa4mfRT5RbPXwGaEHYDDVv469F355Dk7cRxC20lwsyQ aM8fGvIJMM0mkH4lMUV3hpd4+ZlsatO/m5by/phgiMdr9PJ829ULt1O113HDuZrqLwya Cw/A== X-Gm-Message-State: AElRT7GzQjGNYHhriENq/lS7MRnkleoprWgrwA3womaWm6RimipszxdU YXFfzed0XlEPJwTFiklZrboLHw== X-Google-Smtp-Source: AG47ELu4yGEwhXA1aSVutB8+ZA3L33M/GGZ1TJFUmAFpXfzgagTAGYOBca+kcj9J6zKYP0E6tNO4dw== X-Received: by 10.28.69.133 with SMTP id l5mr1751172wmi.100.1520596462579; Fri, 09 Mar 2018 03:54:22 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id r136sm1086958wmf.18.2018.03.09.03.54.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 03:54:22 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 9 Mar 2018 11:54:13 +0000 Message-Id: <20180309115413.9434-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <152042245529.17960.12605436428110116177@mail.alporthouse.com> References: <152042245529.17960.12605436428110116177@mail.alporthouse.com> Subject: [Intel-gfx] [PATCH i-g-t v2] tests/perf_pmu: Use absolute tolerance in accuracy tests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin We need to use absolute tolerance when asserting on percentages. Relative tolerance in this case is unfair and inaccurate since it's strictness varies with relative target busyness. v2: * Do not include spin batch edit and submit into measured time. * Open PMU before child is in test PWM phase. * No need to emit test PWM for twice as long with the new explicit synchroniazation via pipe. * Log test duration in ms for better readability. * Drop inverse assert. (Chris Wilson) Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson Reviewed-by: Chris Wilson # v1 Reviewed-by: Chris Wilson --- tests/perf_pmu.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c index 9ebffc64d1f1..ff9f71540ee4 100644 --- a/tests/perf_pmu.c +++ b/tests/perf_pmu.c @@ -1459,7 +1459,15 @@ static void __rearm_spin_batch(igt_spin_t *spin) __sync_synchronize(); } -#define div_round_up(a, b) (((a) + (b) - 1) / (b)) +#define __assert_within(x, ref, tol_up, tol_down) \ + igt_assert_f((double)(x) <= ((double)(ref) + (tol_up)) && \ + (double)(x) >= ((double)(ref) - (tol_down)), \ + "%f not within +%f/-%f of %f! ('%s' vs '%s')\n", \ + (double)(x), (double)(tol_up), (double)(tol_down), \ + (double)(ref), #x, #ref) + +#define assert_within(x, ref, tolerance) \ + __assert_within(x, ref, tolerance, tolerance) static void accuracy(int gem_fd, const struct intel_execution_engine2 *e, @@ -1493,8 +1501,8 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, while (test_us < min_test_us) test_us += busy_us + idle_us; - igt_info("calibration=%luus, test=%luus; ratio=%.2f%% (%luus/%luus)\n", - pwm_calibration_us, test_us, + igt_info("calibration=%lums, test=%lums; ratio=%.2f%% (%luus/%luus)\n", + pwm_calibration_us / 1000, test_us / 1000, (double)busy_us / (busy_us + idle_us) * 100.0, busy_us, idle_us); @@ -1507,7 +1515,7 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, igt_fork(child, 1) { struct sched_param rt = { .sched_priority = 99 }; const unsigned long timeout[] = { - pwm_calibration_us * 1000, test_us * 2 * 1000 + pwm_calibration_us * 1000, test_us * 1000 }; struct drm_i915_gem_exec_object2 obj = {}; uint64_t total_busy_ns = 0, total_idle_ns = 0; @@ -1537,19 +1545,16 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, igt_nsec_elapsed(&test_start); do { - struct timespec t_busy = { }; - unsigned int target_idle_us; - - igt_nsec_elapsed(&t_busy); + unsigned int target_idle_us, t_busy; /* Restart the spinbatch. */ __rearm_spin_batch(spin); __submit_spin_batch(gem_fd, &obj, e); - measured_usleep(busy_us); + t_busy = measured_usleep(busy_us); igt_spin_batch_end(spin); gem_sync(gem_fd, obj.handle); - total_busy_ns += igt_nsec_elapsed(&t_busy); + total_busy_ns += t_busy; target_idle_us = (100 * total_busy_ns / target_busy_pct - (total_busy_ns + total_idle_ns)) / 1000; @@ -1569,12 +1574,13 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, igt_spin_batch_free(gem_fd, spin); } + fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance)); + /* Let the child run. */ read(link[0], &expected, sizeof(expected)); - assert_within_epsilon(expected, target_busy_pct/100., 0.05); + assert_within(100.0 * expected, target_busy_pct, 5); /* Collect engine busyness for an interesting part of child runtime. */ - fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance)); val[0] = __pmu_read_single(fd, &ts[0]); read(link[0], &expected, sizeof(expected)); val[1] = __pmu_read_single(fd, &ts[1]); @@ -1590,8 +1596,7 @@ accuracy(int gem_fd, const struct intel_execution_engine2 *e, igt_info("error=%.2f%% (%.2f%% vs %.2f%%)\n", __error(busy_r, expected), 100 * busy_r, 100 * expected); - assert_within_epsilon(busy_r, expected, 0.15); - assert_within_epsilon(1 - busy_r, 1 - expected, 0.15); + assert_within(100.0 * busy_r, 100.0 * expected, 2); } igt_main