numa.h   numa.h 
skipping to change at line 20 skipping to change at line 20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should find a copy of v2.1 of the GNU Lesser General Public License You should find a copy of v2.1 of the GNU Lesser General Public License
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 */ /* allow an application to test for the current programming interface: */
#define LIBNUMA_API_VERSION 2
/* Simple NUMA policy library */
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.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
skipping to change at line 46 skipping to change at line 49
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;
struct bitmask { struct bitmask {
unsigned long size; /* number of bits in the map */ unsigned long size; /* number of bits in the map */
unsigned long *maskp; unsigned long *maskp;
}; };
#define howmany(x,y) (((x)+((y)-1))/(y))
#define bitsperlong (8 * sizeof(unsigned long))
#define longsperbits(n) howmany(n, bitsperlong)
#define bytesperbits(x) ((x+7)/8)
/* operations on struct bitmask */ /* operations on struct bitmask */
int numa_bitmask_isbitset(const struct bitmask *, unsigned int); int numa_bitmask_isbitset(const struct bitmask *, unsigned int);
struct bitmask *numa_bitmask_setall(struct bitmask *); struct bitmask *numa_bitmask_setall(struct bitmask *);
struct bitmask *numa_bitmask_clearall(struct bitmask *); struct bitmask *numa_bitmask_clearall(struct bitmask *);
struct bitmask *numa_bitmask_setbit(struct bitmask *, unsigned int); struct bitmask *numa_bitmask_setbit(struct bitmask *, unsigned int);
struct bitmask *numa_bitmask_clearbit(struct bitmask *, unsigned int); struct bitmask *numa_bitmask_clearbit(struct bitmask *, unsigned int);
unsigned int numa_bitmask_nbytes(struct bitmask *); unsigned int numa_bitmask_nbytes(struct bitmask *);
struct bitmask *numa_bitmask_alloc(unsigned int); struct bitmask *numa_bitmask_alloc(unsigned int);
void numa_bitmask_free(struct bitmask *); void numa_bitmask_free(struct bitmask *);
int numa_bitmask_equal(const struct bitmask *, const struct bitmask *); int numa_bitmask_equal(const struct bitmask *, const struct bitmask *);
void copy_nodemask_to_bitmask(nodemask_t *, struct bitmask *); void copy_nodemask_to_bitmask(nodemask_t *, struct bitmask *);
void copy_bitmask_to_nodemask(struct bitmask *, nodemask_t *); void copy_bitmask_to_nodemask(struct bitmask *, nodemask_t *);
void copy_bitmask_to_bitmask(struct bitmask *, struct bitmask *);
/* compatibility for codes that used them: */ /* compatibility for codes that used them: */
static inline void nodemask_zero(struct bitmask *mask) static inline void nodemask_zero(struct bitmask *mask)
{ {
numa_bitmask_clearall(mask); numa_bitmask_clearall(mask);
} }
static inline int nodemask_equal(struct bitmask *a, struct bitmask *b) static inline int nodemask_equal(struct bitmask *a, struct bitmask *b)
{ {
return numa_bitmask_equal(a, b); return numa_bitmask_equal(a, b);
skipping to change at line 120 skipping to change at line 119
/* 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(struct bitmask *nodemask); void numa_set_interleave_mask(struct bitmask *nodemask);
/* Return the current interleaving mask */ /* Return the current interleaving mask */
struct bitmask *numa_get_interleave_mask(void); struct bitmask *numa_get_interleave_mask(void);
/* allocate a bitmask big enough for all nodes */ /* allocate a bitmask big enough for all nodes */
struct bitmask *numa_allocate_nodemask(void); struct bitmask *numa_allocate_nodemask(void);
static inline void numa_free_nodemask(struct bitmask *b)
{
numa_bitmask_free(b);
}
/* 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(struct bitmask *nodemask); void numa_set_membind(struct bitmask *nodemask);
/* Return current membind */ /* Return current membind */
skipping to change at line 205 skipping to change at line 209
/* maximum cpus allowed to current task */ /* maximum cpus allowed to current task */
int numa_num_task_cpus(); int numa_num_task_cpus();
/* maximum nodes allowed to current task */ /* maximum nodes allowed to current task */
int numa_num_task_nodes(); int numa_num_task_nodes();
/* allocate a bitmask the size of the kernel cpumask_t */ /* allocate a bitmask the size of the kernel cpumask_t */
struct bitmask *numa_allocate_cpumask(); struct bitmask *numa_allocate_cpumask();
/* set up to represent the cpus available to the current task */ static inline void numa_free_cpumask(struct bitmask *b)
struct bitmask *numa_all_cpus; {
numa_bitmask_free(b);
}
/* 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, struct bitmask *); 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, ...);
/* When true exit the program on a numa_warn() call */
extern int numa_exit_on_warn;
int numa_migrate_pages(int pid, struct bitmask *from, struct bitmask *to); int numa_migrate_pages(int pid, struct bitmask *from, struct bitmask *to);
int numa_move_pages(int pid, unsigned long count, void **pages, int numa_move_pages(int pid, unsigned long count, void **pages,
const int *nodes, int *status, int flags); const int *nodes, int *status, int flags);
int numa_sched_getaffinity(pid_t, struct bitmask *); int numa_sched_getaffinity(pid_t, struct bitmask *);
int numa_sched_setaffinity(pid_t, struct bitmask *); int numa_sched_setaffinity(pid_t, struct bitmask *);
/* Convert an ascii list of nodes to a bitmask */ /* Convert an ascii list of nodes to a bitmask */
struct bitmask *numa_parse_nodestring(char *); struct bitmask *numa_parse_nodestring(char *);
/* Convert an ascii list of cpu to a bitmask */ /* Convert an ascii list of cpu to a bitmask */
struct bitmask *numa_parse_cpustring(char *); struct bitmask *numa_parse_cpustring(char *);
/* /*
* The following functions are for source code compatibility * The following functions are for source code compatibility
* with releases prior to version 2. * with releases prior to version 2.
* Such codes should be compiled with VERSION1_COMPATIBILITY defined. * Such codes should be compiled with NUMA_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) static inline void numa_set_interleave_mask_compat(nodemask_t *nodemask)
{ {
struct bitmask tmp; struct bitmask tmp;
tmp.maskp = (unsigned long *)nodemask; tmp.maskp = (unsigned long *)nodemask;
tmp.size = sizeof(nodemask_t) * 8; tmp.size = sizeof(nodemask_t) * 8;
numa_set_interleave_mask(&tmp); numa_set_interleave_mask(&tmp);
} }
static inline nodemask_t numa_get_interleave_mask_compat() static inline nodemask_t numa_get_interleave_mask_compat()
skipping to change at line 426 skipping to change at line 376
static inline int numa_sched_setaffinity_compat(pid_t pid, unsigned len, static inline int numa_sched_setaffinity_compat(pid_t pid, unsigned len,
unsigned long *mask) unsigned long *mask)
{ {
struct bitmask tmp; struct bitmask tmp;
tmp.maskp = (unsigned long *)mask; tmp.maskp = (unsigned long *)mask;
tmp.size = len * 8; tmp.size = len * 8;
return numa_sched_setaffinity(pid, &tmp); 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, static inline int numa_node_to_cpus_compat(int node, unsigned long *buffer,
int buffer_len) int buffer_len)
{ {
struct bitmask tmp; struct bitmask tmp;
tmp.maskp = (unsigned long *)buffer; tmp.maskp = (unsigned long *)buffer;
tmp.size = buffer_len * 8; tmp.size = buffer_len * 8;
return numa_node_to_cpus(node, &tmp); 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 */ /* end of version 1 compatibility functions */
/* /*
* To compile an application that uses libnuma version 1: * To compile an application that uses libnuma version 1:
* add -DVERSION1_COMPATIBILITY to your Makefile's CFLAGS * add -DNUMA_VERSION1_COMPATIBILITY to your Makefile's CFLAGS
*/ */
#ifdef VERSION1_COMPATIBILITY #ifdef NUMA_VERSION1_COMPATIBILITY
#include <numacompat1.h> #include <numacompat1.h>
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 12 change blocks. 
138 lines changed or deleted 20 lines changed or added


 numacompat1.h   numacompat1.h 
#define nodemask_clr(m,n) nodemask_clr_compat(m,n)
#define nodemask_isset(m,n) nodemask_isset_compat(m,n)
#define nodemask_equal(m,n) nodemask_equal_compat(m,n)
#define numa_set_interleave_mask(m) numa_set_interleave_mask_compat(m) #define numa_set_interleave_mask(m) numa_set_interleave_mask_compat(m)
#define nodemask_set(m,n) nodemask_set_compat(m,n)
#define nodemask_zero(m) nodemask_zero_compat(m)
#define numa_get_interleave_mask() numa_get_interleave_mask_compat() #define numa_get_interleave_mask() numa_get_interleave_mask_compat()
#define numa_bind(m) numa_bind_compat(m) #define numa_bind(m) numa_bind_compat(m)
#define numa_get_membind(m) numa_get_membind_compat(m) #define numa_get_membind(m) numa_get_membind_compat(m)
#define numa_set_membind(m) numa_set_membind_compat(m) #define numa_set_membind(m) numa_set_membind_compat(m)
#define numa_alloc_interleaved_subset(s,m) numa_alloc_interleaved_subset_co mpat(s,m) #define numa_alloc_interleaved_subset(s,m) numa_alloc_interleaved_subset_co mpat(s,m)
#define numa_run_on_node_mask(m) numa_run_on_node_mask_compat(m) #define numa_run_on_node_mask(m) numa_run_on_node_mask_compat(m)
#define numa_get_run_node_mask() numa_get_run_node_mask_compat() #define numa_get_run_node_mask() numa_get_run_node_mask_compat()
#define numa_interleave_memory(st,si,m) numa_interleave_memory_compat(st,si ,m) #define numa_interleave_memory(st,si,m) numa_interleave_memory_compat(st,si ,m)
#define numa_tonodemask_memory(st,si,m) numa_tonodemask_memory_compat(st,si ,m) #define numa_tonodemask_memory(st,si,m) numa_tonodemask_memory_compat(st,si ,m)
#define numa_sched_getaffinity(p,l,m) numa_sched_getaffinity_compat(p,l,m ) #define numa_sched_getaffinity(p,l,m) numa_sched_getaffinity_compat(p,l,m )
#define numa_sched_setaffinity(p,l,m) numa_sched_setaffinity_compat(p,l,m ) #define numa_sched_setaffinity(p,l,m) numa_sched_setaffinity_compat(p,l,m )
#define printcpumask(n,m,s) printcpumask_compat(n,m,s)
#define printmask(n,m) printmask_compat(n,m)
#define numa_node_to_cpus(n,b,bl) numa_node_to_cpus_compat(n,b,bl) #define numa_node_to_cpus(n,b,bl) numa_node_to_cpus_compat(n,b,bl)
#define verify_shm(p,m) verify_shm_compat(p,m)
#define nodemask(c) nodemask_compat(c)
#define cpumask(c,n) cpumask_compat(c,n)
#undef test_bit
#define test_bit(i,p) test_bit_compat(i,p)
 End of changes. 4 change blocks. 
7 lines changed or deleted 0 lines changed or added


 numaif.h   numaif.h 
skipping to change at line 17 skipping to change at line 17
/* Kernel interface for NUMA API */ /* Kernel interface for NUMA API */
/* System calls */ /* System calls */
extern long get_mempolicy(int *policy, const unsigned long *nmask, extern long get_mempolicy(int *policy, const unsigned long *nmask,
unsigned long maxnode, void *addr, int flags); unsigned long maxnode, void *addr, int flags);
extern long mbind(void *start, unsigned long len, int mode, extern long mbind(void *start, unsigned long len, int mode,
const unsigned long *nmask, unsigned long maxnode, unsigned flags); const unsigned long *nmask, unsigned long maxnode, unsigned flags);
extern long set_mempolicy(int mode, const unsigned long *nmask, extern long set_mempolicy(int mode, const unsigned long *nmask,
unsigned long maxnode); unsigned long maxnode);
extern long migratepages(int pid, unsigned long maxnode, unsigned long *fro extern long migrate_pages(int pid, unsigned long maxnode,
mnode, const unsigned long *frommask,
unsigned long *tonode); const unsigned long *tomask);
extern long move_pages(int pid, unsigned long count, extern long move_pages(int pid, unsigned long count,
void **pages, const int *nodes, int *status, int flags); void **pages, const int *nodes, int *status, int flags);
/* Policies */ /* Policies */
#define MPOL_DEFAULT 0 #define MPOL_DEFAULT 0
#define MPOL_PREFERRED 1 #define MPOL_PREFERRED 1
#define MPOL_BIND 2 #define MPOL_BIND 2
#define MPOL_INTERLEAVE 3 #define MPOL_INTERLEAVE 3
 End of changes. 1 change blocks. 
3 lines changed or deleted 3 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/