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 <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Arnaldo Carvalho de Melo <[email protected]>
> Cc: Alexander Shishkin <[email protected]>
> Cc: Jiri Olsa <[email protected]>
> Cc: Namhyung Kim <[email protected]>
> Cc: [email protected]
> Cc: Russ Anderson <[email protected]>
> Signed-off-by: Kyle Meyer <[email protected]>
> ---
>  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;
>               }
>  

Reply via email to