From: Nikolay Igotti <igotti@gmail.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH v1 7/8] tests/tcg: add new threadcount test
Date: Fri, 15 May 2020 22:51:40 +0300 [thread overview]
Message-ID: <CAEme+7FRtSsVhsgPTQfX+OKNhr_=a9VgqiTexcoKAUh_uD1=eQ@mail.gmail.com> (raw)
In-Reply-To: <20200513173200.11830-8-alex.bennee@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 3058 bytes --]
Sure, use it for anything.
ср, 13 мая 2020 г. в 20:32, Alex Bennée <alex.bennee@linaro.org>:
> Based on the original testcase by Nikolay Igotti.
>
> Message-ID: <CAEme+7GLKg_dNsHizzTKDymX9HyD+Ph2iZ=
> WKhOw2XG+zhViXg@mail.gmail.com>
> Cc: Nikolay Igotti <igotti@gmail.com>
> [Nikolay can we have your signed of by to add the testcase?]
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> tests/tcg/multiarch/threadcount.c | 62 +++++++++++++++++++++++++++++
> tests/tcg/multiarch/Makefile.target | 2 +
> 2 files changed, 64 insertions(+)
> create mode 100644 tests/tcg/multiarch/threadcount.c
>
> diff --git a/tests/tcg/multiarch/threadcount.c
> b/tests/tcg/multiarch/threadcount.c
> new file mode 100644
> index 00000000000..546dd90eeb2
> --- /dev/null
> +++ b/tests/tcg/multiarch/threadcount.c
> @@ -0,0 +1,62 @@
> +/*
> + * 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 <stdint.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <pthread.h>
> +
> +int max_threads = 10;
> +
> +typedef struct {
> + int delay;
> +} ThreadArg;
> +
> +static void *thread_fn(void* varg) {
> + ThreadArg* arg = varg;
> + usleep(arg->delay);
> + free(arg);
> + return NULL;
> +}
> +
> +int main(int argc, char **argv) {
> + int i;
> + pthread_t *threads;
> +
> + if (argc > 1) {
> + max_threads = atoi(argv[1]);
> + }
> + threads = calloc(sizeof(pthread_t), max_threads);
> +
> + for (i = 0; i < max_threads; i++) {
> + ThreadArg* arg = calloc(sizeof(ThreadArg), 1);
> + arg->delay = 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 = 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/Makefile.target
> index 51fb75ecfdd..cb49cc9ccb2 100644
> --- a/tests/tcg/multiarch/Makefile.target
> +++ b/tests/tcg/multiarch/Makefile.target
> @@ -28,6 +28,8 @@ run-float_%: float_%
>
> testthread: LDFLAGS+=-lpthread
>
> +threadcount: LDFLAGS+=-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.
> --
> 2.20.1
>
>
[-- Attachment #2: Type: text/html, Size: 3872 bytes --]
next prev parent reply other threads:[~2020-05-15 19:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-13 17:31 [PATCH v1 0/8] plugins/next (cleanup, cpu_index and lockstep) Alex Bennée
2020-05-13 17:31 ` [PATCH v1 1/8] qemu/plugin: Trivial code movement Alex Bennée
2020-05-13 17:31 ` [PATCH v1 2/8] qemu/plugin: Move !CONFIG_PLUGIN stubs altogether Alex Bennée
2020-05-13 17:31 ` [PATCH v1 3/8] qemu/qemu-plugin: Make qemu_plugin_hwaddr_is_io() hwaddr argument const Alex Bennée
2020-05-13 17:31 ` [PATCH v1 4/8] MAINTAINERS: update the orphaned cpus-common.c file Alex Bennée
2020-05-13 19:26 ` Philippe Mathieu-Daudé
2020-05-13 17:31 ` [PATCH v1 5/8] cpus-common: ensure auto-assigned cpu_indexes don't clash Alex Bennée
2020-05-14 16:27 ` Alex Bennée
2020-05-21 15:53 ` Igor Mammedov
2020-05-21 17:10 ` Alex Bennée
2020-05-22 8:46 ` Igor Mammedow
2020-05-13 17:31 ` [PATCH v1 6/8] linux-user: properly "unrealize" vCPU object Alex Bennée
2020-05-22 9:35 ` Philippe Mathieu-Daudé
2020-05-13 17:31 ` [PATCH v1 7/8] tests/tcg: add new threadcount test Alex Bennée
2020-05-15 19:51 ` Nikolay Igotti [this message]
2020-05-22 9:33 ` Philippe Mathieu-Daudé
2020-05-13 17:32 ` [PATCH v1 8/8] plugins: new lockstep plugin for debugging TCG changes Alex Bennée
2020-05-13 19:25 ` [PATCH v1 0/8] plugins/next (cleanup, cpu_index and lockstep) Philippe Mathieu-Daudé
2020-05-14 0:56 ` no-reply
2020-05-14 1:36 ` no-reply
2020-05-14 1:36 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEme+7FRtSsVhsgPTQfX+OKNhr_=a9VgqiTexcoKAUh_uD1=eQ@mail.gmail.com' \
--to=igotti@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).