4 #include <linux/bitops.h>
9 * hweight_str - Returns the number of bits set in str. Stops at first non-hex
12 static int hweight_str(char *str)
61 static int cached_result;
68 if (sysfs__read_int("devices/system/cpu/smt/active", &cached_result) >= 0) {
74 ncpu = sysconf(_SC_NPROCESSORS_CONF);
75 for (cpu = 0; cpu < ncpu; cpu++) {
76 unsigned long long siblings;
81 snprintf(fn, sizeof fn,
82 "devices/system/cpu/cpu%d/topology/thread_siblings", cpu);
83 if (sysfs__read_str(fn, &str, &strlen) < 0) {
84 snprintf(fn, sizeof fn,
85 "devices/system/cpu/cpu%d/topology/core_cpus", cpu);
86 if (sysfs__read_str(fn, &str, &strlen) < 0)
89 /* Entry is hex, but does not have 0x, so need custom parser */
90 siblings = hweight_str(str);