]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/numa-util.h
json: add helpers for dealing with id128 + strv
[thirdparty/systemd.git] / src / shared / numa-util.h
CommitLineData
1808f768
MS
1/* SPDX-License-Identifier: LGPL-2.1+ */
2#pragma once
3
4#include "cpu-set-util.h"
5#include "missing_syscall.h"
6
7static inline bool mpol_is_valid(int t) {
8 return t >= MPOL_DEFAULT && t <= MPOL_LOCAL;
9}
10
11typedef struct NUMAPolicy {
12 /* Always use numa_policy_get_type() to read the value */
13 int type;
14 CPUSet nodes;
15} NUMAPolicy;
16
17bool numa_policy_is_valid(const NUMAPolicy *p);
18
19static inline int numa_policy_get_type(const NUMAPolicy *p) {
20 return p->type < 0 ? (p->nodes.set ? MPOL_PREFERRED : -1) : p->type;
21}
22
23static inline void numa_policy_reset(NUMAPolicy *p) {
24 assert(p);
25 cpu_set_reset(&p->nodes);
26 p->type = -1;
27}
28
29int apply_numa_policy(const NUMAPolicy *policy);
30int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *set);
31
32const char* mpol_to_string(int i) _const_;
33int mpol_from_string(const char *s) _pure_;