summaryrefslogtreecommitdiffstats
path: root/src/shared/numa-util.h
diff options
context:
space:
mode:
authorMichal Sekletár <msekleta@redhat.com>2020-02-17 13:04:08 +0100
committerMichal Sekletár <msekleta@redhat.com>2020-03-16 08:23:18 +0100
commit1808f76870d8368542f058b99df89cf0a4a2d011 (patch)
treeaf6812637836b24733ff90d808da0d05fe1bf6a5 /src/shared/numa-util.h
parentNEWS: fix use of tabs instead of spaces for one item (diff)
downloadsystemd-1808f76870d8368542f058b99df89cf0a4a2d011.tar.xz
systemd-1808f76870d8368542f058b99df89cf0a4a2d011.zip
shared: split out NUMA code from cpu-set-util.c to numa-util.c
Diffstat (limited to 'src/shared/numa-util.h')
-rw-r--r--src/shared/numa-util.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/shared/numa-util.h b/src/shared/numa-util.h
new file mode 100644
index 0000000000..c99178903b
--- /dev/null
+++ b/src/shared/numa-util.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+#include "cpu-set-util.h"
+#include "missing_syscall.h"
+
+static inline bool mpol_is_valid(int t) {
+ return t >= MPOL_DEFAULT && t <= MPOL_LOCAL;
+}
+
+typedef struct NUMAPolicy {
+ /* Always use numa_policy_get_type() to read the value */
+ int type;
+ CPUSet nodes;
+} NUMAPolicy;
+
+bool numa_policy_is_valid(const NUMAPolicy *p);
+
+static inline int numa_policy_get_type(const NUMAPolicy *p) {
+ return p->type < 0 ? (p->nodes.set ? MPOL_PREFERRED : -1) : p->type;
+}
+
+static inline void numa_policy_reset(NUMAPolicy *p) {
+ assert(p);
+ cpu_set_reset(&p->nodes);
+ p->type = -1;
+}
+
+int apply_numa_policy(const NUMAPolicy *policy);
+int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *set);
+
+const char* mpol_to_string(int i) _const_;
+int mpol_from_string(const char *s) _pure_;