From nobody Fri Apr 26 06:46:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154721820739019.964037784034872; Fri, 11 Jan 2019 06:50:07 -0800 (PST) Received: from localhost ([127.0.0.1]:41653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghy8M-0005hA-7q for importer@patchew.org; Fri, 11 Jan 2019 09:50:06 -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) 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) 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-Google-Smtp-Source: ALg8bN7gr1boHTVM0kBzvAdgR0lSBmjziWrdVFo11KcmBZKynbeviZdYcq2pra5L+Qmc86AxCtowrw== X-Received: by 2002:a1c:f319:: with SMTP id q25mr2555343wmq.151.1547217500971; Fri, 11 Jan 2019 06:38:20 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20Benn=C3=A9e?= , ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e --- tests/atomic64-bench.c | 11 ++++++++--- tests/atomic_add-bench.c | 11 ++++++++--- tests/qht-bench.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) 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) =20 static void run_test(void) { - unsigned int remaining; + GTimer *timer; unsigned int i; =20 while (atomic_read(&n_ready_threads) !=3D n_threads) { cpu_relax(); } + + timer =3D g_timer_new(); + atomic_set(&test_start, true); do { - remaining =3D sleep(duration); - } while (remaining); + sleep(1); + } while (g_timer_elapsed(timer, NULL) < duration); atomic_set(&test_stop, true); =20 + g_timer_destroy(timer); + for (i =3D 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) =20 static void run_test(void) { - unsigned int remaining; + GTimer *timer; unsigned int i; =20 while (atomic_read(&n_ready_threads) !=3D n_threads) { cpu_relax(); } + + timer =3D g_timer_new(); + atomic_set(&test_start, true); do { - remaining =3D sleep(duration); - } while (remaining); + sleep(1); + } while (g_timer_elapsed(timer, NULL) < duration); atomic_set(&test_stop, true); =20 + g_timer_destroy(timer); + for (i =3D 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) =20 static void run_test(void) { - unsigned int remaining; + GTimer *timer; int i; =20 while (atomic_read(&n_ready_threads) !=3D n_rw_threads + n_rz_threads)= { cpu_relax(); } + + timer =3D g_timer_new(); + atomic_set(&test_start, true); do { - remaining =3D sleep(duration); - } while (remaining); + sleep(1); + } while (g_timer_elapsed(timer, NULL) < duration); atomic_set(&test_stop, true); =20 + g_timer_destroy(timer); + for (i =3D 0; i < n_rw_threads; i++) { qemu_thread_join(&rw_threads[i]); } --=20 2.17.1