src/pmdas/perfevent: Fix perfevent agent to return correct cpu numbers in lower smt levels
src/pmdas/perfevent: Fix perfevent agent to return correct cpu numbers in lower smt levels

retrieve_cpuinfo() populates the cpulist based on the number of online
cpus. But the cpuids are populated in the list as contiguous values
starting from index 0 to the total number of online cpus.
This is not applicable incase of a system with discontiguous cpuids,
and hence it fails to return proper cpu numbers in lower smt levels.

Fix this by populating cpulist as per /sys/devices/system/cpu/online.

Ex:
# lscpu
[......]
On-line CPU(s) list:  0-3,8-11
Off-line CPU(s) list: 4-7,12-15
[......]

Before applying the patch:
# ppc64_cpu --smt=4 #pmval perfevent.hwcounters.cpu.branch_misses.value

metric:    perfevent.hwcounters.cpu.branch_misses.value
host:      linux-vg2u
semantics: cumulative counter (converting to rate)
units:     count (converting to count / sec)
samples:   all

cpu0    cpu1   cpu2      cpu3
5123.   2215.  1952.     306.9
1424.   1961.  1134.     698.8
3300.   3451.  589.8     2249.

After applying the patch:
# ppc64_cpu --smt=4
# pmval perfevent.hwcounters.cpu.branch_misses.value

metric:    perfevent.hwcounters.cpu.branch_misses.value
host:      linux-vg2u
semantics: cumulative counter (converting to rate)
units:     count (converting to count / sec)
samples:   all

cpu0   cpu1    cpu2   cpu3  cpu8  cpu9   cpu10  cpu11
400.6  333.7   1622.  3719. 2566. 1864.  1032.  745.3
337.7  293.7   1404.  3473. 572.5 1579.  1093.  1472

Test cases executed before and after the patch:
==============================================
Before applying the patch:

# ./perfevent_test 30
 ===== test_cpu_max_smt ====
Found PMU: pmuname (description) identification 0 (1 events 2 generic counters 3 fixed counters)
pmuname::event (attr0,attr2cannot get attribute info: sadness)
Using configuration entry [pmuname]
perfevent_test: perf_event_test.c:999: test_cpu_max_smt: Assertion `data[i].data[j].id == j' failed.
Aborted (core dumped)

# ./perfevent_test 31
 ===== test_cpu_smt ====
Found PMU: pmuname (description) identification 0 (1 events 2 generic counters 3 fixed counters)
pmuname::event (attr0,attr2cannot get attribute info: sadness)
Using configuration entry [pmuname]
perfevent_test: perf_event_test.c:1031: test_cpu_smt: Assertion `data[i].data[j+4].id == (j+8)' failed.
Aborted (core dumped)'

After applying the patch:

# ./perfevent_test 30
===== test_cpu_max_smt ====
Found PMU: pmuname (description) identification 0 (1 events 2 generic counters 3 fixed counters)
pmuname::event (attr0,attr2cannot get attribute info: sadness)
Using configuration entry [pmuname]

# ./perfevent_test 31
 ===== test_cpu_smt ====
Found PMU: pmuname (description) identification 0 (1 events 2 generic counters 3 fixed counters)
pmuname::event (attr0,attr2cannot get attribute info: sadness)
Using configuration entry [pmuname]

Signed-off-by: Anju T Sudhakar <e8c8e1f4d2d74e058c71d5cc0f36846d7866f919@linux.vnet.ibm.com>

adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp,adfernandes/pcp