Re: [PATCH] perf: fix topology test on systems with sparse CPUs

From: Jiri Olsa
Date: Thu Feb 02 2017 - 06:30:05 EST


On Tue, Jan 31, 2017 at 05:03:51PM +0100, Jan Stancek wrote:

SNIP

>
> There are 2 problems wrt. cpu_topology_map on systems with sparse CPUs:
>
> 1. offline/absent CPUs will have their socket_id and core_id set to -1
> which triggers:
> "socket_id number is too big.You may need to upgrade the perf tool."
>
> 2. size of cpu_topology_map (perf_env.cpu[]) is allocated based on
> _SC_NPROCESSORS_CONF, but can be indexed with CPU ids going above.
> Users of perf_env.cpu[] are using CPU id as index. This can lead
> to read beyond what was allocated:
> ==19991== Invalid read of size 4
> ==19991== at 0x490CEB: check_cpu_topology (topology.c:69)
> ==19991== by 0x490CEB: test_session_topology (topology.c:106)
> ...
>
> For example:
> _SC_NPROCESSORS_CONF == 16
> available: 2 nodes (0-1)
> node 0 cpus: 0 6 8 10 16 22 24 26
> node 0 size: 12004 MB
> node 0 free: 9470 MB
> node 1 cpus: 1 7 9 11 23 25 27
> node 1 size: 12093 MB
> node 1 free: 9406 MB
> node distances:
> node 0 1
> 0: 10 20
> 1: 20 10

so what's max_present_cpu in this example?

jirka