public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 4/6] perf/util/session: Replace MAX_NR_CPUS with nr_cpus_online
@ 2019-08-19 20:23 Kyle Meyer
  2019-08-20  9:18 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Kyle Meyer @ 2019-08-19 20:23 UTC (permalink / raw)
  Cc: Kyle Meyer, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel,
	Russ Anderson, Kyle Meyer

nr_cpus_online, the number of CPUs online during a record session, can be
used as a dynamic alternative for MAX_NR_CPUS in perf_session__cpu_bitmap.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: Russ Anderson <russ.anderson@hpe.com>
Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---
 tools/perf/util/session.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: tip/tools/perf/util/session.c
===================================================================
--- tip.orig/tools/perf/util/session.c
+++ tip/tools/perf/util/session.c
@@ -2284,6 +2284,7 @@ int perf_session__cpu_bitmap(struct perf
 {
 	int i, err = -1;
 	struct perf_cpu_map *map;
+	int nr_cpus_online = session->header.env.nr_cpus_online;
 
 	for (i = 0; i < PERF_TYPE_MAX; ++i) {
 		struct evsel *evsel;
@@ -2308,9 +2309,8 @@ int perf_session__cpu_bitmap(struct perf
 	for (i = 0; i < map->nr; i++) {
 		int cpu = map->map[i];
 
-		if (cpu >= MAX_NR_CPUS) {
-			pr_err("Requested CPU %d too large. "
-			       "Consider raising MAX_NR_CPUS\n", cpu);
+		if (cpu >= nr_cpus_online) {
+			pr_err("Requested CPU %d too large\n", cpu);
 			goto out_delete_map;
 		}
 

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

* Re: [PATCH v3 4/6] perf/util/session: Replace MAX_NR_CPUS with nr_cpus_online
  2019-08-19 20:23 [PATCH v3 4/6] perf/util/session: Replace MAX_NR_CPUS with nr_cpus_online Kyle Meyer
@ 2019-08-20  9:18 ` Jiri Olsa
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2019-08-20  9:18 UTC (permalink / raw)
  To: Kyle Meyer
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Namhyung Kim, linux-kernel, Russ Anderson,
	Kyle Meyer

On Mon, Aug 19, 2019 at 03:23:33PM -0500, Kyle Meyer wrote:
> nr_cpus_online, the number of CPUs online during a record session, can be
> used as a dynamic alternative for MAX_NR_CPUS in perf_session__cpu_bitmap.
> 
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: Russ Anderson <russ.anderson@hpe.com>
> Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
> ---
>  tools/perf/util/session.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> Index: tip/tools/perf/util/session.c
> ===================================================================
> --- tip.orig/tools/perf/util/session.c
> +++ tip/tools/perf/util/session.c
> @@ -2284,6 +2284,7 @@ int perf_session__cpu_bitmap(struct perf
>  {
>  	int i, err = -1;
>  	struct perf_cpu_map *map;
> +	int nr_cpus_online = session->header.env.nr_cpus_online;

so all those bitmaps that use this function are initialized with
MAX_NR_CPUS length, are we sure that session->header.env.nr_cpus_online
is always smaller than MAX_NR_CPUS?

jirka

>  
>  	for (i = 0; i < PERF_TYPE_MAX; ++i) {
>  		struct evsel *evsel;
> @@ -2308,9 +2309,8 @@ int perf_session__cpu_bitmap(struct perf
>  	for (i = 0; i < map->nr; i++) {
>  		int cpu = map->map[i];
>  
> -		if (cpu >= MAX_NR_CPUS) {
> -			pr_err("Requested CPU %d too large. "
> -			       "Consider raising MAX_NR_CPUS\n", cpu);
> +		if (cpu >= nr_cpus_online) {
> +			pr_err("Requested CPU %d too large\n", cpu);
>  			goto out_delete_map;
>  		}
>  

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

end of thread, other threads:[~2019-08-20  9:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-19 20:23 [PATCH v3 4/6] perf/util/session: Replace MAX_NR_CPUS with nr_cpus_online Kyle Meyer
2019-08-20  9:18 ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox