From nobody Fri Nov 14 21:45:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 ARC-Seal: i=1; a=rsa-sha256; t=1590591979; cv=none; d=zohomail.com; s=zohoarc; b=G9ks8Ez8O1bwogIXwb1u0hQOczitmEgWo2nQP/rrUDNF52iZnmzd8nyPS7rB5SYWwQ2S452aPlIoQF2VCPxr2ETey9aOaTGm9bJuJQE0180L8qhZoRNiGXPyc+u3WWtakAwOi3TlFo/I9WkSuhOW1oJIjDM6/AcWCabywa1/CqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590591979; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hyh91ojyztqE2sZmXe5ULEmyNIFPWUmO5p3g1DDRWRY=; b=Vy/wAaYUTF+n7wSCkBJJyghJmnDNECT/zfbHrubXRbd7ys4A6hUzH904adz89f/770mFIgvW88bgwUkQZXXrI01VXS+bVtX4aH51YHHlq80ryNT6pSHFOC9Psc5spPmgw9x9oXkvbKmtnjf0arsQwxyMMiUAu40CaKmU9bUY/4Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590591978970130.5254777679362; Wed, 27 May 2020 08:06:18 -0700 (PDT) Received: from localhost ([::1]:53156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdxdJ-0000bH-Nq for importer@patchew.org; Wed, 27 May 2020 11:06:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdxSc-00021U-W0 for qemu-devel@nongnu.org; Wed, 27 May 2020 10:55:15 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:51171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdxSb-0008G4-KM for qemu-devel@nongnu.org; Wed, 27 May 2020 10:55:14 -0400 Received: by mail-wm1-x32a.google.com with SMTP id v19so3351786wmj.0 for ; Wed, 27 May 2020 07:55:13 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r5sm3194036wrq.0.2020.05.27.07.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 07:55:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2B7C51FF9B; Wed, 27 May 2020 15:54:57 +0100 (BST) 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=Hyh91ojyztqE2sZmXe5ULEmyNIFPWUmO5p3g1DDRWRY=; b=Y4aApPJXQcXVbJh6nUI63OeAs6XKVLi3Kiv4CXNqDbxgoxzp235vX/ZSRCSgkKh4Kg AGSaU3AvdznhIDAnnKg0VB7CjLpFTePwxXLRqNJK0QFNT2utBEoLpqp2o88TqnqsClx5 O/6Q97yt21LonmIdgN7UFp824zRn79wu6bFAYp+8KpNtN9NBCi/QS0ZiW1I8gbkZIwVz pAXwYjTBSdhVuwNBOcT+LvJacf9qjDy2xOQ8/7Z/wL4X4NUFg9HFl8zXmfiniXg3DKvW CT6jOCYBKYka5YpFSN+dyFahiQqNy84VibWzA0AYCvIVwk7wUTpD1TuW38e9ZzuBXaQv F1ZQ== 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=Hyh91ojyztqE2sZmXe5ULEmyNIFPWUmO5p3g1DDRWRY=; b=WhhG8e3UT8eH6Au8zQO3T+5oQy5gLba8FpnBabzMm6+DzBFdeM+gUrv0ZtJ2ju+oXP XxLY9BSoxV4zybr2MrNRRMcWNfneTDsHTfV8maX8A+P20KvZk1O3BsKNshVtGswoP/zX 5sKbR+YIwxoZ16LOMtSGz7PVaSbkcDyRy/9UFEaiY3YrXtRcdl0TiUC8YTTqYCO9GKp5 in/8C2oy2Ni3WNfx5S4kBGKQ5Ap0wGjTOBCYoRTfYLHDyIfdEhQgz5ecX8Yj2mYO7JIk nJbMUhPdeOemELBbRqfvPD4ngC/0kUcdaQSE5/So07NtvTfHRo+rNKDLO/1/b0hbNidq HVuw== X-Gm-Message-State: AOAM531MVy1Pqx6pR5+HmPYfM1xT6A+pXpwc2ozY5/CKHayZ2WntjgUv fvDETxbl0kIIuKjar+oRHy87qA== X-Google-Smtp-Source: ABdhPJybrduI4iysO2J9g1/L2HoQluTusk0GwwQWn/XAaS4oHzskJgtiiGoQ3/pB9TOUeVOIWsUBsQ== X-Received: by 2002:a1c:a3c1:: with SMTP id m184mr5003912wme.91.1590591312078; Wed, 27 May 2020 07:55:12 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 12/12] tests/tcg: add new threadcount test Date: Wed, 27 May 2020 15:54:55 +0100 Message-Id: <20200527145455.2550-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200527145455.2550-1-alex.bennee@linaro.org> References: <20200527145455.2550-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Nikolay Igotti Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Based on the original testcase by Nikolay Igotti. Message-ID: Signed-off-by: Nikolay Igotti Signed-off-by: Alex Benn=C3=A9e Message-Id: <20200520140541.30256-15-alex.bennee@linaro.org> diff --git a/tests/tcg/multiarch/threadcount.c b/tests/tcg/multiarch/thread= count.c new file mode 100644 index 00000000000..545a1c81466 --- /dev/null +++ b/tests/tcg/multiarch/threadcount.c @@ -0,0 +1,64 @@ +/* + * Thread Exerciser + * + * Unlike testthread which is mainly concerned about testing thread + * semantics this test is used to exercise the thread creation and + * accounting. A version of this test found a problem with clashing + * cpu_indexes which caused a break in plugin handling. + * + * Based on the original test case by Nikolay Igotti. + * + * Copyright (c) 2020 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include +#include + +int max_threads =3D 10; + +typedef struct { + int delay; +} ThreadArg; + +static void *thread_fn(void* varg) +{ + ThreadArg *arg =3D varg; + usleep(arg->delay); + free(arg); + return NULL; +} + +int main(int argc, char **argv) +{ + int i; + pthread_t *threads; + + if (argc > 1) { + max_threads =3D atoi(argv[1]); + } + threads =3D calloc(sizeof(pthread_t), max_threads); + + for (i =3D 0; i < max_threads; i++) { + ThreadArg *arg =3D calloc(sizeof(ThreadArg), 1); + arg->delay =3D i * 100; + pthread_create(threads + i, NULL, thread_fn, arg); + } + + printf("Created %d threads\n", max_threads); + + /* sleep until roughly half the threads have "finished" */ + usleep(max_threads * 50); + + for (i =3D 0; i < max_threads; i++) { + pthread_join(threads[i], NULL); + } + + printf("Done\n"); + + return 0; +} diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index 51fb75ecfdd..cb49cc9ccb2 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -28,6 +28,8 @@ run-float_%: float_% =20 testthread: LDFLAGS+=3D-lpthread =20 +threadcount: LDFLAGS+=3D-lpthread + # We define the runner for test-mmap after the individual # architectures have defined their supported pages sizes. If no # additional page sizes are defined we only run the default test. --=20 2.20.1