X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsmp.h;h=51fbd2d7e5d34c01c04df7d13ac4397302a223c0;hb=feac72042ef1572189d4280a4f151ce049ac2b1e;hp=5f81094fc802c7f6559d876c03ae6af6f4be13a4;hpb=95fa2ba4fbbfac95bca6f437b2bb4389789b21eb;p=lttng-ust.git diff --git a/src/common/smp.h b/src/common/smp.h index 5f81094f..51fbd2d7 100644 --- a/src/common/smp.h +++ b/src/common/smp.h @@ -7,11 +7,45 @@ #ifndef _UST_COMMON_SMP_H #define _UST_COMMON_SMP_H +#define LTTNG_UST_CPUMASK_SIZE 4096 + +/* + * Get the CPU possible mask string from sysfs. + * + * buf: the buffer where the mask will be read. + * max_bytes: the maximum number of bytes to write in the buffer. + * + * Returns the number of bytes read or -1 on error. + */ +int get_possible_cpu_mask_from_sysfs(char *buf, size_t max_bytes) + __attribute__((visibility("hidden"))); + +/* + * Get the number of possible CPUs in the system from either + * sysconf(_SC_NPROCESSORS_CONF) or some other mechanism depending on the libc. + * + * Returns the number of possible CPUs in the system or 0 on error. + */ +int get_num_possible_cpus_fallback(void) + __attribute__((visibility("hidden"))); + +/* + * Get the number of CPUs from the possible 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. + */ +int get_num_possible_cpus_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 the system through sysconf and cache it. + * initialized, get the value from "/sys/devices/system/cpu/possible" or + * fallback to sysconf and cache it. * - * If the sysconf call fails, don't populate the cache and return 0. + * If all methods fail, don't populate the cache and return 0. */ int num_possible_cpus(void) __attribute__((visibility("hidden")));