Cpuset Management Utility
|Line 57:||Line 57:|
# cset shield -e bash
# cset shield -e bash
Revision as of 12:57, 27 July 2011
Current Version: 1.5.3
Cpuset is a GPL v2 Python application to make using the cpusets facilities in the Linux kernel easier. The actual included command is called cset and it allows manipulation of cpusets on the system and provides higher level functions such as implementation and control of a basic cpu shielding setup. Cpuset is developed at Novell as part of the SLERT 10 SP2, SP3, and SLERT 11 as well as the SLES 11 releases.
Note: you need to be root to perform most of the functions that cpuset implements.
The cpuset project is hosted on a Google code hosting site. You will find there the public mercurial source repository and a public bug tracking facility. The author of the cpuset tool is Alex Tsariounov <alext at novell dot com>.
A Quick Tour of Cpuset
The cpuset utility (called cset after install) includes three commands: "set", which is used for creating and managing cpusets; "proc", which is used to manage processes in those sets; and "shield", which is a supercommand that implements a basic CPU shielding methodology.
Here is a quick reference on the cset command:
For an in-depth write up of the shield supercommand:
# cset help shield
To see the options for the shield supercommand:
# cset shield --help
For an in-depth write up of the set subcommand (cpuset management):
# cset help set
To see the options for the set command:
# cset set --help
For an in-depth write up of the proc subcommand (process management):
# cset help proc
To see the options for the proc command:
# cset proc --help
Using cpuset to implement shielding
See the cset tutorial for an in-depth discussion.
To create a shield, for example on a 4-way machine, shielding cpus 1,2,3 and leaving cpu 0 for system tasks (unshielded):
# cset shield --cpu 1-3
To move kernel threads from the root cpuset (all processors) to the system processors (unshielded cpus):
# cset shield --kthread on
To run a program in the shield, ie. on the shielded processors:
# cset shield --exec /opt/path/bin/my_code
To move a set of already running processes and threads (tasks) into the shield:
# cset shield --shield 2242,2244,3000-3100
To move a set of already running tasks in the shield out of the shield:
# cset shield --unshield 3000-3100
To destroy the shield and return all processes to the root cpuset (ie. all cpus):
# cset shield --reset
Note that all of the above long options also have corresponding short option. A nice way to experiment with shielding is to first set up a shield and then run a shell on it. Since the cpuset property is inherited for children, all processes run in that shell will be in the shield, for example:
# cset shield -c 1-3 # cset shield -e bash $ run_my_code