linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-perf-users@vger.kernel.org, Leo Yan <leo.yan@linaro.org>,
	German Gomez <german.gomez@arm.com>,
	Zhengjun Xing <zhengjun.xing@linux.intel.com>,
	James Clark <james.clark@arm.com>
Subject: Re: [PATCH 03/12] perf test: Add 'thloop' test workload
Date: Wed, 9 Nov 2022 15:39:55 -0300	[thread overview]
Message-ID: <Y2vz+3u9shFbWy1B@kernel.org> (raw)
In-Reply-To: <20221109174635.859406-4-namhyung@kernel.org>

Em Wed, Nov 09, 2022 at 09:46:26AM -0800, Namhyung Kim escreveu:
> The thloop is similar to noploop but runs in two threads.  This is
> needed to verify perf record --per-thread to handle multi-threaded
> programs properly.
> 
>   $ perf test -w thloop
> 
> It also takes an optional argument to specify runtime in seconds
> (default: 1).
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/tests/builtin-test.c     |  1 +
>  tools/perf/tests/tests.h            |  1 +
>  tools/perf/tests/workloads/Build    |  1 +
>  tools/perf/tests/workloads/thloop.c | 53 +++++++++++++++++++++++++++++
>  4 files changed, 56 insertions(+)
>  create mode 100644 tools/perf/tests/workloads/thloop.c
> 
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index ce641ccfcf81..161f38476e77 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -120,6 +120,7 @@ static struct test_suite **tests[] = {
>  
>  static struct test_workload *workloads[] = {
>  	&workload__noploop,
> +	&workload__thloop,
>  };
>  
>  static int num_subtests(const struct test_suite *t)
> diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
> index d315d0d6fc97..e6edfeeadaeb 100644
> --- a/tools/perf/tests/tests.h
> +++ b/tools/perf/tests/tests.h
> @@ -201,5 +201,6 @@ struct test_workload workload__##work = {	\
>  
>  /* The list of test workloads */
>  DECLARE_WORKLOAD(noploop);
> +DECLARE_WORKLOAD(thloop);
>  
>  #endif /* TESTS_H */
> diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build
> index f98e968d4633..b8964b1099c0 100644
> --- a/tools/perf/tests/workloads/Build
> +++ b/tools/perf/tests/workloads/Build
> @@ -1,3 +1,4 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
>  perf-y += noploop.o
> +perf-y += thloop.o
> diff --git a/tools/perf/tests/workloads/thloop.c b/tools/perf/tests/workloads/thloop.c
> new file mode 100644
> index 000000000000..7fd3ac79e732
> --- /dev/null
> +++ b/tools/perf/tests/workloads/thloop.c
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#include <pthread.h>
> +#include <stdlib.h>
> +#include <signal.h>
> +#include <unistd.h>
> +#include <linux/compiler.h>
> +#include "../tests.h"
> +
> +static volatile int done;
> +static volatile unsigned count;

sig_atomic_t

> +/* We want to check this symbol in perf report */
> +noinline void test_loop(void);
> +
> +static void sighandler(int sig __maybe_unused)
> +{
> +	done = 1;
> +}
> +
> +noinline void test_loop(void)
> +{
> +	while (!done)
> +		count++;
> +}
> +
> +static void *thfunc(void *arg)
> +{
> +	void (*loop_fn)(void) = arg;
> +
> +	loop_fn();
> +	return NULL;
> +}
> +
> +static int thloop(int argc, const char **argv)
> +{
> +	int sec = 1;
> +	pthread_t th;
> +
> +	if (argc > 0)
> +		sec = atoi(argv[0]);
> +
> +	signal(SIGINT, sighandler);
> +	signal(SIGALRM, sighandler);
> +	alarm(sec);
> +
> +	pthread_create(&th, NULL, thfunc, test_loop);
> +	test_loop();
> +	pthread_join(th, NULL);
> +
> +	return 0;
> +}
> +
> +DEFINE_WORKLOAD(thloop);
> -- 
> 2.38.1.431.g37b22c650d-goog

-- 

- Arnaldo

  reply	other threads:[~2022-11-09 18:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 17:46 [PATCHSET 00/12] perf test: Add test workloads (v1) Namhyung Kim
2022-11-09 17:46 ` [PATCH 01/12] perf test: Add -w/--workload option Namhyung Kim
2022-11-09 18:39   ` Arnaldo Carvalho de Melo
2022-11-09 19:00     ` Namhyung Kim
2022-11-09 17:46 ` [PATCH 02/12] perf test: Replace pipe test workload with noploop Namhyung Kim
2022-11-09 17:46 ` [PATCH 03/12] perf test: Add 'thloop' test workload Namhyung Kim
2022-11-09 18:39   ` Arnaldo Carvalho de Melo [this message]
2022-11-09 17:46 ` [PATCH 04/12] perf test: Replace record test workload with thloop Namhyung Kim
2022-11-09 17:46 ` [PATCH 05/12] perf test: Add 'leafloop' test workload Namhyung Kim
2022-11-09 17:46 ` [PATCH 06/12] perf test: Replace arm callgraph fp test workload with leafloop Namhyung Kim
2022-11-10 11:20   ` Leo Yan
2022-11-10 17:45     ` Namhyung Kim
2022-11-09 17:46 ` [PATCH 07/12] perf test: Add 'sqrtloop' test workload Namhyung Kim
2022-11-10 14:49   ` German Gomez
2022-11-10 17:48     ` Namhyung Kim
2022-11-09 17:46 ` [PATCH 08/12] perf test: Replace arm spe fork test workload with sqrtloop Namhyung Kim
2022-11-10 11:45   ` Leo Yan
2022-11-09 17:46 ` [PATCH 09/12] perf test: Add 'brstack' test workload Namhyung Kim
2022-11-09 17:46 ` [PATCH 10/12] perf test: Replace brstack " Namhyung Kim
2022-11-09 17:46 ` [PATCH 11/12] perf test: Add 'datasym' " Namhyung Kim
2022-11-09 17:46 ` [PATCH 12/12] perf test: Replace data symbol test workload with datasym Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2022-11-10 18:19 [PATCHSET 00/12] perf test: Add test workloads (v2) Namhyung Kim
2022-11-10 18:19 ` [PATCH 03/12] perf test: Add 'thloop' test workload Namhyung Kim
2022-11-16 23:38 [PATCHSET 00/12] perf test: Add test workloads (v3) Namhyung Kim
2022-11-16 23:38 ` [PATCH 03/12] perf test: Add 'thloop' test workload Namhyung Kim

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=Y2vz+3u9shFbWy1B@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=german.gomez@arm.com \
    --cc=irogers@google.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=zhengjun.xing@linux.intel.com \
    /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).