2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 #ifndef _UST_COMMON_SMP_H
8 #define _UST_COMMON_SMP_H
10 #define LTTNG_UST_CPUMASK_SIZE 4096
13 * Get the CPU possible mask string from sysfs.
15 * buf: the buffer where the mask will be read.
16 * max_bytes: the maximum number of bytes to write in the buffer.
18 * Returns the number of bytes read or -1 on error.
20 int get_possible_cpu_mask_from_sysfs(char *buf
, size_t max_bytes
)
21 __attribute__((visibility("hidden")));
24 * Get the number of possible CPUs in the system from either
25 * sysconf(_SC_NPROCESSORS_CONF) or some other mechanism depending on the libc.
27 * Returns the number of possible CPUs in the system or 0 on error.
29 int get_num_possible_cpus_fallback(void)
30 __attribute__((visibility("hidden")));
33 * Get the number of CPUs from the possible cpu mask.
35 * pmask: the mask to parse.
36 * len: the len of the mask excluding '\0'.
38 * Returns the number of possible CPUs from the mask or 0 on error.
40 int get_num_possible_cpus_from_mask(const char *pmask
, size_t len
)
41 __attribute__((visibility("hidden")));
44 * Returns the total number of CPUs in the system. If the cache is not yet
45 * initialized, get the value from "/sys/devices/system/cpu/possible" or
46 * fallback to sysconf and cache it.
48 * If all methods fail, don't populate the cache and return 0.
50 int num_possible_cpus(void)
51 __attribute__((visibility("hidden")));
53 #define for_each_possible_cpu(cpu) \
54 for ((cpu) = 0; (cpu) < num_possible_cpus(); (cpu)++)
56 #endif /* _UST_COMMON_SMP_H */
This page took 0.043896 seconds and 5 git commands to generate.