From patchwork Fri Jan 11 14:38:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 155351 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp661855jaa; Fri, 11 Jan 2019 06:48:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN7OhSeaEx1bolIU/5rbWd+BzK2Lniy/CJHmZRah9Qdk1g2B4FrCS3iFh2+VKhshFPrRcT/Z X-Received: by 2002:adf:f8cf:: with SMTP id f15mr13841215wrq.265.1547218093001; Fri, 11 Jan 2019 06:48:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547218092; cv=none; d=google.com; s=arc-20160816; b=lgESppwqeHYQ0e2eVOqETpGzweXVp5CoPuuQa0OoDJ3gnIQ7f/3tGuxAg70tRqZGHF 9nAWu+cktfmfhCHTOeyg3qscXKAJJFrg2ZI7IMJPtfT3sW883AuN94mtAyfi1q9ixYzw MczGg3ao55kAm3IF4hUB14mYhuAZUyV/Zw1OtYd8abH8aibXyfNJeRQZ4LEqtPBmuGyZ VwASAkCdR6UMggtoYZyiK0E4qRhR+r/uFdvpmZWZPKDexoRzzZCk9vv6HixKZZxmYlGz 7A4Q5wmp1WsYRbgT5bo/3NQo8ASKaYvnhZd9MElq4A8SoHioDCh+vCZAYgTaq3ptjnQ6 nF8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature; bh=6jhxwCHVNHSkAlQBJt48QPw2YT+Cg1+dLZmZyEK4QpQ=; b=m9kxRQclvToq4Q8+ZHgQ7E/yVZr3u15tZCuHf6YPuMKOfDtBFzok1MBYbt+kjBmEpg 3H1QZl95d73KHTxokqU/QxAkk0ZvGGaBjHqi6i8VCEqApG1DM2p7KWSI/IWKTRvC2dy2 6XigRNI+sscdjPiMo/DvHzDFkjczo4VxqtakLm/nMsXeEuTeCleoyxCWFn5qWH07tGs9 7cdWQTlf0n5ly/ZPhFXakKtyv/gSIq5Beuk+OOyKB75QMjcY7dKarxSdewopyslagb8S bVTgipxpN4QbBnXPn+bmj/eeVhGyJaMSqrac4xFwv+jK0sI5rSUhRdrg57Cin6yzezx1 rC0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d9EaYesi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r18si43330131wrt.345.2019.01.11.06.48.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 Jan 2019 06:48:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d9EaYesi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:41299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghy6V-0004PE-VX for patch@linaro.org; Fri, 11 Jan 2019 09:48:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghxx8-0005cJ-Bb for qemu-devel@nongnu.org; Fri, 11 Jan 2019 09:38:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghxx6-0005RF-Ch for qemu-devel@nongnu.org; Fri, 11 Jan 2019 09:38:30 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:40428) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghxx2-0005NX-N2 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 09:38:26 -0500 Received: by mail-wm1-x341.google.com with SMTP id f188so2582438wmf.5 for ; Fri, 11 Jan 2019 06:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6jhxwCHVNHSkAlQBJt48QPw2YT+Cg1+dLZmZyEK4QpQ=; b=d9EaYesicGFRkbKsjZC+ortJVn4G5nNiE6m2eM9AqdBer/vhzGujWZEC1o/5xojOG3 XOqiUR1HtpHlBKZBO/5fKMeplpO8aMOKprcF16SYX8GBqePMma+n8aGGdNVtH/CukLxN nnWLuO/1VOireWYswDfnDBvyH7tvxFosSCtmE= 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:mime-version :content-transfer-encoding; bh=6jhxwCHVNHSkAlQBJt48QPw2YT+Cg1+dLZmZyEK4QpQ=; b=H7Ln+6uAfca+u9Df/B3q9pE5o3Rv4bztgUh+7qlJ8KIw9Yw3iU+viCmI19XI4vxZw8 gRgd40TCPHTKXX68/nzEq1IZQ08zdxXpe7IIkz05BUjZiOwV5HX55Y4fkRSRHnv+eXIY tJ7d8YMW1Z1CSPdmIqjJjeX/wwtIqORxbUvNnhjhBya2IDHTbLrGrsxfaIgf2HHOFdrZ fmjxZ8EJFYfUZOlL9u4uYg1r/2V5IxAP0A6xl2FGl0n+0Oh5ToznCS0QsDmZRDLFAbVA DAvYi86fbpH/D/nMGUDwqCUxKaChRF/7NnAFLkg3b6WY0n4Qq38nJ+HfDBOnlZb4cWBJ O/VA== X-Gm-Message-State: AJcUukcKAST35ZWpRU105NUyxX6NbbqXcpuCeiG6u7WdFWEnYKxK91zO LCnNn/93/s6BVBrTqCClwJhcsg== X-Received: by 2002:a1c:f319:: with SMTP id q25mr2555343wmq.151.1547217500971; Fri, 11 Jan 2019 06:38:20 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j14sm54817077wrv.96.2019.01.11.06.38.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Jan 2019 06:38:20 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D7FB03E0510; Fri, 11 Jan 2019 14:38:19 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 11 Jan 2019 14:38:15 +0000 Message-Id: <20190111143815.26107-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [RFC PATCH] tests: replace rem = sleep(time) with g_timer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, cota@braap.org, =?utf-8?q?Alex_Benn=C3=A9e?= , ehabkost@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Relying on sleep to always return having slept isn't safe as a signal may have occurred. If signals are constantly incoming the program will never reach it's termination condition. This is believed to be the mechanism causing time outs for qht-test in Travis. Instead we use a g_timer to determine if the duration of the test has passed and sleep for a second at a time. This may bias benchmark results for short runs. Signed-off-by: Alex Bennée --- tests/atomic64-bench.c | 11 ++++++++--- tests/atomic_add-bench.c | 11 ++++++++--- tests/qht-bench.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/tests/atomic64-bench.c b/tests/atomic64-bench.c index 71692560ed..f087ca5bc2 100644 --- a/tests/atomic64-bench.c +++ b/tests/atomic64-bench.c @@ -74,18 +74,23 @@ static void *thread_func(void *arg) static void run_test(void) { - unsigned int remaining; + GTimer *timer; unsigned int i; while (atomic_read(&n_ready_threads) != n_threads) { cpu_relax(); } + + timer = g_timer_new(); + atomic_set(&test_start, true); do { - remaining = sleep(duration); - } while (remaining); + sleep(1); + } while (g_timer_elapsed(timer, NULL) < duration); atomic_set(&test_stop, true); + g_timer_destroy(timer); + for (i = 0; i < n_threads; i++) { qemu_thread_join(&threads[i]); } diff --git a/tests/atomic_add-bench.c b/tests/atomic_add-bench.c index 2f6c72f63a..5fdf901a71 100644 --- a/tests/atomic_add-bench.c +++ b/tests/atomic_add-bench.c @@ -76,18 +76,23 @@ static void *thread_func(void *arg) static void run_test(void) { - unsigned int remaining; + GTimer *timer; unsigned int i; while (atomic_read(&n_ready_threads) != n_threads) { cpu_relax(); } + + timer = g_timer_new(); + atomic_set(&test_start, true); do { - remaining = sleep(duration); - } while (remaining); + sleep(1); + } while (g_timer_elapsed(timer, NULL) < duration); atomic_set(&test_stop, true); + g_timer_destroy(timer); + for (i = 0; i < n_threads; i++) { qemu_thread_join(&threads[i]); } diff --git a/tests/qht-bench.c b/tests/qht-bench.c index ab4e708180..7473fcb60a 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -398,18 +398,23 @@ static void pr_stats(void) static void run_test(void) { - unsigned int remaining; + GTimer *timer; int i; while (atomic_read(&n_ready_threads) != n_rw_threads + n_rz_threads) { cpu_relax(); } + + timer = g_timer_new(); + atomic_set(&test_start, true); do { - remaining = sleep(duration); - } while (remaining); + sleep(1); + } while (g_timer_elapsed(timer, NULL) < duration); atomic_set(&test_stop, true); + g_timer_destroy(timer); + for (i = 0; i < n_rw_threads; i++) { qemu_thread_join(&rw_threads[i]); }