LIBCPUSET(3) | SGI | LIBCPUSET(3) |
cpuset, cpuset_version, cpuset_pin, cpuset_size, cpuset_where,
cpuset_unpin, cpuset_alloc, cpuset_free, cpuset_cpus_nbits,
cpuset_mems_nbits, cpuset_setcpus, cpuset_setmems, cpuset_set_iopt,
cpuset_set_sopt, cpuset_getcpus, cpuset_getmems, cpuset_cpus_weight,
cpuset_mems_weight, cpuset_get_iopt, cpuset_get_sopt, cpuset_localcpus,
cpuset_localmems, cpuset_cpumemdist, cpuset_cpu2node, cpuset_addr2node,
cpuset_create, cpuset_delete, cpuset_query, cpuset_modify,
cpuset_getcpusetpath, cpuset_cpusetofpid, cpuset_mountpoint,
cpuset_collides_exclusive, cpuset_nuke, cpuset_init_pidlist,
cpuset_pidlist_length, cpuset_get_pidlist, cpuset_freepidlist, cpuset_move,
cpuset_move_all, cpuset_move_cpuset_tasks, cpuset_migrate,
cpuset_migrate_all, cpuset_reattach, cpuset_open_memory_pressure,
cpuset_read_memory_pressure, cpuset_close_memory_pressure,
cpuset_c_rel_to_sys_cpu, cpuset_c_sys_to_rel_cpu, cpuset_c_rel_to_sys_mem,
cpuset_c_sys_to_rel_mem, cpuset_p_rel_to_sys_cpu, cpuset_p_sys_to_rel_cpu,
cpuset_p_rel_to_sys_mem, cpuset_p_sys_to_rel_mem, cpuset_get_placement,
cpuset_equal_placement, cpuset_free_placement, cpuset_fts_open,
cpuset_fts_read, cpuset_fts_reverse, cpuset_fts_rewind, cpuset_fts_get_path,
cpuset_fts_get_stat, cpuset_fts_get_cpuset, cpuset_fts_get_errno,
cpuset_fts_get_info, cpuset_fts_close, cpuset_cpubind, cpuset_latestcpu,
cpuset_membind, cpuset_get_cpu_affinity, cpuset_set_cpu_affinity,
cpuset_get_mem_affinity, cpuset_export, cpuset_import, cpuset_function
- Library for managing CPU and Memory placement.
#include <bitmask.h> #include <cpuset.h> cc ... -lcpuset
int cpuset_pin(int relcpu); int cpuset_size(); int cpuset_where(); int cpuset_unpin();
include 'cpusetf.h' integer relcpu irtn = cpuset_pin(relcpu) irtn = cpuset_size() irtn = cpuset_unpin() irtn = cpuset_where()
int cpuset_version();
struct cpuset *cpuset_alloc(); void cpuset_free(struct cpuset *cp);
int cpuset_cpus_nbits(); int cpuset_mems_nbits();
int cpuset_setcpus(struct cpuset *cp, const struct bitmask *cpus); void cpuset_setmems(struct cpuset *cp, const struct bitmask *mems); int cpuset_set_iopt(struct cpuset *cp, const char *optname, int val); int cpuset_set_sopt(struct cpuset *cp, const char *optname, const char *val);
int cpuset_getcpus(const struct cpuset *cp, struct bitmask *cpus); int cpuset_getmems(const struct cpuset *cp, struct bitmask *mems); int cpuset_cpus_weight(const struct cpuset *cp); int cpuset_mems_weight(const struct cpuset *cp); int cpuset_get_iopt(const struct cpuset *cp, const char *optname); const char *cpuset_get_sopt(const struct cpuset *cp, const char *optname);
int cpuset_localcpus(const struct bitmask *mems, struct bitmask *cpus); int cpuset_localmems(const struct bitmask *cpus, struct bitmask *mems); unsigned int cpuset_cpumemdist(int cpu, int mem); int cpuset_cpu2node(int cpu); int cpuset_addr2node(void *addr);
int cpuset_create(const char *path, const struct *cp); int cpuset_delete(const char *path); int cpuset_query(struct cpuset *cp, const char *path); int cpuset_modify(const char *path, const struct *cp); char *cpuset_getcpusetpath(pid_t pid, char *buf, size_t size); int cpuset_cpusetofpid(struct cpuset *cp, int pid); const char *cpuset_mountpoint(); int cpuset_collides_exclusive(const char *cpusetpath, const struct cpuset *cp); int cpuset_nuke(const char *path, unsigned int seconds);
struct cpuset_pidlist *cpuset_init_pidlist(const char *path, int recurse); int cpuset_pidlist_length(const struct cpuset_pidlist *pl); pid_t cpuset_get_pidlist(const struct cpuset_pidlist *pl, int i); void cpuset_freepidlist(struct cpuset_pidlist *pl);
int cpuset_move(pid_t p, const char *path); int cpuset_move_all(struct cpuset_pid_list *pl, const char *path); int cpuset_move_cpuset_tasks(const char *fromrelpath, const char *torelpath); int cpuset_migrate(pid_t pid, const char *path); int cpuset_migrate_all(struct cpuset_pid_list *pl, const char *path); int cpuset_reattach(const char *path);
int cpuset_open_memory_pressure(const char *cpusetpath); int cpuset_read_memory_pressure(int han); void cpuset_close_memory_pressure(int han);
int cpuset_c_rel_to_sys_cpu(const struct cpuset *cp, int relcpu); int cpuset_c_sys_to_rel_cpu(const struct cpuset *cp, int cpu); int cpuset_c_rel_to_sys_mem(const struct cpuset *cp, int relmem); int cpuset_c_sys_to_rel_mem(const struct cpuset *cp, int mem); int cpuset_p_rel_to_sys_cpu(pid_t pid, int relcpu); int cpuset_p_sys_to_rel_cpu(pid_t pid, int cpu); int cpuset_p_rel_to_sys_mem(pid_t pid, int relmem); int cpuset_p_sys_to_rel_mem(pid_t pid, int mem);
struct cpuset_placement *cpuset_get_placement(pid_t pid); int cpuset_equal_placement(const struct cpuset_placement *plc1, const struct cpuset_placement *plc2); void cpuset_free_placement(struct cpuset_placement *plc);
struct cpuset_fts_tree *cpuset_fts_open(const char *cpusetpath); const struct cpuset_fts_entry *cpuset_fts_read( struct cpuset_fts_tree *cs_tree); void cpuset_fts_reverse(struct cpuset_fts_tree *cs_tree); void cpuset_fts_rewind(struct cpuset_fts_tree *cs_tree); const char *cpuset_fts_get_path( const struct cpuset_fts_entry *cs_entry); const struct stat *cpuset_fts_get_stat( const struct cpuset_fts_entry *cs_entry); const struct cpuset *cpuset_fts_get_cpuset( const struct cpuset_fts_entry *cs_entry); int cpuset_fts_get_errno( const struct cpuset_fts_entry *cs_entry); int cpuset_fts_get_info( const struct cpuset_fts_entry *cs_entry); void cpuset_fts_close(struct cpuset_fts_tree *cs_tree);
int cpuset_cpubind(int cpu); int cpuset_latestcpu(pid_t pid); int cpuset_membind(int mem);
int cpuset_export(const struct cpuset *cp, char *buf, int buflen); int cpuset_import(struct cpuset *cp, const char *file, int *errlinenum_ptr, char *errmsg_bufptr, int errmsg_buflen);
cpuset_function(const char *function_name);
Cpusets are named subsets of a systems CPUs and Memory Nodes. On large SMP and NUMA systems, it is commonly necessary to control which processes and threads can run on which CPUs and Memory Nodes. Such placement can be used to improve overall system performance, and to manage system utilization in accordance with appropriate policies.
This cpuset library provides the mechanisms needed to create, destroy and manage cpusets, and to control the placement of processes and threads within cpusets.
Though this library has many functions, most applications using it will only need the few functions in the Basic Cpuset API. These basic functions enable an application to manage CPU and Memory placement on SMP and NUMA systems within existing cpusets.
The Advanced Cpuset API provides support for creating, destroying and managing cpusets, and for more complex placement within cpusets. Workload managers, batch processors and other system services can use the Advanced Cpuset API in order to manage cpusets across an entire system, or a dedicated portion of a system.
All functions are part of the same library, and fully interoperable. A system imposed permission model ensures that one application will not be able to make changes to the cpusets or placement of other applications, outside of its currently allowed cpuset.
The Basic Cpuset API provides functions usable from C for processor and memory placement within a cpuset.
The basic functions enable an application to place various threads of its execution on specific CPUs within its current cpuset, and perform related functions such as asking how large the current cpuset is, and on which CPU within the current cpuset a thread is currently executing.
The basic cpuset_pin(int relcpu) function uses cpuset relative numbering. In a cpuset of N CPUs, relcpu ranges from zero to N-1. All functions in the Advanced Cpuset API use system wide CPU and Memory Node numbering, to provide a consistent numbering regardless of cpuset configuration.
Memory placement is done automatically by the basic functions, local to the requested CPU. Threads may only be pinned on a single CPU, or unpinned and allowed the run of the entire current cpuset. This avoids the need to allocate and free the bitmasks required to specify a set of several CPUs. The basic functions do not support creating or removing cpusets, only the placement of threads within an existing cpuset. This avoids the need to explicitly allocate and free cpuset structures. Operations only apply to the current thread, avoiding the need to pass the process id of the thread to be affected.
The Basic Cpuset API supports the following functions.
For additional documentation on cpusets, and for details of the
all the other, advanced, routines, see
/usr/share/doc/packages/libcpuset/libcpuset.html and
/usr/share/doc/packages/libbitmask/libbitmask.html. These same documents are
available in plain text format as
/usr/share/doc/packages/libcpuset/libcpuset.txt and
/usr/share/doc/packages/libbitmask/libbitmask.txt.
pj@sgi.com (Paul Jackson)
2006-05-25 | Silicon Graphics, Inc |