X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsmp.h;h=f908b6c6ef39c5e9f8868ec15b19a78f80b54d83;hb=a616fb4e0a0245ae2cbd4614910480df19aa23d6;hp=51fbd2d7e5d34c01c04df7d13ac4397302a223c0;hpb=217babc9b6b5dcc531fb6b8bc5fc6e2906a060be;p=lttng-ust.git diff --git a/src/common/smp.h b/src/common/smp.h index 51fbd2d7..f908b6c6 100644 --- a/src/common/smp.h +++ b/src/common/smp.h @@ -30,27 +30,31 @@ int get_num_possible_cpus_fallback(void) __attribute__((visibility("hidden"))); /* - * Get the number of CPUs from the possible cpu mask. + * Get the highest CPU id from a CPU mask. * * pmask: the mask to parse. * len: the len of the mask excluding '\0'. * - * Returns the number of possible CPUs from the mask or 0 on error. + * Returns the highest CPU id from the mask or -1 on error. */ -int get_num_possible_cpus_from_mask(const char *pmask, size_t len) +int get_max_cpuid_from_mask(const char *pmask, size_t len) __attribute__((visibility("hidden"))); /* - * Returns the total number of CPUs in the system. If the cache is not yet - * initialized, get the value from "/sys/devices/system/cpu/possible" or - * fallback to sysconf and cache it. + * Returns the length of an array that could contain a per-CPU element for each + * possible CPU id for the lifetime of the process. + * + * We currently assume CPU ids are contiguous up the maximum CPU id. + * + * If the cache is not yet initialized, get the value from + * "/sys/devices/system/cpu/possible" or fallback to sysconf and cache it. * * If all methods fail, don't populate the cache and return 0. */ -int num_possible_cpus(void) +int get_possible_cpus_array_len(void) __attribute__((visibility("hidden"))); #define for_each_possible_cpu(cpu) \ - for ((cpu) = 0; (cpu) < num_possible_cpus(); (cpu)++) + for ((cpu) = 0; (cpu) < get_possible_cpus_array_len(); (cpu)++) #endif /* _UST_COMMON_SMP_H */