All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@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 01/12] perf test: Add -w/--workload option
Date: Wed, 9 Nov 2022 11:00:15 -0800	[thread overview]
Message-ID: <CAM9d7ciQ1Co89oHc005SCgEfv3zATHQM6ZnHYTTgsF9uXpNLMg@mail.gmail.com> (raw)
In-Reply-To: <Y2vz3zmn/jIFkCKp@kernel.org>

Hi Arnaldo,

On Wed, Nov 9, 2022 at 10:39 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Wed, Nov 09, 2022 at 09:46:24AM -0800, Namhyung Kim escreveu:
> > --- /dev/null
> > +++ b/tools/perf/tests/workloads/noploop.c
> > @@ -0,0 +1,32 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#include <stdlib.h>
> > +#include <signal.h>
> > +#include <unistd.h>
> > +#include <linux/compiler.h>
> > +#include "../tests.h"
> > +
> > +static volatile int done;
> > +
> > +static void sighandler(int sig __maybe_unused)
> > +{
> > +     done = 1;
> > +}
>
> You forgot to do what was done in:

Oops, right.  Will fix in v2.

Thanks,
Namhyung


>
> 92ea0720ba9cf7f0 perf trace: Use sig_atomic_t to avoid undefined behaviour in a signal handler
> 691768968f2a13eb perf top: Use sig_atomic_t to avoid undefined behaviour in a signal handler
> 01513fdc18f395db perf stat: Use sig_atomic_t to avoid undefined behaviour in a signal handler
> 057929f9d083e80c perf session: Change type to avoid undefined behaviour in a signal handler
> 853596fb71f7c2f7 perf ftrace: Use sig_atomic_t to avoid UB
> 7f3374299f9762ba perf daemon: Use sig_atomic_t to avoid UB
> 8ed28c2b56b78442 perf record: Use sig_atomic_t for signal handlers
> f3c9bd4e16a503cb perf build: Update to C standard to gnu11
>
> To speed up the process here is one of those csets:
>
> ⬢[acme@toolbox perf]$ git show 01513fdc18f395db
> commit 01513fdc18f395dbcc924bc5e9962b12f86f947a
> Author: Ian Rogers <irogers@google.com>
> Date:   Mon Oct 24 11:19:11 2022 -0700
>
>     perf stat: Use sig_atomic_t to avoid undefined behaviour in a signal handler
>
>     Use sig_atomic_t for variables written/accessed in signal
>     handlers. This is undefined behavior as per:
>
>       https://wiki.sei.cmu.edu/confluence/display/c/SIG31-C.+Do+not+access+shared+objects+in+signal+handlers
>
>     Signed-off-by: Ian Rogers <irogers@google.com>
>     Cc: Adrian Hunter <adrian.hunter@intel.com>
>     Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>     Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
>     Cc: German Gomez <german.gomez@arm.com>
>     Cc: Ingo Molnar <mingo@redhat.com>
>     Cc: Jiri Olsa <jolsa@kernel.org>
>     Cc: Leo Yan <leo.yan@linaro.org>
>     Cc: Mark Rutland <mark.rutland@arm.com>
>     Cc: Namhyung Kim <namhyung@kernel.org>
>     Cc: Peter Zijlstra <peterz@infradead.org>
>     Cc: Stephane Eranian <eranian@google.com>
>     Link: https://lore.kernel.org/r/20221024181913.630986-7-irogers@google.com
>     Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index e52601a54b26d669..d5e1670bca204450 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -173,7 +173,7 @@ static struct target target = {
>
>  #define METRIC_ONLY_LEN 20
>
> -static volatile pid_t          child_pid                       = -1;
> +static volatile sig_atomic_t   child_pid                       = -1;
>  static int                     detailed_run                    =  0;
>  static bool                    transaction_run;
>  static bool                    topdown_run                     = false;
> @@ -208,7 +208,7 @@ struct perf_stat {
>  static struct perf_stat                perf_stat;
>  #define STAT_RECORD            perf_stat.record
>
> -static volatile int done = 0;
> +static volatile sig_atomic_t done = 0;
>
>  static struct perf_stat_config stat_config = {
>         .aggr_mode              = AGGR_GLOBAL,
> @@ -580,7 +580,7 @@ static void disable_counters(void)
>         }
>  }
>
> -static volatile int workload_exec_errno;
> +static volatile sig_atomic_t workload_exec_errno;
>
>  /*
>   * evlist__prepare_workload will send a SIGUSR1
> @@ -1039,7 +1039,7 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)
>         evlist__print_counters(evsel_list, &stat_config, &target, ts, argc, argv);
>  }
>
> -static volatile int signr = -1;
> +static volatile sig_atomic_t signr = -1;
>
>  static void skip_signal(int signo)
>  {
> ⬢[acme@toolbox perf]$
>
> > +
> > +static int noploop(int argc, const char **argv)
> > +{
> > +     int sec = 1;
> > +
> > +     if (argc > 0)
> > +             sec = atoi(argv[0]);
> > +
> > +     signal(SIGINT, sighandler);
> > +     signal(SIGALRM, sighandler);
> > +     alarm(sec);
> > +
> > +     while (!done)
> > +             continue;
> > +
> > +     return 0;
> > +}
> > +
> > +DEFINE_WORKLOAD(noploop);
> > --
> > 2.38.1.431.g37b22c650d-goog
>
> --
>
> - Arnaldo

  reply	other threads:[~2022-11-09 19:00 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 [this message]
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
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
2022-11-10 18:19 [PATCHSET 00/12] perf test: Add test workloads (v2) Namhyung Kim
2022-11-10 18:19 ` [PATCH 01/12] perf test: Add -w/--workload option Namhyung Kim
2022-11-16 23:38 [PATCHSET 00/12] perf test: Add test workloads (v3) Namhyung Kim
2022-11-16 23:38 ` [PATCH 01/12] perf test: Add -w/--workload option 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=CAM9d7ciQ1Co89oHc005SCgEfv3zATHQM6ZnHYTTgsF9uXpNLMg@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.