Skip to content

Commit 5501e92

Browse files
ahunter6acmel
authored andcommitted
perf intel-pt: Fix 'CPU too large' error
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: 8c72746 ("perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online") Fixes: 7df4e36 ("perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online") Signed-off-by: Adrian Hunter <[email protected]> Tested-by: Kan Liang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a1bf230 commit 5501e92

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tools/perf/util/machine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,7 +2980,7 @@ int machines__for_each_thread(struct machines *machines,
29802980

29812981
pid_t machine__get_current_tid(struct machine *machine, int cpu)
29822982
{
2983-
int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
2983+
int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
29842984

29852985
if (cpu < 0 || cpu >= nr_cpus || !machine->current_tid)
29862986
return -1;
@@ -2992,7 +2992,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
29922992
pid_t tid)
29932993
{
29942994
struct thread *thread;
2995-
int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
2995+
int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
29962996

29972997
if (cpu < 0)
29982998
return -EINVAL;

tools/perf/util/session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,7 @@ int perf_session__cpu_bitmap(struct perf_session *session,
24042404
{
24052405
int i, err = -1;
24062406
struct perf_cpu_map *map;
2407-
int nr_cpus = min(session->header.env.nr_cpus_online, MAX_NR_CPUS);
2407+
int nr_cpus = min(session->header.env.nr_cpus_avail, MAX_NR_CPUS);
24082408

24092409
for (i = 0; i < PERF_TYPE_MAX; ++i) {
24102410
struct evsel *evsel;

0 commit comments

Comments
 (0)