1NUMA(3) Linux Programmer's Manual NUMA(3)
2
3
4
6 numa - NUMA policy library
7
9 #include <numa.h>
10
11 cc ... -lnuma
12
13 int numa_available(void);
14
15 int numa_max_possible_node(void);
16 int numa_num_possible_nodes();
17
18 int numa_max_node(void);
19 int numa_num_configured_nodes();
20 struct bitmask *numa_get_mems_allowed(void);
21
22 int numa_num_configured_cpus(void);
23 struct bitmask *numa_all_nodes_ptr;
24 struct bitmask *numa_no_nodes_ptr;
25 struct bitmask *numa_all_cpus_ptr;
26
27 int numa_num_thread_cpus();
28 int numa_num_thread_nodes();
29
30 int numa_parse_bitmap(char *line , struct bitmask *mask);
31 struct bitmask *numa_parse_nodestring(char *string);
32 struct bitmask *numa_parse_cpustring(char *string);
33
34 long numa_node_size(int node, long *freep);
35 long long numa_node_size64(int node, long long *freep);
36
37 int numa_preferred(void);
38 void numa_set_preferred(int node);
39 int numa_get_interleave_node(void);
40 struct bitmask *numa_get_interleave_mask(void);
41 void numa_set_interleave_mask(struct bitmask *nodemask);
42 void numa_interleave_memory(void *start, size_t size, struct bitmask
43 *nodemask);
44 void numa_bind(struct bitmask *nodemask);
45 void numa_set_localalloc(void);
46 void numa_set_membind(struct bitmask *nodemask);
47 struct bitmask *numa_get_membind(void);
48
49 void *numa_alloc_onnode(size_t size, int node);
50 void *numa_alloc_local(size_t size);
51 void *numa_alloc_interleaved(size_t size);
52 void *numa_alloc_interleaved_subset(size_t size, struct bitmask *node‐
53 mask); void *numa_alloc(size_t size);
54 void numa_free(void *start, size_t size);
55
56 int numa_run_on_node(int node);
57 int numa_run_on_node_mask(struct bitmask *nodemask);
58 struct bitmask *numa_get_run_node_mask(void);
59
60 void numa_tonode_memory(void *start, size_t size, int node);
61 void numa_tonodemask_memory(void *start, size_t size, struct bitmask
62 *nodemask);
63 void numa_setlocal_memory(void *start, size_t size);
64 void numa_police_memory(void *start, size_t size);
65 void numa_set_bind_policy(int strict);
66 void numa_set_strict(int strict);
67
68 int numa_distance(int node1, int node2);
69
70 int numa_sched_getaffinity(pid_t pid, struct bitmask *mask);
71 int numa_sched_setaffinity(pid_t pid, struct bitmask *mask);
72 int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen);
73 int numa_node_of_cpu(int cpu);
74
75 struct bitmask *numa_allocate_cpumask();
76
77 void numa_free_cpumask();
78 struct bitmask *numa_allocate_nodemask();
79
80 void numa_free_nodemask();
81 struct bitmask *numa_bitmask_alloc(unsigned int n);
82 struct bitmask *numa_bitmask_clearall(struct bitmask *bmp);
83 struct bitmask *numa_bitmask_clearbit(struct bitmask *bmp, unsigned int
84 n);
85 int numa_bitmask_equal(const struct bitmask *bmp1, const struct bitmask
86 *bmp2);
87 void numa_bitmask_free(struct bitmask *bmp);
88 int numa_bitmask_isbitset(const struct bitmask *bmp, unsigned int n);
89 unsigned int numa_bitmask_nbytes(struct bitmask *bmp);
90 struct bitmask *numa_bitmask_setall(struct bitmask *bmp);
91 struct bitmask *numa_bitmask_setbit(struct bitmask *bmp, unsigned int
92 n);
93 void copy_bitmask_to_nodemask(struct bitmask *bmp, nodemask_t *node‐
94 mask)
95 void copy_nodemask_to_bitmask(nodemask_t *nodemask, struct bitmask
96 *bmp)
97 void copy_bitmask_to_bitmask(struct bitmask *bmpfrom, struct bitmask
98 *bmpto)
99
100 int numa_move_pages(int pid, unsigned long count, void **pages, const
101 int *nodes, int *status, int flags);
102 int numa_migrate_pages(int pid, struct bitmask *fromnodes, struct bit‐
103 mask *tonodes);
104
105 void numa_error(char *where);
106
107 extern int numa_exit_on_error;
108 extern int numa_exit_on_warn;
109 void numa_warn(int number, char *where, ...);
110
111
113 The libnuma library offers a simple programming interface to the NUMA
114 (Non Uniform Memory Access) policy supported by the Linux kernel. On a
115 NUMA architecture some memory areas have different latency or bandwidth
116 than others.
117
118 Available policies are page interleaving (i.e., allocate in a round-
119 robin fashion from all, or a subset, of the nodes on the system), pre‐
120 ferred node allocation (i.e., preferably allocate on a particular
121 node), local allocation (i.e., allocate on the node on which the thread
122 is currently executing), or allocation only on specific nodes (i.e.,
123 allocate on some subset of the available nodes). It is also possible
124 to bind threads to specific nodes.
125
126 Numa memory allocation policy may be specified as a per-thread
127 attribute, that is inherited by children threads and processes, or as
128 an attribute of a range of process virtual address space. Numa memory
129 policies specified for a range of virtual address space are shared by
130 all threads in the process. Further more, memory policies specified
131 for a range of a shared memory attached using shmat(2) or mmap(2) from
132 shmfs/hugetlbfs are shared by all processes that attach to that region.
133 Memory policies for shared disk backed file mappings are currently
134 ignored.
135
136 The default memory allocation policy for threads and all memory range
137 is local allocation. This assumes that no ancestor has installed a
138 non-default policy.
139
140 For setting a specific policy globally for all memory allocations in a
141 process and its children it is easiest to start it with the numactl(8)
142 utility. For more finegrained policy inside an application this library
143 can be used.
144
145 All numa memory allocation policy only takes effect when a page is
146 actually faulted into the address space of a process by accessing it.
147 The numa_alloc_* functions take care of this automatically.
148
149 A node is defined as an area where all memory has the same speed as
150 seen from a particular CPU. A node can contain multiple CPUs. Caches
151 are ignored for this definition.
152
153 Most functions in this library are only concerned about numa nodes and
154 their memory. The exceptions to this are: numa_node_to_cpus(),
155 numa_node_of_cpu(), numa_bind(), numa_run_on_node(),
156 numa_run_on_node_mask() and numa_get_run_node_mask(). These functions
157 deal with the CPUs associated with numa nodes. See the descriptions
158 below for more information.
159
160 Some of these functions accept or return a pointer to struct bitmask.
161 A struct bitmask controls a bit map of arbitrary length containing a
162 bit representation of nodes. The predefined variable
163 numa_all_nodes_ptr points to a bit mask that has all available nodes
164 set; numa_no_nodes_ptr points to the empty set.
165
166 Before any other calls in this library can be used numa_available()
167 must be called. If it returns -1, all other functions in this library
168 are undefined.
169
170 numa_max_possible_node() returns the number of the highest possible
171 node in a system. In other words, the size of a kernel type nodemask_t
172 (in bits) minus 1. This number can be gotten by calling numa_num_pos‐
173 sible_nodes() and subtracting 1.
174
175 numa_num_possible_nodes() returns the size of kernel's node mask (ker‐
176 nel type nodemask_t). In other words, large enough to represent the
177 maximum number of nodes that the kernel can handle. This will match the
178 kernel's MAX_NUMNODES value. This count is derived from
179 /proc/self/status, field Mems_allowed.
180
181 numa_max_node() returns the highest node number available on the cur‐
182 rent system. (See the node numbers in /sys/devices/system/node/ ).
183 Also see numa_num_configured_nodes().
184
185 numa_num_configured_nodes() returns the number of memory nodes in the
186 system. This count includes any nodes that are currently disabled. This
187 count is derived from the node numbers in /sys/devices/system/node.
188 (Depends on the kernel being configured with /sys (CONFIG_SYSFS)).
189
190 numa_get_mems_allowed() returns the mask of nodes from which the
191 process is allowed to allocate memory in it's current cpuset context.
192 Any nodes that are not included in the returned bitmask will be ignored
193 in any of the following libnuma memory policy calls.
194
195 numa_num_configured_cpus() returns the number of cpus in the system.
196 This count includes any cpus that are currently disabled. This count is
197 derived from the cpu numbers in /sys/devices/system/cpu. If the kernel
198 is configured without /sys (CONFIG_SYSFS=n) then it falls back to using
199 the number of online cpus.
200
201 numa_all_nodes_ptr points to a bitmask that is allocated by the library
202 with bits representing all nodes on which the calling thread may allo‐
203 cate memory. This set may be up to all nodes on the system, or up to
204 the nodes in the current cpuset. The bitmask is allocated by a call to
205 numa_allocate_nodemask() using size numa_max_possible_node(). The set
206 of nodes to record is derived from /proc/self/status, field
207 "Mems_allowed". The user should not alter this bitmask.
208
209 numa_no_nodes_ptr points to a bitmask that is allocated by the library
210 and left all zeroes. The bitmask is allocated by a call to numa_allo‐
211 cate_nodemask() using size numa_max_possible_node(). The user should
212 not alter this bitmask.
213
214 numa_all_cpus_ptr points to a bitmask that is allocated by the library
215 with bits representing all cpus on which the calling thread may exe‐
216 cute. This set may be up to all cpus on the system, or up to the cpus
217 in the current cpuset. The bitmask is allocated by a call to
218 numa_allocate_cpumask() using size numa_num_possible_cpus(). The set
219 of cpus to record is derived from /proc/self/status, field
220 "Cpus_allowed". The user should not alter this bitmask.
221
222 numa_num_thread_cpus() returns the number of cpus that the calling
223 thread is allowed to use. This count is derived from the map
224 /proc/self/status, field "Cpus_allowed". Also see the bitmask
225 numa_all_cpus_ptr.
226
227 numa_num_thread_nodes() returns the number of nodes on which the call‐
228 ing thread is allowed to allocate memory. This count is derived from
229 the map /proc/self/status, field "Mems_allowed". Also see the bitmask
230 numa_all_nodes_ptr.
231
232 numa_parse_bitmap() parses line , which is a character string such as
233 found in /sys/devices/system/node/nodeN/cpumap into a bitmask struc‐
234 ture. The string contains the hexadecimal representation of a bit map.
235 The bitmask may be allocated with numa_allocate_cpumask(). Returns 0
236 on success. Returns -1 on failure. This function is probably of lit‐
237 tle use to a user application, but it is used by libnuma internally.
238
239 numa_parse_nodestring() parses a character string list of nodes into a
240 bit mask. The bit mask is allocated by numa_allocate_nodemask(). The
241 string is a comma-separated list of node numbers or node ranges. A
242 leading ! can be used to indicate "not" this list (in other words, all
243 nodes except this list), and a leading + can be used to indicate that
244 the node numbers in the list are relative to the thread's cpuset. The
245 string can be "all" to specify all ( numa_num_thread_nodes() ) nodes.
246 Node numbers are limited by the number in the system. See
247 numa_max_node() and numa_num_configured_nodes().
248 Examples: 1-5,7,10 !4-5 +0-3
249 If the string is of 0 length, bitmask numa_no_nodes_ptr is returned.
250 Returns 0 if the string is invalid.
251
252 numa_parse_cpustring() parses a character string list of cpus into a
253 bit mask. The bit mask is allocated by numa_allocate_cpumask(). The
254 string is a comma-separated list of cpu numbers or cpu ranges. A lead‐
255 ing ! can be used to indicate "not" this list (in other words, all cpus
256 except this list), and a leading + can be used to indicate that the cpu
257 numbers in the list are relative to the thread's cpuset. The string
258 can be "all" to specify all ( numa_num_thread_cpus() ) cpus. Cpu num‐
259 bers are limited by the number in the system. See
260 numa_num_thread_cpus() and numa_num_configured_cpus().
261 Examples: 1-5,7,10 !4-5 +0-3
262 Returns 0 if the string is invalid.
263
264 numa_node_size() returns the memory size of a node. If the argument
265 freep is not NULL, it used to return the amount of free memory on the
266 node. On error it returns -1.
267
268 numa_node_size64() works the same as numa_node_size() except that it
269 returns values as long long instead of long. This is useful on 32-bit
270 architectures with large nodes.
271
272 numa_preferred() returns the preferred node of the current thread.
273 This is the node on which the kernel preferably allocates memory,
274 unless some other policy overrides this.
275
276 numa_set_preferred() sets the preferred node for the current thread to
277 node. The system will attempt to allocate memory from the preferred
278 node, but will fall back to other nodes if no memory is available on
279 the the preferred node. Passing a node of -1 argument specifies local
280 allocation and is equivalent to calling numa_set_localalloc().
281
282 numa_get_interleave_mask() returns the current interleave mask if the
283 thread's memory allocation policy is page interleaved. Otherwise, this
284 function returns an empty mask.
285
286 numa_set_interleave_mask() sets the memory interleave mask for the cur‐
287 rent thread to nodemask. All new memory allocations are page inter‐
288 leaved over all nodes in the interleave mask. Interleaving can be
289 turned off again by passing an empty mask (numa_no_nodes). The page
290 interleaving only occurs on the actual page fault that puts a new page
291 into the current address space. It is also only a hint: the kernel will
292 fall back to other nodes if no memory is available on the interleave
293 target.
294
295 numa_interleave_memory() interleaves size bytes of memory page by page
296 from start on nodes specified in nodemask. The size argument will be
297 rounded up to a multiple of the system page size. If nodemask contains
298 nodes that are externally denied to this process, this call will fail.
299 This is a lower level function to interleave allocated but not yet
300 faulted in memory. Not yet faulted in means the memory is allocated
301 using mmap(2) or shmat(2), but has not been accessed by the current
302 process yet. The memory is page interleaved to all nodes specified in
303 nodemask. Normally numa_alloc_interleaved() should be used for private
304 memory instead, but this function is useful to handle shared memory
305 areas. To be useful the memory area should be several megabytes at
306 least (or tens of megabytes of hugetlbfs mappings) If the
307 numa_set_strict() flag is true then the operation will cause a
308 numa_error if there were already pages in the mapping that do not fol‐
309 low the policy.
310
311 numa_bind() binds the current thread and its children to the nodes
312 specified in nodemask. They will only run on the CPUs of the specified
313 nodes and only be able to allocate memory from them. This function is
314 equivalent to calling numa_run_on_node_mask(nodemask) followed by
315 numa_set_membind(nodemask). If threads should be bound to individual
316 CPUs inside nodes consider using numa_node_to_cpus and the
317 sched_setaffinity(2) syscall.
318
319 numa_set_localalloc() sets the memory allocation policy for the calling
320 thread to local allocation. In this mode, the preferred node for mem‐
321 ory allocation is effectively the node where the thread is executing at
322 the time of a page allocation.
323
324 numa_set_membind() sets the memory allocation mask. The thread will
325 only allocate memory from the nodes set in nodemask. Passing an empty
326 nodemask or a nodemask that contains nodes other than those in the mask
327 returned by numa_get_mems_allowed() will result in an error.
328
329 numa_get_membind() returns the mask of nodes from which memory can cur‐
330 rently be allocated. If the returned mask is equal to numa_all_nodes,
331 then memory allocation is allowed from all nodes.
332
333 numa_alloc_onnode() allocates memory on a specific node. The size
334 argument will be rounded up to a multiple of the system page size. if
335 the specified node is externally denied to this process, this call will
336 fail. This function is relatively slow compared to the malloc(3), fam‐
337 ily of functions. The memory must be freed with numa_free(). On
338 errors NULL is returned.
339
340 numa_alloc_local() allocates size bytes of memory on the local node.
341 The size argument will be rounded up to a multiple of the system page
342 size. This function is relatively slow compared to the malloc(3) fam‐
343 ily of functions. The memory must be freed with numa_free(). On
344 errors NULL is returned.
345
346 numa_alloc_interleaved() allocates size bytes of memory page inter‐
347 leaved on all nodes. This function is relatively slow and should only
348 be used for large areas consisting of multiple pages. The interleaving
349 works at page level and will only show an effect when the area is
350 large. The allocated memory must be freed with numa_free(). On error,
351 NULL is returned.
352
353 numa_alloc_interleaved_subset() attempts to allocate size bytes of mem‐
354 ory page interleaved on all nodes. The size argument will be rounded
355 up to a multiple of the system page size. The nodes on which a process
356 is allowed to allocate memory may be constrained externally. If this
357 is the case, this function may fail. This function is relatively slow
358 compare to malloc(3), family of functions and should only be used for
359 large areas consisting of multiple pages. The interleaving works at
360 page level and will only show an effect when the area is large. The
361 allocated memory must be freed with numa_free(). On error, NULL is
362 returned.
363
364 numa_alloc() allocates size bytes of memory with the current NUMA pol‐
365 icy. The size argument will be rounded up to a multiple of the system
366 page size. This function is relatively slow compare to the malloc(3)
367 family of functions. The memory must be freed with numa_free(). On
368 errors NULL is returned.
369
370 numa_free() frees size bytes of memory starting at start, allocated by
371 the numa_alloc_* functions above. The size argument will be rounded up
372 to a multiple of the system page size.
373
374 numa_run_on_node() runs the current thread and its children on a spe‐
375 cific node. They will not migrate to CPUs of other nodes until the node
376 affinity is reset with a new call to numa_run_on_node_mask(). Passing
377 -1 permits the kernel to schedule on all nodes again. On success, 0 is
378 returned; on error -1 is returned, and errno is set to indicate the
379 error.
380
381 numa_run_on_node_mask() runs the current thread and its children only
382 on nodes specified in nodemask. They will not migrate to CPUs of other
383 nodes until the node affinity is reset with a new call to
384 numa_run_on_node_mask() or numa_run_on_node(). Passing numa_all_nodes
385 permits the kernel to schedule on all nodes again. On success, 0 is
386 returned; on error -1 is returned, and errno is set to indicate the
387 error.
388
389 numa_get_run_node_mask() returns the mask of nodes that the current
390 thread is allowed to run on.
391
392 numa_tonode_memory() put memory on a specific node. The constraints
393 described for numa_interleave_memory() apply here too.
394
395 numa_tonodemask_memory() put memory on a specific set of nodes. The
396 constraints described for numa_interleave_memory() apply here too.
397
398 numa_setlocal_memory() locates memory on the current node. The con‐
399 straints described for numa_interleave_memory() apply here too.
400
401 numa_police_memory() locates memory with the current NUMA policy. The
402 constraints described for numa_interleave_memory() apply here too.
403
404 numa_distance() reports the distance in the machine topology between
405 two nodes. The factors are a multiple of 10. It returns 0 when the
406 distance cannot be determined. A node has distance 10 to itself.
407 Reporting the distance requires a Linux kernel version of 2.6.10 or
408 newer.
409
410 numa_set_bind_policy() specifies whether calls that bind memory to a
411 specific node should use the preferred policy or a strict policy. The
412 preferred policy allows the kernel to allocate memory on other nodes
413 when there isn't enough free on the target node. strict will fail the
414 allocation in that case. Setting the argument to specifies strict, 0
415 preferred. Note that specifying more than one node non strict may only
416 use the first node in some kernel versions.
417
418 numa_set_strict() sets a flag that says whether the functions allocat‐
419 ing on specific nodes should use use a strict policy. Strict means the
420 allocation will fail if the memory cannot be allocated on the target
421 node. Default operation is to fall back to other nodes. This doesn't
422 apply to interleave and default.
423
424 numa_get_interleave_node() is used by libnuma internally. It is proba‐
425 bly not useful for user applications. It uses the MPOL_F_NODE flag of
426 the get_mempolicy system call, which is not intended for application
427 use (its operation may change or be removed altogether in future kernel
428 versions). See get_mempolicy(2).
429
430 numa_pagesize() returns the number of bytes in page. This function is
431 simply a fast alternative to repeated calls to the getpagesize system
432 call. See getpagesize(2).
433
434 numa_sched_getaffinity() retrieves a bitmask of the cpus on which a
435 thread may run. The thread is specified by pid. Returns the return
436 value of the sched_getaffinity system call. See sched_getaffinity(2).
437 The bitmask must be at least the size of the kernel's cpu mask struc‐
438 ture. Use numa_allocate_cpumask() to allocate it. Test the bits in the
439 mask by calling numa_bitmask_isbitset().
440
441 numa_sched_setaffinity() sets a thread's allowed cpu's to those cpu's
442 specified in mask. The thread is specified by pid. Returns the return
443 value of the sched_setaffinity system call. See sched_setaffinity(2).
444 You may allocate the bitmask with numa_allocate_cpumask(). Or the bit‐
445 mask may be smaller than the kernel's cpu mask structure. For example,
446 call numa_bitmask_alloc() using a maximum number of cpus from
447 numa_num_configured_cpus(). Set the bits in the mask by calling
448 numa_bitmask_setbit().
449
450 numa_node_to_cpus() converts a node number to a bitmask of CPUs. The
451 user must pass a long enough buffer. If the buffer is not long enough
452 errno will be set to ERANGE and -1 returned. On success 0 is returned.
453
454 numa_node_of_cpu() returns the node that a cpu belongs to. If the user
455 supplies an invalid cpu errno will be set to EINVAL and -1 will be
456 returned.
457
458 numa_allocate_cpumask () returns a bitmask of a size equal to the ker‐
459 nel's cpu mask (kernel type cpumask_t). In other words, large enough
460 to represent NR_CPUS cpus. This number of cpus can be gotten by call‐
461 ing numa_num_possible_cpus(). The bitmask is zero-filled.
462
463 numa_free_cpumask frees a cpumask previously allocate by numa_allo‐
464 cate_cpumask.
465
466 numa_allocate_nodemask() returns a bitmask of a size equal to the ker‐
467 nel's node mask (kernel type nodemask_t). In other words, large enough
468 to represent MAX_NUMNODES nodes. This number of nodes can be gotten by
469 calling numa_num_possible_nodes(). The bitmask is zero-filled.
470
471 numa_free_nodemask() frees a nodemask previous allocated by numa_allo‐
472 cate_nodemask().
473
474 numa_bitmask_alloc() allocates a bitmask structure and its associated
475 bit mask. The memory allocated for the bit mask contains enough words
476 (type unsigned long) to contain n bits. The bit mask is zero-filled.
477 The bitmask structure points to the bit mask and contains the n value.
478
479 numa_bitmask_clearall() sets all bits in the bit mask to 0. The bit‐
480 mask structure points to the bit mask and contains its size ( bmp
481 ->size). The value of bmp is always returned. Note that numa_bit‐
482 mask_alloc() creates a zero-filled bit mask.
483
484 numa_bitmask_clearbit() sets a specified bit in a bit mask to 0. Noth‐
485 ing is done if the n value is greater than the size of the bitmask (and
486 no error is returned). The value of bmp is always returned.
487
488 numa_bitmask_equal() returns 1 if two bitmasks are equal. It returns 0
489 if they are not equal. If the bitmask structures control bit masks of
490 different sizes, the "missing" trailing bits of the smaller bit mask
491 are considered to be 0.
492
493 numa_bitmask_free() deallocates the memory of both the bitmask struc‐
494 ture pointed to by bmp and the bit mask. It is an error to attempt to
495 free this bitmask twice.
496
497 numa_bitmask_isbitset() returns the value of a specified bit in a bit
498 mask. If the n value is greater than the size of the bit map, 0 is
499 returned.
500
501 numa_bitmask_nbytes() returns the size (in bytes) of the bit mask con‐
502 trolled by bmp. The bit masks are always full words (type unsigned
503 long), and the returned size is the actual size of all those words.
504
505 numa_bitmask_setall() sets all bits in the bit mask to 1. The bitmask
506 structure points to the bit mask and contains its size ( bmp ->size).
507 The value of bmp is always returned.
508
509 numa_bitmask_setbit() sets a specified bit in a bit mask to 1. Nothing
510 is done if n is greater than the size of the bitmask (and no error is
511 returned). The value of bmp is always returned.
512
513 copy_bitmask_to_nodemask() copies the body (the bit map itself) of the
514 bitmask structure pointed to by bmp to the nodemask_t structure pointed
515 to by the nodemask pointer. If the two areas differ in size, the copy
516 is truncated to the size of the receiving field or zero-filled.
517
518 copy_nodemask_to_bitmask() copies the nodemask_t structure pointed to
519 by the nodemask pointer to the body (the bit map itself) of the bitmask
520 structure pointed to by the bmp pointer. If the two areas differ in
521 size, the copy is truncated to the size of the receiving field or zero-
522 filled.
523
524 copy_bitmask_to_bitmask() copies the body (the bit map itself) of the
525 bitmask structure pointed to by the bmpfrom pointer to the body of the
526 bitmask structure pointed to by the bmpto pointer. If the two areas
527 differ in size, the copy is truncated to the size of the receiving
528 field or zero-filled.
529
530 numa_move_pages() moves a list of pages in the address space of the
531 currently executing or current process. It simply uses the move_pages
532 system call.
533 pid - ID of thread. If not valid, use the current thread.
534 count - Number of pages.
535 pages - List of pages to move.
536 nodes - List of nodes to which pages can be moved.
537 status - Field to which status is to be returned.
538 flags - MPOL_MF_MOVE or MPOL_MF_MOVE_ALL
539 See move_pages(2).
540
541 numa_migrate_pages() simply uses the migrate_pages system call to cause
542 the pages of the calling thread, or a specified thread, to be migated
543 from one set of nodes to another. See migrate_pages(2). The bit masks
544 representing the nodes should be allocated with numa_allocate_node‐
545 mask() , or with numa_bitmask_alloc() using an n value returned from
546 numa_num_possible_nodes(). A thread's current node set can be gotten
547 by calling numa_get_membind(). Bits in the tonodes mask can be set by
548 calls to numa_bitmask_setbit().
549
550 numa_error() is a libnuma internal function that can be overridden by
551 the user program. This function is called with a char * argument when
552 a libnuma function fails. Overriding the library internal definition
553 makes it possible to specify a different error handling strategy when a
554 libnuma function fails. It does not affect numa_available(). The
555 numa_error() function defined in libnuma prints an error on stderr and
556 terminates the program if numa_exit_on_error is set to a non-zero
557 value. The default value of numa_exit_on_error is zero.
558
559 numa_warn() is a libnuma internal function that can be also overridden
560 by the user program. It is called to warn the user when a libnuma
561 function encounters a non-fatal error. The default implementation
562 prints a warning to stderr. The first argument is a unique number
563 identifying each warning. After that there is a printf(3)-style format
564 string and a variable number of arguments. numa_warn exits the program
565 when numa_exit_on_warn is set to a non-zero value. The default value
566 of numa_exit_on_warn is zero.
567
568
570 Binaries that were compiled for libnuma version 1 need not be re-com‐
571 piled to run with libnuma version 2.
572 Source codes written for libnuma version 1 may be re-compiled without
573 change with version 2 installed. To do so, in the code's Makefile add
574 this option to CFLAGS: -DNUMA_VERSION1_COMPATIBILITY
575
576
578 numa_set_bind_policy and numa_exit_on_error are process global. The
579 other calls are thread safe.
580
581
583 Copyright 2002, 2004, 2007, 2008 Andi Kleen, SuSE Labs. libnuma is
584 under the GNU Lesser General Public License, v2.1.
585
586
588 get_mempolicy(2), set_mempolicy(2), getpagesize(2), mbind(2), mmap(2),
589 shmat(2), numactl(8), sched_getaffinity(2) sched_setaffinity(2)
590 move_pages(2) migrate_pages(2)
591
592
593
594SuSE Labs December 2007 NUMA(3)