mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
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>
This commit is contained in:
parent
057929f9d0
commit
01513fdc18
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user