From patchwork Mon Feb 19 19:12:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10228545 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 E8835602B1 for ; Mon, 19 Feb 2018 19:13:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D853A28B69 for ; Mon, 19 Feb 2018 19:13:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD0B928B6F; Mon, 19 Feb 2018 19:13:07 +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 5512528B72 for ; Mon, 19 Feb 2018 19:13:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C68B46E297; Mon, 19 Feb 2018 19:13:05 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6ADD8996E for ; Mon, 19 Feb 2018 19:13:03 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id t74so17137084wme.3 for ; Mon, 19 Feb 2018 11:13:03 -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; bh=D/NVTuJFTfffm64+txMY6f+LHs1nJctyH5gwVgA2ZlE=; b=pB/v1yes0ifp6j43qk8iNAF3pGlueqAGzQrlR/MA93wM3i41/VNKhnA9EXIOYHiyv4 bYMmR5dQd6msgv//yOaVFPktvctSlWT9lPICCorq6VqiJHXy4yQnVQXcoH1lAqctKEd4 I3AhqScvVJSwL+z0qK5yGDQslbGRkQqMplgKWyOsN3fW/ZX1SlB2K+LsVWgHLr8jOkjT yxFu8DyulkLjnVKdZPKAlbGEqu23PsNjuvKuW6tzBfV+3gkBrvSsjefueDejBilN2Jpu b1xsqZAlrhKQtxUEmwirUqwzg2lRGCJTklVK5vGPVjaGrl44XFxDD6MursEH308gr9sW 1kiQ== 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; bh=D/NVTuJFTfffm64+txMY6f+LHs1nJctyH5gwVgA2ZlE=; b=s2VpsWq2k+km9lPPFAjsbWGj3tfN8TYZ09O1yhzuu8V+EtQRhn2UqE70j3z+ietVHB unTD1rzGO0Z/weps56P96Fk1DJuDyiElsCsRQrhXSVgTpL70naXJI6JqGr4W70wRWTPM bPN0w8cGFY2+Xps7mqV1Uf4iok/mOLw6uDBF+FMGfNND2MHfYGZwiG4FCaUQtiNFA2XV A0NJIFb73qChukrdfijwkoP9j7cAnMs8OMW5J7uLDwH/LO7pif34Nsb65yJDMwyKLuBo UsPURMBD7NURPj5tIbqQTt86ogKG77cmKgycZMlgjQXjrMcbA9ksysc+uXIPOkkCdNlD 8CLA== X-Gm-Message-State: APf1xPANxerD4wnPFpRXzHqUJk3/IE//yL3WfMziiiDls9m1pjba2NZN VprhRaTJ+dMTp2zYdEZstT9wCg== X-Google-Smtp-Source: AH8x225RrfeLdi0kPASjuoUwCaUbhT7Vp2cx8qty+a8D1/E5gu7HviKrPUYS6b0TmF5EeHRSNXe3oQ== X-Received: by 10.28.7.206 with SMTP id 197mr13099596wmh.54.1519067581985; Mon, 19 Feb 2018 11:13:01 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id o204sm9395125wma.1.2018.02.19.11.13.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Feb 2018 11:13:01 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Mon, 19 Feb 2018 19:12:51 +0000 Message-Id: <20180219191251.29766-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 Subject: [Intel-gfx] [PATCH i-g-t] tests/perf_pmu: Test busyness reporting in face of GPU hangs 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 Verify that the reported busyness is in line with what would we expect from a batch which causes a hang and gets kicked out from the engine. Signed-off-by: Tvrtko Ursulin --- tests/perf_pmu.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c index 7fab73e22c2d..90b6ec4db32d 100644 --- a/tests/perf_pmu.c +++ b/tests/perf_pmu.c @@ -168,6 +168,7 @@ static unsigned int e2ring(int gem_fd, const struct intel_execution_engine2 *e) #define TEST_TRAILING_IDLE (4) #define TEST_RUNTIME_PM (8) #define FLAG_LONG (16) +#define FLAG_HANG (32) static void end_spin(int fd, igt_spin_t *spin, unsigned int flags) { @@ -186,11 +187,15 @@ static void end_spin(int fd, igt_spin_t *spin, unsigned int flags) static void single(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags) { + const unsigned int hang_us = 10e6; unsigned long slept; igt_spin_t *spin; - uint64_t val; + uint64_t val[2], ts[2]; int fd; + if (flags & FLAG_HANG) + gem_quiescent_gpu(gem_fd); + fd = open_pmu(I915_PMU_ENGINE_BUSY(e->class, e->instance)); if (flags & TEST_BUSY) @@ -198,17 +203,36 @@ single(int gem_fd, const struct intel_execution_engine2 *e, unsigned int flags) else spin = NULL; - val = pmu_read_single(fd); - slept = measured_usleep(batch_duration_ns / 1000); + val[0] = __pmu_read_single(fd, &ts[0]); + slept = measured_usleep(flags & FLAG_HANG ? + hang_us : batch_duration_ns / 1000); if (flags & TEST_TRAILING_IDLE) end_spin(gem_fd, spin, flags); - val = pmu_read_single(fd) - val; + val[1] = pmu_read_single(fd); end_spin(gem_fd, spin, FLAG_SYNC); igt_spin_batch_free(gem_fd, spin); - close(fd); - assert_within_epsilon(val, flags & TEST_BUSY ? slept : 0.f, tolerance); + if ((flags & TEST_BUSY) && (flags & FLAG_HANG)) { + val[1] = __pmu_read_single(fd, &ts[1]); + close(fd); + igt_info("sampled with hang %.3fms / %.3fms\n", + (val[1] - val[0]) / 1e6, (ts[1] - ts[0]) / 1e6); + /* Check that some busyness was reported. */ + igt_assert(val[1] - val[0] > 0); + /* + * But not more than some reasonable value before which we + * expected the spinner to be kicked out. + */ + igt_assert((val[1] - val[0]) / 1e3 < (double)hang_us * 0.75); + __assert_within_epsilon(val[1] - val[0], hang_us * 1e3, + 0.02f, 10.0f); + } else { + close(fd); + assert_within_epsilon(val[1] - val[0], + flags & TEST_BUSY ? + slept : 0.f, tolerance); + } gem_quiescent_gpu(gem_fd); } @@ -1695,6 +1719,11 @@ igt_main pct[i], e->name) accuracy(fd, e, pct[i]); } + + igt_subtest_f("busy-hang-%s", e->name) { + single(fd, e, TEST_BUSY | FLAG_HANG); + single(fd, e, TEST_BUSY | FLAG_HANG); + } } /**