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