From patchwork Mon Jan 14 15:01:28 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: 155520 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3757808jaa; Mon, 14 Jan 2019 07:06:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN5fcnDPshE3QIjWu8spt9Q4zM1pzWmbKsMGvuRHD1aLuAm3Rw68ruy704FYwV1RXgbfkZ8G X-Received: by 2002:a1c:864f:: with SMTP id i76mr11953484wmd.83.1547478364733; Mon, 14 Jan 2019 07:06:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547478364; cv=none; d=google.com; s=arc-20160816; b=zwaNPpuwccAgDEuF0uvuSCls18MAKWu+giUTheArYPyVBHPEv8xnWzSyQTeWAhx9mv YunnS4oBIY2LJhj8FVUdx6La9Z7RCqVv6uNh6K1TUELsyCFFh9PGFI25LdS5oT0E3Cpe j7oaviWAfCqLGsldZ25555JaYIPqkDRFJzFQsk/2mnXM75WmZRzQc9c9QLMzLMEPl6Kb ANNZJN6SM6mkKXJr6bTgMQIYBf3L9aFwT3B6gchgVtoxUkpApBLwr3pqUfme1zAZS8gt E5nixe26sdu1BfVpQfeUR95UTxDZx+AMyHfzX844pMCv8VSHJCdS5uBmvPCu80Zlp2x1 TJrA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=eJxeslcAF4iyKuUEJ3/FZIaxt6VIaQGDo/07LFcW7Gw=; b=i7eczGkyldW/iUSPHgm7yZz32dmeejXmmg8SCgTrXIT7ArmZZpkVR4dsSiESDOHwwa yY1+raTt1t/QVG5r0uS97OGRMycjv75I/LPflBlnYqSfYQxHh5eu/l2sa47qwXNCuU8d k31W7GxJmcVaLJfgGHbMmILpGNYtt+WjscbDwnPDyaoQlsSajXm/u3HRXJG2BjLKZl96 hVmHRMfXO/22J/1EhTbkC/pFpDY8dIHRA4+2oRKACo/CaD0ucxPimOX8UsfRovLHI+iI LgvS6Q5No3vuH0ztzicR7c3VMxNvUza34FqzG6xZncM0+A8/2lkOWeeQ+DZyR+SvJqLl Ub4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AdQB40Pv; 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 y68si8817301wmc.147.2019.01.14.07.06.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 Jan 2019 07:06:04 -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=AdQB40Pv; 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]:48414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj3oR-00018V-JS for patch@linaro.org; Mon, 14 Jan 2019 10:06:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gj3kF-0006K0-UD for qemu-devel@nongnu.org; Mon, 14 Jan 2019 10:01:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gj3kF-0005PK-3Q for qemu-devel@nongnu.org; Mon, 14 Jan 2019 10:01:43 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:43460) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gj3kE-0005O9-Qu for qemu-devel@nongnu.org; Mon, 14 Jan 2019 10:01:42 -0500 Received: by mail-wr1-x42f.google.com with SMTP id r10so23213786wrs.10 for ; Mon, 14 Jan 2019 07:01:42 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=eJxeslcAF4iyKuUEJ3/FZIaxt6VIaQGDo/07LFcW7Gw=; b=AdQB40PvbcEe8Vl3io3QssH+e2SaJPs/nhz+tGog/S6J22myJDuEzPuWwmzvhEgLOV PhuJ1okvZd7hAgViq0avhCREjF5BMQV37uUheAZJfeAgdKX9l29Q0kQpDBZGwZJivCcq bni2AR3taG01Oxc6YbIqwdb4VQvEUVMZP4CaE= 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:mime-version:content-transfer-encoding; bh=eJxeslcAF4iyKuUEJ3/FZIaxt6VIaQGDo/07LFcW7Gw=; b=tFQOEwAvJImW4wcRLFeS97JfYIdr6qdEdInin1nN/uMLFpYYwBVMBGngleigX1SCj2 fsbQbcxt/lucGBuBot3h91kTGj0rKLcAmNz3d357/omPduGchNP+KDAWQX464//DLGNi FP4AsnfHqzxlywFZHfKmnGpw1y7ExnDmDR60+tP2keBHu7J2BrjxFlWuGroyuITetOVf ScRTVqdfp9xeB/QtDpWLl1gaJOUU1YAtYffqaHx8p0/+2hTM6/2VThbBltRnpJi4s4V9 WqrcUPo0hl/skXh03J8YQGlFqOQR247cwltCycWmPZG7jMoamlsno/d1TO4jefyzSXdL 1yyA== X-Gm-Message-State: AJcUukf/Qu12gsTWQ58lJs4YZC4Jhh9JXJupN4zR6tW8VpxiNBHkQfcT RgRFM9lt0/BqHa1f5jKKjlPTIQ== X-Received: by 2002:adf:dec4:: with SMTP id i4mr23813489wrn.307.1547478101737; Mon, 14 Jan 2019 07:01:41 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k135sm31796223wmd.42.2019.01.14.07.01.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 07:01:38 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 84FE53E059D; Mon, 14 Jan 2019 15:01:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 14 Jan 2019 15:01:28 +0000 Message-Id: <20190114150129.1013-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190114150129.1013-1-alex.bennee@linaro.org> References: <20190114150129.1013-1-alex.bennee@linaro.org> 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::42f Subject: [Qemu-devel] [PULL 20/21] tests: use g_usleep instead of rem = sleep(time) 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org 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 its termination condition. This is believed to be the mechanism causing time outs for qht-test in Travis. The glib g_usleep() deals with all of this for us so lets use it instead. Signed-off-by: Alex Bennée Reviewed-by: Peter Maydell -- 2.17.1 diff --git a/tests/atomic64-bench.c b/tests/atomic64-bench.c index 71692560ed..121a8c14f4 100644 --- a/tests/atomic64-bench.c +++ b/tests/atomic64-bench.c @@ -74,16 +74,14 @@ static void *thread_func(void *arg) static void run_test(void) { - unsigned int remaining; unsigned int i; while (atomic_read(&n_ready_threads) != n_threads) { cpu_relax(); } + atomic_set(&test_start, true); - do { - remaining = sleep(duration); - } while (remaining); + g_usleep(duration * G_USEC_PER_SEC); atomic_set(&test_stop, true); for (i = 0; i < n_threads; i++) { diff --git a/tests/atomic_add-bench.c b/tests/atomic_add-bench.c index 2f6c72f63a..5666f6bbff 100644 --- a/tests/atomic_add-bench.c +++ b/tests/atomic_add-bench.c @@ -76,16 +76,14 @@ static void *thread_func(void *arg) static void run_test(void) { - unsigned int remaining; unsigned int i; while (atomic_read(&n_ready_threads) != n_threads) { cpu_relax(); } + atomic_set(&test_start, true); - do { - remaining = sleep(duration); - } while (remaining); + g_usleep(duration * G_USEC_PER_SEC); atomic_set(&test_stop, true); for (i = 0; i < n_threads; i++) { diff --git a/tests/qht-bench.c b/tests/qht-bench.c index ab4e708180..e3b512f26f 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -398,16 +398,14 @@ static void pr_stats(void) static void run_test(void) { - unsigned int remaining; int i; while (atomic_read(&n_ready_threads) != n_rw_threads + n_rz_threads) { cpu_relax(); } + atomic_set(&test_start, true); - do { - remaining = sleep(duration); - } while (remaining); + g_usleep(duration * G_USEC_PER_SEC); atomic_set(&test_stop, true); for (i = 0; i < n_rw_threads; i++) {