HALF ECHO LEARN / REFERENCE COLLECTION

v262.2

src/shared/numa-util.h

1,018 bytesGit mode 100644Download original fileLGPL-2.1-or-later

Git blob: 6b504b05df2fe0234a3dbb54e13a04e96b322507

Lines 1–40 of 40

/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
 
#include <sys/mempolicy.h>
 
#include "cpu-set-util.h"
#include "forward.h"
 
static inline bool mpol_is_valid(int t) {
        return t >= MPOL_DEFAULT && t <= MPOL_WEIGHTED_INTERLEAVE;
}
 
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_done(&p->nodes);
        p->type = -1;
}
 
int apply_numa_policy(const NUMAPolicy *policy);
int numa_node_get_cpus(size_t node, CPUSet *ret);
int numa_to_cpu_set(const NUMAPolicy *policy, CPUSet *ret);
 
int numa_get_node_from_cpu(unsigned cpu, unsigned *ret);
 
int numa_mask_add_all(CPUSet *mask);
 
DECLARE_STRING_TABLE_LOOKUP(mpol, int);