| numa.h | | numa.h | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| somewhere on your Linux system; if not, write to the Free Software | | somewhere on your Linux system; if not, write to the Free Software | |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ | | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ | |
| | | | |
| #ifndef _NUMA_H | | #ifndef _NUMA_H | |
| #define _NUMA_H 1 | | #define _NUMA_H 1 | |
| | | | |
| /* Simple NUMA poliy library */ | | /* Simple NUMA poliy library */ | |
| | | | |
| #include <stddef.h> | | #include <stddef.h> | |
| #include <string.h> | | #include <string.h> | |
|
| | | #include <sys/types.h> | |
| | | #include <stdlib.h> | |
| | | | |
| #if defined(__x86_64__) || defined(__i386__) | | #if defined(__x86_64__) || defined(__i386__) | |
|
| #define NUMA_NUM_NODES 128 | | #define NUMA_NUM_NODES 128 | |
| #else | | #else | |
|
| #define NUMA_NUM_NODES 2048 | | #define NUMA_NUM_NODES 2048 | |
| #endif | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| typedef struct { | | typedef struct { | |
|
| unsigned long n[NUMA_NUM_NODES/(sizeof(unsigned long)*8)]; | | unsigned long n[NUMA_NUM_NODES/(sizeof(unsigned long)*8)]; | |
| } nodemask_t; | | } nodemask_t; | |
| | | | |
|
| static inline void nodemask_zero(nodemask_t *mask) | | struct bitmask { | |
| { | | unsigned long size; /* number of bits in the map */ | |
| memset(mask->n, 0, sizeof(mask->n)); | | unsigned long *maskp; | |
| } | | }; | |
| | | | |
|
| static inline void nodemask_set(nodemask_t *mask, int node) | | #define howmany(x,y) (((x)+((y)-1))/(y)) | |
| { | | #define bitsperlong (8 * sizeof(unsigned long)) | |
| mask->n[node / (8*sizeof(unsigned long))] |= | | #define longsperbits(n) howmany(n, bitsperlong) | |
| (1UL<<(node%(8*sizeof(unsigned long)))); | | #define bytesperbits(x) ((x+7)/8) | |
| } | | | |
| | | | |
|
| static inline void nodemask_clr(nodemask_t *mask, int node) | | /* operations on struct bitmask */ | |
| { | | int numa_bitmask_isbitset(const struct bitmask *, unsigned int); | |
| mask->n[node / (8*sizeof(unsigned long))] &= | | struct bitmask *numa_bitmask_setall(struct bitmask *); | |
| ~(1UL<<(node%(8*sizeof(unsigned long)))); | | struct bitmask *numa_bitmask_clearall(struct bitmask *); | |
| } | | struct bitmask *numa_bitmask_setbit(struct bitmask *, unsigned int); | |
| static inline int nodemask_isset(const nodemask_t *mask, int node) | | struct bitmask *numa_bitmask_clearbit(struct bitmask *, unsigned int); | |
| | | unsigned int numa_bitmask_nbytes(struct bitmask *); | |
| | | struct bitmask *numa_bitmask_alloc(unsigned int); | |
| | | void numa_bitmask_free(struct bitmask *); | |
| | | int numa_bitmask_equal(const struct bitmask *, const struct bitmask *); | |
| | | void copy_nodemask_to_bitmask(nodemask_t *, struct bitmask *); | |
| | | void copy_bitmask_to_nodemask(struct bitmask *, nodemask_t *); | |
| | | | |
| | | /* compatibility for codes that used them: */ | |
| | | static inline void nodemask_zero(struct bitmask *mask) | |
| { | | { | |
|
| if ((unsigned)node >= NUMA_NUM_NODES) | | numa_bitmask_clearall(mask); | |
| return 0; | | | |
| if (mask->n[node / (8*sizeof(unsigned long))] & | | | |
| (1UL<<(node%(8*sizeof(unsigned long))))) | | | |
| return 1; | | | |
| return 0; | | | |
| } | | } | |
|
| static inline int nodemask_equal(const nodemask_t *a, const nodemask_t *b) | | | |
| | | static inline int nodemask_equal(struct bitmask *a, struct bitmask *b) | |
| { | | { | |
|
| int i; | | return numa_bitmask_equal(a, b); | |
| for (i = 0; i < NUMA_NUM_NODES/(sizeof(unsigned long)*8); i++) | | | |
| if (a->n[i] != b->n[i]) | | | |
| return 0; | | | |
| return 1; | | | |
| } | | } | |
| | | | |
| /* NUMA support available. If this returns a negative value all other funct
ion | | /* NUMA support available. If this returns a negative value all other funct
ion | |
| in this library are undefined. */ | | in this library are undefined. */ | |
| int numa_available(void); | | int numa_available(void); | |
| | | | |
| /* Basic NUMA state */ | | /* Basic NUMA state */ | |
| | | | |
| /* Get max available node */ | | /* Get max available node */ | |
| int numa_max_node(void); | | int numa_max_node(void); | |
|
| | | int numa_max_possible_node(void); | |
| /* Return preferred node */ | | /* Return preferred node */ | |
| int numa_preferred(void); | | int numa_preferred(void); | |
| | | | |
| /* Return node size and free memory */ | | /* Return node size and free memory */ | |
| long long numa_node_size64(int node, long long *freep); | | long long numa_node_size64(int node, long long *freep); | |
| long numa_node_size(int node, long *freep); | | long numa_node_size(int node, long *freep); | |
| | | | |
| int numa_pagesize(void); | | int numa_pagesize(void); | |
| | | | |
| /* Set with all nodes. Only valid after numa_available. */ | | /* Set with all nodes. Only valid after numa_available. */ | |
|
| extern const nodemask_t numa_all_nodes; | | extern struct bitmask *numa_all_nodes_ptr; | |
| | | | |
| | | /* For source compatibility */ | |
| | | extern nodemask_t numa_all_nodes; | |
| | | | |
| | | /* Set with all cpus. */ | |
| | | extern struct bitmask *numa_all_cpus_ptr; | |
| | | | |
| /* Set with no nodes */ | | /* Set with no nodes */ | |
|
| extern const nodemask_t numa_no_nodes; | | extern struct bitmask *numa_no_nodes_ptr; | |
| | | | |
| | | /* Source compatibility */ | |
| | | extern nodemask_t numa_no_nodes; | |
| | | | |
| /* Only run and allocate memory from a specific set of nodes. */ | | /* Only run and allocate memory from a specific set of nodes. */ | |
|
| void numa_bind(const nodemask_t *nodes); | | void numa_bind(struct bitmask *nodes); | |
| | | | |
| /* Set the NUMA node interleaving mask. 0 to turn off interleaving */ | | /* Set the NUMA node interleaving mask. 0 to turn off interleaving */ | |
|
| void numa_set_interleave_mask(const nodemask_t *nodemask); | | void numa_set_interleave_mask(struct bitmask *nodemask); | |
| | | | |
| /* Return the current interleaving mask */ | | /* Return the current interleaving mask */ | |
|
| nodemask_t numa_get_interleave_mask(void); | | struct bitmask *numa_get_interleave_mask(void); | |
| | | | |
| | | /* allocate a bitmask big enough for all nodes */ | |
| | | struct bitmask *numa_allocate_nodemask(void); | |
| | | | |
| /* Some node to preferably allocate memory from for thread. */ | | /* Some node to preferably allocate memory from for thread. */ | |
| void numa_set_preferred(int node); | | void numa_set_preferred(int node); | |
|
| | | | |
| /* Set local memory allocation policy for thread */ | | /* Set local memory allocation policy for thread */ | |
| void numa_set_localalloc(void); | | void numa_set_localalloc(void); | |
|
| | | | |
| /* Only allocate memory from the nodes set in mask. 0 to turn off */ | | /* Only allocate memory from the nodes set in mask. 0 to turn off */ | |
|
| void numa_set_membind(const nodemask_t *nodemask); | | void numa_set_membind(struct bitmask *nodemask); | |
| | | | |
| /* Return current membind */ | | /* Return current membind */ | |
|
| nodemask_t numa_get_membind(void); | | struct bitmask *numa_get_membind(void); | |
| | | | |
| | | /* Return allowed memories [nodes] */ | |
| | | struct bitmask *numa_get_mems_allowed(void); | |
| | | | |
| int numa_get_interleave_node(void); | | int numa_get_interleave_node(void); | |
| | | | |
| /* NUMA memory allocation. These functions always round to page size | | /* NUMA memory allocation. These functions always round to page size | |
| and are relatively slow. */ | | and are relatively slow. */ | |
| | | | |
| /* Alloc memory page interleaved on nodes in mask */ | | /* Alloc memory page interleaved on nodes in mask */ | |
|
| void *numa_alloc_interleaved_subset(size_t size, const nodemask_t *nodemask
); | | void *numa_alloc_interleaved_subset(size_t size, struct bitmask *nodemask); | |
| /* Alloc memory page interleaved on all nodes. */ | | /* Alloc memory page interleaved on all nodes. */ | |
| void *numa_alloc_interleaved(size_t size); | | void *numa_alloc_interleaved(size_t size); | |
| /* Alloc memory located on node */ | | /* Alloc memory located on node */ | |
| void *numa_alloc_onnode(size_t size, int node); | | void *numa_alloc_onnode(size_t size, int node); | |
| /* Alloc memory on local node */ | | /* Alloc memory on local node */ | |
| void *numa_alloc_local(size_t size); | | void *numa_alloc_local(size_t size); | |
| /* Allocation with current policy */ | | /* Allocation with current policy */ | |
| void *numa_alloc(size_t size); | | void *numa_alloc(size_t size); | |
| /* Free memory allocated by the functions above */ | | /* Free memory allocated by the functions above */ | |
| void numa_free(void *mem, size_t size); | | void numa_free(void *mem, size_t size); | |
| | | | |
| /* Low level functions, primarily for shared memory. All memory | | /* Low level functions, primarily for shared memory. All memory | |
| processed by these must not be touched yet */ | | processed by these must not be touched yet */ | |
| | | | |
| /* Interleave an memory area. */ | | /* Interleave an memory area. */ | |
|
| void numa_interleave_memory(void *mem, size_t size, const nodemask_t *mask)
; | | void numa_interleave_memory(void *mem, size_t size, struct bitmask *mask); | |
| | | | |
| /* Allocate a memory area on a specific node. */ | | /* Allocate a memory area on a specific node. */ | |
| void numa_tonode_memory(void *start, size_t size, int node); | | void numa_tonode_memory(void *start, size_t size, int node); | |
| | | | |
| /* Allocate memory on a mask of nodes. */ | | /* Allocate memory on a mask of nodes. */ | |
|
| void numa_tonodemask_memory(void *mem, size_t size, const nodemask_t *mask)
; | | void numa_tonodemask_memory(void *mem, size_t size, struct bitmask *mask); | |
| | | | |
| /* Allocate a memory area on the current node. */ | | /* Allocate a memory area on the current node. */ | |
| void numa_setlocal_memory(void *start, size_t size); | | void numa_setlocal_memory(void *start, size_t size); | |
| | | | |
| /* Allocate memory area with current memory policy */ | | /* Allocate memory area with current memory policy */ | |
| void numa_police_memory(void *start, size_t size); | | void numa_police_memory(void *start, size_t size); | |
| | | | |
| /* Run current thread only on nodes in mask */ | | /* Run current thread only on nodes in mask */ | |
|
| int numa_run_on_node_mask(const nodemask_t *mask); | | int numa_run_on_node_mask(struct bitmask *mask); | |
| /* Run current thread only on node */ | | /* Run current thread only on node */ | |
| int numa_run_on_node(int node); | | int numa_run_on_node(int node); | |
| /* Return current mask of nodes the thread can run on */ | | /* Return current mask of nodes the thread can run on */ | |
|
| nodemask_t numa_get_run_node_mask(void); | | struct bitmask * numa_get_run_node_mask(void); | |
| | | | |
| /* When strict fail allocation when memory cannot be allocated in target no
de(s). */ | | /* When strict fail allocation when memory cannot be allocated in target no
de(s). */ | |
| void numa_set_bind_policy(int strict); | | void numa_set_bind_policy(int strict); | |
| | | | |
| /* Fail when existing memory has incompatible policy */ | | /* Fail when existing memory has incompatible policy */ | |
| void numa_set_strict(int flag); | | void numa_set_strict(int flag); | |
| | | | |
|
| | | /* maximum nodes (size of kernel nodemask_t) */ | |
| | | int numa_num_possible_nodes(); | |
| | | | |
| | | /* maximum cpus (size of kernel cpumask_t) */ | |
| | | int numa_num_possible_cpus(); | |
| | | | |
| | | /* nodes in the system */ | |
| | | int numa_num_configured_nodes(); | |
| | | | |
| | | /* maximum cpus */ | |
| | | int numa_num_configured_cpus(); | |
| | | | |
| | | /* maximum cpus allowed to current task */ | |
| | | int numa_num_task_cpus(); | |
| | | | |
| | | /* maximum nodes allowed to current task */ | |
| | | int numa_num_task_nodes(); | |
| | | | |
| | | /* allocate a bitmask the size of the kernel cpumask_t */ | |
| | | struct bitmask *numa_allocate_cpumask(); | |
| | | | |
| | | /* set up to represent the cpus available to the current task */ | |
| | | struct bitmask *numa_all_cpus; | |
| | | | |
| /* Convert node to CPU mask. -1/errno on failure, otherwise 0. */ | | /* Convert node to CPU mask. -1/errno on failure, otherwise 0. */ | |
|
| int numa_node_to_cpus(int node, unsigned long *buffer, int buffer_len); | | int numa_node_to_cpus(int, struct bitmask *); | |
| | | | |
| /* Report distance of node1 from node2. 0 on error.*/ | | /* Report distance of node1 from node2. 0 on error.*/ | |
| int numa_distance(int node1, int node2); | | int numa_distance(int node1, int node2); | |
| | | | |
| /* Error handling. */ | | /* Error handling. */ | |
| /* This is an internal function in libnuma that can be overwritten by an us
er | | /* This is an internal function in libnuma that can be overwritten by an us
er | |
| program. Default is to print an error to stderr and exit if numa_exit_on
_error | | program. Default is to print an error to stderr and exit if numa_exit_on
_error | |
| is true. */ | | is true. */ | |
| void numa_error(char *where); | | void numa_error(char *where); | |
| | | | |
| /* When true exit the program when a NUMA system call (except numa_availabl
e) | | /* When true exit the program when a NUMA system call (except numa_availabl
e) | |
| fails */ | | fails */ | |
| extern int numa_exit_on_error; | | extern int numa_exit_on_error; | |
| /* Warning function. Can also be overwritten. Default is to print on stderr | | /* Warning function. Can also be overwritten. Default is to print on stderr | |
| once. */ | | once. */ | |
| void numa_warn(int num, char *fmt, ...); | | void numa_warn(int num, char *fmt, ...); | |
| | | | |
|
| int numa_migrate_pages(int pid, const nodemask_t *from, const nodemask_t *t | | int numa_migrate_pages(int pid, struct bitmask *from, struct bitmask *to); | |
| o); | | | |
| | | int numa_move_pages(int pid, unsigned long count, void **pages, | |
| | | const int *nodes, int *status, int flags); | |
| | | | |
| | | int numa_sched_getaffinity(pid_t, struct bitmask *); | |
| | | int numa_sched_setaffinity(pid_t, struct bitmask *); | |
| | | | |
| | | /* Convert an ascii list of nodes to a bitmask */ | |
| | | struct bitmask *numa_parse_nodestring(char *); | |
| | | | |
| | | /* Convert an ascii list of cpu to a bitmask */ | |
| | | struct bitmask *numa_parse_cpustring(char *); | |
| | | | |
| | | /* | |
| | | * The following functions are for source code compatibility | |
| | | * with releases prior to version 2. | |
| | | * Such codes should be compiled with VERSION1_COMPATIBILITY defined. | |
| | | */ | |
| | | | |
| | | static inline void nodemask_zero_compat(nodemask_t *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | numa_bitmask_clearall(&tmp); | |
| | | } | |
| | | | |
| | | static inline void nodemask_set(struct bitmask *mask, int node) | |
| | | { | |
| | | numa_bitmask_setbit(mask, node); | |
| | | } | |
| | | | |
| | | static inline void nodemask_set_compat(nodemask_t *mask, int node) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | numa_bitmask_setbit(&tmp, node); | |
| | | } | |
| | | | |
| | | static inline void nodemask_clr(struct bitmask *mask, int node) | |
| | | { | |
| | | numa_bitmask_clearbit(mask, node); | |
| | | } | |
| | | | |
| | | static inline void nodemask_clr_compat(nodemask_t *mask, int node) | |
| | | { | |
| | | mask->n[node / (8*sizeof(unsigned long))] &= | |
| | | ~(1UL<<(node%(8*sizeof(unsigned long)))); | |
| | | } | |
| | | | |
| | | static inline int nodemask_isset(struct bitmask *mask, int node) | |
| | | { | |
| | | return numa_bitmask_isbitset(mask, node); | |
| | | } | |
| | | | |
| | | static inline int nodemask_isset_compat(nodemask_t *mask, int node) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | return numa_bitmask_isbitset(&tmp, node); | |
| | | } | |
| | | | |
| | | static inline int nodemask_equal_compat(nodemask_t *a, nodemask_t *b) | |
| | | { | |
| | | struct bitmask tmpa, tmpb; | |
| | | | |
| | | tmpa.maskp = (unsigned long *)a; | |
| | | tmpa.size = sizeof(nodemask_t) * sizeof(unsigned long); | |
| | | tmpb.maskp = (unsigned long *)b; | |
| | | tmpb.size = sizeof(nodemask_t) * sizeof(unsigned long); | |
| | | return numa_bitmask_equal(&tmpa, &tmpb); | |
| | | } | |
| | | | |
| | | static inline void numa_set_interleave_mask_compat(nodemask_t *nodemask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)nodemask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | numa_set_interleave_mask(&tmp); | |
| | | } | |
| | | | |
| | | static inline nodemask_t numa_get_interleave_mask_compat() | |
| | | { | |
| | | struct bitmask *tp; | |
| | | nodemask_t mask; | |
| | | | |
| | | tp = numa_get_interleave_mask(); | |
| | | copy_bitmask_to_nodemask(tp, &mask); | |
| | | numa_bitmask_free(tp); | |
| | | return mask; | |
| | | } | |
| | | | |
| | | static inline void numa_bind_compat(nodemask_t *mask) | |
| | | { | |
| | | struct bitmask *tp; | |
| | | | |
| | | tp = numa_allocate_nodemask(); | |
| | | copy_nodemask_to_bitmask(mask, tp); | |
| | | numa_bind(tp); | |
| | | numa_bitmask_free(tp); | |
| | | } | |
| | | | |
| | | static inline void numa_set_membind_compat(nodemask_t *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | numa_set_membind(&tmp); | |
| | | } | |
| | | | |
| | | static inline nodemask_t numa_get_membind_compat() | |
| | | { | |
| | | struct bitmask *tp; | |
| | | nodemask_t mask; | |
| | | | |
| | | tp = numa_get_membind(); | |
| | | copy_bitmask_to_nodemask(tp, &mask); | |
| | | numa_bitmask_free(tp); | |
| | | return mask; | |
| | | } | |
| | | | |
| | | static inline void *numa_alloc_interleaved_subset_compat(size_t size, | |
| | | const nodemask_t *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | return numa_alloc_interleaved_subset(size, &tmp); | |
| | | } | |
| | | | |
| | | static inline int numa_run_on_node_mask_compat(const nodemask_t *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | return numa_run_on_node_mask(&tmp); | |
| | | } | |
| | | | |
| | | static inline nodemask_t numa_get_run_node_mask_compat() | |
| | | { | |
| | | struct bitmask *tp; | |
| | | nodemask_t mask; | |
| | | | |
| | | tp = numa_get_run_node_mask(); | |
| | | copy_bitmask_to_nodemask(tp, &mask); | |
| | | numa_bitmask_free(tp); | |
| | | return mask; | |
| | | } | |
| | | | |
| | | static inline void numa_interleave_memory_compat(void *mem, size_t size, | |
| | | const nodemask_t *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | numa_interleave_memory(mem, size, &tmp); | |
| | | } | |
| | | | |
| | | static inline void numa_tonodemask_memory_compat(void *mem, size_t size, | |
| | | const nodemask_t *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | numa_tonodemask_memory(mem, size, &tmp); | |
| | | } | |
| | | | |
| | | static inline int numa_sched_getaffinity_compat(pid_t pid, unsigned len, | |
| | | unsigned long *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = len * 8; | |
| | | return numa_sched_getaffinity(pid, &tmp); | |
| | | } | |
| | | | |
| | | static inline int numa_sched_setaffinity_compat(pid_t pid, unsigned len, | |
| | | unsigned long *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = len * 8; | |
| | | return numa_sched_setaffinity(pid, &tmp); | |
| | | } | |
| | | | |
| | | void printcpumask(char *name, struct bitmask *mask); | |
| | | static inline void printcpumask_compat(char *name, unsigned long *mask, | |
| | | int size) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = size * 8; | |
| | | printcpumask(name, &tmp); | |
| | | } | |
| | | | |
| | | void printmask(char *name, struct bitmask *mask); | |
| | | static inline void printmask_compat(char *name, nodemask_t *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | printmask(name, &tmp); | |
| | | } | |
| | | | |
| | | static inline int numa_node_to_cpus_compat(int node, unsigned long *buffer, | |
| | | int buffer_len) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)buffer; | |
| | | tmp.size = buffer_len * 8; | |
| | | return numa_node_to_cpus(node, &tmp); | |
| | | } | |
| | | | |
| | | void verify_shm(int policy, struct bitmask *nodes); | |
| | | static inline void verify_shm_compat(int policy, nodemask_t mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = (unsigned long *)&mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | verify_shm(policy, &tmp); | |
| | | } | |
| | | | |
| | | static inline nodemask_t nodemask_compat(char *c) | |
| | | { | |
| | | struct bitmask *tp; | |
| | | nodemask_t mask; | |
| | | | |
| | | tp = numa_parse_nodestring(c); | |
| | | copy_bitmask_to_nodemask(tp, &mask); | |
| | | numa_bitmask_free(tp); | |
| | | return mask; | |
| | | } | |
| | | | |
| | | void complain(char *fmt, ...); | |
| | | static inline unsigned long *cpumask_compat(char *c, int *ncpus) | |
| | | { | |
| | | struct bitmask *tp; | |
| | | unsigned long *cpubuf; | |
| | | | |
| | | tp = numa_parse_cpustring(c); | |
| | | *ncpus = tp->size; | |
| | | cpubuf = (long unsigned int*)calloc(tp->size,1); | |
| | | if (!cpubuf) | |
| | | complain("Out of memory"); | |
| | | memcpy(cpubuf, tp->maskp, tp->size/8); | |
| | | numa_bitmask_free(tp); | |
| | | return cpubuf; | |
| | | } | |
| | | | |
| | | #include <stdio.h> | |
| | | static inline int test_bit_compat(int bit, unsigned long *mask) | |
| | | { | |
| | | struct bitmask tmp; | |
| | | | |
| | | tmp.maskp = mask; | |
| | | tmp.size = sizeof(nodemask_t) * 8; | |
| | | return numa_bitmask_isbitset(&tmp, bit); | |
| | | } | |
| | | | |
| | | /* end of version 1 compatibility functions */ | |
| | | | |
| | | /* | |
| | | * To compile an application that uses libnuma version 1: | |
| | | * add -DVERSION1_COMPATIBILITY to your Makefile's CFLAGS | |
| | | */ | |
| | | #ifdef VERSION1_COMPATIBILITY | |
| | | #include <numacompat1.h> | |
| | | #endif | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 28 change blocks. |
| 45 lines changed or deleted | | 377 lines changed or added | |
|