Messages in this thread Patch in this message | | | Date | Tue, 14 Jun 2022 07:33:50 -0700 | Subject | [PATCH v2 3/6] perf cpumap: Compute mask size in constant time | From | Ian Rogers <> |
| |
perf_cpu_map__max computes the cpumap's maximum value, no need to iterate over all values.
Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/util/synthetic-events.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c index b8a42a096502..0d87df20ec44 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -1213,18 +1213,7 @@ static size_t cpus_size(const struct perf_cpu_map *map) static size_t mask_size(const struct perf_cpu_map *map, int *max) { - int i; - - *max = 0; - - for (i = 0; i < perf_cpu_map__nr(map); i++) { - /* bit position of the cpu is + 1 */ - int bit = perf_cpu_map__cpu(map, i).cpu + 1; - - if (bit > *max) - *max = bit; - } - + *max = perf_cpu_map__max(map).cpu; return sizeof(struct perf_record_record_cpu_map) + BITS_TO_LONGS(*max) * sizeof(long); } -- 2.36.1.476.g0c4daa206d-goog
| |