b6dd5707819af414a4c4a203e1e3d998ad983cf3
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
11 * Get the CPU possible mask string from sysfs.
13 * buf: the buffer where the mask will be read.
14 * max_bytes: the maximum number of bytes to write in the buffer.
16 * Returns the number of bytes read or -1 on error.
18 int get_possible_cpu_mask_from_sysfs(char *buf
, size_t max_bytes
)
19 __attribute__((visibility("hidden")));
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.
25 * Returns the number of possible CPUs in the system or 0 on error.
27 int get_num_possible_cpus_fallback(void)
28 __attribute__((visibility("hidden")));
31 * Get the number of CPUs from the possible cpu mask.
33 * pmask: the mask to parse.
34 * len: the len of the mask excluding '\0'.
36 * Returns the number of possible CPUs from the mask or 0 on error.
38 int get_num_possible_cpus_from_mask(const char *pmask
, size_t len
)
39 __attribute__((visibility("hidden")));
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.
46 * If all methods fail, don't populate the cache and return 0.
48 int num_possible_cpus(void)
49 __attribute__((visibility("hidden")));
51 #define for_each_possible_cpu(cpu) \
52 for ((cpu) = 0; (cpu) < num_possible_cpus(); (cpu)++)
54 #endif /* _UST_COMMON_SMP_H */
This page took 0.033827 seconds and 3 git commands to generate.