Debian Codegraph @

src/shared/numa-util.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <sys/mempolicy.h>
5
6 #include "cpu-set-util.h"
7 #include "shared-forward.h"
8
9 static inline bool mpol_is_valid(int t) {
10 return t >= MPOL_DEFAULT && t <= MPOL_LOCAL;
11 }
12
13 typedef struct NUMAPolicy {
14 /* Always use numa_policy_get_type() to read the value */
15 int type;
16 CPUSet nodes;
17 } NUMAPolicy;
18
19 bool numa_policy_is_valid(const NUMAPolicy *p);
20
21 static inline int numa_policy_get_type(const NUMAPolicy *p) {
22 return p->type < 0 ? (p->nodes.set ? MPOL_PREFERRED : -1) : p->type;
23 }
24
25 static inline void numa_policy_reset(NUMAPolicy *p) {
26 assert(p);
27 cpu_set_done(&p->nodes);
28 p->type = -1;
29 }
30
31 int apply_numa_policy(const NUMAPolicy *policy);
32 int numa_node_get_cpus(size_t node, CPUSet *ret);
33 int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *ret);
34
35 int numa_get_node_from_cpu(unsigned cpu, unsigned *ret);
36
37 int numa_mask_add_all(CPUSet *mask);
38
39 DECLARE_STRING_TABLE_LOOKUP(mpol, int);