cpusetGetFlags(3x)cpusetGetFlags(3x)NAMEcpusetGetFlags - get the mask of flags for a cpuset
SYNOPSIS
#include <cpuset.h>
int cpusetGetFlags(char *qname, int *flags);
DESCRIPTION
The cpusetGetFlags function is used to obtain the attribute flags used
when creating a cpuset. The mask of flags will be copied into the memory
referenced by the flags argument.
Only processes running with a user ID or group ID that has read access
permissions on the permissions file can successfully execute this
function. The qname argument is the name of the specified cpuset.
The return value of the function indicates if the function was
successfully executed.
The mask of flags can be set to any of the following values:
CPUSET_CPU_EXCLUSIVE
Defines a cpuset to be restricted. Only threads attached to the
cpuset queue (descendents of an attached thread inherit the
attachement) may execute on the CPUs contained in the cpuset.
CPUSET_MEMORY_LOCAL
Threads assigned to the cpuset will attempt to assign memory only
from nodes within the cpuset. Assignment of memory from outside
the cpuset will occur only if no free memory is available from
within the cpuset. No restrictions are made on memory assignment
to threads running outside the cpuset.
CPUSET_MEMORY_EXCLUSIVE
Threads assigned to the cpuset will attempt to assign memory only
from nodes within the cpuset. Assignment of memory from outside
the cpuset will occur only if no free memory is available from
within the cpuset. Threads not assigned to the cpuset will not
use memory from within the cpuset unless no memory outside the
cpuset is available. If, at the time a cpuset is created, memory
is already assigned to threads that are already running, no
attempt will be made to explicitly move this memory. If page
migration is enabled, the pages will be migrated when the system
detects that most references to the pages are non-local.
CPUSET_MEMORY_KERNEL_AVOID
The kernel should attempt to avoid allocating memory from nodes
contained in this cpuset. If kernel memory requests cannot be
satisfied from outside this cpuset, this option will be ignored
and allocations will occur from within the cpuset. (This avoidance
currently extends only to keeping buffer cache away from the
Page 1
cpusetGetFlags(3x)cpusetGetFlags(3x)
protected nodes.)
CPUSET_MEMORY_MANDATORY
The kernel will limit all memory allocations to nodes that are
contained in this cpuset. If memory requests cannot be satisfied,
the allocating process will sleep until memory is available. The
process will be killed if no more memory can be allocated. See
policies below.
CPUSET_POLICY_PAGE
Requires MEMORY_MANDATORY. This is the default policy if no policy
is specified. This policy will cause the kernel to page user pages
to the swap file (see swap(1M)) to free physical memory on the
nodes contained in this cpuset. If swap space is exhausted, the
process will be killed.
CPUSET_POLICY_KILL
Requires MEMORY_MANDATORY. The kernel will attempt to free as much
space as possible from kernel heaps, but will not page user pages
to the swap file. If all physical memory on the nodes contained
in this cpuset are exhausted, the process will be killed.
CPUSET_POLICY_SHARE_WARN
When creating a cpuset, if it is possible for the new cpuset to
share memory on a node with another cpuset the new cpuset will be
created but a warning message will be issued. POLICY_SHARE_WARN
and POLICY_SHARE_FAIL cannot be used together.
CPUSET_POLICY_SHARE_FAIL
When creating a cpuset, if it is possible for the new cpuset to
share memory on a node with another cpuset the new cpuset will
fail to be created and an error message will be issued.
POLICY_SHARE_WARN and POLICY_SHARE_FAIL cannot be used together.
EXAMPLES
This example prints out the flags defined for the cpuset mpi_set.
char *qname = "mpi_set";
int flags;
/* Get the limits else print error & exit */
if (!cpusetGetFlags(qname, &flags)) ) {
perror("cpusetGetFlags");
exit(1);
}
if (flags & CPUSET_CPU_EXCLUSIVE)
printf(" CPU_EXCLUSIVE0);
if (flags & CPUSET_EXPLICIT)
printf(" CPU)_EXPLICIT0);
if (flags & CPUSET_KERN)
printf(" KERN0);
if (flags & CPUSET_MEMORY_LOCAL)
Page 2
cpusetGetFlags(3x)cpusetGetFlags(3x)
printf(" MEMORY_LOCAL0);
if (flags & CPUSET_MEMORY_EXCLUSIVE)
printf(" MEMORY_EXCLUSIVE0);
if (flags & CPUSET_MEMORY_KERNEL_AVOID)
printf(" MEMORY_KERNEL_AVOID0);
if (flags & CPUSET_MEMORY_MANDATORY)
printf(" MEMORY_MANDATORY0);
if (flags & CPUSET_POLICY_PAGE)
printf(" POLICY_PAGE0);
if (flags & CPUSET_POLICY_KILL)
printf(" POLICY_KILL0);
if (flags & CPUSET_POLICY_SHARE_WARN)
printf(" POLICY_SHARE_WARN0);
if (flags & CPUSET_POLICY_SHARE_FAIL)
printf(" POLICY_SHARE_FAIL0);
NOTEScpusetGetFlags is found in the library "libcpuset.so", and will be loaded
if the option -lcpuset is used with cc(1) or ld(1).
SEE ALSOcpuset(1), cpusetSetFlags(3x), cpuset(5).
DIAGNOSTICS
If successful, cpusetGetFlags returns 1. If cpusetGetFlags fails, it
returns 0 and errno is set to indicate the error. The possible values
for errno include those values as set by sysmp(2) and sbrk(2).
Page 3