* [PATCH] perf intel-pt: Fix 'CPU too large' error
@ 2021-01-07 17:41 Adrian Hunter
2021-01-07 20:46 ` Liang, Kan
0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2021-01-07 17:41 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa; +Cc: linux-kernel, Kan Liang
In some cases, the number of cpus (nr_cpus_online) is confused with the
maximum cpu number (nr_cpus_avail), which results in the error in the
example below:
Example on system with 8 cpus:
Before:
# echo 0 > /sys/devices/system/cpu/cpu2/online
# ./perf record --kcore -e intel_pt// taskset --cpu-list 7 uname
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.147 MB perf.data ]
# ./perf script --itrace=e
Requested CPU 7 too large. Consider raising MAX_NR_CPUS
0x25908 [0x8]: failed to process type: 68 [Invalid argument]
After:
# ./perf script --itrace=e
#
Fixes: 8c7274691f0d ("perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
Fixes: 7df4e36a4785 ("perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/machine.c | 4 ++--
tools/perf/util/session.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 1ae32a81639c..46844599d25d 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2977,7 +2977,7 @@ int machines__for_each_thread(struct machines *machines,
pid_t machine__get_current_tid(struct machine *machine, int cpu)
{
- int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
+ int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
if (cpu < 0 || cpu >= nr_cpus || !machine->current_tid)
return -1;
@@ -2989,7 +2989,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
pid_t tid)
{
struct thread *thread;
- int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
+ int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
if (cpu < 0)
return -EINVAL;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 3b3c50b12791..2777c2df7d87 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2391,7 +2391,7 @@ int perf_session__cpu_bitmap(struct perf_session *session,
{
int i, err = -1;
struct perf_cpu_map *map;
- int nr_cpus = min(session->header.env.nr_cpus_online, MAX_NR_CPUS);
+ int nr_cpus = min(session->header.env.nr_cpus_avail, MAX_NR_CPUS);
for (i = 0; i < PERF_TYPE_MAX; ++i) {
struct evsel *evsel;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf intel-pt: Fix 'CPU too large' error
2021-01-07 17:41 [PATCH] perf intel-pt: Fix 'CPU too large' error Adrian Hunter
@ 2021-01-07 20:46 ` Liang, Kan
2021-01-15 19:33 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Liang, Kan @ 2021-01-07 20:46 UTC (permalink / raw)
To: Adrian Hunter, Arnaldo Carvalho de Melo, Jiri Olsa; +Cc: linux-kernel
On 1/7/2021 12:41 PM, Adrian Hunter wrote:
> In some cases, the number of cpus (nr_cpus_online) is confused with the
> maximum cpu number (nr_cpus_avail), which results in the error in the
> example below:
>
> Example on system with 8 cpus:
>
> Before:
> # echo 0 > /sys/devices/system/cpu/cpu2/online
> # ./perf record --kcore -e intel_pt// taskset --cpu-list 7 uname
> Linux
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.147 MB perf.data ]
> # ./perf script --itrace=e
> Requested CPU 7 too large. Consider raising MAX_NR_CPUS
> 0x25908 [0x8]: failed to process type: 68 [Invalid argument]
>
> After:
> # ./perf script --itrace=e
> #
>
> Fixes: 8c7274691f0d ("perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
> Fixes: 7df4e36a4785 ("perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
> Cc: stable@vger.kernel.org
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Thanks,
Kan
> ---
> tools/perf/util/machine.c | 4 ++--
> tools/perf/util/session.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 1ae32a81639c..46844599d25d 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -2977,7 +2977,7 @@ int machines__for_each_thread(struct machines *machines,
>
> pid_t machine__get_current_tid(struct machine *machine, int cpu)
> {
> - int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
> + int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
>
> if (cpu < 0 || cpu >= nr_cpus || !machine->current_tid)
> return -1;
> @@ -2989,7 +2989,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
> pid_t tid)
> {
> struct thread *thread;
> - int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
> + int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
>
> if (cpu < 0)
> return -EINVAL;
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 3b3c50b12791..2777c2df7d87 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -2391,7 +2391,7 @@ int perf_session__cpu_bitmap(struct perf_session *session,
> {
> int i, err = -1;
> struct perf_cpu_map *map;
> - int nr_cpus = min(session->header.env.nr_cpus_online, MAX_NR_CPUS);
> + int nr_cpus = min(session->header.env.nr_cpus_avail, MAX_NR_CPUS);
>
> for (i = 0; i < PERF_TYPE_MAX; ++i) {
> struct evsel *evsel;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf intel-pt: Fix 'CPU too large' error
2021-01-07 20:46 ` Liang, Kan
@ 2021-01-15 19:33 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-01-15 19:33 UTC (permalink / raw)
To: Liang, Kan; +Cc: Adrian Hunter, Jiri Olsa, linux-kernel
Em Thu, Jan 07, 2021 at 03:46:03PM -0500, Liang, Kan escreveu:
>
>
> On 1/7/2021 12:41 PM, Adrian Hunter wrote:
> > In some cases, the number of cpus (nr_cpus_online) is confused with the
> > maximum cpu number (nr_cpus_avail), which results in the error in the
> > example below:
> >
> > Example on system with 8 cpus:
> >
> > Before:
> > # echo 0 > /sys/devices/system/cpu/cpu2/online
> > # ./perf record --kcore -e intel_pt// taskset --cpu-list 7 uname
> > Linux
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.147 MB perf.data ]
> > # ./perf script --itrace=e
> > Requested CPU 7 too large. Consider raising MAX_NR_CPUS
> > 0x25908 [0x8]: failed to process type: 68 [Invalid argument]
> >
> > After:
> > # ./perf script --itrace=e
> > #
> >
> > Fixes: 8c7274691f0d ("perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
> > Fixes: 7df4e36a4785 ("perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>
>
> Tested-by: Kan Liang <kan.liang@linux.intel.com>
Thanks, applied.
- Arnaldo
> Thanks,
> Kan
>
> > ---
> > tools/perf/util/machine.c | 4 ++--
> > tools/perf/util/session.c | 2 +-
> > 2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> > index 1ae32a81639c..46844599d25d 100644
> > --- a/tools/perf/util/machine.c
> > +++ b/tools/perf/util/machine.c
> > @@ -2977,7 +2977,7 @@ int machines__for_each_thread(struct machines *machines,
> > pid_t machine__get_current_tid(struct machine *machine, int cpu)
> > {
> > - int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
> > + int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
> > if (cpu < 0 || cpu >= nr_cpus || !machine->current_tid)
> > return -1;
> > @@ -2989,7 +2989,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
> > pid_t tid)
> > {
> > struct thread *thread;
> > - int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
> > + int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
> > if (cpu < 0)
> > return -EINVAL;
> > diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> > index 3b3c50b12791..2777c2df7d87 100644
> > --- a/tools/perf/util/session.c
> > +++ b/tools/perf/util/session.c
> > @@ -2391,7 +2391,7 @@ int perf_session__cpu_bitmap(struct perf_session *session,
> > {
> > int i, err = -1;
> > struct perf_cpu_map *map;
> > - int nr_cpus = min(session->header.env.nr_cpus_online, MAX_NR_CPUS);
> > + int nr_cpus = min(session->header.env.nr_cpus_avail, MAX_NR_CPUS);
> > for (i = 0; i < PERF_TYPE_MAX; ++i) {
> > struct evsel *evsel;
> >
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-15 19:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-07 17:41 [PATCH] perf intel-pt: Fix 'CPU too large' error Adrian Hunter
2021-01-07 20:46 ` Liang, Kan
2021-01-15 19:33 ` 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.