diff options
author | Michal Sekletar <msekleta@redhat.com> | 2019-03-12 18:58:26 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-06-24 16:58:54 +0200 |
commit | b070c7c0e133362ab5e20875e7294908004266af (patch) | |
tree | 2aa0a0554298819e9c5fff3e7190e6261b43f92d /src/shared/cpu-set-util.h | |
parent | Merge pull request #12868 from poettering/doc-243-fixes (diff) | |
download | systemd-b070c7c0e133362ab5e20875e7294908004266af.tar.xz systemd-b070c7c0e133362ab5e20875e7294908004266af.zip |
core: introduce NUMAPolicy and NUMAMask options
Make possible to set NUMA allocation policy for manager. Manager's
policy is by default inherited to all forked off processes. However, it
is possible to override the policy on per-service basis. Currently we
support, these policies: default, prefer, bind, interleave, local.
See man 2 set_mempolicy for details on each policy.
Overall NUMA policy actually consists of two parts. Policy itself and
bitmask representing NUMA nodes where is policy effective. Node mask can
be specified using related option, NUMAMask. Default mask can be
overwritten on per-service level.
Diffstat (limited to 'src/shared/cpu-set-util.h')
-rw-r--r-- | src/shared/cpu-set-util.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/shared/cpu-set-util.h b/src/shared/cpu-set-util.h index fd6a15f446..27812dfd59 100644 --- a/src/shared/cpu-set-util.h +++ b/src/shared/cpu-set-util.h @@ -4,6 +4,7 @@ #include <sched.h> #include "macro.h" +#include "missing_syscall.h" /* This wraps the libc interface with a variable to keep the allocated size. */ typedef struct CPUSet { @@ -48,3 +49,30 @@ int cpu_set_to_dbus(const CPUSet *set, uint8_t **ret, size_t *allocated); int cpu_set_from_dbus(const uint8_t *bits, size_t size, CPUSet *set); int cpus_in_affinity_mask(void); + +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); + +const char* mpol_to_string(int i) _const_; +int mpol_from_string(const char *s) _pure_; |