All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] perf_counts clean up and perf stat report bug fix
@ 2022-05-19  3:20 Ian Rogers
  2022-05-19  3:20 ` [PATCH 1/5] perf stat: Fix and validate inputs in stat events Ian Rogers
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ian Rogers @ 2022-05-19  3:20 UTC (permalink / raw)
  To: Michael Petlan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, James Clark, Kan Liang, Quentin Monnet,
	Dave Marchevsky, Zhengjun Xing, Lv Ruyi, linux-perf-users,
	linux-kernel, netdev, bpf
  Cc: Stephane Eranian, Ian Rogers

perf_counts takes a CPU map index as an argument, however, there were
a few places where this hadn't been cleaned up and the index was
called cpu. In part this led to the bug discovered by Michael Petlan in:
https://lore.kernel.org/linux-perf-users/CAP-5=fWQR=sCuiSMktvUtcbOLidEpUJLCybVF6=BRvORcDOq+g@mail.gmail.com/

Fix the bug, tidy up more of the arguments passed to perf_counts, add
a test to ensure the bug isn't reintroduced and add a helper macro to
iterate over just CPU map indices.

Ian Rogers (5):
  perf stat: Fix and validate inputs in stat events
  perf stat: Add stat record+report test
  perf cpumap: Add perf_cpu_map__for_each_idx
  perf bpf_counter: Tidy use of CPU map index
  perf stat: Make use of index clearer with perf_counts

 tools/lib/perf/include/perf/cpumap.h |  3 ++
 tools/perf/tests/shell/stat.sh       | 13 ++++++
 tools/perf/util/bpf_counter.c        | 61 ++++++++++++++++------------
 tools/perf/util/stat-display.c       | 22 +++++-----
 tools/perf/util/stat.c               | 27 ++++++++----
 5 files changed, 81 insertions(+), 45 deletions(-)

-- 
2.36.1.124.g0e6072fb45-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] perf stat: Fix and validate inputs in stat events
  2022-05-19  3:20 [PATCH 0/5] perf_counts clean up and perf stat report bug fix Ian Rogers
@ 2022-05-19  3:20 ` Ian Rogers
  2022-05-19  3:20 ` [PATCH 2/5] perf stat: Add stat record+report test Ian Rogers
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2022-05-19  3:20 UTC (permalink / raw)
  To: Michael Petlan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, James Clark, Kan Liang, Quentin Monnet,
	Dave Marchevsky, Zhengjun Xing, Lv Ruyi, linux-perf-users,
	linux-kernel, netdev, bpf
  Cc: Stephane Eranian, Ian Rogers

Stat events can come from disk and so need a degree of validation. They
contain a CPU which needs looking up via CPU map to access a counter.
Add the CPU to index translation, alongside validity checking.

Discussion thread:
https://lore.kernel.org/linux-perf-users/CAP-5=fWQR=sCuiSMktvUtcbOLidEpUJLCybVF6=BRvORcDOq+g@mail.gmail.com/

Fixes: 7ac0089d138f ("perf evsel: Pass cpu not cpu map index to synthesize")
Suggested-by: Michael Petlan <mpetlan@redhat.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/stat.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 4a5f3b8ff820..a77c28232298 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -474,9 +474,10 @@ int perf_stat_process_counter(struct perf_stat_config *config,
 int perf_event__process_stat_event(struct perf_session *session,
 				   union perf_event *event)
 {
-	struct perf_counts_values count;
+	struct perf_counts_values count, *ptr;
 	struct perf_record_stat *st = &event->stat;
 	struct evsel *counter;
+	int cpu_map_idx;
 
 	count.val = st->val;
 	count.ena = st->ena;
@@ -487,8 +488,18 @@ int perf_event__process_stat_event(struct perf_session *session,
 		pr_err("Failed to resolve counter for stat event.\n");
 		return -EINVAL;
 	}
-
-	*perf_counts(counter->counts, st->cpu, st->thread) = count;
+	cpu_map_idx = perf_cpu_map__idx(evsel__cpus(counter), (struct perf_cpu){.cpu = st->cpu});
+	if (cpu_map_idx == -1) {
+		pr_err("Invalid CPU %d for event %s.\n", st->cpu, evsel__name(counter));
+		return -EINVAL;
+	}
+	ptr = perf_counts(counter->counts, cpu_map_idx, st->thread);
+	if (ptr == NULL) {
+		pr_err("Failed to find perf count for CPU %d thread %d on event %s.\n",
+			st->cpu, st->thread, evsel__name(counter));
+		return -EINVAL;
+	}
+	*ptr = count;
 	counter->supported = true;
 	return 0;
 }
-- 
2.36.1.124.g0e6072fb45-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] perf stat: Add stat record+report test
  2022-05-19  3:20 [PATCH 0/5] perf_counts clean up and perf stat report bug fix Ian Rogers
  2022-05-19  3:20 ` [PATCH 1/5] perf stat: Fix and validate inputs in stat events Ian Rogers
@ 2022-05-19  3:20 ` Ian Rogers
  2022-05-19  3:20 ` [PATCH 3/5] perf cpumap: Add perf_cpu_map__for_each_idx Ian Rogers
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2022-05-19  3:20 UTC (permalink / raw)
  To: Michael Petlan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, James Clark, Kan Liang, Quentin Monnet,
	Dave Marchevsky, Zhengjun Xing, Lv Ruyi, linux-perf-users,
	linux-kernel, netdev, bpf
  Cc: Stephane Eranian, Ian Rogers

This would have caught:
https://lore.kernel.org/linux-perf-users/CAP-5=fWQR=sCuiSMktvUtcbOLidEpUJLCybVF6=BRvORcDOq+g@mail.gmail.com/

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/shell/stat.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh
index c7894764d4a6..9313ef2739e0 100755
--- a/tools/perf/tests/shell/stat.sh
+++ b/tools/perf/tests/shell/stat.sh
@@ -16,6 +16,18 @@ test_default_stat() {
   echo "Basic stat command test [Success]"
 }
 
+test_stat_record_report() {
+  echo "stat record and report test"
+  if ! perf stat record -o - true | perf stat report -i - 2>&1 | \
+    egrep -q "Performance counter stats for 'pipe':"
+  then
+    echo "stat record and report test [Failed]"
+    err=1
+    return
+  fi
+  echo "stat record and report test [Success]"
+}
+
 test_topdown_groups() {
   # Topdown events must be grouped with the slots event first. Test that
   # parse-events reorders this.
@@ -62,6 +74,7 @@ test_topdown_weak_groups() {
 }
 
 test_default_stat
+test_stat_record_report
 test_topdown_groups
 test_topdown_weak_groups
 exit $err
-- 
2.36.1.124.g0e6072fb45-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] perf cpumap: Add perf_cpu_map__for_each_idx
  2022-05-19  3:20 [PATCH 0/5] perf_counts clean up and perf stat report bug fix Ian Rogers
  2022-05-19  3:20 ` [PATCH 1/5] perf stat: Fix and validate inputs in stat events Ian Rogers
  2022-05-19  3:20 ` [PATCH 2/5] perf stat: Add stat record+report test Ian Rogers
@ 2022-05-19  3:20 ` Ian Rogers
  2022-05-19  3:20 ` [PATCH 4/5] perf bpf_counter: Tidy use of CPU map index Ian Rogers
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2022-05-19  3:20 UTC (permalink / raw)
  To: Michael Petlan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, James Clark, Kan Liang, Quentin Monnet,
	Dave Marchevsky, Zhengjun Xing, Lv Ruyi, linux-perf-users,
	linux-kernel, netdev, bpf
  Cc: Stephane Eranian, Ian Rogers

A variant of perf_cpu_map__for_each_cpu that just iterates index values
without the corresponding load of the CPU.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/lib/perf/include/perf/cpumap.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/lib/perf/include/perf/cpumap.h b/tools/lib/perf/include/perf/cpumap.h
index 4a2edbdb5e2b..24de795b09bb 100644
--- a/tools/lib/perf/include/perf/cpumap.h
+++ b/tools/lib/perf/include/perf/cpumap.h
@@ -31,4 +31,7 @@ LIBPERF_API bool perf_cpu_map__has(const struct perf_cpu_map *map, struct perf_c
 	     (idx) < perf_cpu_map__nr(cpus);			\
 	     (idx)++, (cpu) = perf_cpu_map__cpu(cpus, idx))
 
+#define perf_cpu_map__for_each_idx(idx, cpus)				\
+	for ((idx) = 0; (idx) < perf_cpu_map__nr(cpus); (idx)++)
+
 #endif /* __LIBPERF_CPUMAP_H */
-- 
2.36.1.124.g0e6072fb45-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] perf bpf_counter: Tidy use of CPU map index
  2022-05-19  3:20 [PATCH 0/5] perf_counts clean up and perf stat report bug fix Ian Rogers
                   ` (2 preceding siblings ...)
  2022-05-19  3:20 ` [PATCH 3/5] perf cpumap: Add perf_cpu_map__for_each_idx Ian Rogers
@ 2022-05-19  3:20 ` Ian Rogers
  2022-05-19  3:20 ` [PATCH 5/5] perf stat: Make use of index clearer with perf_counts Ian Rogers
  2022-05-23 12:54 ` [PATCH 0/5] perf_counts clean up and perf stat report bug fix Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2022-05-19  3:20 UTC (permalink / raw)
  To: Michael Petlan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, James Clark, Kan Liang, Quentin Monnet,
	Dave Marchevsky, Zhengjun Xing, Lv Ruyi, linux-perf-users,
	linux-kernel, netdev, bpf
  Cc: Stephane Eranian, Ian Rogers

BPF counters are typically running across all CPUs and so the CPU map
index and CPU number are the same. There may be cases with offline CPUs
where this isn't the case and so ensure the cpu map index for
perf_counts is going to be a valid index by explicitly iterating over
the CPU map. This also makes it clearer that users of perf_counts are
using an index. Collapse some multiple uses of perf_counts into single
uses.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/bpf_counter.c | 61 ++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c
index 3ce8d03cb7ec..d4931f54e1dd 100644
--- a/tools/perf/util/bpf_counter.c
+++ b/tools/perf/util/bpf_counter.c
@@ -224,25 +224,25 @@ static int bpf_program_profiler__disable(struct evsel *evsel)
 
 static int bpf_program_profiler__read(struct evsel *evsel)
 {
-	// perf_cpu_map uses /sys/devices/system/cpu/online
-	int num_cpu = evsel__nr_cpus(evsel);
 	// BPF_MAP_TYPE_PERCPU_ARRAY uses /sys/devices/system/cpu/possible
 	// Sometimes possible > online, like on a Ryzen 3900X that has 24
 	// threads but its possible showed 0-31 -acme
 	int num_cpu_bpf = libbpf_num_possible_cpus();
 	struct bpf_perf_event_value values[num_cpu_bpf];
 	struct bpf_counter *counter;
+	struct perf_counts_values *counts;
 	int reading_map_fd;
 	__u32 key = 0;
-	int err, cpu;
+	int err, idx, bpf_cpu;
 
 	if (list_empty(&evsel->bpf_counter_list))
 		return -EAGAIN;
 
-	for (cpu = 0; cpu < num_cpu; cpu++) {
-		perf_counts(evsel->counts, cpu, 0)->val = 0;
-		perf_counts(evsel->counts, cpu, 0)->ena = 0;
-		perf_counts(evsel->counts, cpu, 0)->run = 0;
+	perf_cpu_map__for_each_idx(idx, evsel__cpus(evsel)) {
+		counts = perf_counts(evsel->counts, idx, 0);
+		counts->val = 0;
+		counts->ena = 0;
+		counts->run = 0;
 	}
 	list_for_each_entry(counter, &evsel->bpf_counter_list, list) {
 		struct bpf_prog_profiler_bpf *skel = counter->skel;
@@ -256,10 +256,15 @@ static int bpf_program_profiler__read(struct evsel *evsel)
 			return err;
 		}
 
-		for (cpu = 0; cpu < num_cpu; cpu++) {
-			perf_counts(evsel->counts, cpu, 0)->val += values[cpu].counter;
-			perf_counts(evsel->counts, cpu, 0)->ena += values[cpu].enabled;
-			perf_counts(evsel->counts, cpu, 0)->run += values[cpu].running;
+		for (bpf_cpu = 0; bpf_cpu < num_cpu_bpf; bpf_cpu++) {
+			idx = perf_cpu_map__idx(evsel__cpus(evsel),
+						(struct perf_cpu){.cpu = bpf_cpu});
+			if (idx == -1)
+				continue;
+			counts = perf_counts(evsel->counts, idx, 0);
+			counts->val += values[bpf_cpu].counter;
+			counts->ena += values[bpf_cpu].enabled;
+			counts->run += values[bpf_cpu].running;
 		}
 	}
 	return 0;
@@ -621,6 +626,7 @@ static int bperf__read(struct evsel *evsel)
 	struct bperf_follower_bpf *skel = evsel->follower_skel;
 	__u32 num_cpu_bpf = cpu__max_cpu().cpu;
 	struct bpf_perf_event_value values[num_cpu_bpf];
+	struct perf_counts_values *counts;
 	int reading_map_fd, err = 0;
 	__u32 i;
 	int j;
@@ -639,29 +645,32 @@ static int bperf__read(struct evsel *evsel)
 		case BPERF_FILTER_GLOBAL:
 			assert(i == 0);
 
-			perf_cpu_map__for_each_cpu(entry, j, all_cpu_map) {
-				cpu = entry.cpu;
-				perf_counts(evsel->counts, cpu, 0)->val = values[cpu].counter;
-				perf_counts(evsel->counts, cpu, 0)->ena = values[cpu].enabled;
-				perf_counts(evsel->counts, cpu, 0)->run = values[cpu].running;
+			perf_cpu_map__for_each_cpu(entry, j, evsel__cpus(evsel)) {
+				counts = perf_counts(evsel->counts, j, 0);
+				counts->val = values[entry.cpu].counter;
+				counts->ena = values[entry.cpu].enabled;
+				counts->run = values[entry.cpu].running;
 			}
 			break;
 		case BPERF_FILTER_CPU:
-			cpu = evsel->core.cpus->map[i].cpu;
-			perf_counts(evsel->counts, i, 0)->val = values[cpu].counter;
-			perf_counts(evsel->counts, i, 0)->ena = values[cpu].enabled;
-			perf_counts(evsel->counts, i, 0)->run = values[cpu].running;
+			cpu = perf_cpu_map__cpu(evsel__cpus(evsel), i).cpu;
+			assert(cpu >= 0);
+			counts = perf_counts(evsel->counts, i, 0);
+			counts->val = values[cpu].counter;
+			counts->ena = values[cpu].enabled;
+			counts->run = values[cpu].running;
 			break;
 		case BPERF_FILTER_PID:
 		case BPERF_FILTER_TGID:
-			perf_counts(evsel->counts, 0, i)->val = 0;
-			perf_counts(evsel->counts, 0, i)->ena = 0;
-			perf_counts(evsel->counts, 0, i)->run = 0;
+			counts = perf_counts(evsel->counts, 0, i);
+			counts->val = 0;
+			counts->ena = 0;
+			counts->run = 0;
 
 			for (cpu = 0; cpu < num_cpu_bpf; cpu++) {
-				perf_counts(evsel->counts, 0, i)->val += values[cpu].counter;
-				perf_counts(evsel->counts, 0, i)->ena += values[cpu].enabled;
-				perf_counts(evsel->counts, 0, i)->run += values[cpu].running;
+				counts->val += values[cpu].counter;
+				counts->ena += values[cpu].enabled;
+				counts->run += values[cpu].running;
 			}
 			break;
 		default:
-- 
2.36.1.124.g0e6072fb45-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] perf stat: Make use of index clearer with perf_counts
  2022-05-19  3:20 [PATCH 0/5] perf_counts clean up and perf stat report bug fix Ian Rogers
                   ` (3 preceding siblings ...)
  2022-05-19  3:20 ` [PATCH 4/5] perf bpf_counter: Tidy use of CPU map index Ian Rogers
@ 2022-05-19  3:20 ` Ian Rogers
  2022-05-23 12:54 ` [PATCH 0/5] perf_counts clean up and perf stat report bug fix Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 7+ messages in thread
From: Ian Rogers @ 2022-05-19  3:20 UTC (permalink / raw)
  To: Michael Petlan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, James Clark, Kan Liang, Quentin Monnet,
	Dave Marchevsky, Zhengjun Xing, Lv Ruyi, linux-perf-users,
	linux-kernel, netdev, bpf
  Cc: Stephane Eranian, Ian Rogers

Try to disambiguate further when perf_counts is being accessed it is
with a cpu map index rather than a CPU.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/stat-display.c | 22 ++++++++++++----------
 tools/perf/util/stat.c         | 10 ++++------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 98669ca5a86b..606f09b09226 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -764,11 +764,11 @@ static int cmp_val(const void *a, const void *b)
 
 static struct perf_aggr_thread_value *sort_aggr_thread(
 					struct evsel *counter,
-					int nthreads, int ncpus,
 					int *ret,
 					struct target *_target)
 {
-	int cpu, thread, i = 0;
+	int nthreads = perf_thread_map__nr(counter->core.threads);
+	int i = 0;
 	double uval;
 	struct perf_aggr_thread_value *buf;
 
@@ -776,13 +776,17 @@ static struct perf_aggr_thread_value *sort_aggr_thread(
 	if (!buf)
 		return NULL;
 
-	for (thread = 0; thread < nthreads; thread++) {
+	for (int thread = 0; thread < nthreads; thread++) {
+		int idx;
 		u64 ena = 0, run = 0, val = 0;
 
-		for (cpu = 0; cpu < ncpus; cpu++) {
-			val += perf_counts(counter->counts, cpu, thread)->val;
-			ena += perf_counts(counter->counts, cpu, thread)->ena;
-			run += perf_counts(counter->counts, cpu, thread)->run;
+		perf_cpu_map__for_each_idx(idx, evsel__cpus(counter)) {
+			struct perf_counts_values *counts =
+				perf_counts(counter->counts, idx, thread);
+
+			val += counts->val;
+			ena += counts->ena;
+			run += counts->run;
 		}
 
 		uval = val * counter->scale;
@@ -817,13 +821,11 @@ static void print_aggr_thread(struct perf_stat_config *config,
 			      struct evsel *counter, char *prefix)
 {
 	FILE *output = config->output;
-	int nthreads = perf_thread_map__nr(counter->core.threads);
-	int ncpus = perf_cpu_map__nr(counter->core.cpus);
 	int thread, sorted_threads;
 	struct aggr_cpu_id id;
 	struct perf_aggr_thread_value *buf;
 
-	buf = sort_aggr_thread(counter, nthreads, ncpus, &sorted_threads, _target);
+	buf = sort_aggr_thread(counter, &sorted_threads, _target);
 	if (!buf) {
 		perror("cannot sort aggr thread");
 		return;
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index a77c28232298..37ea2d044708 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -237,14 +237,12 @@ void evlist__reset_prev_raw_counts(struct evlist *evlist)
 
 static void evsel__copy_prev_raw_counts(struct evsel *evsel)
 {
-	int ncpus = evsel__nr_cpus(evsel);
-	int nthreads = perf_thread_map__nr(evsel->core.threads);
+	int idx, nthreads = perf_thread_map__nr(evsel->core.threads);
 
 	for (int thread = 0; thread < nthreads; thread++) {
-		for (int cpu = 0; cpu < ncpus; cpu++) {
-			*perf_counts(evsel->counts, cpu, thread) =
-				*perf_counts(evsel->prev_raw_counts, cpu,
-					     thread);
+		perf_cpu_map__for_each_idx(idx, evsel__cpus(evsel)) {
+			*perf_counts(evsel->counts, idx, thread) =
+				*perf_counts(evsel->prev_raw_counts, idx, thread);
 		}
 	}
 
-- 
2.36.1.124.g0e6072fb45-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] perf_counts clean up and perf stat report bug fix
  2022-05-19  3:20 [PATCH 0/5] perf_counts clean up and perf stat report bug fix Ian Rogers
                   ` (4 preceding siblings ...)
  2022-05-19  3:20 ` [PATCH 5/5] perf stat: Make use of index clearer with perf_counts Ian Rogers
@ 2022-05-23 12:54 ` Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-05-23 12:54 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Michael Petlan, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, James Clark, Kan Liang,
	Quentin Monnet, Dave Marchevsky, Zhengjun Xing, Lv Ruyi,
	linux-perf-users, linux-kernel, netdev, bpf, Stephane Eranian

Em Wed, May 18, 2022 at 08:20:00PM -0700, Ian Rogers escreveu:
> perf_counts takes a CPU map index as an argument, however, there were
> a few places where this hadn't been cleaned up and the index was
> called cpu. In part this led to the bug discovered by Michael Petlan in:
> https://lore.kernel.org/linux-perf-users/CAP-5=fWQR=sCuiSMktvUtcbOLidEpUJLCybVF6=BRvORcDOq+g@mail.gmail.com/
> 
> Fix the bug, tidy up more of the arguments passed to perf_counts, add
> a test to ensure the bug isn't reintroduced and add a helper macro to
> iterate over just CPU map indices.

Applied 2-5 to perf/core. The first is already in 5.18


Thanks,

- Arnaldo
 
> Ian Rogers (5):
>   perf stat: Fix and validate inputs in stat events
>   perf stat: Add stat record+report test
>   perf cpumap: Add perf_cpu_map__for_each_idx
>   perf bpf_counter: Tidy use of CPU map index
>   perf stat: Make use of index clearer with perf_counts
> 
>  tools/lib/perf/include/perf/cpumap.h |  3 ++
>  tools/perf/tests/shell/stat.sh       | 13 ++++++
>  tools/perf/util/bpf_counter.c        | 61 ++++++++++++++++------------
>  tools/perf/util/stat-display.c       | 22 +++++-----
>  tools/perf/util/stat.c               | 27 ++++++++----
>  5 files changed, 81 insertions(+), 45 deletions(-)
> 
> -- 
> 2.36.1.124.g0e6072fb45-goog

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-23 12:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19  3:20 [PATCH 0/5] perf_counts clean up and perf stat report bug fix Ian Rogers
2022-05-19  3:20 ` [PATCH 1/5] perf stat: Fix and validate inputs in stat events Ian Rogers
2022-05-19  3:20 ` [PATCH 2/5] perf stat: Add stat record+report test Ian Rogers
2022-05-19  3:20 ` [PATCH 3/5] perf cpumap: Add perf_cpu_map__for_each_idx Ian Rogers
2022-05-19  3:20 ` [PATCH 4/5] perf bpf_counter: Tidy use of CPU map index Ian Rogers
2022-05-19  3:20 ` [PATCH 5/5] perf stat: Make use of index clearer with perf_counts Ian Rogers
2022-05-23 12:54 ` [PATCH 0/5] perf_counts clean up and perf stat report bug fix Arnaldo Carvalho de Melo

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.