.. | .. |
---|
15 | 15 | if (cached) |
---|
16 | 16 | return cached_result; |
---|
17 | 17 | |
---|
| 18 | + if (sysfs__read_int("devices/system/cpu/smt/active", &cached_result) >= 0) |
---|
| 19 | + goto done; |
---|
| 20 | + |
---|
18 | 21 | ncpu = sysconf(_SC_NPROCESSORS_CONF); |
---|
19 | 22 | for (cpu = 0; cpu < ncpu; cpu++) { |
---|
20 | 23 | unsigned long long siblings; |
---|
.. | .. |
---|
23 | 26 | char fn[256]; |
---|
24 | 27 | |
---|
25 | 28 | snprintf(fn, sizeof fn, |
---|
26 | | - "devices/system/cpu/cpu%d/topology/thread_siblings", |
---|
27 | | - cpu); |
---|
28 | | - if (sysfs__read_str(fn, &str, &strlen) < 0) |
---|
29 | | - continue; |
---|
| 29 | + "devices/system/cpu/cpu%d/topology/core_cpus", cpu); |
---|
| 30 | + if (sysfs__read_str(fn, &str, &strlen) < 0) { |
---|
| 31 | + snprintf(fn, sizeof fn, |
---|
| 32 | + "devices/system/cpu/cpu%d/topology/thread_siblings", |
---|
| 33 | + cpu); |
---|
| 34 | + if (sysfs__read_str(fn, &str, &strlen) < 0) |
---|
| 35 | + continue; |
---|
| 36 | + } |
---|
30 | 37 | /* Entry is hex, but does not have 0x, so need custom parser */ |
---|
31 | 38 | siblings = strtoull(str, NULL, 16); |
---|
32 | 39 | free(str); |
---|
.. | .. |
---|
38 | 45 | } |
---|
39 | 46 | if (!cached) { |
---|
40 | 47 | cached_result = 0; |
---|
| 48 | +done: |
---|
41 | 49 | cached = true; |
---|
42 | 50 | } |
---|
43 | 51 | return cached_result; |
---|