From patchwork Tue Aug 14 15:05: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: 10565815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7ECB515A6 for ; Tue, 14 Aug 2018 15:05:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71CE92A05E for ; Tue, 14 Aug 2018 15:05:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6626C2A0E6; Tue, 14 Aug 2018 15:05:34 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 1E7A32A05E for ; Tue, 14 Aug 2018 15:05:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0F6B6E288; Tue, 14 Aug 2018 15:05:32 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E2846E284 for ; Tue, 14 Aug 2018 15:05:30 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id j5-v6so17494099wrr.8 for ; Tue, 14 Aug 2018 08:05:30 -0700 (PDT) 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=5PAr9+wsQg3+iKK2f3LNsUg4zL3ks4HgE5OktJj2SzI=; b=jdAMimwgLIVZq/6AgWyLXwnlziy4APIx5DujRUDXZp4+TY7mHU+CAKheRP9Kd49pYy IAedFajFh4Rj17wA6zKcpSh931YwisfkS6EqQwnctAyBLwYoy5krYrJ44tt7Oq1J7pyJ cRC3AVrI9TvMyf9pAaq2/CygwxldzlSkDV1fAM26A7rKeYmQhqjPxCc0ppkfRSi+dBkb CQwi1m1a8w1GtD8H2VxRlWWzPaFH0AcWe84RmhdFNVQUzhSIYjOE167y/8gxVBfgfCE1 pPhLeZCuBUax9e6EkIbd/ngYHFuKbwQThSzO7G+wNF/Qgxu1UoJD87EC9lftrNcXwgv0 yS6Q== X-Gm-Message-State: AOUpUlHldeBUsGlqUT5lnub163tkICh0DbAuOxvsIPmw8uAQ3jBSV/gM z10eDO0b3Q2o67L7LxHFUBK2Mq2cXXA= X-Google-Smtp-Source: AA+uWPwXt3jz9uTPtXLRKNDtYUlDpMgLT9NRwlTG13w6JAE070vrjBxvq0oJkP4f8CE1u5GtwYhCkA== X-Received: by 2002:adf:9aa3:: with SMTP id a32-v6mr13368557wrc.75.1534259129210; Tue, 14 Aug 2018 08:05:29 -0700 (PDT) Received: from localhost.localdomain ([95.144.165.93]) by smtp.gmail.com with ESMTPSA id x82-v6sm39942383wmd.11.2018.08.14.08.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 08:05:28 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Tue, 14 Aug 2018 16:05:13 +0100 Message-Id: <20180814150519.20204-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814150519.20204-1-tvrtko.ursulin@linux.intel.com> References: <20180814150519.20204-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 1/7] gem_wsim: Check sleep times 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 Notice in more places if we are running behind. Signed-off-by: Tvrtko Ursulin --- benchmarks/gem_wsim.c | 52 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index 80f180829241..ead91b0f009b 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -1718,6 +1718,21 @@ static bool sync_deps(struct workload *wrk, struct w_step *w) return synced; } +static unsigned int measured_usleep(unsigned int usec) +{ + struct timespec ts = { }; + unsigned int slept; + + slept = igt_nsec_elapsed(&ts); + igt_assert(slept == 0); + do { + usleep(usec - slept); + slept = igt_nsec_elapsed(&ts) / 1000; + } while (slept < usec); + + return igt_nsec_elapsed(&ts); +} + static void *run_workload(void *data) { struct workload *wrk = (struct workload *)data; @@ -1739,7 +1754,7 @@ static void *run_workload(void *data) count++) { unsigned int cur_seqno = wrk->sync_seqno; - clock_gettime(CLOCK_MONOTONIC, &wrk->repeat_start); + igt_gettime(&wrk->repeat_start); for (i = 0, w = wrk->steps; wrk->run && (i < wrk->nr_steps); i++, w++) { @@ -1751,13 +1766,14 @@ static void *run_workload(void *data) } else if (w->type == PERIOD) { struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); + igt_gettime(&now); do_sleep = w->period - elapsed_us(&wrk->repeat_start, &now); if (do_sleep < 0) { - if (verbose > 1) - printf("%u: Dropped period @ %u/%u (%dus late)!\n", - wrk->id, count, i, do_sleep); + if (verbose > 1 && + -do_sleep > 10 * w->period / 100) + printf("%u: Missed period @ %u/%u (%dus late)!\n", + wrk->id, count, i, -do_sleep); continue; } } else if (w->type == SYNC) { @@ -1793,7 +1809,31 @@ static void *run_workload(void *data) } if (do_sleep || w->type == PERIOD) { - usleep(do_sleep); + long slept = measured_usleep(do_sleep) / 1000; + + if ( w->type == PERIOD) { + struct timespec now; + + igt_gettime(&now); + + slept = elapsed_us(&wrk->repeat_start, + &now); + + if (verbose > 1 && + slept > (110 * w->period / 100)) + printf("%u: Overslept period by %ldus @ %u/%u! (%uus)\n", + wrk->id, + -slept, count, + i, w->period); + } else { + if (verbose > 1 && + slept > (110 * do_sleep / 100)) + printf("%u: Overslept by %ldus @ %u/%u! (%uus)\n", + wrk->id, + slept - do_sleep, count, + i, do_sleep); + } + continue; }