mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Unconditionally fall back to software if opening hardware counters fails
If hardware counters are not available, fall back to SW regardless of why the hardware counters aren't available. The error code can be either ENOTSUPP or ENODEV depending on CPU type, so it's simpler to just retry in all cases, and only fail if the software fallback failed.
This commit is contained in:
13
collector.c
13
collector.c
@ -360,14 +360,11 @@ counter_new (Collector *collector,
|
||||
|
||||
if ((fd = sysprof_perf_counter_open (&attr, -1, cpu, -1, 0)) < 0)
|
||||
{
|
||||
if (errno == ENODEV)
|
||||
{
|
||||
attr.type = PERF_TYPE_SOFTWARE;
|
||||
attr.config = PERF_COUNT_SW_CPU_CLOCK;
|
||||
attr.sample_period = 1000000;
|
||||
|
||||
fd = sysprof_perf_counter_open (&attr, -1, cpu, -1, 0);
|
||||
}
|
||||
attr.type = PERF_TYPE_SOFTWARE;
|
||||
attr.config = PERF_COUNT_SW_CPU_CLOCK;
|
||||
attr.sample_period = 1000000;
|
||||
|
||||
fd = sysprof_perf_counter_open (&attr, -1, cpu, -1, 0);
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
|
||||
Reference in New Issue
Block a user