Back to index

numactl  2.0.8~rc4
Classes | Defines | Functions | Variables
numa.h File Reference
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <stdlib.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nodemask_t
struct  bitmask

Defines

#define LIBNUMA_API_VERSION   2
#define NUMA_NUM_NODES   2048

Functions

int numa_bitmask_isbitset (const struct bitmask *, unsigned int)
struct bitmasknuma_bitmask_setall (struct bitmask *)
struct bitmasknuma_bitmask_clearall (struct bitmask *)
struct bitmasknuma_bitmask_setbit (struct bitmask *, unsigned int)
struct bitmasknuma_bitmask_clearbit (struct bitmask *, unsigned int)
unsigned int numa_bitmask_nbytes (struct bitmask *)
struct bitmasknuma_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 *)
void copy_bitmask_to_bitmask (struct bitmask *, struct bitmask *)
static void nodemask_zero (nodemask_t *mask)
static void nodemask_zero_compat (nodemask_t *mask)
static void nodemask_set_compat (nodemask_t *mask, int node)
static void nodemask_clr_compat (nodemask_t *mask, int node)
static int nodemask_isset_compat (const nodemask_t *mask, int node)
static int nodemask_equal (const nodemask_t *a, const nodemask_t *b)
static int nodemask_equal_compat (const nodemask_t *a, const nodemask_t *b)
int numa_available (void)
int numa_max_node (void)
int numa_max_possible_node (void)
int numa_preferred (void)
long long numa_node_size64 (int node, long long *freep)
long numa_node_size (int node, long *freep)
int numa_pagesize (void)
void numa_bind (struct bitmask *nodes)
void numa_set_interleave_mask (struct bitmask *nodemask)
struct bitmasknuma_get_interleave_mask (void)
struct bitmasknuma_allocate_nodemask (void)
static void numa_free_nodemask (struct bitmask *b)
void numa_set_preferred (int node)
void numa_set_localalloc (void)
void numa_set_membind (struct bitmask *nodemask)
struct bitmasknuma_get_membind (void)
struct bitmasknuma_get_mems_allowed (void)
int numa_get_interleave_node (void)
void * numa_alloc_interleaved_subset (size_t size, struct bitmask *nodemask)
void * numa_alloc_interleaved (size_t size)
void * numa_alloc_onnode (size_t size, int node)
void * numa_alloc_local (size_t size)
void * numa_alloc (size_t size)
void * numa_realloc (void *old_addr, size_t old_size, size_t new_size)
void numa_free (void *mem, size_t size)
void numa_interleave_memory (void *mem, size_t size, struct bitmask *mask)
void numa_tonode_memory (void *start, size_t size, int node)
void numa_tonodemask_memory (void *mem, size_t size, struct bitmask *mask)
void numa_setlocal_memory (void *start, size_t size)
void numa_police_memory (void *start, size_t size)
int numa_run_on_node_mask (struct bitmask *mask)
int numa_run_on_node (int node)
struct bitmasknuma_get_run_node_mask (void)
void numa_set_bind_policy (int strict)
void numa_set_strict (int flag)
int numa_num_possible_nodes ()
int numa_num_possible_cpus ()
int numa_num_configured_nodes ()
int numa_num_configured_cpus ()
int numa_num_task_cpus ()
int numa_num_thread_cpus ()
int numa_num_task_nodes ()
int numa_num_thread_nodes ()
struct bitmasknuma_allocate_cpumask ()
static void numa_free_cpumask (struct bitmask *b)
int numa_node_to_cpus (int, struct bitmask *)
int numa_node_of_cpu (int cpu)
int numa_distance (int node1, int node2)
void numa_error (char *where)
void numa_warn (int num, char *fmt,...)
int numa_migrate_pages (int pid, struct bitmask *from, struct bitmask *to)
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 *)
struct bitmasknuma_parse_nodestring (char *)
struct bitmasknuma_parse_cpustring (char *)
static void numa_set_interleave_mask_compat (nodemask_t *nodemask)
static nodemask_t numa_get_interleave_mask_compat ()
static void numa_bind_compat (nodemask_t *mask)
static void numa_set_membind_compat (nodemask_t *mask)
static nodemask_t numa_get_membind_compat ()
static void * numa_alloc_interleaved_subset_compat (size_t size, const nodemask_t *mask)
static int numa_run_on_node_mask_compat (const nodemask_t *mask)
static nodemask_t numa_get_run_node_mask_compat ()
static void numa_interleave_memory_compat (void *mem, size_t size, const nodemask_t *mask)
static void numa_tonodemask_memory_compat (void *mem, size_t size, const nodemask_t *mask)
static int numa_sched_getaffinity_compat (pid_t pid, unsigned len, unsigned long *mask)
static int numa_sched_setaffinity_compat (pid_t pid, unsigned len, unsigned long *mask)
static int numa_node_to_cpus_compat (int node, unsigned long *buffer, int buffer_len)

Variables

struct bitmasknuma_all_nodes_ptr
struct bitmasknuma_nodes_ptr
nodemask_t numa_all_nodes
struct bitmasknuma_all_cpus_ptr
struct bitmasknuma_no_nodes_ptr
nodemask_t numa_no_nodes
int numa_exit_on_error
int numa_exit_on_warn

Class Documentation

struct nodemask_t

Definition at line 40 of file numa.h.

Class Members
unsigned long n
struct bitmask

Definition at line 44 of file numa.h.

Class Members
unsigned long * maskp
unsigned long size

Define Documentation

#define LIBNUMA_API_VERSION   2

Definition at line 21 of file numa.h.

#define NUMA_NUM_NODES   2048

Definition at line 33 of file numa.h.


Function Documentation

void copy_bitmask_to_bitmask ( struct bitmask ,
struct bitmask  
)

Definition at line 1084 of file libnuma.c.

{
       int bytes;

       if (bmpfrom->size >= bmpto->size) {
              memcpy(bmpto->maskp, bmpfrom->maskp, CPU_BYTES(bmpto->size));
       } else if (bmpfrom->size < bmpto->size) {
              bytes = CPU_BYTES(bmpfrom->size);
              memcpy(bmpto->maskp, bmpfrom->maskp, bytes);
              memset(((char *)bmpto->maskp)+bytes, 0,
                                   CPU_BYTES(bmpto->size)-bytes);
       }
}

Here is the caller graph for this function:

void copy_bitmask_to_nodemask ( struct bitmask ,
nodemask_t  
)

Definition at line 1065 of file libnuma.c.

{
       int max, i;

       memset(nmp, 0, sizeof(nodemask_t));
        max = (sizeof(nodemask_t)*8);
       for (i=0; i<bmp->size; i++) {
              if (i >= max)
                     break;
              if (numa_bitmask_isbitset(bmp, i))
                     nodemask_set_compat((nodemask_t *)nmp, i);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void copy_nodemask_to_bitmask ( nodemask_t ,
struct bitmask  
)

Definition at line 1102 of file libnuma.c.

{
       int max, i;

       numa_bitmask_clearall(bmp);
        max = (sizeof(nodemask_t)*8);
       if (max > bmp->size)
              max = bmp->size;
       for (i=0; i<max; i++) {
              if (nodemask_isset_compat(nmp, i))
                     numa_bitmask_setbit(bmp, i);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nodemask_clr_compat ( nodemask_t mask,
int  node 
) [inline, static]

Definition at line 89 of file numa.h.

{
       mask->n[node / (8*sizeof(unsigned long))] &=
              ~(1UL<<(node%(8*sizeof(unsigned long))));
}
static int nodemask_equal ( const nodemask_t a,
const nodemask_t b 
) [inline, static]

Definition at line 105 of file numa.h.

{
       struct bitmask tmp_a, tmp_b;

       tmp_a.maskp = (unsigned long *)a;
       tmp_a.size = sizeof(nodemask_t) * 8;

       tmp_b.maskp = (unsigned long *)b;
       tmp_b.size = sizeof(nodemask_t) * 8;

       return numa_bitmask_equal(&tmp_a, &tmp_b);
}

Here is the call graph for this function:

static int nodemask_equal_compat ( const nodemask_t a,
const nodemask_t b 
) [inline, static]

Definition at line 118 of file numa.h.

{
       struct bitmask tmp_a, tmp_b;

       tmp_a.maskp = (unsigned long *)a;
       tmp_a.size = sizeof(nodemask_t) * 8;

       tmp_b.maskp = (unsigned long *)b;
       tmp_b.size = sizeof(nodemask_t) * 8;

       return numa_bitmask_equal(&tmp_a, &tmp_b);
}

Here is the call graph for this function:

static int nodemask_isset_compat ( const nodemask_t mask,
int  node 
) [inline, static]

Definition at line 95 of file numa.h.

{
       if ((unsigned)node >= NUMA_NUM_NODES)
              return 0;
       if (mask->n[node / (8*sizeof(unsigned long))] &
              (1UL<<(node%(8*sizeof(unsigned long)))))
              return 1;
       return 0;
}

Here is the caller graph for this function:

static void nodemask_set_compat ( nodemask_t mask,
int  node 
) [inline, static]

Definition at line 83 of file numa.h.

{
       mask->n[node / (8*sizeof(unsigned long))] |=
              (1UL<<(node%(8*sizeof(unsigned long))));
}

Here is the caller graph for this function:

static void nodemask_zero ( nodemask_t mask) [inline, static]

Definition at line 65 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = sizeof(nodemask_t) * 8;
       numa_bitmask_clearall(&tmp);
}

Here is the call graph for this function:

static void nodemask_zero_compat ( nodemask_t mask) [inline, static]

Definition at line 74 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = sizeof(nodemask_t) * 8;
       numa_bitmask_clearall(&tmp);
}

Here is the call graph for this function:

void* numa_alloc ( size_t  size)

Definition at line 867 of file libnuma.c.

{
       char *mem;
       mem = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
                 0, 0); 
       if (mem == (char *)-1)
              return NULL;
       numa_police_memory_int(mem, size);
       return mem;
} 

Here is the caller graph for this function:

void* numa_alloc_interleaved ( size_t  size)

Definition at line 928 of file libnuma.c.

{ 
       return numa_alloc_interleaved_subset_v2_int(size, numa_all_nodes_ptr);
} 

Here is the caller graph for this function:

void* numa_alloc_interleaved_subset ( size_t  size,
struct bitmask nodemask 
)

Here is the caller graph for this function:

static void* numa_alloc_interleaved_subset_compat ( size_t  size,
const nodemask_t mask 
) [inline, static]

Definition at line 374 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = sizeof(nodemask_t) * 8;
       return numa_alloc_interleaved_subset(size, &tmp);
}

Here is the call graph for this function:

void* numa_alloc_local ( size_t  size)

Definition at line 1021 of file libnuma.c.

{ 
       char *mem; 
       mem = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
                 0, 0); 
       if (mem == (char *)-1)
              mem =  NULL;
       else
              dombind(mem, size, MPOL_PREFERRED, NULL);
       return mem;   
} 

Here is the call graph for this function:

Here is the caller graph for this function:

void* numa_alloc_onnode ( size_t  size,
int  node 
)

Definition at line 1004 of file libnuma.c.

{ 
       char *mem; 
       struct bitmask *bmp;

       bmp = numa_allocate_nodemask();
       numa_bitmask_setbit(bmp, node);
       mem = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
                 0, 0);  
       if (mem == (char *)-1)
              mem = NULL;
       else 
              dombind(mem, size, bind_policy, bmp);
       numa_bitmask_free(bmp);
       return mem;   
} 

Here is the call graph for this function:

Here is the caller graph for this function:

struct bitmask* numa_allocate_cpumask ( ) [read]

Definition at line 707 of file libnuma.c.

{
       int ncpus = numa_num_possible_cpus();

       return numa_bitmask_alloc(ncpus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct bitmask* numa_allocate_nodemask ( void  ) [read]

Definition at line 730 of file libnuma.c.

{
       struct bitmask *bmp;
       int nnodes = numa_max_possible_node_v2_int() + 1;

       bmp = numa_bitmask_alloc(nnodes);
       return bmp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int numa_available ( void  )

Definition at line 799 of file libnuma.c.

{
       if (get_mempolicy(NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS)
              return -1; 
       return 0;
} 

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_bind ( struct bitmask nodes)

Here is the caller graph for this function:

static void numa_bind_compat ( nodemask_t mask) [inline, static]

Definition at line 344 of file numa.h.

Here is the call graph for this function:

struct bitmask* numa_bitmask_alloc ( unsigned  int) [read]

Definition at line 192 of file libnuma.c.

{
       struct bitmask *bmp;

       if (n < 1) {
              numa_error("request to allocate mask for invalid number; abort\n");
              exit(1);
       }
       bmp = malloc(sizeof(*bmp));
       if (bmp == 0)
              goto oom;
       bmp->size = n;
       bmp->maskp = calloc(longsperbits(n), sizeof(unsigned long));
       if (bmp->maskp == 0) {
              free(bmp);
              goto oom;
       }
       return bmp;

oom:
       numa_error("Out of memory allocating bitmask");
       exit(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct bitmask* numa_bitmask_clearall ( struct bitmask ) [read]

Definition at line 160 of file libnuma.c.

{
       unsigned int i;
       for (i = 0; i < bmp->size; i++)
              _setbit(bmp, i, 0);
       return bmp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct bitmask* numa_bitmask_clearbit ( struct bitmask ,
unsigned  int 
) [read]

Definition at line 176 of file libnuma.c.

{
       _setbit(bmp, i, 0);
       return bmp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int numa_bitmask_equal ( const struct bitmask ,
const struct bitmask  
)

Definition at line 229 of file libnuma.c.

{
       unsigned int i;
       for (i = 0; i < bmp1->size || i < bmp2->size; i++)
              if (_getbit(bmp1, i) != _getbit(bmp2, i))
                     return 0;
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_bitmask_free ( struct bitmask )

Definition at line 217 of file libnuma.c.

{
       if (bmp == 0)
              return;
       free(bmp->maskp);
       bmp->maskp = (unsigned long *)0xdeadcdef;  /* double free tripwire */
       free(bmp);
       return;
}

Here is the caller graph for this function:

int numa_bitmask_isbitset ( const struct bitmask ,
unsigned  int 
)

Definition at line 145 of file libnuma.c.

{
       return _getbit(bmp, i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int numa_bitmask_nbytes ( struct bitmask )

Definition at line 183 of file libnuma.c.

{
       return longsperbits(bmp->size) * sizeof(unsigned long);
}

Here is the caller graph for this function:

struct bitmask* numa_bitmask_setall ( struct bitmask ) [read]

Definition at line 151 of file libnuma.c.

{
       unsigned int i;
       for (i = 0; i < bmp->size; i++)
              _setbit(bmp, i, 1);
       return bmp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct bitmask* numa_bitmask_setbit ( struct bitmask ,
unsigned  int 
) [read]

Definition at line 169 of file libnuma.c.

{
       _setbit(bmp, i, 1);
       return bmp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int numa_distance ( int  node1,
int  node2 
)

Definition at line 110 of file distance.c.

{
       if (!distance_table) {
              int err = read_distance_table();
              if (err < 0)
                     return 0;
       }
       return distance_table[a * distance_numnodes + b];
}

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_error ( char *  where)

Definition at line 252 of file libnuma.c.

{ 
       int olde = errno;
       perror(where); 
       if (numa_exit_on_error)
              exit(1); 
       errno = olde;
} 

Here is the caller graph for this function:

void numa_free ( void *  mem,
size_t  size 
)

Definition at line 1168 of file libnuma.c.

{ 
       munmap(mem, size); 
} 

Here is the caller graph for this function:

static void numa_free_cpumask ( struct bitmask b) [inline, static]

Definition at line 274 of file numa.h.

Here is the call graph for this function:

static void numa_free_nodemask ( struct bitmask b) [inline, static]

Definition at line 180 of file numa.h.

Here is the call graph for this function:

struct bitmask* numa_get_interleave_mask ( void  ) [read]

Here is the caller graph for this function:

static nodemask_t numa_get_interleave_mask_compat ( ) [inline, static]

Definition at line 333 of file numa.h.

{
       struct bitmask *tp;
       nodemask_t mask;

       tp = numa_get_interleave_mask();
       copy_bitmask_to_nodemask(tp, &mask);
       numa_bitmask_free(tp);
       return mask;
}

Here is the call graph for this function:

int numa_get_interleave_node ( void  )

Definition at line 996 of file libnuma.c.

{ 
       int nd;
       if (get_mempolicy(&nd, NULL, 0, 0, MPOL_F_NODE) == 0)
              return nd;
       return 0;     
} 

Here is the call graph for this function:

Here is the caller graph for this function:

struct bitmask* numa_get_membind ( void  ) [read]

Here is the caller graph for this function:

static nodemask_t numa_get_membind_compat ( ) [inline, static]

Definition at line 363 of file numa.h.

{
       struct bitmask *tp;
       nodemask_t mask;

       tp = numa_get_membind();
       copy_bitmask_to_nodemask(tp, &mask);
       numa_bitmask_free(tp);
       return mask;
}

Here is the call graph for this function:

struct bitmask* numa_get_mems_allowed ( void  ) [read]

Definition at line 1152 of file libnuma.c.

{
       struct bitmask *bmp;

       /*
        * can change, so query on each call.
        */
       bmp = numa_allocate_nodemask();
       if (get_mempolicy(NULL, bmp->maskp, bmp->size + 1, 0,
                            MPOL_F_MEMS_ALLOWED) < 0)
              numa_error("get_mempolicy");
       return bmp;
}

Here is the call graph for this function:

struct bitmask* numa_get_run_node_mask ( void  ) [read]

Here is the caller graph for this function:

static nodemask_t numa_get_run_node_mask_compat ( ) [inline, static]

Definition at line 393 of file numa.h.

{
       struct bitmask *tp;
       nodemask_t mask;

       tp = numa_get_run_node_mask();
       copy_bitmask_to_nodemask(tp, &mask);
       numa_bitmask_free(tp);
       return mask;
}

Here is the call graph for this function:

void numa_interleave_memory ( void *  mem,
size_t  size,
struct bitmask mask 
)

Here is the caller graph for this function:

static void numa_interleave_memory_compat ( void *  mem,
size_t  size,
const nodemask_t mask 
) [inline, static]

Definition at line 404 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = sizeof(nodemask_t) * 8;
       numa_interleave_memory(mem, size, &tmp);
}

Here is the call graph for this function:

int numa_max_node ( void  )

Definition at line 673 of file libnuma.c.

{
       return maxconfigurednode;
}

Here is the caller graph for this function:

int numa_max_possible_node ( void  )
int numa_migrate_pages ( int  pid,
struct bitmask from,
struct bitmask to 
)

Definition at line 1616 of file libnuma.c.

{
       int numa_num_nodes = numa_num_possible_nodes();

       return migrate_pages(pid, numa_num_nodes + 1, fromnodes->maskp,
                                                 tonodes->maskp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int numa_move_pages ( int  pid,
unsigned long  count,
void **  pages,
const int *  nodes,
int *  status,
int  flags 
)

Definition at line 1624 of file libnuma.c.

{
       return move_pages(pid, count, pages, nodes, status, flags);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int numa_node_of_cpu ( int  cpu)

Definition at line 1404 of file libnuma.c.

{
       struct bitmask *bmp;
       int ncpus, nnodes, node, ret;

       ncpus = numa_num_possible_cpus();
       if (cpu > ncpus){
              errno = EINVAL;
              return -1;
       }
       bmp = numa_bitmask_alloc(ncpus);
       nnodes = numa_max_node();
       for (node = 0; node <= nnodes; node++){
              numa_node_to_cpus_v2_int(node, bmp);
              if (numa_bitmask_isbitset(bmp, cpu)){
                     ret = node;
                     goto end;
              }
       }
       ret = -1;
       errno = EINVAL;
end:
       numa_bitmask_free(bmp);
       return ret;
}

Here is the call graph for this function:

long numa_node_size ( int  node,
long *  freep 
)

Definition at line 790 of file libnuma.c.

{      
       long long f2; 
       long sz = numa_node_size64_int(node, &f2);
       if (freep) 
              *freep = f2; 
       return sz;    
}
long long numa_node_size64 ( int  node,
long long *  freep 
)

Definition at line 740 of file libnuma.c.

{ 
       size_t len = 0;
       char *line = NULL;
       long long size = -1;
       FILE *f; 
       char fn[64];
       int ok = 0;
       int required = freep ? 2 : 1; 

       if (freep) 
              *freep = -1; 
       sprintf(fn,"/sys/devices/system/node/node%d/meminfo", node); 
       f = fopen(fn, "r");
       if (!f)
              return -1; 
       while (getdelim(&line, &len, '\n', f) > 0) { 
              char *end;
              char *s = strcasestr(line, "kB"); 
              if (!s) 
                     continue; 
              --s; 
              while (s > line && isspace(*s))
                     --s;
              while (s > line && isdigit(*s))
                     --s; 
              if (strstr(line, "MemTotal")) { 
                     size = strtoull(s,&end,0) << 10; 
                     if (end == s) 
                            size = -1;
                     else
                            ok++; 
              }
              if (freep && strstr(line, "MemFree")) { 
                     *freep = strtoull(s,&end,0) << 10; 
                     if (end == s) 
                            *freep = -1;
                     else
                            ok++; 
              }
       } 
       fclose(f); 
       free(line);
       if (ok != required)
              numa_warn(W_badmeminfo, "Cannot parse sysfs meminfo (%d)", ok);
       return size;
}

Here is the caller graph for this function:

int numa_node_to_cpus ( int  ,
struct bitmask  
)

Here is the caller graph for this function:

static int numa_node_to_cpus_compat ( int  node,
unsigned long *  buffer,
int  buffer_len 
) [inline, static]

Definition at line 444 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)buffer;
       tmp.size = buffer_len * 8;
       return numa_node_to_cpus(node, &tmp);
}

Here is the call graph for this function:

Definition at line 621 of file libnuma.c.

{

       return maxconfiguredcpu+1;
}

Here is the caller graph for this function:

Definition at line 601 of file libnuma.c.

{
       /*
       * NOTE: this function's behavior matches the documentation (ie: it
       * returns a count of nodes with memory) despite the poor function
       * naming.  We also cannot use the similarly poorly named
       * numa_all_nodes_ptr as it only tracks nodes with memory from which
       * the calling process can allocate.  Think sparse nodes, memory-less
       * nodes, cpusets...
       */
       int memnodecount=0, i;

       for (i=0; i <= maxconfigurednode; i++) {
              if (numa_bitmask_isbitset(numa_memnode_ptr, i))
                     memnodecount++;
       }
       return memnodecount;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 634 of file libnuma.c.

{
       return cpumask_sz;
}

Here is the caller graph for this function:

Definition at line 628 of file libnuma.c.

{
       return nodemask_sz;
}

Here is the caller graph for this function:

Definition at line 655 of file libnuma.c.

{
       return numproccpu;
}

Here is the caller graph for this function:

Definition at line 640 of file libnuma.c.

{
       return numprocnode;
}

Here is the caller graph for this function:

Definition at line 664 of file libnuma.c.

{
       return numa_num_task_cpus();
}

Here is the call graph for this function:

Definition at line 649 of file libnuma.c.

{
       return numa_num_task_nodes();
}

Here is the call graph for this function:

int numa_pagesize ( void  )

Definition at line 302 of file libnuma.c.

{ 
       static int pagesize;
       if (pagesize > 0) 
              return pagesize;
       pagesize = getpagesize();
       return pagesize;
} 

Here is the caller graph for this function:

struct bitmask* numa_parse_cpustring ( char *  ) [read]

Definition at line 1864 of file libnuma.c.

{
       int invert = 0, relative=0;
       int conf_cpus = numa_num_configured_cpus();
       char *end;
       struct bitmask *mask;

       mask = numa_allocate_cpumask();

       if (s[0] == 0)
              return mask;
       if (*s == '!') {
              invert = 1;
              s++;
       }
       if (*s == '+') {
              relative++;
              s++;
       }
       do {
              unsigned long arg;
              int i;

              if (!strcmp(s,"all")) {
                     copy_bitmask_to_bitmask(numa_all_cpus_ptr, mask);
                     s+=4;
                     break;
              }
              arg = get_nr(s, &end, numa_all_cpus_ptr, relative);
              if (end == s) {
                     numa_warn(W_cpuparse, "unparseable cpu description `%s'\n", s);
                     goto err;
              }
              if (!numa_bitmask_isbitset(numa_all_cpus_ptr, arg)) {
                     numa_warn(W_cpuparse, "cpu argument %s is out of range\n", s);
                     goto err;
              }
              i = arg;
              numa_bitmask_setbit(mask, i);
              s = end;
              if (*s == '-') {
                     char *end2;
                     unsigned long arg2;
                     int i;
                     arg2 = get_nr(++s, &end2, numa_all_cpus_ptr, relative);
                     if (end2 == s) {
                            numa_warn(W_cpuparse, "missing cpu argument %s\n", s);
                            goto err;
                     }
                     if (!numa_bitmask_isbitset(numa_all_cpus_ptr, arg2)) {
                            numa_warn(W_cpuparse, "cpu argument %s out of range\n", s);
                            goto err;
                     }
                     while (arg <= arg2) {
                            i = arg;
                            if (numa_bitmask_isbitset(numa_all_cpus_ptr, i))
                                   numa_bitmask_setbit(mask, i);
                            arg++;
                     }
                     s = end2;
              }
       } while (*s++ == ',');
       if (s[-1] != '\0')
              goto err;
       if (invert) {
              int i;
              for (i = 0; i < conf_cpus; i++) {
                     if (numa_bitmask_isbitset(mask, i))
                            numa_bitmask_clearbit(mask, i);
                     else
                            numa_bitmask_setbit(mask, i);
              }
       }
       return mask;

err:
       numa_bitmask_free(mask);
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct bitmask* numa_parse_nodestring ( char *  ) [read]

Definition at line 1760 of file libnuma.c.

{
       int invert = 0, relative = 0;
       int conf_nodes = numa_num_configured_nodes();
       char *end;
       struct bitmask *mask;

       mask = numa_allocate_nodemask();

       if (s[0] == 0){
              copy_bitmask_to_bitmask(numa_no_nodes_ptr, mask);
              return mask; /* return freeable mask */
       }
       if (*s == '!') {
              invert = 1;
              s++;
       }
       if (*s == '+') {
              relative++;
              s++;
       }
       do {
              unsigned long arg;
              int i;
              if (isalpha(*s)) {
                     int n;
                     if (!strcmp(s,"all")) {
                            copy_bitmask_to_bitmask(numa_all_nodes_ptr,
                                                 mask);
                            s+=4;
                            break;
                     }
                     n = resolve_affinity(s, mask);
                     if (n != NO_IO_AFFINITY) {
                            if (n < 0)
                                   goto err;
                            s += strlen(s) + 1;
                            break;
                     }
              }
              arg = get_nr(s, &end, numa_all_nodes_ptr, relative);
              if (end == s) {
                     numa_warn(W_nodeparse, "unparseable node description `%s'\n", s);
                     goto err;
              }
              if (!numa_bitmask_isbitset(numa_all_nodes_ptr, arg)) {
                     numa_warn(W_nodeparse, "node argument %d is out of range\n", arg);
                     goto err;
              }
              i = arg;
              numa_bitmask_setbit(mask, i);
              s = end;
              if (*s == '-') {
                     char *end2;
                     unsigned long arg2;
                     arg2 = get_nr(++s, &end2, numa_all_nodes_ptr, relative);
                     if (end2 == s) {
                            numa_warn(W_nodeparse, "missing node argument %s\n", s);
                            goto err;
                     }
                     if (!numa_bitmask_isbitset(numa_all_nodes_ptr, arg2)) {
                            numa_warn(W_nodeparse, "node argument %d out of range\n", arg2);
                            goto err;
                     }
                     while (arg <= arg2) {
                            i = arg;
                            if (numa_bitmask_isbitset(numa_all_nodes_ptr,i))
                                   numa_bitmask_setbit(mask, i);
                            arg++;
                     }
                     s = end2;
              }
       } while (*s++ == ',');
       if (s[-1] != '\0')
              goto err;
       if (invert) {
              int i;
              for (i = 0; i < conf_nodes; i++) {
                     if (numa_bitmask_isbitset(mask, i))
                            numa_bitmask_clearbit(mask, i);
                     else
                            numa_bitmask_setbit(mask, i);
              }
       }
       return mask;

err:
       numa_bitmask_free(mask);
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_police_memory ( void *  start,
size_t  size 
)

Definition at line 857 of file libnuma.c.

{
       int pagesize = numa_pagesize_int();
       unsigned long i; 
       for (i = 0; i < size; i += pagesize)
              asm volatile("" :: "r" (((volatile unsigned char *)mem)[i]));
}

Here is the caller graph for this function:

int numa_preferred ( void  )

Definition at line 1657 of file libnuma.c.

{ 
       int policy;
       int ret;
       struct bitmask *bmp;

       bmp = numa_allocate_nodemask();
       getpol(&policy, bmp);
       if (policy == MPOL_PREFERRED || policy == MPOL_BIND) { 
              int i;
              int max = numa_num_possible_nodes();
              for (i = 0; i < max ; i++) 
                     if (numa_bitmask_isbitset(bmp, i)){
                            ret = i;
                            goto end;
                     }
       }
       /* could read the current CPU from /proc/self/status. Probably 
          not worth it. */
       ret = 0; /* or random one? */
end:
       numa_bitmask_free(bmp);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* numa_realloc ( void *  old_addr,
size_t  old_size,
size_t  new_size 
)

Definition at line 878 of file libnuma.c.

{
       char *mem;
       mem = mremap(old_addr, old_size, new_size, MREMAP_MAYMOVE);
       if (mem == (char *)-1)
              return NULL;
       /*
        *     The memory policy of the allocated pages is preserved by mremap(), so
        *     there is no need to (re)set it here. If the policy of the original
        *     allocation is not set, the new pages will be allocated according to the
        *     process' mempolicy. Trying to allocate explicitly the new pages on the
        *     same node as the original ones would require changing the policy of the
        *     newly allocated pages, which violates the numa_realloc() semantics.
        */ 
       return mem;
}

Here is the caller graph for this function:

int numa_run_on_node ( int  node)

Definition at line 1630 of file libnuma.c.

{ 
       int numa_num_nodes = numa_num_possible_nodes();
       int ret = -1;
       struct bitmask *cpus;

       if (node >= numa_num_nodes){
              errno = EINVAL;
              goto out;
       }

       cpus = numa_allocate_cpumask();

       if (node == -1)
              numa_bitmask_setall(cpus);
       else if (numa_node_to_cpus_v2_int(node, cpus) < 0){
              numa_warn(W_noderunmask, "Cannot read node cpumask from sysfs");
              goto free;
       }

       ret = numa_sched_setaffinity_v2_int(0, cpus);
free:
       numa_bitmask_free(cpus);
out:
       return ret;
} 

Here is the call graph for this function:

Here is the caller graph for this function:

int numa_run_on_node_mask ( struct bitmask mask)

Here is the caller graph for this function:

static int numa_run_on_node_mask_compat ( const nodemask_t mask) [inline, static]

Definition at line 384 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = sizeof(nodemask_t) * 8;
       return numa_run_on_node_mask(&tmp);
}

Here is the call graph for this function:

int numa_sched_getaffinity ( pid_t  ,
struct bitmask  
)

Here is the caller graph for this function:

static int numa_sched_getaffinity_compat ( pid_t  pid,
unsigned  len,
unsigned long *  mask 
) [inline, static]

Definition at line 424 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = len * 8;
       return numa_sched_getaffinity(pid, &tmp);
}

Here is the call graph for this function:

int numa_sched_setaffinity ( pid_t  ,
struct bitmask  
)

Here is the caller graph for this function:

static int numa_sched_setaffinity_compat ( pid_t  pid,
unsigned  len,
unsigned long *  mask 
) [inline, static]

Definition at line 434 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = len * 8;
       return numa_sched_setaffinity(pid, &tmp);
}

Here is the call graph for this function:

void numa_set_bind_policy ( int  strict)

Definition at line 1033 of file libnuma.c.

{ 
       if (strict) 
              bind_policy = MPOL_BIND; 
       else
              bind_policy = MPOL_PREFERRED;
} 

Here is the caller graph for this function:

void numa_set_interleave_mask ( struct bitmask nodemask)

Here is the caller graph for this function:

static void numa_set_interleave_mask_compat ( nodemask_t nodemask) [inline, static]

Definition at line 324 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)nodemask;
       tmp.size = sizeof(nodemask_t) * 8;
       numa_set_interleave_mask(&tmp);
}

Here is the call graph for this function:

void numa_set_localalloc ( void  )

Definition at line 1695 of file libnuma.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_set_membind ( struct bitmask nodemask)

Here is the caller graph for this function:

static void numa_set_membind_compat ( nodemask_t mask) [inline, static]

Definition at line 354 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = sizeof(nodemask_t) * 8;
       numa_set_membind(&tmp);
}

Here is the call graph for this function:

void numa_set_preferred ( int  node)

Definition at line 1682 of file libnuma.c.

{ 
       struct bitmask *bmp;

       bmp = numa_allocate_nodemask();
       if (node >= 0) {
              numa_bitmask_setbit(bmp, node);
              setpol(MPOL_PREFERRED, bmp);
       } else
              setpol(MPOL_DEFAULT, bmp);
       numa_bitmask_free(bmp);
} 

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_set_strict ( int  flag)

Definition at line 1718 of file libnuma.c.

Here is the caller graph for this function:

void numa_setlocal_memory ( void *  start,
size_t  size 
)

Definition at line 852 of file libnuma.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_tonode_memory ( void *  start,
size_t  size,
int  node 
)

Definition at line 824 of file libnuma.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void numa_tonodemask_memory ( void *  mem,
size_t  size,
struct bitmask mask 
)

Here is the caller graph for this function:

static void numa_tonodemask_memory_compat ( void *  mem,
size_t  size,
const nodemask_t mask 
) [inline, static]

Definition at line 414 of file numa.h.

{
       struct bitmask tmp;

       tmp.maskp = (unsigned long *)mask;
       tmp.size = sizeof(nodemask_t) * 8;
       numa_tonodemask_memory(mem, size, &tmp);
}

Here is the call graph for this function:

void numa_warn ( int  num,
char *  fmt,
  ... 
)

Definition at line 261 of file libnuma.c.

{ 
       static unsigned warned;
       va_list ap;
       int olde = errno;
       
       /* Give each warning only once */
       if ((1<<num) & warned)
              return; 
       warned |= (1<<num); 

       va_start(ap,fmt);
       fprintf(stderr, "libnuma: Warning: ");
       vfprintf(stderr, fmt, ap);
       fputc('\n', stderr);
       va_end(ap);

       errno = olde;
} 

Variable Documentation

Definition at line 50 of file libnuma.c.

Definition at line 46 of file libnuma.c.

Definition at line 49 of file libnuma.c.

Definition at line 76 of file libnuma.c.

Definition at line 77 of file libnuma.c.

Definition at line 45 of file libnuma.c.

Definition at line 48 of file libnuma.c.

Definition at line 55 of file libnuma.c.