All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	James Clark <james.clark@arm.com>,
	Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Riccardo Mancini <rickyman7@gmail.com>,
	German Gomez <german.gomez@arm.com>,
	Colin Ian King <colin.king@intel.com>,
	Song Liu <songliubraving@fb.com>,
	Dave Marchevsky <davemarchevsky@fb.com>,
	Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
	Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>,
	Leo Yan <leo.yan@linaro.org>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Stephane Eranian <eranian@google.com>, Ian Rogers <irogers@google.com>
Subject: [PATCH 3/6] perf cpumap: Compute mask size in constant time
Date: Mon, 13 Jun 2022 01:47:36 -0700	[thread overview]
Message-ID: <20220613084739.1159111-4-irogers@google.com> (raw)
In-Reply-To: <20220613084739.1159111-1-irogers@google.com>

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


  parent reply	other threads:[~2022-06-13  8:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13  8:47 [PATCH 0/6] Corrections to cpu map event encoding Ian Rogers
2022-06-13  8:47 ` [PATCH 1/6] perf cpumap: Const map for max Ian Rogers
2022-06-13  8:47 ` [PATCH 2/6] perf cpumap: Synthetic events and const/static Ian Rogers
2022-06-13  8:47 ` Ian Rogers [this message]
2022-06-13  8:47 ` [PATCH 4/6] perf cpumap: Fix alignment for masks in event encoding Ian Rogers
2022-06-13  8:47 ` [PATCH 5/6] perf events: Prefer union over variable length array Ian Rogers
2022-06-13  8:47 ` [PATCH 6/6] perf cpumap: Add range data encoding Ian Rogers

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=20220613084739.1159111-4-irogers@google.com \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=colin.king@intel.com \
    --cc=davemarchevsky@fb.com \
    --cc=eranian@google.com \
    --cc=german.gomez@arm.com \
    --cc=gustavoars@kernel.org \
    --cc=james.clark@arm.com \
    --cc=jolsa@kernel.org \
    --cc=keescook@chromium.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rickyman7@gmail.com \
    --cc=songliubraving@fb.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.