commit
7c9c4134b3
@ -0,0 +1,5 @@
|
|||||||
|
set nocompatible
|
||||||
|
set hlsearch
|
||||||
|
set ai
|
||||||
|
set sw=4
|
||||||
|
set expandtab
|
@ -0,0 +1,2 @@
|
|||||||
|
Alex Tsariounov <alext@novell.com>
|
||||||
|
http://www.novell.com/realtime
|
@ -0,0 +1,22 @@
|
|||||||
|
This is a distutils-based package and as such, it contains
|
||||||
|
a number of differnet installation methods. By far the most
|
||||||
|
convenient is to create an rpm. This rpm can then be later
|
||||||
|
updated or removed by the rpm packaging utility (rpm).
|
||||||
|
|
||||||
|
To create an rpm, use the following command:
|
||||||
|
|
||||||
|
python setup.py bdist_rpm
|
||||||
|
|
||||||
|
For basic installation:
|
||||||
|
|
||||||
|
python setup.py install
|
||||||
|
|
||||||
|
By default, the above command installs cpuset in the
|
||||||
|
$HOME/{bin,lib,share} directories. For a different location,
|
||||||
|
use the --prefix option:
|
||||||
|
|
||||||
|
python setup.py install --prefix=/usr
|
||||||
|
|
||||||
|
For more information:
|
||||||
|
|
||||||
|
http://docs.python.org/inst/inst.html
|
@ -0,0 +1,41 @@
|
|||||||
|
AUTHORS
|
||||||
|
COPYING
|
||||||
|
INSTALL
|
||||||
|
MANIFEST
|
||||||
|
MANIFEST.in
|
||||||
|
Makefile
|
||||||
|
README
|
||||||
|
TODO
|
||||||
|
cset
|
||||||
|
setup.cfg
|
||||||
|
setup.py
|
||||||
|
cpuset/__init__.py
|
||||||
|
cpuset/cset.py
|
||||||
|
cpuset/main.py
|
||||||
|
cpuset/task.py
|
||||||
|
cpuset/util.py
|
||||||
|
cpuset/version.py
|
||||||
|
cpuset/commands/__init__.py
|
||||||
|
cpuset/commands/common.py
|
||||||
|
cpuset/commands/mem.py
|
||||||
|
cpuset/commands/proc.py
|
||||||
|
cpuset/commands/set.py
|
||||||
|
cpuset/commands/shield.py
|
||||||
|
doc/Makefile
|
||||||
|
doc/asciidoc.conf
|
||||||
|
doc/callouts.xsl
|
||||||
|
doc/cset-proc.1
|
||||||
|
doc/cset-proc.html
|
||||||
|
doc/cset-proc.txt
|
||||||
|
doc/cset-set.1
|
||||||
|
doc/cset-set.html
|
||||||
|
doc/cset-set.txt
|
||||||
|
doc/cset-shield.1
|
||||||
|
doc/cset-shield.html
|
||||||
|
doc/cset-shield.txt
|
||||||
|
doc/cset.1
|
||||||
|
doc/cset.html
|
||||||
|
doc/cset.txt
|
||||||
|
doc/tutorial.conf
|
||||||
|
doc/tutorial.txt
|
||||||
|
t/README
|
@ -0,0 +1,3 @@
|
|||||||
|
include README Makefile MANIFEST MANIFEST.in AUTHORS COPYING INSTALL ChangeLog TODO
|
||||||
|
include t/README
|
||||||
|
include doc/*.txt doc/Makefile doc/*.conf doc/callouts.xsl doc/*.1 doc/*.html
|
@ -0,0 +1,32 @@
|
|||||||
|
PREFIX ?= $(HOME)
|
||||||
|
DESTDIR ?= /
|
||||||
|
PYTHON ?= python
|
||||||
|
|
||||||
|
all:
|
||||||
|
$(PYTHON) setup.py build
|
||||||
|
|
||||||
|
install:
|
||||||
|
$(PYTHON) setup.py install --prefix=$(PREFIX) --root=$(DESTDIR)
|
||||||
|
|
||||||
|
test:
|
||||||
|
cd t && $(MAKE) all
|
||||||
|
|
||||||
|
doc:
|
||||||
|
cd doc && $(MAKE) all
|
||||||
|
|
||||||
|
clean:
|
||||||
|
for dir in doc t; do \
|
||||||
|
(cd $$dir && $(MAKE) clean); \
|
||||||
|
done
|
||||||
|
rm -rf build
|
||||||
|
rm -f cpuset/*.pyc
|
||||||
|
rm -f cpuset/commands/*.pyc
|
||||||
|
rm -f TAGS
|
||||||
|
|
||||||
|
clobber: clean
|
||||||
|
rm -rf dist
|
||||||
|
|
||||||
|
tags:
|
||||||
|
ctags -e -R cpuset/*
|
||||||
|
|
||||||
|
.PHONY: all install doc test clean
|
@ -0,0 +1,25 @@
|
|||||||
|
Cpuset is a Python application that forms a wrapper around the
|
||||||
|
standard Linux filesystem calls to make using the cpusets facilities
|
||||||
|
in the Linux kernel easier.
|
||||||
|
|
||||||
|
For the latest version see http://opensuse.org/build_service/cpuset
|
||||||
|
Bugs or feature requests should be sent to http://bugs.opensuse.org
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 only as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
@ -0,0 +1,4 @@
|
|||||||
|
The TODO list before 1.0:
|
||||||
|
|
||||||
|
- implement test suite in tests/
|
||||||
|
|
@ -0,0 +1,5 @@
|
|||||||
|
set nocompatible
|
||||||
|
set hlsearch
|
||||||
|
set ai
|
||||||
|
set sw=4
|
||||||
|
set expandtab
|
@ -0,0 +1,23 @@
|
|||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
Substrate code and ideas taken from the excellent stgit 0.13, see
|
||||||
|
https://gna.org/projects/stgit and http://www.procode.org/stgit/
|
||||||
|
Stacked GIT is under GPL V2 or later.
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
"""
|
@ -0,0 +1,5 @@
|
|||||||
|
set nocompatible
|
||||||
|
set hlsearch
|
||||||
|
set ai
|
||||||
|
set sw=4
|
||||||
|
set expandtab
|
@ -0,0 +1,23 @@
|
|||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
Substrate code and ideas taken from the excellent stgit 0.13, see
|
||||||
|
https://gna.org/projects/stgit and http://www.procode.org/stgit/
|
||||||
|
Stacked GIT is under GPL V2 or later.
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
"""
|
@ -0,0 +1,25 @@
|
|||||||
|
"""Common functions and variables for all commands
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Command exception class
|
||||||
|
class CmdException(Exception):
|
||||||
|
pass
|
||||||
|
|
@ -0,0 +1,63 @@
|
|||||||
|
"""Memory node manipulation command
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, os, logging
|
||||||
|
from optparse import OptionParser, make_option
|
||||||
|
|
||||||
|
from cpuset.commands.common import *
|
||||||
|
from cpuset import cset
|
||||||
|
from cpuset.util import *
|
||||||
|
|
||||||
|
global log
|
||||||
|
log = logging.getLogger('mem')
|
||||||
|
|
||||||
|
help = 'create and destroy memory nodes within cpusets'
|
||||||
|
usage = """%prog [options] [cpuset name]
|
||||||
|
|
||||||
|
Create and manage memory node assignments to cpusets. Note that for
|
||||||
|
non-NUMA machines, the memory node assignment will always be 0 (zero)
|
||||||
|
and is so set by default. Thus this command only needs to be used
|
||||||
|
for NUMA machines.
|
||||||
|
"""
|
||||||
|
|
||||||
|
options = [make_option('-l', '--list',
|
||||||
|
help = 'list memory nodes in specified cpuset',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-c', '--create',
|
||||||
|
metavar = 'NODESPEC',
|
||||||
|
help = 'create a memory node in specified cpuset'),
|
||||||
|
make_option('-d', '--destroy',
|
||||||
|
help = 'destroy specified memory node in specified cpuset',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-m', '--move',
|
||||||
|
help = 'move specified memory node to specified cpuset',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-s', '--set',
|
||||||
|
metavar = 'CPUSET',
|
||||||
|
help = 'specify immediate cpuset'),
|
||||||
|
make_option('-t', '--toset',
|
||||||
|
help = 'specify destination cpuset'),
|
||||||
|
make_option('-f', '--fromset',
|
||||||
|
help = 'specify origination cpuset')
|
||||||
|
]
|
||||||
|
|
||||||
|
def func(parser, options, args):
|
||||||
|
log.debug("entering mem, options=%s, args=%s", options, args)
|
@ -0,0 +1,572 @@
|
|||||||
|
"""Process manipulation command
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, os, re, logging, pwd, grp
|
||||||
|
from optparse import OptionParser, make_option
|
||||||
|
|
||||||
|
from cpuset import cset
|
||||||
|
from cpuset.util import *
|
||||||
|
from cpuset.commands.common import *
|
||||||
|
try: from cpuset.commands import set
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
global log
|
||||||
|
log = logging.getLogger('proc')
|
||||||
|
|
||||||
|
help = 'create and manage processes within cpusets'
|
||||||
|
usage = """%prog [options] [path/program [args]]
|
||||||
|
|
||||||
|
This command is used to run and manage arbitrary processes on
|
||||||
|
specified cpusets. It is also used to move pre-existing processes
|
||||||
|
and threads to specified cpusets. You may note there is no
|
||||||
|
"kill" or "destroy" option -- use the standard OS ^C or kill
|
||||||
|
commands for that.
|
||||||
|
|
||||||
|
To list which tasks are running in a particular cpuset, use the
|
||||||
|
--list command.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
# cset proc --list --set priset
|
||||||
|
This command will list all the tasks running in the
|
||||||
|
cpuset called "priset".
|
||||||
|
|
||||||
|
Processes are created by specifying the path to the executable
|
||||||
|
and specifying the cpuset that the process is to be created in.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
# cset proc --set=blazing_cpuset --exec /usr/bin/fast_code
|
||||||
|
This command will execute the /usr/bin/fast_code program
|
||||||
|
on the "blazing_cpuset" cpuset.
|
||||||
|
|
||||||
|
The PIDSPEC argument taken for the move command is a comma
|
||||||
|
separated list of PIDs or TIDs. The list can also include
|
||||||
|
brackets of PIDs or TIDs (i.e. tasks) that are inclusive of the
|
||||||
|
endpoints.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600-700 Means processes 1, 2 and from 600 to 700
|
||||||
|
|
||||||
|
Note that the range of PIDs or TIDs does not need to have every
|
||||||
|
position populated. In other words, for the example above, if
|
||||||
|
there is only one process, say PID 57, in the range of 50-65,
|
||||||
|
then only that process will be moved.
|
||||||
|
|
||||||
|
To move a PIDSPEC to a specific cpuset, you can either specify
|
||||||
|
the PIDSPEC with --pid and the destination cpuset with --toset,
|
||||||
|
or use the short hand and list the cpuset name after the PIDSPEC
|
||||||
|
for the --move arguments.
|
||||||
|
|
||||||
|
The move command accepts multiple common calling methods.
|
||||||
|
For example, the following commands are equivalent:
|
||||||
|
# cset proc --move 2442,3000-3200 reserved_set
|
||||||
|
# cset proc --move --pid=2442,3000-3200 --toset=reserved_set
|
||||||
|
These commands move the tasks defined as 2442 and any
|
||||||
|
running task between 3000 and 3200 inclusive of the ends
|
||||||
|
to the cpuset called "reserved_set".
|
||||||
|
|
||||||
|
Specifying the --fromset is not necesary since the tasks will be
|
||||||
|
moved to the destination cpuset no matter which cpuset they are
|
||||||
|
currently running on.
|
||||||
|
|
||||||
|
Note however that if you do specify a cpuset with the --fromset
|
||||||
|
option, then only those tasks that are both in the PIDSPEC *and*
|
||||||
|
are running in the cpuset specified by --fromset will be moved.
|
||||||
|
I.e., if there is a task running on the system but not in
|
||||||
|
--fromset that is in PIDSPEC, it will not be moved.
|
||||||
|
|
||||||
|
To move all userspace tasks from one cpuset to another, you need
|
||||||
|
to specify the source and destination cpuset by name.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
# cset proc --move --fromset=comp1 --toset=comp42
|
||||||
|
This command specifies that all processes and threads
|
||||||
|
running on cpuset "comp1" be moved to cpuset "comp42".
|
||||||
|
|
||||||
|
Note that the move command will not move kernel threads unless
|
||||||
|
the -k/--kthread switch is specified. If it is, then all unbound
|
||||||
|
kernel threads will be added to the move. Unbound kernel threads
|
||||||
|
are those that can run on any CPU. If you also specify the
|
||||||
|
-a/--all switch, then all tasks, kernel or not, bound or not,
|
||||||
|
will be moved.
|
||||||
|
|
||||||
|
CAUTION: Please be cautious with the --all switch, since moving a
|
||||||
|
kernel thread that is bound to a specific CPU to a cpuset that
|
||||||
|
does not include that CPU can cause a system hang.
|
||||||
|
|
||||||
|
You must specify unique cpuset names for the both exec and move
|
||||||
|
commands. If a simple name passed to the --fromset, --toset and
|
||||||
|
--set parameters is unique on the system then that command
|
||||||
|
executes. However, if there are multiple cpusets by that name,
|
||||||
|
then you will need to specify which one you mean with a full path
|
||||||
|
rooted at the base cpuset tree.
|
||||||
|
|
||||||
|
For example, suppose you have the following cpuset tree:
|
||||||
|
/group1
|
||||||
|
/myset
|
||||||
|
/yourset
|
||||||
|
/group2
|
||||||
|
/myset
|
||||||
|
/yourset
|
||||||
|
|
||||||
|
Then, to move a process from myset in group1 to yourset in
|
||||||
|
group2, you would have to issue the following command:
|
||||||
|
# cset proc --move --pid=50 --fromset=/group1/myset \\
|
||||||
|
--toset=/group2/yourset
|
||||||
|
"""
|
||||||
|
|
||||||
|
verbose = 0
|
||||||
|
options = [make_option('-l', '--list',
|
||||||
|
help = 'list processes in the specified cpuset',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-e', '--exec',
|
||||||
|
help = 'execute arguments in the specified cpuset',
|
||||||
|
dest = 'exc',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-u', '--user',
|
||||||
|
help = 'use this USER to --exec (id or name)'),
|
||||||
|
make_option('-g', '--group',
|
||||||
|
help = 'use this GROUP to --exec (id or name)'),
|
||||||
|
make_option('-m', '--move',
|
||||||
|
help = 'move specified tasks to specified cpuset; '
|
||||||
|
'to move a PIDSPEC to a cpuset, use -m PIDSPEC cpuset; '
|
||||||
|
'to move all tasks specify --fromset and --toset',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-p', '--pid',
|
||||||
|
metavar = 'PIDSPEC',
|
||||||
|
help = 'specify pid or tid specification'),
|
||||||
|
make_option('-s', '--set',
|
||||||
|
metavar = 'CPUSET',
|
||||||
|
help = 'specify name of immediate cpuset'),
|
||||||
|
make_option('-t', '--toset',
|
||||||
|
help = 'specify name of destination cpuset'),
|
||||||
|
make_option('-f', '--fromset',
|
||||||
|
help = 'specify name of origination cpuset'),
|
||||||
|
make_option('-k', '--kthread',
|
||||||
|
help = 'move, or include moving, unbound kernel threads',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-a', '--all',
|
||||||
|
help = 'force all processes and threads to be moved',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-v', '--verbose',
|
||||||
|
help = 'prints more detailed output, additive',
|
||||||
|
action = 'count')
|
||||||
|
]
|
||||||
|
|
||||||
|
def func(parser, options, args):
|
||||||
|
log.debug("entering func, options=%s, args=%s", options, args)
|
||||||
|
|
||||||
|
global verbose
|
||||||
|
if options.verbose: verbose = options.verbose
|
||||||
|
|
||||||
|
cset.rescan()
|
||||||
|
|
||||||
|
tset = None
|
||||||
|
if options.list or options.exc:
|
||||||
|
if options.set:
|
||||||
|
tset = cset.unique_set(options.set)
|
||||||
|
elif options.toset:
|
||||||
|
tset = cset.unique_set(options.toset)
|
||||||
|
elif len(args) > 0:
|
||||||
|
tset = cset.unique_set(args[0])
|
||||||
|
if options.exc: del args[0]
|
||||||
|
else: tset = args
|
||||||
|
else:
|
||||||
|
raise CpusetException("cpuset not specified")
|
||||||
|
try:
|
||||||
|
log.debug("operating on set %s", tset.path)
|
||||||
|
except:
|
||||||
|
log.debug("operating on sets %s", tset)
|
||||||
|
|
||||||
|
if options.exc: run(tset, args, options.user, options.group)
|
||||||
|
|
||||||
|
if options.list:
|
||||||
|
list_sets(tset)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.move or options.kthread:
|
||||||
|
# first, we need to know the destination
|
||||||
|
tset = None
|
||||||
|
if options.toset:
|
||||||
|
tset = cset.unique_set(options.toset)
|
||||||
|
elif options.set:
|
||||||
|
tset = cset.unique_set(options.set)
|
||||||
|
elif len(args) > 0:
|
||||||
|
if len(args) > 1 and options.pid == None:
|
||||||
|
options.pid = args[0]
|
||||||
|
tset = cset.unique_set(args[1])
|
||||||
|
else:
|
||||||
|
tset = cset.unique_set(args[0])
|
||||||
|
else:
|
||||||
|
raise CpusetException("destination cpuset not specified")
|
||||||
|
set.active(tset)
|
||||||
|
# next, if there is a pidspec, move just that
|
||||||
|
if options.pid:
|
||||||
|
fset = None
|
||||||
|
if options.fromset and not options.all:
|
||||||
|
fset = cset.unique_set(options.fromset)
|
||||||
|
pids = pidspec_to_list(options.pid, fset)
|
||||||
|
if len(pids):
|
||||||
|
l = []
|
||||||
|
l.append('--> moving following pidspec: %s' % options.pid)
|
||||||
|
l.extend(task_detail_header(' '))
|
||||||
|
l.extend(task_detail_table(pids, ' ', 76))
|
||||||
|
log.info("\n".join(l))
|
||||||
|
selective_move(None, tset, pids, options.kthread, options.all)
|
||||||
|
log.info('done')
|
||||||
|
else:
|
||||||
|
# here we assume move everything from fromset to toset
|
||||||
|
if options.fromset == None:
|
||||||
|
raise CpusetException("origination cpuset not specified")
|
||||||
|
fset = cset.unique_set(options.fromset)
|
||||||
|
nt = len(fset.tasks)
|
||||||
|
if nt == 0:
|
||||||
|
raise CpusetException('no tasks to move from cpuset "%s"'
|
||||||
|
% fset.path)
|
||||||
|
if options.move:
|
||||||
|
log.info('--> moving all tasks from "%s" to "%s"...',
|
||||||
|
fset.path, tset.path)
|
||||||
|
selective_move(fset, tset, None, options.kthread, options.all)
|
||||||
|
else:
|
||||||
|
log.info('--> moving all kernel threads from "%s" to "%s"...',
|
||||||
|
fset.path, tset.path)
|
||||||
|
# this is a -k "move", so only move kernel threads
|
||||||
|
pids = []
|
||||||
|
for task in fset.tasks:
|
||||||
|
try: os.readlink('/proc/'+task+'/exe')
|
||||||
|
except: pids.append(task)
|
||||||
|
selective_move(fset, tset, pids, options.kthread, options.all)
|
||||||
|
log.info('done')
|
||||||
|
return
|
||||||
|
|
||||||
|
# default no options is list
|
||||||
|
list_sets(args)
|
||||||
|
|
||||||
|
def list_sets(args):
|
||||||
|
l = []
|
||||||
|
if isinstance(args, list):
|
||||||
|
for s in args: l.extend(cset.find_sets(s))
|
||||||
|
else:
|
||||||
|
l.extend(cset.find_sets(args))
|
||||||
|
for s in l:
|
||||||
|
if len(s.tasks) > 0:
|
||||||
|
if verbose:
|
||||||
|
log_detailed_task_table(s, ' ')
|
||||||
|
else:
|
||||||
|
log_detailed_task_table(s, ' ', 76)
|
||||||
|
else:
|
||||||
|
log.info(cset.summary(s))
|
||||||
|
|
||||||
|
def move(fromset, toset, plist=None):
|
||||||
|
log.debug('entering move, fromset=%s toset=%s list=%s', fromset, toset, plist)
|
||||||
|
if isinstance(fromset, str):
|
||||||
|
fset = cset.unique_set(fromset)
|
||||||
|
elif not isinstance(fromset, cset.CpuSet) and plist == None:
|
||||||
|
raise CpusetException(
|
||||||
|
"passed fromset=%s, which is not a string or CpuSet" % fromset)
|
||||||
|
else:
|
||||||
|
fset = fromset
|
||||||
|
if isinstance(toset, str):
|
||||||
|
tset = cset.unique_set(toset)
|
||||||
|
elif not isinstance(toset, cset.CpuSet):
|
||||||
|
raise CpusetException(
|
||||||
|
"passed toset=%s, which is not a string or CpuSet" % toset)
|
||||||
|
else:
|
||||||
|
tset = toset
|
||||||
|
if plist == None:
|
||||||
|
log.debug('moving default of all processes')
|
||||||
|
tset.tasks = fset.tasks
|
||||||
|
else:
|
||||||
|
tset.tasks = plist
|
||||||
|
|
||||||
|
def selective_move(fset, tset, plist=None, kthread=None, force=None):
|
||||||
|
log.debug('entering selective_move, fset=%s tset=%s plist=%s kthread=%s force=%s',
|
||||||
|
fset, tset, plist, kthread, force)
|
||||||
|
target = cset.unique_set(tset)
|
||||||
|
tasks = []
|
||||||
|
task_heap = []
|
||||||
|
task_check = []
|
||||||
|
utsk = 0
|
||||||
|
ktsk = 0
|
||||||
|
autsk = 0
|
||||||
|
aktsk = 0
|
||||||
|
utsknr = 0
|
||||||
|
ktsknr = 0
|
||||||
|
ktskb = 0
|
||||||
|
if fset:
|
||||||
|
task_check = cset.unique_set(fset).tasks
|
||||||
|
if plist:
|
||||||
|
task_heap = plist
|
||||||
|
else:
|
||||||
|
task_heap = cset.unique_set(fset).tasks
|
||||||
|
for task in task_heap:
|
||||||
|
try:
|
||||||
|
# kernel threads do not have an excutable image
|
||||||
|
os.readlink('/proc/'+task+'/exe')
|
||||||
|
autsk += 1
|
||||||
|
if fset and not force:
|
||||||
|
try:
|
||||||
|
task_check.index(task)
|
||||||
|
tasks.append(task)
|
||||||
|
utsk += 1
|
||||||
|
except:
|
||||||
|
log.debug(' task %s not running in %s, skipped',
|
||||||
|
task, fset.name)
|
||||||
|
utsknr += 1
|
||||||
|
else:
|
||||||
|
tasks.append(task)
|
||||||
|
utsk += 1
|
||||||
|
except:
|
||||||
|
aktsk += 1
|
||||||
|
try:
|
||||||
|
# this is in try because the task may not exist by the
|
||||||
|
# time we do this, in that case, just ignore it
|
||||||
|
if kthread:
|
||||||
|
if force:
|
||||||
|
tasks.append(task)
|
||||||
|
ktsk += 1
|
||||||
|
else:
|
||||||
|
if is_unbound(task):
|
||||||
|
tasks.append(task)
|
||||||
|
ktsk += 1
|
||||||
|
else:
|
||||||
|
log.debug(' kernel thread %s is bound, not adding',
|
||||||
|
task)
|
||||||
|
ktskb += 1
|
||||||
|
except:
|
||||||
|
log.debug(' kernel thread %s not found , perhaps it went away',
|
||||||
|
task)
|
||||||
|
ktsknr += 1
|
||||||
|
# ok, move 'em
|
||||||
|
log.debug('moving %d tasks to "%s"...', len(tasks), tset.name)
|
||||||
|
if len(tasks) == 0:
|
||||||
|
log.info('** no task matched move criteria')
|
||||||
|
if autsk > 0:
|
||||||
|
l = []
|
||||||
|
l.append('moving')
|
||||||
|
l.append(str(utsk))
|
||||||
|
l.append('userspace tasks')
|
||||||
|
if utsknr > 0:
|
||||||
|
l.append('- not moving')
|
||||||
|
l.append(str(utsknr))
|
||||||
|
l.append('tasks (not in fromset)')
|
||||||
|
log.info(' '.join(l))
|
||||||
|
if ktsk > 0 or kthread:
|
||||||
|
l = []
|
||||||
|
l.append('moving')
|
||||||
|
l.append(str(ktsk))
|
||||||
|
l.append('kernel threads')
|
||||||
|
if ktskb > 0:
|
||||||
|
l.append('- not moving')
|
||||||
|
l.append(str(ktskb))
|
||||||
|
l.append('threads (not unbound)')
|
||||||
|
log.info(' '.join(l))
|
||||||
|
if aktsk > 0 and force and not kthread and autsk == 0:
|
||||||
|
log.info('** not moving kernel threads since both --all and --kthread needed')
|
||||||
|
if ktsknr > 0:
|
||||||
|
l = []
|
||||||
|
l.append('--> not moving')
|
||||||
|
l.append(str(ktsknr))
|
||||||
|
l.append('tasks because they are missing (race)')
|
||||||
|
move(None, target, tasks)
|
||||||
|
|
||||||
|
def run(tset, args, usr_par=None, grp_par=None):
|
||||||
|
if isinstance(tset, str):
|
||||||
|
s = cset.unique_set(tset)
|
||||||
|
elif not isinstance(tset, cset.CpuSet):
|
||||||
|
raise CpusetException(
|
||||||
|
"passed set=%s, which is not a string or CpuSet" % tset)
|
||||||
|
else:
|
||||||
|
s = tset
|
||||||
|
log.debug('entering run, set=%s args=%s ', s.path, args)
|
||||||
|
set.active(s)
|
||||||
|
# check user
|
||||||
|
if usr_par:
|
||||||
|
try:
|
||||||
|
user = pwd.getpwnam(usr_par)[2]
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
user = pwd.getpwuid(int(usr_par))[2]
|
||||||
|
except:
|
||||||
|
raise CpusetException('unknown user: "%s"' % usr_par)
|
||||||
|
if grp_par:
|
||||||
|
try:
|
||||||
|
group = grp.getgrnam(grp_par)[2]
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
group = grp.getgrgid(int(grp_par))[2]
|
||||||
|
except:
|
||||||
|
raise CpusetException('unknown group: "%s"' % grp_par)
|
||||||
|
elif usr_par:
|
||||||
|
# if user is specified but group is not, and user is not root,
|
||||||
|
# then use the users group
|
||||||
|
if user != 0:
|
||||||
|
try:
|
||||||
|
group = grp.getgrnam('users')[2]
|
||||||
|
grp_par = True
|
||||||
|
except:
|
||||||
|
pass # just forget it
|
||||||
|
# move myself into target cpuset and exec child
|
||||||
|
move_pidspec(str(os.getpid()), s)
|
||||||
|
log.info('--> last message, executed args into cpuset "%s", new pid is: %s',
|
||||||
|
s.path, os.getpid())
|
||||||
|
# change user and group before exec
|
||||||
|
if grp_par: os.setgid(group)
|
||||||
|
if usr_par: os.setuid(user)
|
||||||
|
os.execvp(args[0], args)
|
||||||
|
|
||||||
|
def is_unbound(proc):
|
||||||
|
# FIXME: popen is slow... need to use sched_getaffinity() directly,
|
||||||
|
# but python doesn't have it... maybe use pyrex to wrap....
|
||||||
|
line = os.popen('/usr/bin/taskset -p ' + str(proc), 'r').readline()
|
||||||
|
aff = line.split()[-1]
|
||||||
|
log.debug('is_unbound, proc=%s aff=%s allcpumask=%s',
|
||||||
|
proc, aff, cset.allcpumask)
|
||||||
|
if aff == cset.allcpumask: return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def pidspec_to_list(pidspec, fset=None):
|
||||||
|
log.debug('entering pidspecToList, pidspec=%s', pidspec)
|
||||||
|
if fset:
|
||||||
|
if isinstance(fset, str): fset = cset.unique_set(fset)
|
||||||
|
elif not isinstance(fset, cset.CpuSet):
|
||||||
|
raise CpusetException("passed fset=%s, which is not a string or CpuSet" % fset)
|
||||||
|
log.debug('from-set specified as: %s', fset.path)
|
||||||
|
if not isinstance(pidspec, str):
|
||||||
|
raise CpusetException('pidspec=%s is not a string' % pidspec)
|
||||||
|
groups = pidspec.split(',')
|
||||||
|
plist = []
|
||||||
|
if fset: chktsk = fset.tasks
|
||||||
|
log.debug('parsing groups: %s', groups)
|
||||||
|
for sub in groups:
|
||||||
|
items = sub.split('-')
|
||||||
|
if len(items) == 1:
|
||||||
|
if not len(items[0]):
|
||||||
|
# two consecutive commas in pidspec, just continue processing
|
||||||
|
continue
|
||||||
|
# one pid in this group
|
||||||
|
if fset:
|
||||||
|
try:
|
||||||
|
chktsk.index(items[0])
|
||||||
|
plist.append(items[0])
|
||||||
|
log.debug(' added single pid: %s', items[0])
|
||||||
|
except:
|
||||||
|
log.debug(' task %s not running in %s, skipped', items[0], fset.name)
|
||||||
|
else:
|
||||||
|
plist.append(items[0])
|
||||||
|
log.debug(' added single pid: %s', items[0])
|
||||||
|
elif len(items) == 2:
|
||||||
|
# a range of pids, only include those that exist
|
||||||
|
rng = [str(x) for x in range(int(items[0]), int(items[1])+1)
|
||||||
|
if os.access('/proc/'+str(x), os.F_OK)]
|
||||||
|
if fset:
|
||||||
|
for tsk in rng:
|
||||||
|
try:
|
||||||
|
chktsk.index(tsk)
|
||||||
|
plist.append(tsk)
|
||||||
|
log.debug(' added task from range: %s', tsk)
|
||||||
|
except:
|
||||||
|
log.debug(' task %s not running in %s, skipped', tsk, fset.name)
|
||||||
|
else:
|
||||||
|
plist.extend(rng)
|
||||||
|
log.debug(' added range of pids from %s-%s: %s', items[0], items[1], rng)
|
||||||
|
else:
|
||||||
|
raise CpusetException('pidspec=%s has bad group=%s' % (pidspec, items))
|
||||||
|
log.debug('returning parsed pid list: %s', plist)
|
||||||
|
log.info('%s tasks match criteria', len(plist))
|
||||||
|
return plist
|
||||||
|
|
||||||
|
def move_pidspec(pidspec, toset, fset=None):
|
||||||
|
log.debug('entering move_pidspec, pidspec=%s toset=%s', pidspec, toset)
|
||||||
|
if not fset:
|
||||||
|
pids = pidspec_to_list(pidspec)
|
||||||
|
else:
|
||||||
|
# if fromset is specified, only move tasks that are in pidspec
|
||||||
|
# and are running in fromset
|
||||||
|
log.debug('specified fset=%s', fset)
|
||||||
|
pids = pidspec_to_list(pidspec, fset)
|
||||||
|
if len(pids) == 0:
|
||||||
|
raise CpusetException('tasks do not match all criteria, none moved')
|
||||||
|
move(None, toset, pids)
|
||||||
|
|
||||||
|
def task_detail(pid, width=65):
|
||||||
|
# get task details from /proc
|
||||||
|
pid = str(pid)
|
||||||
|
if not os.access('/proc/'+pid, os.F_OK):
|
||||||
|
raise CpusetException('task "%s" does not exist' % pid)
|
||||||
|
status = file('/proc/'+pid+'/status', 'r').readlines()
|
||||||
|
stdict = {}
|
||||||
|
for line in status:
|
||||||
|
try:
|
||||||
|
stdict[line.split()[0][:-1]] = line.split(':')[1].strip()
|
||||||
|
except:
|
||||||
|
pass # sometimes, we get an extra \n out of this file...
|
||||||
|
cmdline = file('/proc/'+pid+'/cmdline').readline()
|
||||||
|
# assume that a zero delimits the cmdline (it does now...)
|
||||||
|
cmdline = cmdline.replace('\0', ' ')
|
||||||
|
used = 0
|
||||||
|
out = pwd.getpwuid(int(stdict['Uid'].split()[0]))[0][:8].ljust(8)
|
||||||
|
used += 8
|
||||||
|
out += stdict['Pid'].rjust(6)
|
||||||
|
used += 6
|
||||||
|
out += stdict['PPid'].rjust(6)
|
||||||
|
used += 6
|
||||||
|
out += stdict['State'].split()[0].center(3)
|
||||||
|
used += 3
|
||||||
|
try:
|
||||||
|
os.readlink('/proc/'+pid+'/exe')
|
||||||
|
#prog = stdict['Name'] + ' '.join(cmdline.split()[1:])
|
||||||
|
prog = cmdline
|
||||||
|
except:
|
||||||
|
prog = '['+stdict['Name']+']'
|
||||||
|
if width == 0:
|
||||||
|
out += prog
|
||||||
|
else:
|
||||||
|
out += prog[:(width-used)]
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
||||||
|
def task_detail_header(indent=None):
|
||||||
|
if indent == None: istr = ""
|
||||||
|
else: istr = indent
|
||||||
|
l = []
|
||||||
|
l.append(istr + 'USER PID PPID S TASK NAME')
|
||||||
|
l.append(istr + '-------- ----- ----- - ---------')
|
||||||
|
return l
|
||||||
|
|
||||||
|
def task_detail_table(pids, indent=None, width=None):
|
||||||
|
l = []
|
||||||
|
if indent == None: istr = ""
|
||||||
|
else: istr = indent
|
||||||
|
for task in pids:
|
||||||
|
if width: l.append(istr + task_detail(task, width))
|
||||||
|
else: l.append(istr + task_detail(task, 0))
|
||||||
|
return l
|
||||||
|
|
||||||
|
def log_detailed_task_table(set, indent=None, width=None):
|
||||||
|
log.debug("entering print_detailed_task_table, set=%s indent=%s width=%s",
|
||||||
|
set.path, indent, width)
|
||||||
|
l = []
|
||||||
|
l.append(cset.summary(set))
|
||||||
|
l.extend(task_detail_header(indent))
|
||||||
|
l.extend(task_detail_table(set.tasks, indent, width))
|
||||||
|
log.info("\n".join(l))
|
||||||
|
|
@ -0,0 +1,393 @@
|
|||||||
|
"""Cpuset manipulation command
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, os, logging
|
||||||
|
from optparse import OptionParser, make_option
|
||||||
|
|
||||||
|
from cpuset import cset
|
||||||
|
from cpuset.util import *
|
||||||
|
from cpuset.commands.common import *
|
||||||
|
try: from cpuset.commands import proc
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
global log
|
||||||
|
log = logging.getLogger('set')
|
||||||
|
|
||||||
|
help = 'create, modify and destroy cpusets'
|
||||||
|
usage = """%prog [options] [cpuset name]
|
||||||
|
|
||||||
|
This command is used to create, modify, and destroy cpusets.
|
||||||
|
Cpusets form a tree-like structure rooted at the root cpuset
|
||||||
|
which always includes all system CPUs and all system memory
|
||||||
|
nodes.
|
||||||
|
|
||||||
|
A cpuset is an organizational unit that defines a group of CPUs
|
||||||
|
and a group of memory nodes where a process or thread (i.e. task)
|
||||||
|
is allowed to run on. For non-NUMA machines, the memory node is
|
||||||
|
always 0 (zero) and cannot be set to anything else. For NUMA
|
||||||
|
machines, the memory node can be set to a similar specifcation
|
||||||
|
as the CPU definition and will tie those memory nodes to that
|
||||||
|
cpuset. You will usually want the memory nodes that belong to
|
||||||
|
the CPUs defined to be in the same cpuset.
|
||||||
|
|
||||||
|
A cpuset can have exclusive right to the CPUs defined in it.
|
||||||
|
This means that only this cpuset can own these CPUs. Similarly,
|
||||||
|
a cpuset can have exclusive right to the memory nodes defined in
|
||||||
|
it. This means that only this cpuset can own these memory
|
||||||
|
nodes.
|
||||||
|
|
||||||
|
Cpusets can be specified by name or by path; however, care
|
||||||
|
should be taken when specifying by name if the name is not
|
||||||
|
unique. This tool will generally not let you do destructive
|
||||||
|
things to non-unique cpuset names.
|
||||||
|
|
||||||
|
Cpusets are uniquely specified by path. The path starts at where
|
||||||
|
the cpusets filesystem is mounted so you generally do not have to
|
||||||
|
know where that is. For example, so specify a cpuset that is
|
||||||
|
called "two" which is a subset of "one" which in turn is a subset
|
||||||
|
of the root cpuset, use the path "/one/two" regardless of where
|
||||||
|
the cpusets filesystem is mounted.
|
||||||
|
|
||||||
|
When specifying CPUs, a so-called CPUSPEC is used. The CPUSPEC
|
||||||
|
will accept a comma-separated list of CPUs and inclusive range
|
||||||
|
specifications. For example, --cpu=1,3,5-7 will assign CPU1,
|
||||||
|
CPU3, CPU5, CPU6, and CPU7 to the specified cpuset.
|
||||||
|
|
||||||
|
Note that cpusets follow certain rules. For example, children
|
||||||
|
can only include CPUs that the parents already have. If you do
|
||||||
|
not follow those rules, the kernel cpuset subsystem will not let
|
||||||
|
you create that cpuset. For example, if you create a cpuset that
|
||||||
|
contains CPU3, and then attempt to create a child of that cpuset
|
||||||
|
with a CPU other than 3, you will get an error, and the cpuset
|
||||||
|
will not be active. The error is somewhat cryptic in that it is
|
||||||
|
usually a "Permission denied" error.
|
||||||
|
|
||||||
|
Memory nodes are specified with a MEMSPEC in a similar way to
|
||||||
|
the CPUSPEC. For example, --mem=1,3-6 will assign MEM1, MEM3,
|
||||||
|
MEM4, MEM5, and MEM6 to the specified cpuset.
|
||||||
|
|
||||||
|
Note that if you attempt to create or modify a cpuset with a
|
||||||
|
memory node specification that is not valid, you may get a
|
||||||
|
cryptic error message, "No space left on device", and the
|
||||||
|
modification will not be allowed.
|
||||||
|
|
||||||
|
When you destroy a cpuset, then the tasks running in that set are
|
||||||
|
moved to the parent of that cpuset. If this is not what you
|
||||||
|
want, then manually move those tasks to the cpuset of your choice
|
||||||
|
with the 'cset proc' command (see 'cset proc --help' for more
|
||||||
|
information).
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
|
||||||
|
Create a cpuset with the default memory specification:
|
||||||
|
|
||||||
|
# cset set --cpu=2,4,6-8 --set=new_set
|
||||||
|
|
||||||
|
This command creates a cpuset called "new_set" located
|
||||||
|
off the root cpuset which holds CPUS 2,4,6,7,8 and node 0
|
||||||
|
(interleaved) memory. Note that --set is optional, and
|
||||||
|
you can just specify the name for the new cpuset after
|
||||||
|
all arguments.
|
||||||
|
|
||||||
|
Create a cpuset that specifies both CPUs and memory nodes:
|
||||||
|
|
||||||
|
# cset set --cpu=3 --mem=3 /rad/set_one
|
||||||
|
|
||||||
|
Note that this command uses the full path method to
|
||||||
|
specify the name of the new cpuset "/rad/set_one". It
|
||||||
|
also names the new cpuset implicitily (i.e. no --set
|
||||||
|
option, although you can use that if you want to). If
|
||||||
|
the "set_one" name is unique, you can subsequently refer
|
||||||
|
to is just by that. Memory node 3 is assigned to this
|
||||||
|
cpuset as well as CPU 3.
|
||||||
|
|
||||||
|
The above commands will create the new cpusets, or if they
|
||||||
|
already exist, they will modify them to the new specifications."""
|
||||||
|
|
||||||
|
verbose = 0
|
||||||
|
options = [make_option('-l', '--list',
|
||||||
|
help = 'list the named cpuset(s); recursive list if also -r; '
|
||||||
|
'members if also -a',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-c', '--cpu',
|
||||||
|
help = 'create or modify cpuset in the specified '
|
||||||
|
'cpuset with CPUSPEC specification',
|
||||||
|
metavar = 'CPUSPEC'),
|
||||||
|
make_option('-m', '--mem',
|
||||||
|
help = 'specify which memory nodes to assign '
|
||||||
|
'to the created or modified cpuset',
|
||||||
|
metavar = 'MEMSPEC'),
|
||||||
|
make_option('-d', '--destroy',
|
||||||
|
help = 'destroy specified cpuset',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-s', '--set',
|
||||||
|
metavar = 'CPUSET',
|
||||||
|
help = 'specify cpuset'),
|
||||||
|
make_option('-a', '--all',
|
||||||
|
help = 'also do listing of member cpusets',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-r', '--recurse',
|
||||||
|
help = 'do recursive listing, for use with --list',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-v', '--verbose',
|
||||||
|
help = 'prints more detailed output, additive',
|
||||||
|
action = 'count'),
|
||||||
|
make_option('--cpu_exclusive',
|
||||||
|
help = 'mark this cpuset as owning its CPUs exclusively',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('--mem_exclusive',
|
||||||
|
help = 'mark this cpuset as owning its MEMs exclusively',
|
||||||
|
action = 'store_true'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def func(parser, options, args):
|
||||||
|
log.debug("entering func, options=%s, args=%s", options, args)
|
||||||
|
global verbose
|
||||||
|
if options.verbose: verbose = options.verbose
|
||||||
|
|
||||||
|
cset.rescan()
|
||||||
|
|
||||||
|
if options.list:
|
||||||
|
if options.set:
|
||||||
|
list_sets(options.set, options.recurse, options.all)
|
||||||
|
return
|
||||||
|
if len(args): list_sets(args, options.recurse, options.all)
|
||||||
|
else: list_sets('root', options.recurse, options.all)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.cpu or options.mem:
|
||||||
|
# create or modify cpuset
|
||||||
|
create_from_options(options, args)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.destroy:
|
||||||
|
if options.set: destroy_sets(options.set)
|
||||||
|
else: destroy_sets(args)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.cpu_exclusive or options.mem_exclusive:
|
||||||
|
# modification of existing cpusets for exclusivity
|
||||||
|
return
|
||||||
|
|
||||||
|
# default behavior if no options specified is list
|
||||||
|
log.debug('no options set, default is listing cpusets')
|
||||||
|
if len(args): list_sets(args, options.recurse, options.all)
|
||||||
|
else: list_sets('root', options.recurse, options.all)
|
||||||
|
|
||||||
|
def list_sets(tset, recurse=None, members=None):
|
||||||
|
log.debug('entering list_sets, tset=%s recurse=%s', tset, recurse)
|
||||||
|
sl = []
|
||||||
|
if isinstance(tset, list):
|
||||||
|
for s in tset: sl.extend(cset.find_sets(s))
|
||||||
|
else:
|
||||||
|
sl.extend(cset.find_sets(tset))
|
||||||
|
log.debug('total unique sets in passed tset: %d', len(sl))
|
||||||
|
if recurse: members = True
|
||||||
|
if members:
|
||||||
|
sl2 = []
|
||||||
|
for s in sl:
|
||||||
|
sl2.append(s)
|
||||||
|
if len(s.subsets) > 0:
|
||||||
|
sl2.extend(s.subsets)
|
||||||
|
if recurse:
|
||||||
|
for node in s.subsets:
|
||||||
|
for nd in cset.walk_set(node):
|
||||||
|
sl2.append(nd)
|
||||||
|
sl = sl2
|
||||||
|
pl = ['']
|
||||||
|
pl.extend(set_header(' '))
|
||||||
|
for s in sl:
|
||||||
|
if verbose:
|
||||||
|
pl.append(set_details(s,' ', 0))
|
||||||
|
else:
|
||||||
|
pl.append(set_details(s,' '))
|
||||||
|
log.info("\n".join(pl))
|
||||||
|
|
||||||
|
def destroy_sets(sets):
|
||||||
|
log.debug('enter destroy_sets, sets=%s', sets)
|
||||||
|
nl = []
|
||||||
|
try:
|
||||||
|
nl.extend(sets)
|
||||||
|
except:
|
||||||
|
nl.append(sets)
|
||||||
|
# check that sets passed are ok, will raise if one is bad
|
||||||
|
for s in nl:
|
||||||
|
st = cset.unique_set(s)
|
||||||
|
if len(st.subsets) > 0:
|
||||||
|
raise CpusetException('cpuset "%s" has subsets, delete them first'
|
||||||
|
% st.path)
|
||||||
|
# ok, good to go
|
||||||
|
for s in nl:
|
||||||
|
s = cset.unique_set(s)
|
||||||
|
log.info('--> processing cpuset "%s", moving %s tasks to parent "%s"...',
|
||||||
|
s.name, len(s.tasks), s.parent.path)
|
||||||
|
proc.move(s, s.parent)
|
||||||
|
log.info('deleting cpuset "%s"', s.path)
|
||||||
|
destroy(s)
|
||||||
|
log.info('done')
|
||||||
|
|
||||||
|
def destroy(name):
|
||||||
|
log.debug('entering destroy, name=%s', name)
|
||||||
|
if isinstance(name, str):
|
||||||
|
set = cset.unique_set(name)
|
||||||
|
elif not isinstance(name, cset.CpuSet):
|
||||||
|
raise CpusetException(
|
||||||
|
"passed name=%s, which is not a string or CpuSet" % name)
|
||||||
|
else:
|
||||||
|
set = name
|
||||||
|
if len(set.tasks) > 0:
|
||||||
|
log.debug('%i tasks still running in set %s', len(set.tasks), name)
|
||||||
|
raise CpusetException(
|
||||||
|
"trying to destroy cpuset %s with tasks running" % name)
|
||||||
|
os.rmdir(cset.CpuSet.basepath+set.path)
|
||||||
|
# fixme: perhaps reparsing the all the sets is not so efficient...
|
||||||
|
cset.rescan()
|
||||||
|
|
||||||
|
def create_from_options(options, args):
|
||||||
|
log.debug('entering create_from_options, options=%s args=%s', options, args)
|
||||||
|
# figure out target cpuset name, if --set not used, use first arg
|
||||||
|
if options.set:
|
||||||
|
tset = options.set
|
||||||
|
elif len(args) > 0:
|
||||||
|
tset = args[0]
|
||||||
|
else:
|
||||||
|
raise CpusetException('cpuset not specified')
|
||||||
|
cspec = None
|
||||||
|
mspec = None
|
||||||
|
cx = None
|
||||||
|
mx = None
|
||||||
|
if options.cpu:
|
||||||
|
cset.cpuspec_check(options.cpu)
|
||||||
|
cspec = options.cpu
|
||||||
|
if options.mem:
|
||||||
|
cset.memspec_check(options.mem)
|
||||||
|
mspec = options.mem
|
||||||
|
if options.cpu_exclusive: cx = options.cpu_exclusive
|
||||||
|
if options.mem_exclusive: mx = options.mem_exclusive
|
||||||
|
try:
|
||||||
|
create(tset, cspec, mspec, cx, mx)
|
||||||
|
if not mspec: modify(tset, memspec='0') # always need at least this
|
||||||
|
log.info('--> created cpuset "%s"', tset)
|
||||||
|
except CpusetExists:
|
||||||
|
modify(tset, cspec, mspec, cx, mx)
|
||||||
|
log.info('--> modified cpuset "%s"', tset)
|
||||||
|
active(tset)
|
||||||
|
|
||||||
|
def create(name, cpuspec, memspec, cx, mx):
|
||||||
|
log.debug('entering create, name=%s cpuspec=%s memspec=%s cx=%s mx=%s',
|
||||||
|
name, cpuspec, memspec, cx, mx)
|
||||||
|
try:
|
||||||
|
cset.unique_set(name)
|
||||||
|
except CpusetNotFound:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
raise CpusetException('cpuset "%s" not unique, please specify by path' % name)
|
||||||
|
else:
|
||||||
|
raise CpusetExists('attempt to create already existing set: "%s"' % name)
|
||||||
|
# FIXME: check if name is a path here
|
||||||
|
os.mkdir(cset.CpuSet.basepath+'/'+name)
|
||||||
|
# fixme: perhaps reparsing the all the sets is not so efficient...
|
||||||
|
cset.rescan()
|
||||||
|
log.debug('created new cpuset "%s"', name)
|
||||||
|
modify(name, cpuspec, memspec, cx, mx)
|
||||||
|
|
||||||
|
def modify(name, cpuspec=None, memspec=None, cx=None, mx=None):
|
||||||
|
log.debug('entering modify, name=%s cpuspec=%s memspec=%s cx=%s mx=%s',
|
||||||
|
name, cpuspec, memspec, cx, mx)
|
||||||
|
if isinstance(name, str):
|
||||||
|
nset = cset.unique_set(name)
|
||||||
|
elif not isinstance(name, cset.CpuSet):
|
||||||
|
raise CpusetException(
|
||||||
|
"passed name=%s, which is not a string or CpuSet" % name)
|
||||||
|
else:
|
||||||
|
nset = name
|
||||||
|
log.debug('modifying cpuset "%s"', nset.name)
|
||||||
|
if cpuspec: nset.cpus = cpuspec
|
||||||
|
if memspec: nset.mems = memspec
|
||||||
|
if cx: nset.cpu_exclusive = cx
|
||||||
|
if mx: nset.mem_exclusive = mx
|
||||||
|
|
||||||
|
def active(name):
|
||||||
|
log.debug("entering active, name=%s", name)
|
||||||
|
if isinstance(name, str):
|
||||||
|
set = cset.unique_set(name)
|
||||||
|
elif not isinstance(name, cset.CpuSet):
|
||||||
|
raise CpusetException("passing bogus name=%s" % name)
|
||||||
|
else:
|
||||||
|
set = name
|
||||||
|
if set.cpus == '':
|
||||||
|
raise CpusetException('"%s" cpuset not active, no cpus defined' % set.path)
|
||||||
|
if set.mems == '':
|
||||||
|
raise CpusetException('"%s" cpuset not active, no mems defined' % set.path)
|
||||||
|
|
||||||
|
def set_header(indent=None):
|
||||||
|
if indent: istr = indent
|
||||||
|
else: istr = ''
|
||||||
|
l = []
|
||||||
|
# '1234567890-1234567890-1234567890-1234567890-1234567890'
|
||||||
|
l.append(istr + ' Name CPUs-X MEMs-X Tasks Subs Path')
|
||||||
|
l.append(istr + '------------ ---------- - ------- - ----- ---- ----------')
|
||||||
|
return l
|
||||||
|
|
||||||
|
def set_details(name, indent=None, width=75):
|
||||||
|
if isinstance(name, str):
|
||||||
|
set = cset.unique_set(name)
|
||||||
|
elif not isinstance(name, cset.CpuSet):
|
||||||
|
raise CpusetException("passing bogus set=%s" % name)
|
||||||
|
else:
|
||||||
|
set = name
|
||||||
|
if indent: istr = indent
|
||||||
|
else: istr = ''
|
||||||
|
l = []
|
||||||
|
used = 0
|
||||||
|
l.append(istr)
|
||||||
|
used += len(istr)
|
||||||
|
l.append(set.name.rjust(12))
|
||||||
|
used += 12
|
||||||
|
cs = set.cpus
|
||||||
|
if cs == '': cs = '*****'
|
||||||
|
l.append(cs.rjust(11))
|
||||||
|
used += 11
|
||||||
|
if set.cpu_exclusive:
|
||||||
|
l.append(' y')
|
||||||
|
else:
|
||||||
|
l.append(' n')
|
||||||
|
used += 2
|
||||||
|
cs = set.mems
|
||||||
|
if cs == '': cs = '*****'
|
||||||
|
l.append(cs.rjust(8))
|
||||||
|
used += 8
|
||||||
|
if set.mem_exclusive:
|
||||||
|
l.append(' y')
|
||||||
|
else:
|
||||||
|
l.append(' n')
|
||||||
|
used += 2
|
||||||
|
l.append(str(len(set.tasks)).rjust(6))
|
||||||
|
used += 6
|
||||||
|
l.append(str(len(set.subsets)).rjust(5))
|
||||||
|
used += 5
|
||||||
|
l.append(' ')
|
||||||
|
used += 1
|
||||||
|
if width == 0:
|
||||||
|
l.append(set.path)
|
||||||
|
else:
|
||||||
|
l.append(set.path[:(width-used)])
|
||||||
|
return ''.join(l)
|
@ -0,0 +1,472 @@
|
|||||||
|
"""Shield supercommand
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, os, logging
|
||||||
|
from optparse import OptionParser, make_option
|
||||||
|
|
||||||
|
from cpuset.commands.common import *
|
||||||
|
from cpuset.commands import proc
|
||||||
|
from cpuset.commands import set
|
||||||
|
from cpuset import cset
|
||||||
|
from cpuset.util import *
|
||||||
|
|
||||||
|
global log
|
||||||
|
log = logging.getLogger('shield')
|
||||||
|
|
||||||
|
help = 'supercommand to set up and manage basic shielding'
|
||||||
|
usage = """%prog [options] [path/program]
|
||||||
|
|
||||||
|
This is a supercommand that creates basic cpu shielding. The
|
||||||
|
normal cset commands can of course be used to create this basic
|
||||||
|
shield, but the shield command combines many such commands to
|
||||||
|
create and manage a common type of cpu shielding setup.
|
||||||
|
|
||||||
|
The concept of shielding implies at minimum three cpusets, for
|
||||||
|
example: root, user and system. The root cpuset always exists in
|
||||||
|
all implementations of cpusets and contains all available CPUs on
|
||||||
|
the machine. The system cpuset is so named because normal system
|
||||||
|
tasks are made to run on it. The user cpuset is so named because
|
||||||
|
that is the "shielded" cpuset on which you would run your tasks
|
||||||
|
of interest.
|
||||||
|
|
||||||
|
Usually, CPU zero would be in the system set and the rest of the
|
||||||
|
CPUs would be in the user set. After creation of the cpusets,
|
||||||
|
all processes running in the root cpuset are moved to the system
|
||||||
|
cpuset. Thus any new processes or threads spawned from these
|
||||||
|
processes will also run the system cpuset.
|
||||||
|
|
||||||
|
If the optional --kthread=on option is given to the shield
|
||||||
|
command, then all kernel threads (with exception of the per-CPU
|
||||||
|
bound interrupt kernel threads) are also moved to the system set.
|
||||||
|
|
||||||
|
One executes processes on the shielded user cpuset with the
|
||||||
|
--exec subcommand or moves processes or threads to the shielded
|
||||||
|
cpuset with the --shield subcommand. Note that you do not need to
|
||||||
|
specify which cpuset a process or thread is running in initially
|
||||||
|
when using the --shield subcommand.
|
||||||
|
|
||||||
|
To create a shield, you would execute the shield command with the
|
||||||
|
--cpu option that specifies CPUSPEC argument that assigns CPUs to
|
||||||
|
be under the shield (this means assigned to the user cpuset, all
|
||||||
|
other cpus will be assigned to the system set).
|
||||||
|
|
||||||
|
For example:
|
||||||
|
# cset shield --cpu=3
|
||||||
|
On a 4-way machine, this command will dedicate the first
|
||||||
|
3 processors, CPU0-CPU2, for the system set (unshielded)
|
||||||
|
and only the last processor, CPU3, for the user set
|
||||||
|
(shielded).
|
||||||
|
|
||||||
|
The CPUSPEC will accept a comma separated list of CPUs and
|
||||||
|
inclusive range specifications. For example, --cpu=1,3,5-7 will
|
||||||
|
assign CPU1, CPU3, CPU5, CPU6, and CPU7 to the user (or shielded)
|
||||||
|
cpuset.
|
||||||
|
|
||||||
|
If you do not like the names "system" and "user" for the
|
||||||
|
unshielded and shielded sets respectively, or if those names are
|
||||||
|
used already, then use the --sysset and --userset options.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
# cset shield --sysset=free --userset=cage --cpu=2,3 --kthread=on
|
||||||
|
|
||||||
|
The above command will use the name "free" for the unshielded
|
||||||
|
system cpuset, the name "cage" for the shielded user cpuset,
|
||||||
|
initialize these cpusets and dedicate CPU0 and CPU1 to the "free"
|
||||||
|
set and (on a 4-way machine) dedicate CPU2 and CPU3 to the "cage"
|
||||||
|
set. Further, the command moves all processes and threads,
|
||||||
|
including kernel threads from the root cpuset to the "free"
|
||||||
|
cpuset. Note however that if you do use the --syset/--userset
|
||||||
|
options, then you must continue to use those for every invocation
|
||||||
|
of the shield supercommand.
|
||||||
|
|
||||||
|
After initialization, you can run the process of interest on the
|
||||||
|
shielded cpuset with the --exec subcommand, or move processes or
|
||||||
|
threads already running to the shielded cpuset with the --shield
|
||||||
|
subcommand.
|
||||||
|
|
||||||
|
The PIDSPEC argument taken for the --shield (or -s) subcommand is
|
||||||
|
a comma separated list of PIDs or TIDs. The list can also
|
||||||
|
include brackets of PIDs or TIDs that are inclusive of the
|
||||||
|
endpoints.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600-700 Means processes 1, 2 and from 600 to 700
|
||||||
|
|
||||||
|
# cset shield --shield=50-65
|
||||||
|
This command moves all processes and threads with PID or
|
||||||
|
TID in the range 50-65 inclusive, from any cpuset they may
|
||||||
|
be running in into the shielded user cpuset.
|
||||||
|
|
||||||
|
Note that the range of PIDs or TIDs does not need to have every
|
||||||
|
position populated. In other words, for the example above, if
|
||||||
|
there is only one process, say PID 57, in the range of 50-65,
|
||||||
|
then only that process will be moved.
|
||||||
|
|
||||||
|
DANGER: Please note that there is no checking of processes you
|
||||||
|
request to move into the shield with the --shield command. This
|
||||||
|
means that the tool will happily move, for example, kernel
|
||||||
|
threads that are bound to specific CPUs with this command. You
|
||||||
|
can hang your system by indiscriminately specifying arbitrary
|
||||||
|
PIDs to the --shield command so please be careful.
|
||||||
|
|
||||||
|
The --unshield (or -u) subcommand will remove the specified
|
||||||
|
processes or threads from the shielded cpuset and move them into
|
||||||
|
the unshielded (or system) cpuset. This option also takes a
|
||||||
|
PIDSPEC argument, the same as for the --shield subcommand.
|
||||||
|
|
||||||
|
Both the --shield and the --unshield commands will also finally
|
||||||
|
output the number of tasks running in the shield and out of the
|
||||||
|
shield. If you do not specify a PIDSPEC to these commands, then
|
||||||
|
just that status is output. By specifying also a --verbose in
|
||||||
|
addition, then you will get a listing of every task that is
|
||||||
|
running in either the shield or out of the shield.
|
||||||
|
|
||||||
|
Using no subcommand, ie. only "cset shield", will output the
|
||||||
|
status of both shield and non-shield. Tasks will be listed if
|
||||||
|
--verbose is used.
|
||||||
|
|
||||||
|
You can adjust which CPUs are in the shielded cpuset by issuing
|
||||||
|
the --cpu subcommand again anytime after the shield has been
|
||||||
|
initialized.
|
||||||
|
|
||||||
|
For example if the original shield contained CPU0 and CPU1 in the
|
||||||
|
system set and CPU2 and CPU3 in the user set, if you then issue
|
||||||
|
the following command:
|
||||||
|
|
||||||
|
# cset shield --cpu=1,2,3
|
||||||
|
|
||||||
|
then that command will move CPU1 into the shielded "user" cpuset.
|
||||||
|
Any processes or threads that were running on CPU1 that belonged
|
||||||
|
to the unshielded "system" cpuset are migrated to CPU0 by the
|
||||||
|
system.
|
||||||
|
|
||||||
|
The --reset subcommand will in essence destroy the shield. For
|
||||||
|
example, if there was a shield on a 4-way machine with CPU0 in
|
||||||
|
system and CPUs 1-3 in user with processes running on the user
|
||||||
|
cpuset (i.e. in the shield), and a --reset subcommand was issued,
|
||||||
|
then all processes running in both system and user cpusets would
|
||||||
|
be migrated to the root cpuset (which has access to all CPUs and
|
||||||
|
never goes away), after which both system and user cpusets would
|
||||||
|
be destroyed.
|
||||||
|
|
||||||
|
Note that even though you can mix general usage of cpusets with
|
||||||
|
the shielding concepts described here, you generally will not
|
||||||
|
want to. For more complex shielding or usage scenarios, one
|
||||||
|
would generally use the normal cpuset commands (i.e. cset set
|
||||||
|
and proc) directly."""
|
||||||
|
|
||||||
|
USR_SET = '/user'
|
||||||
|
SYS_SET = '/system'
|
||||||
|
verbose = 0
|
||||||
|
|
||||||
|
# callback for --shield/--unshield, allows optional argument
|
||||||
|
# if no arg, then status of either shield or unshield is displayed
|
||||||
|
def shield_cb(option, opt_str, value, parser):
|
||||||
|
if value == None:
|
||||||
|
try:
|
||||||
|
arg = parser.rargs[0]
|
||||||
|
if arg[0] != '-':
|
||||||
|
# assign and consume argument
|
||||||
|
value = arg
|
||||||
|
del parser.rargs[0]
|
||||||
|
else:
|
||||||
|
value = True
|
||||||
|
except IndexError, err:
|
||||||
|
# no further arguments
|
||||||
|
value = True
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
setattr(parser.values, option.dest, value)
|
||||||
|
|
||||||
|
options = [make_option('-c', '--cpu',
|
||||||
|
metavar = 'CPUSPEC',
|
||||||
|
help = 'modifies or initializes the shield cpusets'),
|
||||||
|
make_option('-r', '--reset',
|
||||||
|
help = 'destroys the shield',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-e', '--exec',
|
||||||
|
help = 'executes args in the shield',
|
||||||
|
dest = 'exc',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('--user',
|
||||||
|
help = 'use this USER for --exec (id or name)'),
|
||||||
|
make_option('--group',
|
||||||
|
help = 'use this GROUP for --exec (id or name)'),
|
||||||
|
make_option('-s', '--shield',
|
||||||
|
action = 'callback',
|
||||||
|
callback=shield_cb,
|
||||||
|
dest = 'shield',
|
||||||
|
metavar = 'PIDSPEC',
|
||||||
|
help = 'shield specified PIDSPEC of processes or threads'),
|
||||||
|
make_option('-u', '--unshield',
|
||||||
|
action = 'callback',
|
||||||
|
callback=shield_cb,
|
||||||
|
dest = 'unshield',
|
||||||
|
metavar = 'PIDSPEC',
|
||||||
|
help = 'remove specified PIDSPEC of processes or threads from shield'),
|
||||||
|
make_option('-k', '--kthread',
|
||||||
|
metavar = 'on|off',
|
||||||
|
choices = ['on', 'off'],
|
||||||
|
help = 'shield from unbound interrupt threads as well'),
|
||||||
|
make_option('-f', '--force',
|
||||||
|
help = 'force operation, use with care',
|
||||||
|
action = 'store_true'),
|
||||||
|
make_option('-v', '--verbose',
|
||||||
|
help = 'prints more detailed output, additive',
|
||||||
|
action = 'count'),
|
||||||
|
make_option('--sysset',
|
||||||
|
help = 'optionally specify system cpuset name'),
|
||||||
|
make_option('--userset',
|
||||||
|
help = 'optionally specify user cpuset name')
|
||||||
|
]
|
||||||
|
|
||||||
|
def func(parser, options, args):
|
||||||
|
log.debug("entering shield, options=%s, args=%s", options, args)
|
||||||
|
global verbose
|
||||||
|
if options.verbose: verbose = options.verbose
|
||||||
|
cset.rescan()
|
||||||
|
|
||||||
|
if options.sysset:
|
||||||
|
global SYS_SET
|
||||||
|
SYS_SET = options.sysset
|
||||||
|
if options.userset:
|
||||||
|
global USR_SET
|
||||||
|
USR_SET = options.userset
|
||||||
|
|
||||||
|
if (not options.cpu and not options.reset and not options.exc and
|
||||||
|
not options.shield and not options.unshield and not options.kthread):
|
||||||
|
shield_exists()
|
||||||
|
if len(args) == 0:
|
||||||
|
log.info("--> shielding system active with")
|
||||||
|
print_all_stats()
|
||||||
|
else:
|
||||||
|
exec_args(args, options.user, options.group)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.reset:
|
||||||
|
reset_shield()
|
||||||
|
return
|
||||||
|
|
||||||
|
# note that the following options fall through to others
|
||||||
|
# to allow for multiple options/commands on one cmdline
|
||||||
|
if options.cpu: make_shield(options.cpu, options.kthread)
|
||||||
|
|
||||||
|
elif options.kthread: make_kthread(options.kthread)
|
||||||
|
|
||||||
|
if options.exc: exec_args(args, options.user, options.group)
|
||||||
|
|
||||||
|
if options.shield:
|
||||||
|
shield_exists()
|
||||||
|
try:
|
||||||
|
log.info('--> shielding following pidspec: %s', options.shield)
|
||||||
|
if options.force:
|
||||||
|
proc.move_pidspec(options.shield, USR_SET)
|
||||||
|
else:
|
||||||
|
proc.move_pidspec(options.shield, USR_SET, SYS_SET)
|
||||||
|
log.info('done')
|
||||||
|
except Exception, err:
|
||||||
|
if str(err).find('Permission denied') != -1:
|
||||||
|
raise
|
||||||
|
if options.shield != True:
|
||||||
|
log.info(err)
|
||||||
|
log.info('--> bad pidspec: %s, shield state is:', options.shield)
|
||||||
|
else:
|
||||||
|
log.info('--> shielded state is:')
|
||||||
|
print_usr_stats()
|
||||||
|
|
||||||
|
if options.unshield:
|
||||||
|
shield_exists()
|
||||||
|
try:
|
||||||
|
log.info('--> unshielding following pidspec: %s', options.unshield)
|
||||||
|
if options.force:
|
||||||
|
proc.move_pidspec(options.unshield, SYS_SET)
|
||||||
|
else:
|
||||||
|
proc.move_pidspec(options.unshield, SYS_SET, USR_SET)
|
||||||
|
log.info('done')
|
||||||
|
except Exception, err:
|
||||||
|
if str(err).find('Permission denied') != -1:
|
||||||
|
raise
|
||||||
|
if options.unshield != True:
|
||||||
|
log.info('--> bad pidspec: %s, unshielded state is:', options.unshield)
|
||||||
|
else:
|
||||||
|
log.info('--> not shielded state is:')
|
||||||
|
print_sys_stats()
|
||||||
|
|
||||||
|
def print_all_stats():
|
||||||
|
print_sys_stats()
|
||||||
|
print_usr_stats()
|
||||||
|
|
||||||
|
def print_sys_stats():
|
||||||
|
if verbose and len(cset.unique_set(SYS_SET).tasks) > 0:
|
||||||
|
if verbose == 1:
|
||||||
|
proc.log_detailed_task_table(cset.unique_set(SYS_SET), ' ', 76)
|
||||||
|
else:
|
||||||
|
proc.log_detailed_task_table(cset.unique_set(SYS_SET), ' ')
|
||||||
|
else:
|
||||||
|
log.info(cset.summary(cset.unique_set(SYS_SET)))
|
||||||
|
|
||||||
|
def print_usr_stats():
|
||||||
|
if verbose and len(cset.unique_set(USR_SET).tasks) > 0:
|
||||||
|
if verbose == 1:
|
||||||
|
proc.log_detailed_task_table(cset.unique_set(USR_SET), ' ', 76)
|
||||||
|
else:
|
||||||
|
proc.log_detailed_task_table(cset.unique_set(USR_SET), ' ')
|
||||||
|
else:
|
||||||
|
log.info(cset.summary(cset.unique_set(USR_SET)))
|
||||||
|
|
||||||
|
def shield_exists():
|
||||||
|
try:
|
||||||
|
cset.unique_set(USR_SET)
|
||||||
|
cset.unique_set(SYS_SET)
|
||||||
|
return True
|
||||||
|
except CpusetNotFound:
|
||||||
|
log.info('can\'t find "%s" and "%s" cpusets on system...', SYS_SET, USR_SET)
|
||||||
|
raise CpusetException('--> shielding not active on system')
|
||||||
|
|
||||||
|
def reset_shield():
|
||||||
|
log.info("--> deactivating/reseting shielding")
|
||||||
|
shield_exists()
|
||||||
|
tasks = cset.unique_set(USR_SET).tasks
|
||||||
|
log.info('moving %s tasks from "%s" user set to root set...',
|
||||||
|
len(tasks), USR_SET)
|
||||||
|
proc.move(USR_SET, 'root')
|
||||||
|
tasks = cset.unique_set(SYS_SET).tasks
|
||||||
|
log.info('moving %s tasks from "%s" system set to root set...',
|
||||||
|
len(tasks), SYS_SET)
|
||||||
|
proc.move(SYS_SET, 'root')
|
||||||
|
log.info('deleting "%s" and "%s" sets', USR_SET, SYS_SET)
|
||||||
|
set.destroy(USR_SET)
|
||||||
|
set.destroy(SYS_SET)
|
||||||
|
log.info('done')
|
||||||
|
|
||||||
|
def make_shield(cpuspec, kthread):
|
||||||
|
memspec = '0' # FIXME: for numa, we probably want a more intelligent scheme
|
||||||
|
log.debug("entering make_shield, cpuspec=%s kthread=%s", cpuspec, kthread)
|
||||||
|
# create base cpusets for shield
|
||||||
|
cset.cpuspec_check(cpuspec)
|
||||||
|
cpuspec_inv = cset.cpuspec_inverse(cpuspec)
|
||||||
|
try:
|
||||||
|
shield_exists()
|
||||||
|
except:
|
||||||
|
log.debug("shielding does not exist, creating")
|
||||||
|
try:
|
||||||
|
set.create(USR_SET, cpuspec, memspec, True, False)
|
||||||
|
set.create(SYS_SET, cpuspec_inv, memspec, True, False)
|
||||||
|
except Exception, instance:
|
||||||
|
# unroll
|
||||||
|
try: set.destroy(USR_SET)
|
||||||
|
except: pass
|
||||||
|
try: set.destroy(SYS_SET)
|
||||||
|
except: pass
|
||||||
|
log.critical('--> failed to create shield, hint: do other cpusets exist?')
|
||||||
|
raise instance
|
||||||
|
log.info('--> activating shielding:')
|
||||||
|
else:
|
||||||
|
log.debug("shielding exists, modifying cpuspec")
|
||||||
|
# note, since we're going to modify the cpu assigments to these sets,
|
||||||
|
# they cannot be exclusive, the following modify() calls will make
|
||||||
|
# them exclusive again
|
||||||
|
cset.unique_set(USR_SET).cpu_exclusive = False
|
||||||
|
cset.unique_set(SYS_SET).cpu_exclusive = False
|
||||||
|
set.modify(USR_SET, cpuspec, memspec, False, False)
|
||||||
|
set.modify(SYS_SET, cpuspec_inv, memspec, False, False)
|
||||||
|
# reset cpu exlusivity
|
||||||
|
cset.unique_set(USR_SET).cpu_exclusive = True
|
||||||
|
cset.unique_set(SYS_SET).cpu_exclusive = True
|
||||||
|
log.info('--> shielding modified with:')
|
||||||
|
# move root tasks into system set
|
||||||
|
root_tasks = cset.unique_set('/').tasks
|
||||||
|
log.debug("number of root tasks are: %s", len(root_tasks))
|
||||||
|
# figure out what in root set is not a kernel thread
|
||||||
|
tasks = []
|
||||||
|
for task in root_tasks:
|
||||||
|
try:
|
||||||
|
os.readlink('/proc/'+task+'/exe')
|
||||||
|
tasks.append(task)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if len(tasks) != 0:
|
||||||
|
log.info("moving %s tasks from root into system cpuset...", len(tasks))
|
||||||
|
proc.move('root', SYS_SET, tasks)
|
||||||
|
# move kernel theads into system set if asked for
|
||||||
|
if kthread == 'on':
|
||||||
|
root_tasks = cset.unique_set('/').tasks
|
||||||
|
tasks = []
|
||||||
|
for task in root_tasks:
|
||||||
|
try:
|
||||||
|
if proc.is_unbound(task): tasks.append(task)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if len(tasks) != 0:
|
||||||
|
log.info("kthread shield activated, moving %s tasks into system cpuset...",
|
||||||
|
len(tasks))
|
||||||
|
proc.move('root', SYS_SET, tasks)
|
||||||
|
# print out stats
|
||||||
|
print_all_stats()
|
||||||
|
|
||||||
|
def make_kthread(state):
|
||||||
|
log.debug("entering make_kthread, state=%s", state)
|
||||||
|
shield_exists()
|
||||||
|
if state == 'on':
|
||||||
|
log.info('--> activating kthread shielding')
|
||||||
|
root_tasks = cset.unique_set('/').tasks
|
||||||
|
log.debug('root set has %d tasks, checking for unbound',
|
||||||
|
len(root_tasks))
|
||||||
|
tasks = []
|
||||||
|
for task in root_tasks:
|
||||||
|
try:
|
||||||
|
if proc.is_unbound(task): tasks.append(task)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if len(tasks) != 0:
|
||||||
|
log.debug("total root tasks %s", len(root_tasks))
|
||||||
|
log.info("kthread shield activated, moving %s tasks into system cpuset...",
|
||||||
|
len(tasks))
|
||||||
|
proc.move('root', SYS_SET, tasks)
|
||||||
|
if verbose == 1:
|
||||||
|
proc.log_detailed_task_table(tasks, ' ', 76)
|
||||||
|
elif verbose > 1:
|
||||||
|
proc.log_detailed_task_table(tasks, ' ')
|
||||||
|
else:
|
||||||
|
log.info('--> deactivating kthread shielding')
|
||||||
|
usr_tasks = cset.unique_set(SYS_SET).tasks
|
||||||
|
tasks = []
|
||||||
|
for task in usr_tasks:
|
||||||
|
try:
|
||||||
|
os.readlink('/proc/'+task+'/exe')
|
||||||
|
except:
|
||||||
|
tasks.append(task)
|
||||||
|
if len(tasks) != 0:
|
||||||
|
log.info("moving %s tasks into root cpuset...", len(tasks))
|
||||||
|
proc.move(SYS_SET, '/', tasks)
|
||||||
|
if verbose == 1:
|
||||||
|
proc.log_detailed_task_table(tasks, ' ', 76)
|
||||||
|
elif verbose > 1:
|
||||||
|
proc.log_detailed_task_table(tasks, ' ')
|
||||||
|
log.info('done')
|
||||||
|
|
||||||
|
def exec_args(args, upar, gpar):
|
||||||
|
log.debug("entering exec_args, args=%s", args)
|
||||||
|
shield_exists()
|
||||||
|
proc.run(USR_SET, args, upar, gpar)
|
||||||
|
|
@ -0,0 +1,432 @@
|
|||||||
|
"""Cpuset class and cpuset graph, importing module will create model
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os, re, sys, logging
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.path.insert(0, "..")
|
||||||
|
logging.basicConfig()
|
||||||
|
|
||||||
|
from cpuset.util import *
|
||||||
|
global log
|
||||||
|
log = logging.getLogger('cset')
|
||||||
|
|
||||||
|
class CpuSet(object):
|
||||||
|
# sets is a class variable dict that keeps track of all
|
||||||
|
# cpusets discovered such that we can link them in properly.
|
||||||
|
# The basepath is it's base path, the sets are indexed via
|
||||||
|
# a relative path from this basepath.
|
||||||
|
sets = {}
|
||||||
|
basepath = ''
|
||||||
|
|
||||||
|
def __init__(self, path=None):
|
||||||
|
log.debug("initializing CpuSet")
|
||||||
|
if (path == None):
|
||||||
|
# recursively find all cpusets and link together
|
||||||
|
# note: a breadth-first search could do this in one
|
||||||
|
# pass, but there are never many cpusets, so
|
||||||
|
# that optimization is left for the future
|
||||||
|
log.debug("finding all cpusets")
|
||||||
|
path = self.locate_cpusets()
|
||||||
|
CpuSet.basepath = path
|
||||||
|
log.debug("creating root node at %s", path)
|
||||||
|
self.__root = True
|
||||||
|
self.name = 'root'
|
||||||
|
self.path = '/'
|
||||||
|
self.parent = self
|
||||||
|
if (CpuSet.sets):
|
||||||
|
del CpuSet.sets
|
||||||
|
CpuSet.sets = {}
|
||||||
|
CpuSet.sets[self.path] = self
|
||||||
|
# bottom-up search otherwise links will not exist
|
||||||
|
log.debug("starting bottom-up discovery walk...")
|
||||||
|
for dir, dirs, files in os.walk(path, topdown=False):
|
||||||
|
log.debug("*** walking %s", dir)
|
||||||
|
if dir != CpuSet.basepath:
|
||||||
|
node = CpuSet(dir)
|
||||||
|
else:
|
||||||
|
node = self
|
||||||
|
node.subsets = []
|
||||||
|
for sub in dirs:
|
||||||
|
if len(sub) > 0:
|
||||||
|
relpath = os.path.join(dir,sub).replace(CpuSet.basepath, '')
|
||||||
|
else:
|
||||||
|
relpath = '/'
|
||||||
|
node.subsets.append(CpuSet.sets[relpath])
|
||||||
|
log.debug("%s has %i subsets: [%s]", dir,
|
||||||
|
len(node.subsets), '|'.join(dirs))
|
||||||
|
|
||||||
|
log.debug("staring top-down parenting walk...")
|
||||||
|
for dir, dirs, files in os.walk(path):
|
||||||
|
dir = dir.replace(CpuSet.basepath, '')
|
||||||
|
if len(dir) == 0: dir = '/'
|
||||||
|
node = CpuSet.sets[dir]
|
||||||
|
log.debug("~~~ walking %s", node.path)
|
||||||
|
if dir == '/':
|
||||||
|
log.debug("parent is self (root cpuset), skipping")
|
||||||
|
else:
|
||||||
|
parpath = dir[0:dir.rfind('/')]
|
||||||
|
log.debug('parpath decodes to: %s from dir of: %s', parpath, dir)
|
||||||
|
if CpuSet.sets.has_key(parpath):
|
||||||
|
log.debug("parent is %s", parpath)
|
||||||
|
node.parent = CpuSet.sets[parpath]
|
||||||
|
else:
|
||||||
|
log.debug("parent is root cpuset")
|
||||||
|
node.parent = CpuSet.sets['/']
|
||||||
|
log.debug("found %i cpusets", len(CpuSet.sets))
|
||||||
|
else:
|
||||||
|
# one new cpuset node
|
||||||
|
log.debug("new cpuset node absolute: %s", path)
|
||||||
|
if len(path) > len(CpuSet.basepath):
|
||||||
|
path = path.replace(CpuSet.basepath, '')
|
||||||
|
else:
|
||||||
|
path = '/'
|
||||||
|
log.debug(" relative: %s", path)
|
||||||
|
if CpuSet.sets.has_key(path):
|
||||||
|
log.debug("the cpuset %s already exists, skipping", path)
|
||||||
|
self = CpuSet.sets[path] # questionable....
|
||||||
|
return
|
||||||
|
cpus = CpuSet.basepath + path + "/cpus"
|
||||||
|
if not os.access(cpus, os.F_OK):
|
||||||
|
# not a cpuset directory
|
||||||
|
str = '%s is not a cpuset directory' % (CpuSet.basepath + path)
|
||||||
|
log.error(str)
|
||||||
|
raise CpusetException(str)
|
||||||
|
self.__root = False
|
||||||
|
self.read_cpuset(path)
|
||||||
|
CpuSet.sets[path] = self
|
||||||
|
|
||||||
|
def locate_cpusets(self):
|
||||||
|
log.debug("locating cpuset filesystem...")
|
||||||
|
cpuset = re.compile(r"none (/.+) cpuset .+")
|
||||||
|
cgroup = re.compile(r"none (/.+) cgroup .+")
|
||||||
|
path = None
|
||||||
|
f = file("/proc/mounts")
|
||||||
|
for line in f:
|
||||||
|
res = cpuset.search(line)
|
||||||
|
if res:
|
||||||
|
path = res.group(1)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if cgroup.search(line):
|
||||||
|
groups = line.split()
|
||||||
|
if re.search("cpuset", groups[3]):
|
||||||
|
path = groups[1]
|
||||||
|
break
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
if not path:
|
||||||
|
# mounted cpusets not found, so mount them
|
||||||
|
# FIXME: provide default mount directory from config file
|
||||||
|
if not os.access("/cpusets", os.F_OK):
|
||||||
|
os.mkdir("/cpusets")
|
||||||
|
ret = os.system("mount -t cpuset none /cpusets")
|
||||||
|
if ret:
|
||||||
|
raise CpusetException(
|
||||||
|
'mount of cpuset filesystem failed, do you have permission?')
|
||||||
|
path = "/cpusets"
|
||||||
|
log.debug("cpusets mounted at: " + path)
|
||||||
|
return path
|
||||||
|
|
||||||
|
def read_cpuset(self, path):
|
||||||
|
log.debug("reading cpuset passed relpath: %s", path)
|
||||||
|
self.path = path
|
||||||
|
log.debug("...path=%s", path)
|
||||||
|
self.name = path[path.rfind('/')+1:]
|
||||||
|
log.debug("...name=%s", self.name)
|
||||||
|
|
||||||
|
# Properties of cpuset node
|
||||||
|
def delprop(self):
|
||||||
|
raise AttributeError, "deletion of properties not allowed"
|
||||||
|
|
||||||
|
def getcpus(self):
|
||||||
|
f = file(CpuSet.basepath+self.path+"/cpus")
|
||||||
|
return f.readline()[:-1]
|
||||||
|
def setcpus(self, newval):
|
||||||
|
cpuspec_check(newval)
|
||||||
|
f = file(CpuSet.basepath+self.path+"/cpus",'w')
|
||||||
|
f.write(str(newval))
|
||||||
|
f.close()
|
||||||
|
log.debug("-> prop_set %s.cpus = %s", self.path, newval)
|
||||||
|
cpus = property(fget=getcpus, fset=setcpus, fdel=delprop, doc="CPU specifier")
|
||||||
|
|
||||||
|
def getmems(self):
|
||||||
|
f = file(CpuSet.basepath+self.path+"/mems")
|
||||||
|
return f.readline()[:-1]
|
||||||
|
def setmems(self, newval):
|
||||||
|
# FIXME: check format for correctness
|
||||||
|
f = file(CpuSet.basepath+self.path+"/mems",'w')
|
||||||
|
f.write(str(newval))
|
||||||
|
f.close()
|
||||||
|
log.debug("-> prop_set %s.mems = %s", self.path, newval)
|
||||||
|
mems = property(getmems, setmems, delprop, "Mem node specifier")
|
||||||
|
|
||||||
|
def getcpuxlsv(self):
|
||||||
|
f = file(CpuSet.basepath+self.path+"/cpu_exclusive")
|
||||||
|
if f.readline()[:-1] == '1':
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
def setcpuxlsv(self, newval):
|
||||||
|
log.debug("-> prop_set %s.cpu_exclusive = %s", self.path, newval)
|
||||||
|
f = file(CpuSet.basepath+self.path+"/cpu_exclusive",'w')
|
||||||
|
if newval:
|
||||||
|
f.write('1')
|
||||||
|
else:
|
||||||
|
f.write('0')
|
||||||
|
f.close()
|
||||||
|
cpu_exclusive = property(getcpuxlsv, setcpuxlsv, delprop,
|
||||||
|
"CPU exclusive flag")
|
||||||
|
|
||||||
|
def getmemxlsv(self):
|
||||||
|
f = file(CpuSet.basepath+self.path+"/mem_exclusive")
|
||||||
|
if f.readline()[:-1] == '1':
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
def setmemxlsv(self, newval):
|
||||||
|
log.debug("-> prop_set %s.mem_exclusive = %s", self.path, newval)
|
||||||
|
f = file(CpuSet.basepath+self.path+"/mem_exclusive",'w')
|
||||||
|
if newval:
|
||||||
|
f.write('1')
|
||||||
|
else:
|
||||||
|
f.write('0')
|
||||||
|
f.close()
|
||||||
|
mem_exclusive = property(getmemxlsv, setmemxlsv, delprop,
|
||||||
|
"Memory exclusive flag")
|
||||||
|
|
||||||
|
def gettasks(self):
|
||||||
|
f = file(CpuSet.basepath+self.path+"/tasks")
|
||||||
|
lst = []
|
||||||
|
for task in f: lst.append(task[:-1])
|
||||||
|
return lst
|
||||||
|
def settasks(self, tasklist):
|
||||||
|
if len(tasklist) > 3:
|
||||||
|
pb = ProgressBar(len(tasklist), '=')
|
||||||
|
tick = 0
|
||||||
|
prog = True
|
||||||
|
else:
|
||||||
|
prog = False
|
||||||
|
for task in tasklist:
|
||||||
|
try:
|
||||||
|
f = file(CpuSet.basepath+self.path+"/tasks",'w')
|
||||||
|
f.write(task)
|
||||||
|
f.close()
|
||||||
|
except Exception, err:
|
||||||
|
if str(err).find('Permission denied') != -1:
|
||||||
|
raise
|
||||||
|
# if here, means process is already gone, racy stuff...
|
||||||
|
if prog:
|
||||||
|
tick += 1
|
||||||
|
pb(tick)
|
||||||
|
log.debug("-> prop_set %s.tasks set with %s tasks", self.path,
|
||||||
|
len(tasklist))
|
||||||
|
tasks = property(gettasks, settasks, delprop, "Task list")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Helper functions
|
||||||
|
#
|
||||||
|
|
||||||
|
def unique_set(name):
|
||||||
|
"""find a unique cpuset by name or path, raise if multiple sets found"""
|
||||||
|
log.debug("entering unique_set, name=%s", name)
|
||||||
|
if isinstance(name, CpuSet): return name
|
||||||
|
nl = find_sets(name)
|
||||||
|
if len(nl) > 1:
|
||||||
|
raise CpusetNotUnique('cpuset name "%s" not unique: %s' % (name,
|
||||||
|
[x.path for x in nl]) )
|
||||||
|
return nl[0]
|
||||||
|
|
||||||
|
def find_sets(name):
|
||||||
|
"""find cpusets by name or path, return None if not found"""
|
||||||
|
log = logging.getLogger("cset.find_sets")
|
||||||
|
log.debug('finding "%s" in cpusets', name)
|
||||||
|
nodelist = []
|
||||||
|
if name.find('/') == -1:
|
||||||
|
log.debug("find by name")
|
||||||
|
name = name.lower()
|
||||||
|
if name == 'root':
|
||||||
|
log.debug("returning root set")
|
||||||
|
nodelist.append(RootSet)
|
||||||
|
else:
|
||||||
|
log.debug("walking from: %s", RootSet.name)
|
||||||
|
for node in walk_set(RootSet):
|
||||||
|
if node.name == name:
|
||||||
|
log.debug('... found node "%s"', name)
|
||||||
|
nodelist.append(node)
|
||||||
|
else:
|
||||||
|
log.debug("find by path")
|
||||||
|
if name in CpuSet.sets:
|
||||||
|
log.debug('... found node "%s"', CpuSet.sets[name].name)
|
||||||
|
nodelist.append(CpuSet.sets[name])
|
||||||
|
if len(nodelist) == 0:
|
||||||
|
raise CpusetNotFound('cpuset "%s" not found in cpusets' % name)
|
||||||
|
return nodelist
|
||||||
|
|
||||||
|
def walk_set(set):
|
||||||
|
""" generator for walking cpuset graph, breadth-first, more or less... """
|
||||||
|
log = logging.getLogger("cset.walk_set")
|
||||||
|
for node in set.subsets:
|
||||||
|
log.debug("+++ yield %s", node.name)
|
||||||
|
yield node
|
||||||
|
|
||||||
|
for node in set.subsets:
|
||||||
|
for result in walk_set(node):
|
||||||
|
log.debug("++++++ yield %s", node.name)
|
||||||
|
yield result
|
||||||
|
|
||||||
|
def rescan():
|
||||||
|
""" re-read the cpuset directory to sync system with data structs """
|
||||||
|
global RootSet, maxcpu, allcpumask
|
||||||
|
RootSet = CpuSet()
|
||||||
|
# figure out system properties
|
||||||
|
maxcpu = int(RootSet.cpus[-1])
|
||||||
|
allcpumask = calc_cpumask(maxcpu)
|
||||||
|
|
||||||
|
def cpuspec_check(cpuspec):
|
||||||
|
""" check format of cpuspec for validity """
|
||||||
|
log.debug("cpuspec_check(%s), maxcpu=%s", cpuspec, maxcpu)
|
||||||
|
groups = cpuspec.split(',')
|
||||||
|
if int(groups[-1].split('-')[-1]) > int(maxcpu):
|
||||||
|
str = 'CPUSPEC "%s" specifies higher max(%s) than available(%s)' % \
|
||||||
|
(cpuspec, groups[-1].split('-')[-1], maxcpu)
|
||||||
|
log.debug(str)
|
||||||
|
raise CpusetException(str)
|
||||||
|
mo = re.search("[^0-9,\-]", cpuspec)
|
||||||
|
if mo:
|
||||||
|
str = 'CPUSPEC "%s" contains invalid charaters: %s' % (cpuspec, mo.group())
|
||||||
|
log.debug(str)
|
||||||
|
raise CpusetException(str)
|
||||||
|
|
||||||
|
def memspec_check(memspec):
|
||||||
|
"""check format of memspec for validity """
|
||||||
|
# FIXME: look under /sys/devices/system/node for numa memory node
|
||||||
|
# information and check the memspec that way, currently we only do
|
||||||
|
# a basic check
|
||||||
|
log.debug("memspec_check(%s)", memspec)
|
||||||
|
mo = re.search("[^0-9,\-]", memspec)
|
||||||
|
if mo:
|
||||||
|
str = 'MEMSPEC "%s" contains invalid charaters: %s' % (memspec, mo.group())
|
||||||
|
log.debug(str)
|
||||||
|
raise CpusetException(str)
|
||||||
|
|
||||||
|
def cpuspec_inverse(cpuspec):
|
||||||
|
""" calculate inverse of cpu specification """
|
||||||
|
cpus = [0 for x in range(maxcpu+1)]
|
||||||
|
groups = cpuspec.split(',')
|
||||||
|
log.debug("cpuspec_inverse(%s) maxcpu=%d groups=%d",
|
||||||
|
cpuspec, maxcpu, len(groups))
|
||||||
|
for set in groups:
|
||||||
|
items = set.split('-')
|
||||||
|
if len(items) == 1:
|
||||||
|
if not len(items[0]):
|
||||||
|
# common error of two consecutive commas in cpuspec,
|
||||||
|
# just ignore it and keep going
|
||||||
|
continue
|
||||||
|
cpus[int(items[0])] = 1
|
||||||
|
elif len(items) == 2:
|
||||||
|
for x in range(int(items[0]), int(items[1])+1):
|
||||||
|
cpus[x] = 1
|
||||||
|
else:
|
||||||
|
raise CpusetException("cpuspec(%s) has bad group %s" % (cpuspec, set))
|
||||||
|
log.debug("cpuspec array: %s", cpus)
|
||||||
|
# calculate inverse of array
|
||||||
|
for x in range(0, len(cpus)):
|
||||||
|
if cpus[x] == 0:
|
||||||
|
cpus[x] = 1
|
||||||
|
else:
|
||||||
|
cpus[x] = 0
|
||||||
|
log.debug(" inverse: %s", cpus)
|
||||||
|
# build cpuspec expression
|
||||||
|
nspec = ""
|
||||||
|
ingrp = False
|
||||||
|
for x in range(0, len(cpus)):
|
||||||
|
if cpus[x] == 0 and ingrp:
|
||||||
|
nspec += str(begin)
|
||||||
|
if x > begin+1:
|
||||||
|
if cpus[x] == 1:
|
||||||
|
nspec += '-' + str(x)
|
||||||
|
else:
|
||||||
|
nspec += '-' + str(x-1)
|
||||||
|
ingrp = False
|
||||||
|
if cpus[x] == 1:
|
||||||
|
if not ingrp:
|
||||||
|
if len(nspec): nspec += ','
|
||||||
|
begin = x
|
||||||
|
ingrp = True
|
||||||
|
if x == len(cpus)-1:
|
||||||
|
nspec += str(begin)
|
||||||
|
if x > begin:
|
||||||
|
nspec += '-' + str(x)
|
||||||
|
log.debug("inverse cpuspec: %s", nspec)
|
||||||
|
return nspec
|
||||||
|
|
||||||
|
def summary(set):
|
||||||
|
"""return summary of cpuset with number of tasks running"""
|
||||||
|
log.debug("entering summary, set=%s", set.path)
|
||||||
|
return ('"%s" cpuset of: %+10s cpu, with: %+5s tasks running' %
|
||||||
|
(set.name, set.cpus, len(set.tasks)) )
|
||||||
|
|
||||||
|
def calc_cpumask(max):
|
||||||
|
all = 1
|
||||||
|
ii = 1
|
||||||
|
while ii < max+1:
|
||||||
|
all |= 1 << ii
|
||||||
|
ii += 1
|
||||||
|
return "%x" % all
|
||||||
|
|
||||||
|
|
||||||
|
# Test if stand-alone execution
|
||||||
|
if __name__ == '__main__':
|
||||||
|
rescan()
|
||||||
|
|
||||||
|
# first create them, then find them
|
||||||
|
try:
|
||||||
|
os.makedirs(CpuSet.basepath+'/csettest/one/x')
|
||||||
|
os.mkdir(CpuSet.basepath+'/csettest/one/y')
|
||||||
|
os.makedirs(CpuSet.basepath+'/csettest/two/x')
|
||||||
|
os.mkdir(CpuSet.basepath+'/csettest/two/y')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
print 'Max cpu on system:', maxcpu
|
||||||
|
print 'All cpu mask: 0x%s' % allcpumask
|
||||||
|
|
||||||
|
print '------- find_sets tests --------'
|
||||||
|
print 'Find by root of "root" -> ', find_sets("root")
|
||||||
|
print 'Find by path of "/" -> ', find_sets("/")
|
||||||
|
|
||||||
|
print 'Find by path of "/csettest/one" -> ', find_sets("/csettest/one")
|
||||||
|
print 'Find by name of "one" -> ', find_sets("one")
|
||||||
|
print 'Find by path of "/csettest/two" -> ', find_sets("/csettest/two")
|
||||||
|
print 'Find by name of "two" -> ', find_sets("two")
|
||||||
|
|
||||||
|
print 'Find by path of "/csettest/one/x" -> ', find_sets("/csettest/one/x")
|
||||||
|
print 'Find by name of "x" -> ', find_sets("x")
|
||||||
|
print 'Find by path of "/csettest/two/y" -> ', find_sets("/csettest/two/y")
|
||||||
|
print 'Find by name of "y" -> ', find_sets("y")
|
||||||
|
|
||||||
|
try:
|
||||||
|
node = find_sets("cantfindmenoway")
|
||||||
|
print 'Found "cantfindmenoway??!? -> ', node
|
||||||
|
except CpusetException, err:
|
||||||
|
print 'Caught exeption for non-existant set (correctly)-> ', err
|
||||||
|
|
@ -0,0 +1,212 @@
|
|||||||
|
"""Front end command line tool for Linux cpusets
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, os
|
||||||
|
from optparse import OptionParser
|
||||||
|
import cpuset.commands
|
||||||
|
from cpuset.commands.common import CmdException
|
||||||
|
from cpuset.util import CpusetException
|
||||||
|
|
||||||
|
#
|
||||||
|
# The commands map
|
||||||
|
#
|
||||||
|
class Commands(dict):
|
||||||
|
"""Commands class. It performs on-demand module loading
|
||||||
|
"""
|
||||||
|
def canonical_cmd(self, key):
|
||||||
|
"""Return the canonical name for a possibly-shortenned
|
||||||
|
command name.
|
||||||
|
"""
|
||||||
|
candidates = [cmd for cmd in self.keys() if cmd.startswith(key)]
|
||||||
|
|
||||||
|
if not candidates:
|
||||||
|
log.error('Unknown command: %s', key)
|
||||||
|
log.error('Try "%s help" for a list of supported commands', prog)
|
||||||
|
sys.exit(1)
|
||||||
|
elif len(candidates) > 1:
|
||||||
|
log.error('Ambiguous command: %s', key)
|
||||||
|
log.error('Candidates are: %s', ', '.join(candidates))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
return candidates[0]
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
"""Return the command python module name based.
|
||||||
|
"""
|
||||||
|
global prog
|
||||||
|
|
||||||
|
cmd_mod = self.get(key) or self.get(self.canonical_cmd(key))
|
||||||
|
|
||||||
|
__import__('cpuset.commands.' + cmd_mod)
|
||||||
|
return getattr(cpuset.commands, cmd_mod)
|
||||||
|
|
||||||
|
commands = Commands({
|
||||||
|
'shield': 'shield',
|
||||||
|
'set': 'set',
|
||||||
|
# 'mem': 'mem',
|
||||||
|
'proc': 'proc',
|
||||||
|
})
|
||||||
|
|
||||||
|
supercommands = (
|
||||||
|
'shield',
|
||||||
|
)
|
||||||
|
|
||||||
|
def _print_helpstring(cmd):
|
||||||
|
print ' ' + cmd + ' ' * (12 - len(cmd)) + commands[cmd].help
|
||||||
|
|
||||||
|
def print_help():
|
||||||
|
print 'Usage: %s <command> [options]' % os.path.basename(sys.argv[0])
|
||||||
|
print
|
||||||
|
print 'Generic commands:'
|
||||||
|
print ' help print the detailed command usage'
|
||||||
|
print ' version display version information'
|
||||||
|
print ' copyright display copyright information'
|
||||||
|
|
||||||
|
cmds = commands.keys()
|
||||||
|
cmds.sort()
|
||||||
|
print
|
||||||
|
print 'Super commands (high-level and multi-function):'
|
||||||
|
for cmd in supercommands:
|
||||||
|
_print_helpstring(cmd)
|
||||||
|
print
|
||||||
|
print 'Regular commands:'
|
||||||
|
for cmd in cmds:
|
||||||
|
if not cmd in supercommands:
|
||||||
|
_print_helpstring(cmd)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
global prog
|
||||||
|
prog = os.path.basename(sys.argv[0])
|
||||||
|
|
||||||
|
global logfile
|
||||||
|
logfile = None
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print >> sys.stderr, 'usage: %s <command>' % prog
|
||||||
|
print >> sys.stderr, \
|
||||||
|
' Try "%s --help" for a list of supported commands' % prog
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# configure logging
|
||||||
|
import logging
|
||||||
|
console = logging.StreamHandler(sys.stdout)
|
||||||
|
console.setLevel(logging.INFO)
|
||||||
|
formatter = logging.Formatter(prog + ': %(message)s')
|
||||||
|
console.setFormatter(formatter)
|
||||||
|
logging.getLogger('').addHandler(console)
|
||||||
|
global log
|
||||||
|
log = logging.getLogger('')
|
||||||
|
log.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
cmd = sys.argv[1]
|
||||||
|
if cmd in ['-l', '--log']:
|
||||||
|
# FIXME: very fragile
|
||||||
|
logfile = sys.argv[2]
|
||||||
|
#trace = logging.FileHandler('/var/log/cset.log', 'w')
|
||||||
|
trace = logging.FileHandler(logfile, 'a')
|
||||||
|
trace.setLevel(logging.DEBUG)
|
||||||
|
formatter = logging.Formatter('%(asctime)s %(name)-6s %(levelname)-8s %(message)s',
|
||||||
|
'%y%m%d-%H:%M:%S')
|
||||||
|
trace.setFormatter(formatter)
|
||||||
|
logging.getLogger('').addHandler(trace)
|
||||||
|
log.debug("---------- STARTING ----------")
|
||||||
|
from cpuset.version import version
|
||||||
|
log.debug('Cpuset (cset) %s' % version)
|
||||||
|
del(sys.argv[2])
|
||||||
|
del(sys.argv[1])
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
cmd = sys.argv[1]
|
||||||
|
else:
|
||||||
|
log.debug("no arguments to process, exit")
|
||||||
|
print >> sys.stderr, 'usage: %s <command>' % prog
|
||||||
|
print >> sys.stderr, \
|
||||||
|
' Try "%s --help" for a list of supported commands' % prog
|
||||||
|
sys.exit(1)
|
||||||
|
if cmd in ['-h', '--help']:
|
||||||
|
if len(sys.argv) >= 3:
|
||||||
|
cmd = commands.canonical_cmd(sys.argv[2])
|
||||||
|
sys.argv[2] = '--help'
|
||||||
|
else:
|
||||||
|
print_help()
|
||||||
|
sys.exit(0)
|
||||||
|
if cmd == 'help':
|
||||||
|
if len(sys.argv) == 3 and not sys.argv[2] in ['-h', '--help']:
|
||||||
|
cmd = commands.canonical_cmd(sys.argv[2])
|
||||||
|
if not cmd in commands:
|
||||||
|
log.error('help: "%s" command unknown' % cmd)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
sys.argv[0] += ' %s' % cmd
|
||||||
|
command = commands[cmd]
|
||||||
|
parser = OptionParser(usage = command.usage,
|
||||||
|
option_list = command.options)
|
||||||
|
from pydoc import pager
|
||||||
|
pager(parser.format_help())
|
||||||
|
else:
|
||||||
|
print_help()
|
||||||
|
sys.exit(0)
|
||||||
|
if cmd in ['-v', '--version', 'version']:
|
||||||
|
from cpuset.version import version
|
||||||
|
log.info('Cpuset (cset) %s' % version)
|
||||||
|
sys.exit(0)
|
||||||
|
if cmd in ['copyright']:
|
||||||
|
log.info(__copyright__)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# re-build the command line arguments
|
||||||
|
cmd = commands.canonical_cmd(cmd)
|
||||||
|
sys.argv[0] += ' %s' % cmd
|
||||||
|
del(sys.argv[1])
|
||||||
|
log.debug('cmdline: ' + ' '.join(sys.argv))
|
||||||
|
|
||||||
|
try:
|
||||||
|
debug_level = int(os.environ['CSET_DEBUG_LEVEL'])
|
||||||
|
except KeyError:
|
||||||
|
debug_level = 0
|
||||||
|
except ValueError:
|
||||||
|
log.error('Invalid CSET_DEBUG_LEVEL environment variable')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# importing the cset class creates the model
|
||||||
|
log.debug("creating cpuset model")
|
||||||
|
import cpuset.cset
|
||||||
|
command = commands[cmd]
|
||||||
|
usage = command.usage.split('\n')[0].strip()
|
||||||
|
parser = OptionParser(usage = usage, option_list = command.options)
|
||||||
|
parser.disable_interspersed_args()
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
command.func(parser, options, args)
|
||||||
|
except (ValueError, OSError, IOError, CpusetException, CmdException), err:
|
||||||
|
log.critical('%s: %s' % (cmd, err))
|
||||||
|
if str(err).find('Permission denied') != -1:
|
||||||
|
log.critical('insufficient permissions, you probably need to be root')
|
||||||
|
if str(err).find('invalid literal') != -1:
|
||||||
|
log.critical('option not understood')
|
||||||
|
if debug_level:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
sys.exit(2)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
sys.exit(0)
|
@ -0,0 +1,21 @@
|
|||||||
|
"""Task class
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
@ -0,0 +1,92 @@
|
|||||||
|
"""Utility functions
|
||||||
|
"""
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, time
|
||||||
|
|
||||||
|
class CpusetException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class CpusetAbort(CpusetException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class CpusetNotFound(CpusetException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class CpusetNotUnique(CpusetException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class CpusetExists(CpusetException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# a twirling bar progress indicator
|
||||||
|
class TwirlyBar:
|
||||||
|
def __init__(self):
|
||||||
|
import sys
|
||||||
|
self.__dict__['__call__'] = self.tick
|
||||||
|
self.__state = 0
|
||||||
|
self.__bar = ('|', '/', '-', '\\')
|
||||||
|
|
||||||
|
def tick(self):
|
||||||
|
print '\b' + self.__bar[self.__state] + '\b',
|
||||||
|
self.__state = self.__state + 1
|
||||||
|
if self.__state > 3: self.__state = 0
|
||||||
|
|
||||||
|
def fastick(self):
|
||||||
|
for x in range(10):
|
||||||
|
self.tick()
|
||||||
|
time.sleep(0.04)
|
||||||
|
|
||||||
|
# a progress bar indicator
|
||||||
|
class ProgressBar:
|
||||||
|
def __init__(self, finalcount, progresschar=None):
|
||||||
|
self.__dict__['__call__'] = self.progress
|
||||||
|
self.finalcount=finalcount
|
||||||
|
self.blockcount=0
|
||||||
|
# Use ascii block char for progress if none passed
|
||||||
|
if not progresschar:
|
||||||
|
self.block=chr(178)
|
||||||
|
else:
|
||||||
|
self.block=progresschar
|
||||||
|
self.f=sys.stdout
|
||||||
|
if not self.finalcount: return
|
||||||
|
self.f.write('[')
|
||||||
|
for i in range(50): self.f.write(' ')
|
||||||
|
self.f.write(']%')
|
||||||
|
for i in range(52): self.f.write('\b')
|
||||||
|
|
||||||
|
def progress(self, count):
|
||||||
|
count=min(count, self.finalcount)
|
||||||
|
|
||||||
|
if self.finalcount:
|
||||||
|
percentcomplete=int(round(100*count/self.finalcount))
|
||||||
|
if percentcomplete < 1: percentcomplete=1
|
||||||
|
else:
|
||||||
|
percentcomplete=100
|
||||||
|
|
||||||
|
blockcount=int(percentcomplete/2)
|
||||||
|
if blockcount > self.blockcount:
|
||||||
|
for i in range(self.blockcount,blockcount):
|
||||||
|
self.f.write(self.block)
|
||||||
|
self.f.flush()
|
||||||
|
|
||||||
|
if percentcomplete == 100: self.f.write("]\n")
|
||||||
|
self.blockcount=blockcount
|
||||||
|
|
@ -0,0 +1,19 @@
|
|||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2008 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
"""
|
||||||
|
|
||||||
|
version = '1.04'
|
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
__copyright__ = """
|
||||||
|
Copyright (C) 2007 Novell Inc.
|
||||||
|
Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License version 2 as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
Substrate code and ideas taken from the excellent stgit 0.13, see
|
||||||
|
https://gna.org/projects/stgit and http://www.procode.org/stgit/
|
||||||
|
Stacked GIT is under GPL V2 or later.
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys, os
|
||||||
|
|
||||||
|
# Try to detect where it is run from and set prefix and the search path.
|
||||||
|
# It is assumed that the user installed cpuset using the --prefix= option
|
||||||
|
prefix, bin = os.path.split(sys.path[0])
|
||||||
|
|
||||||
|
if bin == 'bin' and prefix != sys.prefix:
|
||||||
|
sys.prefix = prefix
|
||||||
|
sys.exec_prefix = prefix
|
||||||
|
|
||||||
|
major, minor = sys.version_info[0:2]
|
||||||
|
local_path = [os.path.join(prefix, 'lib', 'python'),
|
||||||
|
os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor)),
|
||||||
|
os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor),
|
||||||
|
'site-packages')]
|
||||||
|
sys.path = local_path + sys.path
|
||||||
|
|
||||||
|
from cpuset.main import main
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1,70 @@
|
|||||||
|
MAN1_TXT=$(wildcard cset*.txt)
|
||||||
|
|
||||||
|
DOC_HTML=$(patsubst %.txt,%.html,$(MAN1_TXT) $(MAN7_TXT))
|
||||||
|
|
||||||
|
ARTICLES =
|
||||||
|
# with their own formatting rules.
|
||||||
|
SP_ARTICLES = tutorial
|
||||||
|
|
||||||
|
DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
|
||||||
|
DOC_PDF += $(patsubst %,%.pdf,$(ARTICLES) $(SP_ARTICLES))
|
||||||
|
|
||||||
|
DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
|
||||||
|
DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
|
||||||
|
|
||||||
|
prefix?=$(HOME)/man
|
||||||
|
mandir?=$(prefix)
|
||||||
|
man1dir=$(mandir)/man1
|
||||||
|
# DESTDIR=
|
||||||
|
|
||||||
|
ASCIIDOC=asciidoc --unsafe
|
||||||
|
ASCIIDOC_EXTRA =
|
||||||
|
INSTALL?=install
|
||||||
|
|
||||||
|
#
|
||||||
|
# Please note that there is a minor bug in asciidoc.
|
||||||
|
# The version after 6.0.3 _will_ include the patch found here:
|
||||||
|
# http://marc.theaimsgroup.com/?l=git&m=111558757202243&w=2
|
||||||
|
#
|
||||||
|
# Until that version is released you may have to apply the patch
|
||||||
|
# yourself - yes, all 6 characters of it!
|
||||||
|
#
|
||||||
|
|
||||||
|
all: html man
|
||||||
|
|
||||||
|
html: $(DOC_HTML)
|
||||||
|
pdf: $(DOC_PDF)
|
||||||
|
|
||||||
|
$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN7): asciidoc.conf
|
||||||
|
|
||||||
|
man: man1
|
||||||
|
man1: $(DOC_MAN1)
|
||||||
|
|
||||||
|
install: man
|
||||||
|
$(INSTALL) -d -m755 $(DESTDIR)$(man1dir)
|
||||||
|
$(INSTALL) -m644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
|
||||||
|
cd $(DESTDIR)$(man1dir); gzip *.1
|
||||||
|
|
||||||
|
-include doc.dep
|
||||||
|
|
||||||
|
clean:
|
||||||
|
#rm -f *.xml *.html *.pdf *.1 *.7 doc.dep
|
||||||
|
rm -f *.xml *.pdf doc.dep
|
||||||
|
|
||||||
|
%.html : %.txt
|
||||||
|
$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $(ASCIIDOC_EXTRA) $<
|
||||||
|
|
||||||
|
%.1 %.7 : %.xml
|
||||||
|
xmlto -m callouts.xsl man $<
|
||||||
|
|
||||||
|
%.xml : %.txt
|
||||||
|
$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf $<
|
||||||
|
|
||||||
|
%.pdf: %.xml
|
||||||
|
xmlto pdf $<
|
||||||
|
|
||||||
|
# special formatting rules
|
||||||
|
tutorial.html : %.html : %.txt
|
||||||
|
$(ASCIIDOC) -b xhtml11 -d article -f tutorial.conf $(ASCIIDOC_EXTRA) $<
|
||||||
|
tutorial.xml : %.xml : %.txt
|
||||||
|
$(ASCIIDOC) -b docbook -d article -f tutorial.conf $<
|
@ -0,0 +1,59 @@
|
|||||||
|
## csetlink: macro
|
||||||
|
#
|
||||||
|
# Usage: csetlink:command[manpage-section]
|
||||||
|
#
|
||||||
|
# Note, {0} is the manpage section, while {target} is the command.
|
||||||
|
#
|
||||||
|
# Show cset link as: <command>(<section>); if section is defined, else just show
|
||||||
|
# the command.
|
||||||
|
|
||||||
|
[attributes]
|
||||||
|
caret=^
|
||||||
|
startsb=[
|
||||||
|
endsb=]
|
||||||
|
tilde=~
|
||||||
|
|
||||||
|
ifdef::backend-docbook[]
|
||||||
|
[manlink-inlinemacro]
|
||||||
|
{0%{target}}
|
||||||
|
{0#<citerefentry>}
|
||||||
|
{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
|
||||||
|
{0#</citerefentry>}
|
||||||
|
endif::backend-docbook[]
|
||||||
|
|
||||||
|
ifdef::backend-docbook[]
|
||||||
|
# "unbreak" docbook-xsl v1.68 for manpages. v1.69 works with or without this.
|
||||||
|
[listingblock]
|
||||||
|
<example><title>{title}</title>
|
||||||
|
<literallayout>
|
||||||
|
|
|
||||||
|
</literallayout>
|
||||||
|
{title#}</example>
|
||||||
|
endif::backend-docbook[]
|
||||||
|
|
||||||
|
ifdef::backend-xhtml11[]
|
||||||
|
[manlink-inlinemacro]
|
||||||
|
<a href="{target}.html">{target}{0?({0})}</a>
|
||||||
|
endif::backend-xhtml11[]
|
||||||
|
|
||||||
|
# csetlink
|
||||||
|
|
||||||
|
ifdef::backend-docbook[]
|
||||||
|
[csetlink-inlinemacro]
|
||||||
|
<citerefentry>
|
||||||
|
<refentrytitle>cset-{target}</refentrytitle><manvolnum>1</manvolnum>
|
||||||
|
</citerefentry>
|
||||||
|
endif::backend-docbook[]
|
||||||
|
|
||||||
|
ifdef::backend-xhtml11[]
|
||||||
|
[csetlink-inlinemacro]
|
||||||
|
<a href="cset-{target}.html">cset-{target}(1)</a>
|
||||||
|
endif::backend-xhtml11[]
|
||||||
|
|
||||||
|
# csetdesc
|
||||||
|
[csetdesc-inlinemacro]
|
||||||
|
{sys:../cset help|grep " {target}" | tr -s ' '| cut -d' ' -f3-}
|
||||||
|
|
||||||
|
[csetdesc-blockmacro]
|
||||||
|
csetlink:{target}[]::
|
||||||
|
csetdesc:{target}[]
|
@ -0,0 +1,30 @@
|
|||||||
|
<!-- callout.xsl: converts asciidoc callouts to man page format -->
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||||
|
<xsl:template match="co">
|
||||||
|
<xsl:value-of select="concat('\fB(',substring-after(@id,'-'),')\fR')"/>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="calloutlist">
|
||||||
|
<xsl:text>.sp </xsl:text>
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
<xsl:text> </xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
<xsl:template match="callout">
|
||||||
|
<xsl:value-of select="concat('\fB',substring-after(@arearefs,'-'),'. \fR')"/>
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
<xsl:text>.br </xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- sorry, this is not about callouts, but attempts to work around
|
||||||
|
spurious .sp at the tail of the line docbook stylesheets seem to add -->
|
||||||
|
<xsl:template match="simpara">
|
||||||
|
<xsl:variable name="content">
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:value-of select="normalize-space($content)"/>
|
||||||
|
<xsl:if test="not(ancestor::authorblurb) and
|
||||||
|
not(ancestor::personblurb)">
|
||||||
|
<xsl:text> </xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
@ -0,0 +1,173 @@
|
|||||||
|
.\" ** You probably do not want to edit this file directly **
|
||||||
|
.\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
|
||||||
|
.\" Instead of manually editing it, you probably should edit the DocBook XML
|
||||||
|
.\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
|
||||||
|
.TH "CSET\-PROC" "1" "05/30/2008" "" ""
|
||||||
|
.\" disable hyphenation
|
||||||
|
.nh
|
||||||
|
.\" disable justification (adjust text to left margin only)
|
||||||
|
.ad l
|
||||||
|
.SH "NAME"
|
||||||
|
cset\-proc \- manage processes running in cpusets
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
.sp
|
||||||
|
.nf
|
||||||
|
\fIcset\fR [cset options] \fIproc\fR [proc options] [args]
|
||||||
|
\fIcset\fR proc \-\-help
|
||||||
|
\fIcset\fR proc
|
||||||
|
\fIcset\fR proc my_set my_other_set
|
||||||
|
\fIcset\fR proc \-\-list \-\-set my_set
|
||||||
|
\fIcset\fR proc \-\-exec my_set /opt/software/my_code \-\-my_opt_1
|
||||||
|
\fIcset\fR proc \-\-set my_set \-\-exec /opt/software/my_code \-\-my_opt_1
|
||||||
|
\fIcset\fR proc \-\-move 2442,3000\-3200 my_set
|
||||||
|
\fIcset\fR proc \-\-move \-\-pid=2442,3000\-3200 \-\-toset=my_set
|
||||||
|
\fIcset\fR proc \-\-move \-\-fromset=my_set_1 \-\-toset=my_set_2
|
||||||
|
\fIcset\fR proc \-\-move \-\-pid=42 \-\-fromset=/group1/myset \-\-toset=/group2/yourset
|
||||||
|
.fi
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.TP
|
||||||
|
\-h, \-\-help
|
||||||
|
prints the list of options for this command
|
||||||
|
.TP
|
||||||
|
\-l, \-\-list
|
||||||
|
list processes in the specified cpuset
|
||||||
|
.TP
|
||||||
|
\-e, \-\-exec
|
||||||
|
execute arguments in the specified cpuset
|
||||||
|
.TP
|
||||||
|
\-u USER, \-\-user=USER
|
||||||
|
use this USER to \-\-exec (id or name)
|
||||||
|
.TP
|
||||||
|
\-g GROUP, \-\-group=GROUP
|
||||||
|
use this GROUP to \-\-exec (id or name)
|
||||||
|
.TP
|
||||||
|
\-m, \-\-move
|
||||||
|
move specified tasks to specified cpuset; to move a PIDSPEC to a cpuset, use \-m PIDSPEC cpuset; to move all tasks specify \-\-fromset and \-\-toset
|
||||||
|
.TP
|
||||||
|
\-p PIDSPEC, \-\-pid=PIDSPEC
|
||||||
|
specify pid or tid specification
|
||||||
|
.TP
|
||||||
|
\-s CPUSET, \-\-set=CPUSET
|
||||||
|
specify name of immediate cpuset
|
||||||
|
.TP
|
||||||
|
\-t TOSET, \-\-toset=TOSET
|
||||||
|
specify name of destination cpuset
|
||||||
|
.TP
|
||||||
|
\-f FROMSET, \-\-fromset=FROMSET
|
||||||
|
specify name of origination cpuset
|
||||||
|
.TP
|
||||||
|
\-k, \-\-kthread
|
||||||
|
move, or include moving, unbound kernel threads
|
||||||
|
.TP
|
||||||
|
\-a, \-\-all
|
||||||
|
force all processes and threads to be moved
|
||||||
|
.TP
|
||||||
|
\-v, \-\-verbose
|
||||||
|
prints more detailed output, additive
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
This command is used to run and manage arbitrary processes on specified cpusets. It is also used to move pre\-existing processes and threads to specified cpusets. You may note there is no "kill" or "destroy" option \(em use the standard OS ^C or kill commands for that.
|
||||||
|
|
||||||
|
To list which tasks are running in a particular cpuset, use the \-\-list command.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
\fB# cset proc \-\-list \-\-set priset\fR
|
||||||
|
|
||||||
|
This command will list all the tasks running in the cpuset called "priset".
|
||||||
|
|
||||||
|
Processes are created by specifying the path to the executable and specifying the cpuset that the process is to be created in.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
\fB# cset proc \-\-set=blazing_cpuset \-\-exec /usr/bin/fast_code\fR
|
||||||
|
|
||||||
|
This command will execute the /usr/bin/fast_code program on the "blazing_cpuset" cpuset.
|
||||||
|
|
||||||
|
The PIDSPEC argument taken for the move command is a comma separated list of PIDs or TIDs. The list can also include brackets of PIDs or TIDs (i.e. tasks) that are inclusive of the endpoints.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
.sp
|
||||||
|
.nf
|
||||||
|
1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600\-700 Means processes 1, 2 and from 600 to 700
|
||||||
|
.fi
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
The range of PIDs or TIDs does not need to have every position populated. In other words, for the example above, if there is only one process, say PID 57, in the range of 50\-65, then only that process will be moved.
|
||||||
|
|
||||||
|
To move a PIDSPEC to a specific cpuset, you can either specify the PIDSPEC with \-\-pid and the destination cpuset with \-\-toset, or use the short hand and list the cpuset name after the PIDSPEC for the \-\-move arguments.
|
||||||
|
|
||||||
|
The move command accepts multiple common calling methods. For example, the following commands are equivalent:
|
||||||
|
|
||||||
|
\fB# cset proc \-\-move 2442,3000\-3200 reserved_set\fR
|
||||||
|
|
||||||
|
\fB# cset proc \-\-move \-\-pid=2442,3000\-3200 \-\-toset=reserved_set\fR
|
||||||
|
|
||||||
|
These commands move the tasks defined as 2442 and any running task between 3000 and 3200 inclusive of the ends to the cpuset called "reserved_set".
|
||||||
|
|
||||||
|
Specifying the \-\-fromset is not necesary since the tasks will be moved to the destination cpuset no matter which cpuset they are currently running on.
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
However, if you do specify a cpuset with the \-\-fromset option, then only those tasks that are both in the PIDSPEC \fBand\fR are running in the cpuset specified by \-\-fromset will be moved. I.e., if there is a task running on the system but not in \-\-fromset that is in PIDSPEC, it will not be moved.
|
||||||
|
|
||||||
|
To move all userspace tasks from one cpuset to another, you need to specify the source and destination cpuset by name.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
\fB# cset proc \-\-move \-\-fromset=comp1 \-\-toset=comp42\fR
|
||||||
|
|
||||||
|
This command specifies that all processes and threads running on cpuset "comp1" be moved to cpuset "comp42".
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
This move command will not move kernel threads unless the \-k/\-\-kthread switch is specified. If it is, then all unbound kernel threads will be added to the move. Unbound kernel threads are those that can run on any CPU. If you \fBalso specify\fR the \-a/\-\-all switch, then all tasks, kernel or not, bound or not, will be moved.
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBCaution\fR
|
||||||
|
Please be cautious with the \-\-all switch, since moving a kernel thread that is bound to a specific CPU to a cpuset that does not include that CPU can cause a system hang.
|
||||||
|
|
||||||
|
You must specify unique cpuset names for the both exec and move commands. If a simple name passed to the \-\-fromset, \-\-toset and \-\-set parameters is unique on the system then that command executes. However, if there are multiple cpusets by that name, then you will need to specify which one you mean with a full path rooted at the base cpuset tree.
|
||||||
|
|
||||||
|
For example, suppose you have the following cpuset tree:
|
||||||
|
.sp
|
||||||
|
.nf
|
||||||
|
/cpusets
|
||||||
|
/group1
|
||||||
|
/myset
|
||||||
|
/yourset
|
||||||
|
/group2
|
||||||
|
/myset
|
||||||
|
/yourset
|
||||||
|
.fi
|
||||||
|
Then, to move a process from myset in group1 to yourset in group2, you would have to issue the following command:
|
||||||
|
|
||||||
|
# cset proc \-\-move \-\-pid=50 \-\-fromset=/group1/myset \-\-toset=/group2/yourset
|
||||||
|
|
||||||
|
You do not have to worry about where in the Linux filesystem the cpuset filesystem is mounted. The cset command takes care of that. Any cpusets that are specifed by path (such as above), are done with respect to the root of the cpuset filesystem.
|
||||||
|
.SH "LICENSE"
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
.SH "COPYRIGHT"
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
.SH "AUTHOR"
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked GIT (stgit) v0.13 (see http://gna.org/projects/stgit and http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBcset\fR(1), \fBcset\-set\fR(1), \fBcset\-shield\fR(1), \fBtaskset\fR(1), \fBchrt\fR(1)
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
||||||
|
|
@ -0,0 +1,577 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta name="generator" content="AsciiDoc 8.1.0" />
|
||||||
|
<style type="text/css">
|
||||||
|
/* Debug borders */
|
||||||
|
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
|
||||||
|
/*
|
||||||
|
border: 1px solid red;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 1em 5% 1em 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: blue;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
a:visited {
|
||||||
|
color: fuchsia;
|
||||||
|
}
|
||||||
|
|
||||||
|
em {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
tt {
|
||||||
|
color: navy;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
margin-top: 1.2em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sectionbody {
|
||||||
|
font-family: serif;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border: 1px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
span#author {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
span#email {
|
||||||
|
}
|
||||||
|
span#revision {
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: small;
|
||||||
|
border-top: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
margin-top: 4.0em;
|
||||||
|
}
|
||||||
|
div#footer-text {
|
||||||
|
float: left;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div#footer-badges {
|
||||||
|
float: right;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#preamble,
|
||||||
|
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
|
||||||
|
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-right: 10%;
|
||||||
|
margin-top: 1.5em;
|
||||||
|
margin-bottom: 1.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-top: 2.5em;
|
||||||
|
margin-bottom: 2.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.content { /* Block element content. */
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Block element titles. */
|
||||||
|
div.title, caption.title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div.title + * {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
td div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content + div.title {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sidebarblock > div.content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock {
|
||||||
|
margin-right: 0%;
|
||||||
|
}
|
||||||
|
div.listingblock > div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock > div.content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.attribution {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
div.verseblock + div.attribution {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.admonitionblock .icon {
|
||||||
|
vertical-align: top;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #527bbd;
|
||||||
|
padding-right: 0.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock td.content {
|
||||||
|
padding-left: 0.5em;
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock > div.content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.verseblock div.content {
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.imageblock div.content { padding-left: 0; }
|
||||||
|
div.imageblock img { border: 1px solid silver; }
|
||||||
|
span.image img { border-style: none; }
|
||||||
|
|
||||||
|
dl {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
dt {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
dd > *:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul, ol {
|
||||||
|
list-style-position: outside;
|
||||||
|
}
|
||||||
|
ol.olist2 {
|
||||||
|
list-style-type: lower-alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tableblock > table {
|
||||||
|
border: 3px solid #527bbd;
|
||||||
|
}
|
||||||
|
thead {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
tfoot {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.hlist {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist1 {
|
||||||
|
vertical-align: top;
|
||||||
|
font-style: italic;
|
||||||
|
padding-right: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist2 {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
div#footer-badges { display: none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
div#toctitle {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toclevel1, div.toclevel2 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
div.toclevel2 {
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
include1::./stylesheets/xhtml11-manpage.css[]
|
||||||
|
/* Workarounds for IE6's broken and incomplete CSS2. */
|
||||||
|
|
||||||
|
div.sidebar-content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
div.sidebar-title, div.image-title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 0.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock-content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock-content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding-left: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IE6 sets dynamically generated links as visited. */
|
||||||
|
div#toc a:visited { color: blue; }
|
||||||
|
</style>
|
||||||
|
<title>cset-proc(1)</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<h1>
|
||||||
|
cset-proc(1) Manual Page
|
||||||
|
</h1>
|
||||||
|
<h2>NAME</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>cset-proc -
|
||||||
|
manage processes running in cpusets
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2>SYNOPSIS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<div class="verseblock">
|
||||||
|
<div class="content"><em>cset</em> [cset options] <em>proc</em> [proc options] [args]
|
||||||
|
<em>cset</em> proc --help
|
||||||
|
<em>cset</em> proc
|
||||||
|
<em>cset</em> proc my_set my_other_set
|
||||||
|
<em>cset</em> proc --list --set my_set
|
||||||
|
<em>cset</em> proc --exec my_set /opt/software/my_code --my_opt_1
|
||||||
|
<em>cset</em> proc --set my_set --exec /opt/software/my_code --my_opt_1
|
||||||
|
<em>cset</em> proc --move 2442,3000-3200 my_set
|
||||||
|
<em>cset</em> proc --move --pid=2442,3000-3200 --toset=my_set
|
||||||
|
<em>cset</em> proc --move --fromset=my_set_1 --toset=my_set_2
|
||||||
|
<em>cset</em> proc --move --pid=42 --fromset=/group1/myset --toset=/group2/yourset</div></div>
|
||||||
|
</div>
|
||||||
|
<h2>OPTIONS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
-h, --help
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
prints the list of options for this command
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-l, --list
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
list processes in the specified cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-e, --exec
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
execute arguments in the specified cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-u USER, --user=USER
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
use this USER to --exec (id or name)
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-g GROUP, --group=GROUP
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
use this GROUP to --exec (id or name)
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-m, --move
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
move specified tasks to specified cpuset; to move a PIDSPEC to a
|
||||||
|
cpuset, use -m PIDSPEC cpuset; to move all tasks specify --fromset
|
||||||
|
and --toset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-p PIDSPEC, --pid=PIDSPEC
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
specify pid or tid specification
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-s CPUSET, --set=CPUSET
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
specify name of immediate cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-t TOSET, --toset=TOSET
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
specify name of destination cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-f FROMSET, --fromset=FROMSET
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
specify name of origination cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-k, --kthread
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
move, or include moving, unbound kernel threads
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-a, --all
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
force all processes and threads to be moved
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-v, --verbose
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
prints more detailed output, additive
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<h2>DESCRIPTION</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>This command is used to run and manage arbitrary processes on
|
||||||
|
specified cpusets. It is also used to move pre-existing processes and
|
||||||
|
threads to specified cpusets. You may note there is no "kill" or
|
||||||
|
"destroy" option — use the standard OS ^C or kill commands for that.</p>
|
||||||
|
<p>To list which tasks are running in a particular cpuset, use the --list
|
||||||
|
command.</p>
|
||||||
|
<p>For example:</p>
|
||||||
|
<p><strong><tt># cset proc --list --set priset</tt></strong></p>
|
||||||
|
<p>This command will list all the tasks running in the cpuset called
|
||||||
|
"priset".</p>
|
||||||
|
<p>Processes are created by specifying the path to the executable
|
||||||
|
and specifying the cpuset that the process is to be created in.</p>
|
||||||
|
<p>For example:</p>
|
||||||
|
<p><strong><tt># cset proc --set=blazing_cpuset --exec /usr/bin/fast_code</tt></strong></p>
|
||||||
|
<p>This command will execute the /usr/bin/fast_code program on the
|
||||||
|
"blazing_cpuset" cpuset.</p>
|
||||||
|
<p>The PIDSPEC argument taken for the move command is a comma
|
||||||
|
separated list of PIDs or TIDs. The list can also include
|
||||||
|
brackets of PIDs or TIDs (i.e. tasks) that are inclusive of the
|
||||||
|
endpoints.</p>
|
||||||
|
<p>For example:</p>
|
||||||
|
<div class="literalblock">
|
||||||
|
<div class="content">
|
||||||
|
<pre><tt>1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600-700 Means processes 1, 2 and from 600 to 700</tt></pre>
|
||||||
|
</div></div>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">The range of PIDs or TIDs does not need to have every
|
||||||
|
position populated. In other words, for the example above, if
|
||||||
|
there is only one process, say PID 57, in the range of 50-65,
|
||||||
|
then only that process will be moved.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<p>To move a PIDSPEC to a specific cpuset, you can either specify
|
||||||
|
the PIDSPEC with --pid and the destination cpuset with --toset,
|
||||||
|
or use the short hand and list the cpuset name after the PIDSPEC
|
||||||
|
for the --move arguments.</p>
|
||||||
|
<p>The move command accepts multiple common calling methods.
|
||||||
|
For example, the following commands are equivalent:</p>
|
||||||
|
<p><strong><tt># cset proc --move 2442,3000-3200 reserved_set</tt></strong></p>
|
||||||
|
<p><strong><tt># cset proc --move --pid=2442,3000-3200 --toset=reserved_set</tt></strong></p>
|
||||||
|
<p>These commands move the tasks defined as 2442 and any running task
|
||||||
|
between 3000 and 3200 inclusive of the ends to the cpuset called
|
||||||
|
"reserved_set".</p>
|
||||||
|
<p>Specifying the --fromset is not necesary since the tasks will be
|
||||||
|
moved to the destination cpuset no matter which cpuset they are
|
||||||
|
currently running on.</p>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">However, if you do specify a cpuset with the --fromset
|
||||||
|
option, then only those tasks that are both in the PIDSPEC <strong>and</strong>
|
||||||
|
are running in the cpuset specified by --fromset will be moved.
|
||||||
|
I.e., if there is a task running on the system but not in
|
||||||
|
--fromset that is in PIDSPEC, it will not be moved.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<p>To move all userspace tasks from one cpuset to another, you need
|
||||||
|
to specify the source and destination cpuset by name.</p>
|
||||||
|
<p>For example:</p>
|
||||||
|
<p><strong><tt># cset proc --move --fromset=comp1 --toset=comp42</tt></strong></p>
|
||||||
|
<p>This command specifies that all processes and threads
|
||||||
|
running on cpuset "comp1" be moved to cpuset "comp42".</p>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">This move command will not move kernel threads unless
|
||||||
|
the -k/--kthread switch is specified. If it is, then all unbound
|
||||||
|
kernel threads will be added to the move. Unbound kernel threads
|
||||||
|
are those that can run on any CPU. If you <strong>also specify</strong> the
|
||||||
|
-a/--all switch, then all tasks, kernel or not, bound or not,
|
||||||
|
will be moved.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Caution</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">Please be cautious with the --all switch, since moving a
|
||||||
|
kernel thread that is bound to a specific CPU to a cpuset that
|
||||||
|
does not include that CPU can cause a system hang.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<p>You must specify unique cpuset names for the both exec and move
|
||||||
|
commands. If a simple name passed to the --fromset, --toset and
|
||||||
|
--set parameters is unique on the system then that command
|
||||||
|
executes. However, if there are multiple cpusets by that name,
|
||||||
|
then you will need to specify which one you mean with a full path
|
||||||
|
rooted at the base cpuset tree.</p>
|
||||||
|
<p>For example, suppose you have the following cpuset tree:</p>
|
||||||
|
<div class="literalblock">
|
||||||
|
<div class="content">
|
||||||
|
<pre><tt>/cpusets
|
||||||
|
/group1
|
||||||
|
/myset
|
||||||
|
/yourset
|
||||||
|
/group2
|
||||||
|
/myset
|
||||||
|
/yourset</tt></pre>
|
||||||
|
</div></div>
|
||||||
|
<p>Then, to move a process from myset in group1 to yourset in
|
||||||
|
group2, you would have to issue the following command:</p>
|
||||||
|
<p><tt># cset proc --move --pid=50 --fromset=/group1/myset --toset=/group2/yourset</tt></p>
|
||||||
|
<p>You do not have to worry about where in the Linux filesystem the
|
||||||
|
cpuset filesystem is mounted. The cset command takes care of that.
|
||||||
|
Any cpusets that are specifed by path (such as above), are done with
|
||||||
|
respect to the root of the cpuset filesystem.</p>
|
||||||
|
</div>
|
||||||
|
<h2>LICENSE</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Cpuset is licensed under the GNU GPL V2 only.</p>
|
||||||
|
</div>
|
||||||
|
<h2>COPYRIGHT</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Copyright (c) 2008 Novell Inc.</p>
|
||||||
|
</div>
|
||||||
|
<h2>AUTHOR</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Written by Alex Tsariounov <alext@novell.com>.</p>
|
||||||
|
<p>Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.</p>
|
||||||
|
</div>
|
||||||
|
<h2>SEE ALSO</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p><a href="cset.html">cset(1)</a>, <a href="cset-set.html">cset-set(1)</a>, <a href="cset-shield.html">cset-shield(1)</a>, <a href="taskset.html">taskset(1)</a>,
|
||||||
|
<a href="chrt.html">chrt(1)</a></p>
|
||||||
|
<p>/usr/src/linux/Documentation/cpusets.txt</p>
|
||||||
|
</div>
|
||||||
|
<div id="footer">
|
||||||
|
<div id="footer-text">
|
||||||
|
Version 1.0<br />
|
||||||
|
Last updated 30-May-2008 14:33:23 MDT
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,205 @@
|
|||||||
|
cset-proc(1)
|
||||||
|
============
|
||||||
|
Alex Tsariounov <alext@novell.com>
|
||||||
|
v1.0, May 2008
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cset-proc - manage processes running in cpusets
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
[verse]
|
||||||
|
'cset' [cset options] 'proc' [proc options] [args]
|
||||||
|
'cset' proc --help
|
||||||
|
'cset' proc
|
||||||
|
'cset' proc my_set my_other_set
|
||||||
|
'cset' proc --list --set my_set
|
||||||
|
'cset' proc --exec my_set /opt/software/my_code --my_opt_1
|
||||||
|
'cset' proc --set my_set --exec /opt/software/my_code --my_opt_1
|
||||||
|
'cset' proc --move 2442,3000-3200 my_set
|
||||||
|
'cset' proc --move --pid=2442,3000-3200 --toset=my_set
|
||||||
|
'cset' proc --move --fromset=my_set_1 --toset=my_set_2
|
||||||
|
'cset' proc --move --pid=42 --fromset=/group1/myset --toset=/group2/yourset
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-------
|
||||||
|
-h, --help::
|
||||||
|
prints the list of options for this command
|
||||||
|
|
||||||
|
-l, --list::
|
||||||
|
list processes in the specified cpuset
|
||||||
|
|
||||||
|
-e, --exec::
|
||||||
|
execute arguments in the specified cpuset
|
||||||
|
|
||||||
|
-u USER, --user=USER::
|
||||||
|
use this USER to --exec (id or name)
|
||||||
|
|
||||||
|
-g GROUP, --group=GROUP::
|
||||||
|
use this GROUP to --exec (id or name)
|
||||||
|
|
||||||
|
-m, --move::
|
||||||
|
move specified tasks to specified cpuset; to move a PIDSPEC to a
|
||||||
|
cpuset, use -m PIDSPEC cpuset; to move all tasks specify --fromset
|
||||||
|
and --toset
|
||||||
|
|
||||||
|
-p PIDSPEC, --pid=PIDSPEC::
|
||||||
|
specify pid or tid specification
|
||||||
|
|
||||||
|
-s CPUSET, --set=CPUSET::
|
||||||
|
specify name of immediate cpuset
|
||||||
|
|
||||||
|
-t TOSET, --toset=TOSET::
|
||||||
|
specify name of destination cpuset
|
||||||
|
|
||||||
|
-f FROMSET, --fromset=FROMSET::
|
||||||
|
specify name of origination cpuset
|
||||||
|
|
||||||
|
-k, --kthread::
|
||||||
|
move, or include moving, unbound kernel threads
|
||||||
|
|
||||||
|
-a, --all::
|
||||||
|
force all processes and threads to be moved
|
||||||
|
|
||||||
|
-v, --verbose::
|
||||||
|
prints more detailed output, additive
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This command is used to run and manage arbitrary processes on
|
||||||
|
specified cpusets. It is also used to move pre-existing processes and
|
||||||
|
threads to specified cpusets. You may note there is no "kill" or
|
||||||
|
"destroy" option -- use the standard OS ^C or kill commands for that.
|
||||||
|
|
||||||
|
To list which tasks are running in a particular cpuset, use the --list
|
||||||
|
command.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
*+# cset proc --list --set priset+*
|
||||||
|
|
||||||
|
This command will list all the tasks running in the cpuset called
|
||||||
|
"priset".
|
||||||
|
|
||||||
|
Processes are created by specifying the path to the executable
|
||||||
|
and specifying the cpuset that the process is to be created in.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
*+# cset proc --set=blazing_cpuset --exec /usr/bin/fast_code+*
|
||||||
|
|
||||||
|
This command will execute the /usr/bin/fast_code program on the
|
||||||
|
"blazing_cpuset" cpuset.
|
||||||
|
|
||||||
|
The PIDSPEC argument taken for the move command is a comma
|
||||||
|
separated list of PIDs or TIDs. The list can also include
|
||||||
|
brackets of PIDs or TIDs (i.e. tasks) that are inclusive of the
|
||||||
|
endpoints.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600-700 Means processes 1, 2 and from 600 to 700
|
||||||
|
|
||||||
|
NOTE: The range of PIDs or TIDs does not need to have every
|
||||||
|
position populated. In other words, for the example above, if
|
||||||
|
there is only one process, say PID 57, in the range of 50-65,
|
||||||
|
then only that process will be moved.
|
||||||
|
|
||||||
|
To move a PIDSPEC to a specific cpuset, you can either specify
|
||||||
|
the PIDSPEC with --pid and the destination cpuset with --toset,
|
||||||
|
or use the short hand and list the cpuset name after the PIDSPEC
|
||||||
|
for the --move arguments.
|
||||||
|
|
||||||
|
The move command accepts multiple common calling methods.
|
||||||
|
For example, the following commands are equivalent:
|
||||||
|
|
||||||
|
*+# cset proc --move 2442,3000-3200 reserved_set+*
|
||||||
|
|
||||||
|
*+# cset proc --move --pid=2442,3000-3200 --toset=reserved_set+*
|
||||||
|
|
||||||
|
These commands move the tasks defined as 2442 and any running task
|
||||||
|
between 3000 and 3200 inclusive of the ends to the cpuset called
|
||||||
|
"reserved_set".
|
||||||
|
|
||||||
|
Specifying the --fromset is not necesary since the tasks will be
|
||||||
|
moved to the destination cpuset no matter which cpuset they are
|
||||||
|
currently running on.
|
||||||
|
|
||||||
|
NOTE: However, if you do specify a cpuset with the --fromset
|
||||||
|
option, then only those tasks that are both in the PIDSPEC *and*
|
||||||
|
are running in the cpuset specified by --fromset will be moved.
|
||||||
|
I.e., if there is a task running on the system but not in
|
||||||
|
--fromset that is in PIDSPEC, it will not be moved.
|
||||||
|
|
||||||
|
To move all userspace tasks from one cpuset to another, you need
|
||||||
|
to specify the source and destination cpuset by name.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
*+# cset proc --move --fromset=comp1 --toset=comp42+*
|
||||||
|
|
||||||
|
This command specifies that all processes and threads
|
||||||
|
running on cpuset "comp1" be moved to cpuset "comp42".
|
||||||
|
|
||||||
|
NOTE: This move command will not move kernel threads unless
|
||||||
|
the -k/--kthread switch is specified. If it is, then all unbound
|
||||||
|
kernel threads will be added to the move. Unbound kernel threads
|
||||||
|
are those that can run on any CPU. If you *also specify* the
|
||||||
|
-a/--all switch, then all tasks, kernel or not, bound or not,
|
||||||
|
will be moved.
|
||||||
|
|
||||||
|
CAUTION: Please be cautious with the --all switch, since moving a
|
||||||
|
kernel thread that is bound to a specific CPU to a cpuset that
|
||||||
|
does not include that CPU can cause a system hang.
|
||||||
|
|
||||||
|
You must specify unique cpuset names for the both exec and move
|
||||||
|
commands. If a simple name passed to the --fromset, --toset and
|
||||||
|
--set parameters is unique on the system then that command
|
||||||
|
executes. However, if there are multiple cpusets by that name,
|
||||||
|
then you will need to specify which one you mean with a full path
|
||||||
|
rooted at the base cpuset tree.
|
||||||
|
|
||||||
|
For example, suppose you have the following cpuset tree:
|
||||||
|
|
||||||
|
/cpusets
|
||||||
|
/group1
|
||||||
|
/myset
|
||||||
|
/yourset
|
||||||
|
/group2
|
||||||
|
/myset
|
||||||
|
/yourset
|
||||||
|
|
||||||
|
Then, to move a process from myset in group1 to yourset in
|
||||||
|
group2, you would have to issue the following command:
|
||||||
|
|
||||||
|
+# cset proc --move --pid=50 --fromset=/group1/myset --toset=/group2/yourset+
|
||||||
|
|
||||||
|
You do not have to worry about where in the Linux filesystem the
|
||||||
|
cpuset filesystem is mounted. The cset command takes care of that.
|
||||||
|
Any cpusets that are specifed by path (such as above), are done with
|
||||||
|
respect to the root of the cpuset filesystem.
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
-------
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
manlink:cset[1], csetlink:set[], csetlink:shield[], manlink:taskset[1],
|
||||||
|
manlink:chrt[1]
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
@ -0,0 +1,109 @@
|
|||||||
|
.\" ** You probably do not want to edit this file directly **
|
||||||
|
.\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
|
||||||
|
.\" Instead of manually editing it, you probably should edit the DocBook XML
|
||||||
|
.\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
|
||||||
|
.TH "CSET\-SET" "1" "05/30/2008" "" ""
|
||||||
|
.\" disable hyphenation
|
||||||
|
.nh
|
||||||
|
.\" disable justification (adjust text to left margin only)
|
||||||
|
.ad l
|
||||||
|
.SH "NAME"
|
||||||
|
cset\-set \- manage sets of cpus
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
.sp
|
||||||
|
.nf
|
||||||
|
\fIcset\fR [cset options] \fIset\fR [set options] [args]
|
||||||
|
\fIcset\fR set \-\-help
|
||||||
|
\fIcset\fR set
|
||||||
|
\fIcset\fR set \-\-all
|
||||||
|
\fIcset\fR set \-\-recurse
|
||||||
|
\fIcset\fR set \-\-list myset
|
||||||
|
\fIcset\fR set myset
|
||||||
|
\fIcset\fR set \-\-all myset
|
||||||
|
\fIcset\fR set \-\-recurse \-\-list myset
|
||||||
|
\fIcset\fR set \-\-cpu 2\-5 \-\-mem 0 \-\-set newset
|
||||||
|
\fIcset\fR set \-\-cpu 2\-5 newset
|
||||||
|
\fIcset\fR set \-\-cpu 1,2,5\-7 another_set
|
||||||
|
\fIcset\fR set \-\-destroy newset
|
||||||
|
\fIcset\fR set \-\-destroy /mygroup_sets/my_set
|
||||||
|
.fi
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.TP
|
||||||
|
\-h, \-\-help
|
||||||
|
prints the list of options for this command
|
||||||
|
.TP
|
||||||
|
\-l, \-\-list
|
||||||
|
list the named cpuset(s); if \-a is used, will list members of named cpuset; if \-r is used, will list recursively
|
||||||
|
.TP
|
||||||
|
\-c CPUSPEC, \-\-cpu=CPUSPEC
|
||||||
|
create or modify cpuset in the specified cpuset with CPUSPEC specification
|
||||||
|
.TP
|
||||||
|
\-m MEMSPEC, \-\-mem=MEMSPEC
|
||||||
|
specify which memory nodes to assign to the created or modified cpuset
|
||||||
|
.TP
|
||||||
|
\-d, \-\-destroy
|
||||||
|
destroy specified cpuset
|
||||||
|
.TP
|
||||||
|
\-s CPUSET, \-\-set=CPUSET
|
||||||
|
specify cpuset name to be acted on
|
||||||
|
.TP
|
||||||
|
\-a, \-\-all
|
||||||
|
also do listing of members of specified cpuset, for use with \-\-list
|
||||||
|
.TP
|
||||||
|
\-r, \-\-recurse
|
||||||
|
do recursive listing, for use with \-\-list
|
||||||
|
.TP
|
||||||
|
\-v, \-\-verbose
|
||||||
|
prints more detailed output, for the set command, using this flag will not chop listing to fit in 80 columns
|
||||||
|
.TP
|
||||||
|
\-\-cpu_exclusive
|
||||||
|
mark this cpuset as owning its CPUs exclusively
|
||||||
|
.TP
|
||||||
|
\-\-mem_exclusive
|
||||||
|
mark this cpuset as owning its MEMs exclusively
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
This command is used to create, modify, and destroy cpusets. Cpusets form a tree\-like structure rooted at the root cpuset which always includes all system CPUs and all system memory nodes.
|
||||||
|
|
||||||
|
A cpuset is an organizational unit that defines a group of CPUs and a group of memory nodes where a process or thread (i.e. task) is allowed to run on. For non\-NUMA machines, the memory node is always 0 (zero) and cannot be set to anything else. For NUMA machines, the memory node can be set to a similar specifcation as the CPU definition and will tie those memory nodes to that cpuset. You will usually want the memory nodes that belong to the CPUs defined to be in the same cpuset.
|
||||||
|
|
||||||
|
A cpuset can have exclusive right to the CPUs defined in it. This means that only this cpuset can own these CPUs. Similarly, a cpuset can have exclusive right to the memory nodes defined in it. This means that only this cpuset can own these memory nodes.
|
||||||
|
|
||||||
|
Cpusets can be specified by name or by path; however, care should be taken when specifying by name if the name is not unique. This tool will generally not let you do destructive things to non\-unique cpuset names.
|
||||||
|
|
||||||
|
Cpusets are uniquely specified by path. The path starts at where the cpusets filesystem is mounted so you generally do not have to know where that is. For example, so specify a cpuset that is called "two" which is a subset of "one" which in turn is a subset of the root cpuset, use the path "/one/two" regardless of where the cpusets filesystem is mounted.
|
||||||
|
|
||||||
|
When specifying CPUs, a so\-called CPUSPEC is used. The CPUSPEC will accept a comma\-separated list of CPUs and inclusive range specifications. For example, \-\-cpu=1,3,5\-7 will assign CPU1, CPU3, CPU5, CPU6, and CPU7 to the specified cpuset.
|
||||||
|
|
||||||
|
Note that cpusets follow certain rules. For example, children can only include CPUs that the parents already have. If you do not follow those rules, the kernel cpuset subsystem will not let you create that cpuset. For example, if you create a cpuset that contains CPU3, and then attempt to create a child of that cpuset with a CPU other than 3, you will get an error, and the cpuset will not be active. The error is somewhat cryptic in that it is usually a "Permission denied" error.
|
||||||
|
|
||||||
|
Memory nodes are specified with a MEMSPEC in a similar way to the CPUSPEC. For example, \-\-mem=1,3\-6 will assign MEM1, MEM3, MEM4, MEM5, and MEM6 to the specified cpuset.
|
||||||
|
|
||||||
|
Note that if you attempt to create or modify a cpuset with a memory node specification that is not valid, you may get a cryptic error message, "No space left on device", and the modification will not be allowed.
|
||||||
|
|
||||||
|
When you destroy a cpuset, then the tasks running in that set are moved to the parent of that cpuset. If this is not what you want, then manually move those tasks to the cpuset of your choice with the \fIcset proc\fR command (see \fIcset proc \-\-help\fR for more information).
|
||||||
|
.SS "EXAMPLES"
|
||||||
|
.TP
|
||||||
|
Create a cpuset with the default memory specification
|
||||||
|
\fB# cset set \-\-cpu=2,4,6\-8 \-\-set=new_set\fR
|
||||||
|
|
||||||
|
This command creates a cpuset called "new_set" located off the root cpuset which holds CPUS 2,4,6,7,8 and node 0 (interleaved) memory. Note that \-\-set is optional, and you can just specify the name for the new cpuset after all arguments.
|
||||||
|
.TP
|
||||||
|
Create a cpuset that specifies both CPUs and memory nodes
|
||||||
|
\fB# cset set \-\-cpu=3 \-\-mem=3 /rad/set_one\fR
|
||||||
|
|
||||||
|
Note that this command uses the full path method to specify the name of the new cpuset "/rad/set_one". It also names the new cpuset implicitily (i.e. no \-\-set option, although you can use that if you want to). If the "set_one" name is unique, you can subsequently refer to is just by that. Memory node 3 is assigned to this cpuset as well as CPU 3.
|
||||||
|
|
||||||
|
The above commands will create the new cpusets, or if they already exist, they will modify them to the new specifications.
|
||||||
|
.SH "LICENSE"
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
.SH "COPYRIGHT"
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
.SH "AUTHOR"
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked GIT (stgit) v0.13 (see http://gna.org/projects/stgit and http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBcset\fR(1), \fBcset\-proc\fR(1), \fBcset\-shield\fR(1), \fBtaskset\fR(1), \fBchrt\fR(1)
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
||||||
|
|
@ -0,0 +1,536 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta name="generator" content="AsciiDoc 8.1.0" />
|
||||||
|
<style type="text/css">
|
||||||
|
/* Debug borders */
|
||||||
|
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
|
||||||
|
/*
|
||||||
|
border: 1px solid red;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 1em 5% 1em 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: blue;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
a:visited {
|
||||||
|
color: fuchsia;
|
||||||
|
}
|
||||||
|
|
||||||
|
em {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
tt {
|
||||||
|
color: navy;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
margin-top: 1.2em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sectionbody {
|
||||||
|
font-family: serif;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border: 1px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
span#author {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
span#email {
|
||||||
|
}
|
||||||
|
span#revision {
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: small;
|
||||||
|
border-top: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
margin-top: 4.0em;
|
||||||
|
}
|
||||||
|
div#footer-text {
|
||||||
|
float: left;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div#footer-badges {
|
||||||
|
float: right;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#preamble,
|
||||||
|
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
|
||||||
|
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-right: 10%;
|
||||||
|
margin-top: 1.5em;
|
||||||
|
margin-bottom: 1.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-top: 2.5em;
|
||||||
|
margin-bottom: 2.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.content { /* Block element content. */
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Block element titles. */
|
||||||
|
div.title, caption.title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div.title + * {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
td div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content + div.title {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sidebarblock > div.content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock {
|
||||||
|
margin-right: 0%;
|
||||||
|
}
|
||||||
|
div.listingblock > div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock > div.content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.attribution {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
div.verseblock + div.attribution {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.admonitionblock .icon {
|
||||||
|
vertical-align: top;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #527bbd;
|
||||||
|
padding-right: 0.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock td.content {
|
||||||
|
padding-left: 0.5em;
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock > div.content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.verseblock div.content {
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.imageblock div.content { padding-left: 0; }
|
||||||
|
div.imageblock img { border: 1px solid silver; }
|
||||||
|
span.image img { border-style: none; }
|
||||||
|
|
||||||
|
dl {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
dt {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
dd > *:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul, ol {
|
||||||
|
list-style-position: outside;
|
||||||
|
}
|
||||||
|
ol.olist2 {
|
||||||
|
list-style-type: lower-alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tableblock > table {
|
||||||
|
border: 3px solid #527bbd;
|
||||||
|
}
|
||||||
|
thead {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
tfoot {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.hlist {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist1 {
|
||||||
|
vertical-align: top;
|
||||||
|
font-style: italic;
|
||||||
|
padding-right: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist2 {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
div#footer-badges { display: none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
div#toctitle {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toclevel1, div.toclevel2 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
div.toclevel2 {
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
include1::./stylesheets/xhtml11-manpage.css[]
|
||||||
|
/* Workarounds for IE6's broken and incomplete CSS2. */
|
||||||
|
|
||||||
|
div.sidebar-content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
div.sidebar-title, div.image-title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 0.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock-content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock-content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding-left: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IE6 sets dynamically generated links as visited. */
|
||||||
|
div#toc a:visited { color: blue; }
|
||||||
|
</style>
|
||||||
|
<title>cset-set(1)</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<h1>
|
||||||
|
cset-set(1) Manual Page
|
||||||
|
</h1>
|
||||||
|
<h2>NAME</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>cset-set -
|
||||||
|
manage sets of cpus
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2>SYNOPSIS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<div class="verseblock">
|
||||||
|
<div class="content"><em>cset</em> [cset options] <em>set</em> [set options] [args]
|
||||||
|
<em>cset</em> set --help
|
||||||
|
<em>cset</em> set
|
||||||
|
<em>cset</em> set --all
|
||||||
|
<em>cset</em> set --recurse
|
||||||
|
<em>cset</em> set --list myset
|
||||||
|
<em>cset</em> set myset
|
||||||
|
<em>cset</em> set --all myset
|
||||||
|
<em>cset</em> set --recurse --list myset
|
||||||
|
<em>cset</em> set --cpu 2-5 --mem 0 --set newset
|
||||||
|
<em>cset</em> set --cpu 2-5 newset
|
||||||
|
<em>cset</em> set --cpu 1,2,5-7 another_set
|
||||||
|
<em>cset</em> set --destroy newset
|
||||||
|
<em>cset</em> set --destroy /mygroup_sets/my_set</div></div>
|
||||||
|
</div>
|
||||||
|
<h2>OPTIONS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
-h, --help
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
prints the list of options for this command
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-l, --list
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
list the named cpuset(s); if -a is used, will list members of named
|
||||||
|
cpuset; if -r is used, will list recursively
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-c CPUSPEC, --cpu=CPUSPEC
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
create or modify cpuset in the specified cpuset with CPUSPEC
|
||||||
|
specification
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-m MEMSPEC, --mem=MEMSPEC
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
specify which memory nodes to assign to the created or modified
|
||||||
|
cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-d, --destroy
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
destroy specified cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-s CPUSET, --set=CPUSET
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
specify cpuset name to be acted on
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-a, --all
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
also do listing of members of specified cpuset, for use with --list
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-r, --recurse
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
do recursive listing, for use with --list
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-v, --verbose
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
prints more detailed output, for the set command, using this flag
|
||||||
|
will not chop listing to fit in 80 columns
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
--cpu_exclusive
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
mark this cpuset as owning its CPUs exclusively
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
--mem_exclusive
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
mark this cpuset as owning its MEMs exclusively
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<h2>DESCRIPTION</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>This command is used to create, modify, and destroy cpusets.
|
||||||
|
Cpusets form a tree-like structure rooted at the root cpuset
|
||||||
|
which always includes all system CPUs and all system memory
|
||||||
|
nodes.</p>
|
||||||
|
<p>A cpuset is an organizational unit that defines a group of CPUs
|
||||||
|
and a group of memory nodes where a process or thread (i.e. task)
|
||||||
|
is allowed to run on. For non-NUMA machines, the memory node is
|
||||||
|
always 0 (zero) and cannot be set to anything else. For NUMA
|
||||||
|
machines, the memory node can be set to a similar specifcation
|
||||||
|
as the CPU definition and will tie those memory nodes to that
|
||||||
|
cpuset. You will usually want the memory nodes that belong to
|
||||||
|
the CPUs defined to be in the same cpuset.</p>
|
||||||
|
<p>A cpuset can have exclusive right to the CPUs defined in it.
|
||||||
|
This means that only this cpuset can own these CPUs. Similarly,
|
||||||
|
a cpuset can have exclusive right to the memory nodes defined in
|
||||||
|
it. This means that only this cpuset can own these memory
|
||||||
|
nodes.</p>
|
||||||
|
<p>Cpusets can be specified by name or by path; however, care
|
||||||
|
should be taken when specifying by name if the name is not
|
||||||
|
unique. This tool will generally not let you do destructive
|
||||||
|
things to non-unique cpuset names.</p>
|
||||||
|
<p>Cpusets are uniquely specified by path. The path starts at where
|
||||||
|
the cpusets filesystem is mounted so you generally do not have to
|
||||||
|
know where that is. For example, so specify a cpuset that is
|
||||||
|
called "two" which is a subset of "one" which in turn is a subset
|
||||||
|
of the root cpuset, use the path "/one/two" regardless of where
|
||||||
|
the cpusets filesystem is mounted.</p>
|
||||||
|
<p>When specifying CPUs, a so-called CPUSPEC is used. The CPUSPEC
|
||||||
|
will accept a comma-separated list of CPUs and inclusive range
|
||||||
|
specifications. For example, --cpu=1,3,5-7 will assign CPU1,
|
||||||
|
CPU3, CPU5, CPU6, and CPU7 to the specified cpuset.</p>
|
||||||
|
<p>Note that cpusets follow certain rules. For example, children
|
||||||
|
can only include CPUs that the parents already have. If you do
|
||||||
|
not follow those rules, the kernel cpuset subsystem will not let
|
||||||
|
you create that cpuset. For example, if you create a cpuset that
|
||||||
|
contains CPU3, and then attempt to create a child of that cpuset
|
||||||
|
with a CPU other than 3, you will get an error, and the cpuset
|
||||||
|
will not be active. The error is somewhat cryptic in that it is
|
||||||
|
usually a "Permission denied" error.</p>
|
||||||
|
<p>Memory nodes are specified with a MEMSPEC in a similar way to
|
||||||
|
the CPUSPEC. For example, --mem=1,3-6 will assign MEM1, MEM3,
|
||||||
|
MEM4, MEM5, and MEM6 to the specified cpuset.</p>
|
||||||
|
<p>Note that if you attempt to create or modify a cpuset with a
|
||||||
|
memory node specification that is not valid, you may get a
|
||||||
|
cryptic error message, "No space left on device", and the
|
||||||
|
modification will not be allowed.</p>
|
||||||
|
<p>When you destroy a cpuset, then the tasks running in that set are
|
||||||
|
moved to the parent of that cpuset. If this is not what you
|
||||||
|
want, then manually move those tasks to the cpuset of your choice
|
||||||
|
with the <em>cset proc</em> command (see <em>cset proc --help</em> for more
|
||||||
|
information).</p>
|
||||||
|
<h3>EXAMPLES</h3>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
Create a cpuset with the default memory specification
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
<strong><tt># cset set --cpu=2,4,6-8 --set=new_set</tt></strong>
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<p>This command creates a cpuset called "new_set" located
|
||||||
|
off the root cpuset which holds CPUS 2,4,6,7,8 and node 0
|
||||||
|
(interleaved) memory. Note that --set is optional, and
|
||||||
|
you can just specify the name for the new cpuset after
|
||||||
|
all arguments.</p>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
Create a cpuset that specifies both CPUs and memory nodes
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
<strong><tt># cset set --cpu=3 --mem=3 /rad/set_one</tt></strong>
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<p>Note that this command uses the full path method to
|
||||||
|
specify the name of the new cpuset "/rad/set_one". It
|
||||||
|
also names the new cpuset implicitily (i.e. no --set
|
||||||
|
option, although you can use that if you want to). If
|
||||||
|
the "set_one" name is unique, you can subsequently refer
|
||||||
|
to is just by that. Memory node 3 is assigned to this
|
||||||
|
cpuset as well as CPU 3.</p>
|
||||||
|
<p>The above commands will create the new cpusets, or if they
|
||||||
|
already exist, they will modify them to the new specifications.</p>
|
||||||
|
</div>
|
||||||
|
<h2>LICENSE</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Cpuset is licensed under the GNU GPL V2 only.</p>
|
||||||
|
</div>
|
||||||
|
<h2>COPYRIGHT</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Copyright (c) 2008 Novell Inc.</p>
|
||||||
|
</div>
|
||||||
|
<h2>AUTHOR</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Written by Alex Tsariounov <alext@novell.com>.</p>
|
||||||
|
<p>Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.</p>
|
||||||
|
</div>
|
||||||
|
<h2>SEE ALSO</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p><a href="cset.html">cset(1)</a>, <a href="cset-proc.html">cset-proc(1)</a>, <a href="cset-shield.html">cset-shield(1)</a>, <a href="taskset.html">taskset(1)</a>,
|
||||||
|
<a href="chrt.html">chrt(1)</a></p>
|
||||||
|
<p>/usr/src/linux/Documentation/cpusets.txt</p>
|
||||||
|
</div>
|
||||||
|
<div id="footer">
|
||||||
|
<div id="footer-text">
|
||||||
|
Version 1.0<br />
|
||||||
|
Last updated 30-May-2008 14:33:23 MDT
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,179 @@
|
|||||||
|
cset-set(1)
|
||||||
|
===========
|
||||||
|
Alex Tsariounov <alext@novell.com>
|
||||||
|
v1.0, May 2008
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cset-set - manage sets of cpus
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
[verse]
|
||||||
|
'cset' [cset options] 'set' [set options] [args]
|
||||||
|
'cset' set --help
|
||||||
|
'cset' set
|
||||||
|
'cset' set --all
|
||||||
|
'cset' set --recurse
|
||||||
|
'cset' set --list myset
|
||||||
|
'cset' set myset
|
||||||
|
'cset' set --all myset
|
||||||
|
'cset' set --recurse --list myset
|
||||||
|
'cset' set --cpu 2-5 --mem 0 --set newset
|
||||||
|
'cset' set --cpu 2-5 newset
|
||||||
|
'cset' set --cpu 1,2,5-7 another_set
|
||||||
|
'cset' set --destroy newset
|
||||||
|
'cset' set --destroy /mygroup_sets/my_set
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-------
|
||||||
|
-h, --help::
|
||||||
|
prints the list of options for this command
|
||||||
|
|
||||||
|
-l, --list::
|
||||||
|
list the named cpuset(s); if -a is used, will list members of named
|
||||||
|
cpuset; if -r is used, will list recursively
|
||||||
|
|
||||||
|
-c CPUSPEC, --cpu=CPUSPEC::
|
||||||
|
create or modify cpuset in the specified cpuset with CPUSPEC
|
||||||
|
specification
|
||||||
|
|
||||||
|
-m MEMSPEC, --mem=MEMSPEC::
|
||||||
|
specify which memory nodes to assign to the created or modified
|
||||||
|
cpuset
|
||||||
|
|
||||||
|
-d, --destroy::
|
||||||
|
destroy specified cpuset
|
||||||
|
|
||||||
|
-s CPUSET, --set=CPUSET::
|
||||||
|
specify cpuset name to be acted on
|
||||||
|
|
||||||
|
-a, --all::
|
||||||
|
also do listing of members of specified cpuset, for use with --list
|
||||||
|
|
||||||
|
-r, --recurse::
|
||||||
|
do recursive listing, for use with --list
|
||||||
|
|
||||||
|
-v, --verbose::
|
||||||
|
prints more detailed output, for the set command, using this flag
|
||||||
|
will not chop listing to fit in 80 columns
|
||||||
|
|
||||||
|
--cpu_exclusive::
|
||||||
|
mark this cpuset as owning its CPUs exclusively
|
||||||
|
|
||||||
|
--mem_exclusive::
|
||||||
|
mark this cpuset as owning its MEMs exclusively
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This command is used to create, modify, and destroy cpusets.
|
||||||
|
Cpusets form a tree-like structure rooted at the root cpuset
|
||||||
|
which always includes all system CPUs and all system memory
|
||||||
|
nodes.
|
||||||
|
|
||||||
|
A cpuset is an organizational unit that defines a group of CPUs
|
||||||
|
and a group of memory nodes where a process or thread (i.e. task)
|
||||||
|
is allowed to run on. For non-NUMA machines, the memory node is
|
||||||
|
always 0 (zero) and cannot be set to anything else. For NUMA
|
||||||
|
machines, the memory node can be set to a similar specifcation
|
||||||
|
as the CPU definition and will tie those memory nodes to that
|
||||||
|
cpuset. You will usually want the memory nodes that belong to
|
||||||
|
the CPUs defined to be in the same cpuset.
|
||||||
|
|
||||||
|
A cpuset can have exclusive right to the CPUs defined in it.
|
||||||
|
This means that only this cpuset can own these CPUs. Similarly,
|
||||||
|
a cpuset can have exclusive right to the memory nodes defined in
|
||||||
|
it. This means that only this cpuset can own these memory
|
||||||
|
nodes.
|
||||||
|
|
||||||
|
Cpusets can be specified by name or by path; however, care
|
||||||
|
should be taken when specifying by name if the name is not
|
||||||
|
unique. This tool will generally not let you do destructive
|
||||||
|
things to non-unique cpuset names.
|
||||||
|
|
||||||
|
Cpusets are uniquely specified by path. The path starts at where
|
||||||
|
the cpusets filesystem is mounted so you generally do not have to
|
||||||
|
know where that is. For example, so specify a cpuset that is
|
||||||
|
called "two" which is a subset of "one" which in turn is a subset
|
||||||
|
of the root cpuset, use the path "/one/two" regardless of where
|
||||||
|
the cpusets filesystem is mounted.
|
||||||
|
|
||||||
|
When specifying CPUs, a so-called CPUSPEC is used. The CPUSPEC
|
||||||
|
will accept a comma-separated list of CPUs and inclusive range
|
||||||
|
specifications. For example, --cpu=1,3,5-7 will assign CPU1,
|
||||||
|
CPU3, CPU5, CPU6, and CPU7 to the specified cpuset.
|
||||||
|
|
||||||
|
Note that cpusets follow certain rules. For example, children
|
||||||
|
can only include CPUs that the parents already have. If you do
|
||||||
|
not follow those rules, the kernel cpuset subsystem will not let
|
||||||
|
you create that cpuset. For example, if you create a cpuset that
|
||||||
|
contains CPU3, and then attempt to create a child of that cpuset
|
||||||
|
with a CPU other than 3, you will get an error, and the cpuset
|
||||||
|
will not be active. The error is somewhat cryptic in that it is
|
||||||
|
usually a "Permission denied" error.
|
||||||
|
|
||||||
|
Memory nodes are specified with a MEMSPEC in a similar way to
|
||||||
|
the CPUSPEC. For example, --mem=1,3-6 will assign MEM1, MEM3,
|
||||||
|
MEM4, MEM5, and MEM6 to the specified cpuset.
|
||||||
|
|
||||||
|
Note that if you attempt to create or modify a cpuset with a
|
||||||
|
memory node specification that is not valid, you may get a
|
||||||
|
cryptic error message, "No space left on device", and the
|
||||||
|
modification will not be allowed.
|
||||||
|
|
||||||
|
When you destroy a cpuset, then the tasks running in that set are
|
||||||
|
moved to the parent of that cpuset. If this is not what you
|
||||||
|
want, then manually move those tasks to the cpuset of your choice
|
||||||
|
with the 'cset proc' command (see 'cset proc --help' for more
|
||||||
|
information).
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
~~~~~~~~
|
||||||
|
|
||||||
|
Create a cpuset with the default memory specification::
|
||||||
|
|
||||||
|
*+# cset set --cpu=2,4,6-8 --set=new_set+*
|
||||||
|
|
||||||
|
This command creates a cpuset called "new_set" located
|
||||||
|
off the root cpuset which holds CPUS 2,4,6,7,8 and node 0
|
||||||
|
(interleaved) memory. Note that --set is optional, and
|
||||||
|
you can just specify the name for the new cpuset after
|
||||||
|
all arguments.
|
||||||
|
|
||||||
|
Create a cpuset that specifies both CPUs and memory nodes::
|
||||||
|
|
||||||
|
*+# cset set --cpu=3 --mem=3 /rad/set_one+*
|
||||||
|
|
||||||
|
Note that this command uses the full path method to
|
||||||
|
specify the name of the new cpuset "/rad/set_one". It
|
||||||
|
also names the new cpuset implicitily (i.e. no --set
|
||||||
|
option, although you can use that if you want to). If
|
||||||
|
the "set_one" name is unique, you can subsequently refer
|
||||||
|
to is just by that. Memory node 3 is assigned to this
|
||||||
|
cpuset as well as CPU 3.
|
||||||
|
|
||||||
|
The above commands will create the new cpusets, or if they
|
||||||
|
already exist, they will modify them to the new specifications.
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
-------
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
manlink:cset[1], csetlink:proc[], csetlink:shield[], manlink:taskset[1],
|
||||||
|
manlink:chrt[1]
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
@ -0,0 +1,173 @@
|
|||||||
|
.\" ** You probably do not want to edit this file directly **
|
||||||
|
.\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
|
||||||
|
.\" Instead of manually editing it, you probably should edit the DocBook XML
|
||||||
|
.\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
|
||||||
|
.TH "CSET\-SHIELD" "1" "05/30/2008" "" ""
|
||||||
|
.\" disable hyphenation
|
||||||
|
.nh
|
||||||
|
.\" disable justification (adjust text to left margin only)
|
||||||
|
.ad l
|
||||||
|
.SH "NAME"
|
||||||
|
cset\-shield \- cpuset supercommand which implements cpu shielding
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
.sp
|
||||||
|
.nf
|
||||||
|
\fIcset\fR [cset options] \fIshield\fR [shield options] [args]
|
||||||
|
\fIcset\fR shield \-\-help
|
||||||
|
\fIcset\fR shield
|
||||||
|
\fIcset\fR shield \-\-cpu 1\-7
|
||||||
|
\fIcset\fR shield \-\-cpu 1\-7 \-\-kthread=on
|
||||||
|
\fIcset\fR shield \-\-exec /opt/software/myapp/doit \-\-my_opt1 \-\-my_opt2
|
||||||
|
\fIcset\fR shield \-\-user appuser \-\-exec run_benchmark.sh
|
||||||
|
\fIcset\fR shield \-\-shield 1024,2048,5000\-1000
|
||||||
|
\fIcset\fR shield \-\-unshield 6000\-8500
|
||||||
|
\fIcset\fR shield \-\-kthread=off
|
||||||
|
\fIcset\fR shield \-\-kthread=on
|
||||||
|
\fIcset\fR shield \-\-shield bash
|
||||||
|
.fi
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.TP
|
||||||
|
\-h, \-\-help
|
||||||
|
prints the list of options for this command
|
||||||
|
.TP
|
||||||
|
\-c CPUSPEC, \-\-cpu=CPUSPEC
|
||||||
|
modifies or initializes the shield cpusets
|
||||||
|
.TP
|
||||||
|
\-r, \-\-reset
|
||||||
|
destroys the shield
|
||||||
|
.TP
|
||||||
|
\-e, \-\-exec
|
||||||
|
executes args in the shield
|
||||||
|
.TP
|
||||||
|
\-\-user=USER
|
||||||
|
use this USER for \-\-exec (id or name)
|
||||||
|
.TP
|
||||||
|
\-\-group=GROUP
|
||||||
|
use this GROUP for \-\-exec (id or name)
|
||||||
|
.TP
|
||||||
|
\-s PIDSPEC, \-\-shield=PIDSPEC
|
||||||
|
shield specified PIDSPEC of processes or threads
|
||||||
|
.TP
|
||||||
|
\-u PIDSPEC, \-\-unshield=PIDSPEC
|
||||||
|
remove specified PIDSPEC of processes or threads from the shield, the task keep running in the unshielded cpuset
|
||||||
|
.TP
|
||||||
|
\-k on|off, \-\-kthread=on|off
|
||||||
|
shield from unbound interrupt threads as well
|
||||||
|
.TP
|
||||||
|
\-f, \-\-force
|
||||||
|
force operation, use with care
|
||||||
|
.TP
|
||||||
|
\-v, \-\-verbose
|
||||||
|
prints more detailed output, additive
|
||||||
|
.TP
|
||||||
|
\-\-sysset=SYSSET
|
||||||
|
optionally specify system cpuset name
|
||||||
|
.TP
|
||||||
|
\-\-userset=USERSET
|
||||||
|
optionally specify user cpuset name
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
This is a supercommand that creates basic cpu shielding. The normal cset commands can of course be used to create this basic shield, but the shield command combines many such commands to create and manage a common type of cpu shielding setup.
|
||||||
|
|
||||||
|
The concept of shielding implies at minimum three cpusets, for example: root, user and system. The root cpuset always exists in all implementations of cpusets and contains all available CPUs on the machine. The system cpuset is so named because normal system tasks are made to run on it. The user cpuset is so named because that is the "shielded" cpuset on which you would run your tasks of interest.
|
||||||
|
|
||||||
|
Usually, CPU zero would be in the system set and the rest of the CPUs would be in the user set. After creation of the cpusets, all processes running in the root cpuset are moved to the system cpuset. Thus any new processes or threads spawned from these processes will also run the system cpuset.
|
||||||
|
|
||||||
|
If the optional \-\-kthread=on option is given to the shield command, then all kernel threads (with exception of the per\-CPU bound interrupt kernel threads) are also moved to the system set.
|
||||||
|
|
||||||
|
One executes processes on the shielded user cpuset with the \-\-exec subcommand or moves processes or threads to the shielded cpuset with the \-\-shield subcommand.
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
You do not need to specify which cpuset a process or thread is running in initially when using the \-\-shield subcommand.
|
||||||
|
|
||||||
|
To create a shield, you would execute the shield command with the \-\-cpu option that specifies CPUSPEC argument that assigns CPUs to be under the shield (this means assigned to the user cpuset, all other cpus will be assigned to the system set).
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
\fB# cset shield \-\-cpu=3\fR
|
||||||
|
|
||||||
|
On a 4\-way machine, this command will dedicate the first 3 processors, CPU0\-CPU2, for the system set (unshielded) and only the last processor, CPU3, for the user set (shielded).
|
||||||
|
|
||||||
|
The CPUSPEC will accept a comma separated list of CPUs and inclusive range specifications. For example, \-\-cpu=1,3,5\-7 will assign CPU1, CPU3, CPU5, CPU6, and CPU7 to the user (or shielded) cpuset.
|
||||||
|
|
||||||
|
If you do not like the names "system" and "user" for the unshielded and shielded sets respectively, or if those names are used already, then use the \-\-sysset and \-\-userset options.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
\fB# cset shield \-\-sysset=free \-\-userset=cage \-\-cpu=2,3 \-\-kthread=on\fR
|
||||||
|
|
||||||
|
The above command will use the name "free" for the unshielded system cpuset, the name "cage" for the shielded user cpuset, initialize these cpusets and dedicate CPU0 and CPU1 to the "free" set and (on a 4\-way machine) dedicate CPU2 and CPU3 to the "cage" set. Further, the command moves all processes and threads, including kernel threads from the root cpuset to the "free" cpuset.
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
If you do use the \-\-syset/\-\-userset options, then you must continue to use those for every invocation of the shield supercommand.
|
||||||
|
|
||||||
|
After initialization, you can run the process of interest on the shielded cpuset with the \-\-exec subcommand, or move processes or threads already running to the shielded cpuset with the \-\-shield subcommand.
|
||||||
|
|
||||||
|
The PIDSPEC argument taken for the \-\-shield (or \-s) subcommand is a comma separated list of PIDs or TIDs. The list can also include brackets of PIDs or TIDs that are inclusive of the endpoints.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
.sp
|
||||||
|
.nf
|
||||||
|
1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600\-700 Means processes 1, 2 and from 600 to 700
|
||||||
|
.fi
|
||||||
|
\fB# cset shield \-\-shield=50\-65\fR
|
||||||
|
|
||||||
|
The above command moves all processes and threads with PID or TID in the range 50\-65 inclusive, from any cpuset they may be running in into the shielded user cpuset.
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
The range of PIDs or TIDs does not need to have every position populated. In other words, for the example above, if there is only one process, say PID 57, in the range of 50\-65, then only that process will be moved.
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBCaution\fR
|
||||||
|
Please note that there is no checking of processes you request to move into the shield with the \-\-shield command. This means that the tool will happily move, for example, kernel threads that are bound to specific CPUs with this command. You can hang your system by indiscriminately specifying arbitrary PIDs to the \-\-shield command so please be careful.
|
||||||
|
|
||||||
|
The \-\-unshield (or \-u) subcommand will remove the specified processes or threads from the shielded cpuset and move them into the unshielded (or system) cpuset. This option also takes a PIDSPEC argument, the same as for the \-\-shield subcommand.
|
||||||
|
|
||||||
|
Both the \-\-shield and the \-\-unshield commands will also finally output the number of tasks running in the shield and out of the shield. If you do not specify a PIDSPEC to these commands, then just that status is output. By specifying also a \-\-verbose in addition, then you will get a listing of every task that is running in either the shield or out of the shield.
|
||||||
|
|
||||||
|
Using no subcommand, ie. only "cset shield", will output the status of both shield and non\-shield. Tasks will be listed if \-\-verbose is used.
|
||||||
|
|
||||||
|
You can adjust which CPUs are in the shielded cpuset by issuing the \-\-cpu subcommand again anytime after the shield has been initialized.
|
||||||
|
|
||||||
|
For example if the original shield contained CPU0 and CPU1 in the system set and CPU2 and CPU3 in the user set, if you then issue the following command:
|
||||||
|
|
||||||
|
\fB# cset shield \-\-cpu=1,2,3\fR
|
||||||
|
|
||||||
|
then that command will move CPU1 into the shielded "user" cpuset. Any processes or threads that were running on CPU1 that belonged to the unshielded "system" cpuset are migrated to CPU0 by the system.
|
||||||
|
|
||||||
|
The \-\-reset subcommand will in essence destroy the shield. For example, if there was a shield on a 4\-way machine with CPU0 in system and CPUs 1\-3 in user with processes running on the user cpuset (i.e. in the shield), and a \-\-reset subcommand was issued, then all processes running in both system and user cpusets would be migrated to the root cpuset (which has access to all CPUs and never goes away), after which both system and user cpusets would be destroyed.
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
Even though you can mix general usage of cpusets with the shielding concepts described here, you generally will not want to. For more complex shielding or usage scenarios, one would generally use the normal cpuset commands (i.e. cset set and proc) directly.
|
||||||
|
.SH "LICENSE"
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
.SH "COPYRIGHT"
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
.SH "AUTHOR"
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked GIT (stgit) v0.13 (see http://gna.org/projects/stgit and http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBcset\fR(1), \fBcset\-set\fR(1), \fBcset\-proc\fR(1), \fBtaskset\fR(1), \fBchrt\fR(1)
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
||||||
|
|
@ -0,0 +1,613 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta name="generator" content="AsciiDoc 8.1.0" />
|
||||||
|
<style type="text/css">
|
||||||
|
/* Debug borders */
|
||||||
|
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
|
||||||
|
/*
|
||||||
|
border: 1px solid red;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 1em 5% 1em 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: blue;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
a:visited {
|
||||||
|
color: fuchsia;
|
||||||
|
}
|
||||||
|
|
||||||
|
em {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
tt {
|
||||||
|
color: navy;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
margin-top: 1.2em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sectionbody {
|
||||||
|
font-family: serif;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border: 1px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
span#author {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
span#email {
|
||||||
|
}
|
||||||
|
span#revision {
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: small;
|
||||||
|
border-top: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
margin-top: 4.0em;
|
||||||
|
}
|
||||||
|
div#footer-text {
|
||||||
|
float: left;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div#footer-badges {
|
||||||
|
float: right;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#preamble,
|
||||||
|
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
|
||||||
|
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-right: 10%;
|
||||||
|
margin-top: 1.5em;
|
||||||
|
margin-bottom: 1.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-top: 2.5em;
|
||||||
|
margin-bottom: 2.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.content { /* Block element content. */
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Block element titles. */
|
||||||
|
div.title, caption.title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div.title + * {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
td div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content + div.title {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sidebarblock > div.content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock {
|
||||||
|
margin-right: 0%;
|
||||||
|
}
|
||||||
|
div.listingblock > div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock > div.content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.attribution {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
div.verseblock + div.attribution {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.admonitionblock .icon {
|
||||||
|
vertical-align: top;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #527bbd;
|
||||||
|
padding-right: 0.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock td.content {
|
||||||
|
padding-left: 0.5em;
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock > div.content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.verseblock div.content {
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.imageblock div.content { padding-left: 0; }
|
||||||
|
div.imageblock img { border: 1px solid silver; }
|
||||||
|
span.image img { border-style: none; }
|
||||||
|
|
||||||
|
dl {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
dt {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
dd > *:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul, ol {
|
||||||
|
list-style-position: outside;
|
||||||
|
}
|
||||||
|
ol.olist2 {
|
||||||
|
list-style-type: lower-alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tableblock > table {
|
||||||
|
border: 3px solid #527bbd;
|
||||||
|
}
|
||||||
|
thead {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
tfoot {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.hlist {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist1 {
|
||||||
|
vertical-align: top;
|
||||||
|
font-style: italic;
|
||||||
|
padding-right: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist2 {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
div#footer-badges { display: none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
div#toctitle {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toclevel1, div.toclevel2 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
div.toclevel2 {
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
include1::./stylesheets/xhtml11-manpage.css[]
|
||||||
|
/* Workarounds for IE6's broken and incomplete CSS2. */
|
||||||
|
|
||||||
|
div.sidebar-content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
div.sidebar-title, div.image-title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 0.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock-content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock-content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding-left: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IE6 sets dynamically generated links as visited. */
|
||||||
|
div#toc a:visited { color: blue; }
|
||||||
|
</style>
|
||||||
|
<title>cset-shield(1)</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<h1>
|
||||||
|
cset-shield(1) Manual Page
|
||||||
|
</h1>
|
||||||
|
<h2>NAME</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>cset-shield -
|
||||||
|
cpuset supercommand which implements cpu shielding
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2>SYNOPSIS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<div class="verseblock">
|
||||||
|
<div class="content"><em>cset</em> [cset options] <em>shield</em> [shield options] [args]
|
||||||
|
<em>cset</em> shield --help
|
||||||
|
<em>cset</em> shield
|
||||||
|
<em>cset</em> shield --cpu 1-7
|
||||||
|
<em>cset</em> shield --cpu 1-7 --kthread=on
|
||||||
|
<em>cset</em> shield --exec /opt/software/myapp/doit --my_opt1 --my_opt2
|
||||||
|
<em>cset</em> shield --user appuser --exec run_benchmark.sh
|
||||||
|
<em>cset</em> shield --shield 1024,2048,5000-1000
|
||||||
|
<em>cset</em> shield --unshield 6000-8500
|
||||||
|
<em>cset</em> shield --kthread=off
|
||||||
|
<em>cset</em> shield --kthread=on
|
||||||
|
<em>cset</em> shield --shield bash</div></div>
|
||||||
|
</div>
|
||||||
|
<h2>OPTIONS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
-h, --help
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
prints the list of options for this command
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-c CPUSPEC, --cpu=CPUSPEC
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
modifies or initializes the shield cpusets
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-r, --reset
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
destroys the shield
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-e, --exec
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
executes args in the shield
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
--user=USER
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
use this USER for --exec (id or name)
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
--group=GROUP
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
use this GROUP for --exec (id or name)
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-s PIDSPEC, --shield=PIDSPEC
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
shield specified PIDSPEC of processes or threads
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-u PIDSPEC, --unshield=PIDSPEC
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
remove specified PIDSPEC of processes or threads from the shield,
|
||||||
|
the task keep running in the unshielded cpuset
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-k on|off, --kthread=on|off
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
shield from unbound interrupt threads as well
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-f, --force
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
force operation, use with care
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
-v, --verbose
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
prints more detailed output, additive
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
--sysset=SYSSET
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
optionally specify system cpuset name
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
--userset=USERSET
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
optionally specify user cpuset name
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<h2>DESCRIPTION</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>This is a supercommand that creates basic cpu shielding. The
|
||||||
|
normal cset commands can of course be used to create this basic
|
||||||
|
shield, but the shield command combines many such commands to
|
||||||
|
create and manage a common type of cpu shielding setup.</p>
|
||||||
|
<p>The concept of shielding implies at minimum three cpusets, for
|
||||||
|
example: root, user and system. The root cpuset always exists in
|
||||||
|
all implementations of cpusets and contains all available CPUs on
|
||||||
|
the machine. The system cpuset is so named because normal system
|
||||||
|
tasks are made to run on it. The user cpuset is so named because
|
||||||
|
that is the "shielded" cpuset on which you would run your tasks
|
||||||
|
of interest.</p>
|
||||||
|
<p>Usually, CPU zero would be in the system set and the rest of the
|
||||||
|
CPUs would be in the user set. After creation of the cpusets,
|
||||||
|
all processes running in the root cpuset are moved to the system
|
||||||
|
cpuset. Thus any new processes or threads spawned from these
|
||||||
|
processes will also run the system cpuset.</p>
|
||||||
|
<p>If the optional --kthread=on option is given to the shield
|
||||||
|
command, then all kernel threads (with exception of the per-CPU
|
||||||
|
bound interrupt kernel threads) are also moved to the system set.</p>
|
||||||
|
<p>One executes processes on the shielded user cpuset with the
|
||||||
|
--exec subcommand or moves processes or threads to the shielded
|
||||||
|
cpuset with the --shield subcommand.</p>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">You do not need to specify which cpuset a process or thread
|
||||||
|
is running in initially when using the --shield subcommand.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<p>To create a shield, you would execute the shield command with the
|
||||||
|
--cpu option that specifies CPUSPEC argument that assigns CPUs to
|
||||||
|
be under the shield (this means assigned to the user cpuset, all
|
||||||
|
other cpus will be assigned to the system set).</p>
|
||||||
|
<p>For example:</p>
|
||||||
|
<p><strong><tt># cset shield --cpu=3</tt></strong></p>
|
||||||
|
<p>On a 4-way machine, this command will dedicate the first
|
||||||
|
3 processors, CPU0-CPU2, for the system set (unshielded)
|
||||||
|
and only the last processor, CPU3, for the user set
|
||||||
|
(shielded).</p>
|
||||||
|
<p>The CPUSPEC will accept a comma separated list of CPUs and
|
||||||
|
inclusive range specifications. For example, --cpu=1,3,5-7 will
|
||||||
|
assign CPU1, CPU3, CPU5, CPU6, and CPU7 to the user (or shielded)
|
||||||
|
cpuset.</p>
|
||||||
|
<p>If you do not like the names "system" and "user" for the
|
||||||
|
unshielded and shielded sets respectively, or if those names are
|
||||||
|
used already, then use the --sysset and --userset options.</p>
|
||||||
|
<p>For example:</p>
|
||||||
|
<p><strong><tt># cset shield --sysset=free --userset=cage --cpu=2,3 --kthread=on</tt></strong></p>
|
||||||
|
<p>The above command will use the name "free" for the unshielded
|
||||||
|
system cpuset, the name "cage" for the shielded user cpuset,
|
||||||
|
initialize these cpusets and dedicate CPU0 and CPU1 to the "free"
|
||||||
|
set and (on a 4-way machine) dedicate CPU2 and CPU3 to the "cage"
|
||||||
|
set. Further, the command moves all processes and threads,
|
||||||
|
including kernel threads from the root cpuset to the "free"
|
||||||
|
cpuset.</p>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">If you do use the --syset/--userset options, then you must
|
||||||
|
continue to use those for every invocation of the shield supercommand.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<p>After initialization, you can run the process of interest on the
|
||||||
|
shielded cpuset with the --exec subcommand, or move processes or
|
||||||
|
threads already running to the shielded cpuset with the --shield
|
||||||
|
subcommand.</p>
|
||||||
|
<p>The PIDSPEC argument taken for the --shield (or -s) subcommand is
|
||||||
|
a comma separated list of PIDs or TIDs. The list can also
|
||||||
|
include brackets of PIDs or TIDs that are inclusive of the
|
||||||
|
endpoints.</p>
|
||||||
|
<p>For example:</p>
|
||||||
|
<div class="literalblock">
|
||||||
|
<div class="content">
|
||||||
|
<pre><tt>1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600-700 Means processes 1, 2 and from 600 to 700</tt></pre>
|
||||||
|
</div></div>
|
||||||
|
<p><strong><tt># cset shield --shield=50-65</tt></strong></p>
|
||||||
|
<p>The above command moves all processes and threads with PID or
|
||||||
|
TID in the range 50-65 inclusive, from any cpuset they may
|
||||||
|
be running in into the shielded user cpuset.</p>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">The range of PIDs or TIDs does not need to have every
|
||||||
|
position populated. In other words, for the example above, if
|
||||||
|
there is only one process, say PID 57, in the range of 50-65,
|
||||||
|
then only that process will be moved.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Caution</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">Please note that there is no checking of processes you
|
||||||
|
request to move into the shield with the --shield command. This
|
||||||
|
means that the tool will happily move, for example, kernel
|
||||||
|
threads that are bound to specific CPUs with this command. You
|
||||||
|
can hang your system by indiscriminately specifying arbitrary
|
||||||
|
PIDs to the --shield command so please be careful.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<p>The --unshield (or -u) subcommand will remove the specified
|
||||||
|
processes or threads from the shielded cpuset and move them into
|
||||||
|
the unshielded (or system) cpuset. This option also takes a
|
||||||
|
PIDSPEC argument, the same as for the --shield subcommand.</p>
|
||||||
|
<p>Both the --shield and the --unshield commands will also finally
|
||||||
|
output the number of tasks running in the shield and out of the
|
||||||
|
shield. If you do not specify a PIDSPEC to these commands, then
|
||||||
|
just that status is output. By specifying also a --verbose in
|
||||||
|
addition, then you will get a listing of every task that is
|
||||||
|
running in either the shield or out of the shield.</p>
|
||||||
|
<p>Using no subcommand, ie. only "cset shield", will output the
|
||||||
|
status of both shield and non-shield. Tasks will be listed if
|
||||||
|
--verbose is used.</p>
|
||||||
|
<p>You can adjust which CPUs are in the shielded cpuset by issuing
|
||||||
|
the --cpu subcommand again anytime after the shield has been
|
||||||
|
initialized.</p>
|
||||||
|
<p>For example if the original shield contained CPU0 and CPU1 in the
|
||||||
|
system set and CPU2 and CPU3 in the user set, if you then issue
|
||||||
|
the following command:</p>
|
||||||
|
<p><strong><tt># cset shield --cpu=1,2,3</tt></strong></p>
|
||||||
|
<p>then that command will move CPU1 into the shielded "user" cpuset.
|
||||||
|
Any processes or threads that were running on CPU1 that belonged
|
||||||
|
to the unshielded "system" cpuset are migrated to CPU0 by the
|
||||||
|
system.</p>
|
||||||
|
<p>The --reset subcommand will in essence destroy the shield. For
|
||||||
|
example, if there was a shield on a 4-way machine with CPU0 in
|
||||||
|
system and CPUs 1-3 in user with processes running on the user
|
||||||
|
cpuset (i.e. in the shield), and a --reset subcommand was issued,
|
||||||
|
then all processes running in both system and user cpusets would
|
||||||
|
be migrated to the root cpuset (which has access to all CPUs and
|
||||||
|
never goes away), after which both system and user cpusets would
|
||||||
|
be destroyed.</p>
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">Even though you can mix general usage of cpusets with
|
||||||
|
the shielding concepts described here, you generally will not
|
||||||
|
want to. For more complex shielding or usage scenarios, one
|
||||||
|
would generally use the normal cpuset commands (i.e. cset set
|
||||||
|
and proc) directly.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2>LICENSE</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Cpuset is licensed under the GNU GPL V2 only.</p>
|
||||||
|
</div>
|
||||||
|
<h2>COPYRIGHT</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Copyright (c) 2008 Novell Inc.</p>
|
||||||
|
</div>
|
||||||
|
<h2>AUTHOR</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Written by Alex Tsariounov <alext@novell.com>.</p>
|
||||||
|
<p>Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.</p>
|
||||||
|
</div>
|
||||||
|
<h2>SEE ALSO</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p><a href="cset.html">cset(1)</a>, <a href="cset-set.html">cset-set(1)</a>, <a href="cset-proc.html">cset-proc(1)</a>, <a href="taskset.html">taskset(1)</a>,
|
||||||
|
<a href="chrt.html">chrt(1)</a></p>
|
||||||
|
<p>/usr/src/linux/Documentation/cpusets.txt</p>
|
||||||
|
</div>
|
||||||
|
<div id="footer">
|
||||||
|
<div id="footer-text">
|
||||||
|
Version 1.0<br />
|
||||||
|
Last updated 30-May-2008 14:33:24 MDT
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,238 @@
|
|||||||
|
cset-shield(1)
|
||||||
|
==============
|
||||||
|
Alex Tsariounov <alext@novell.com>
|
||||||
|
v1.0, May 2008
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cset-shield - cpuset supercommand which implements cpu shielding
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
[verse]
|
||||||
|
'cset' [cset options] 'shield' [shield options] [args]
|
||||||
|
'cset' shield --help
|
||||||
|
'cset' shield
|
||||||
|
'cset' shield --cpu 1-7
|
||||||
|
'cset' shield --cpu 1-7 --kthread=on
|
||||||
|
'cset' shield --exec /opt/software/myapp/doit --my_opt1 --my_opt2
|
||||||
|
'cset' shield --user appuser --exec run_benchmark.sh
|
||||||
|
'cset' shield --shield 1024,2048,5000-1000
|
||||||
|
'cset' shield --unshield 6000-8500
|
||||||
|
'cset' shield --kthread=off
|
||||||
|
'cset' shield --kthread=on
|
||||||
|
'cset' shield --shield bash
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-------
|
||||||
|
-h, --help::
|
||||||
|
prints the list of options for this command
|
||||||
|
|
||||||
|
-c CPUSPEC, --cpu=CPUSPEC::
|
||||||
|
modifies or initializes the shield cpusets
|
||||||
|
|
||||||
|
-r, --reset::
|
||||||
|
destroys the shield
|
||||||
|
|
||||||
|
-e, --exec::
|
||||||
|
executes args in the shield
|
||||||
|
|
||||||
|
--user=USER::
|
||||||
|
use this USER for --exec (id or name)
|
||||||
|
|
||||||
|
--group=GROUP::
|
||||||
|
use this GROUP for --exec (id or name)
|
||||||
|
|
||||||
|
-s PIDSPEC, --shield=PIDSPEC::
|
||||||
|
shield specified PIDSPEC of processes or threads
|
||||||
|
|
||||||
|
-u PIDSPEC, --unshield=PIDSPEC::
|
||||||
|
remove specified PIDSPEC of processes or threads from the shield,
|
||||||
|
the task keep running in the unshielded cpuset
|
||||||
|
|
||||||
|
-k on|off, --kthread=on|off::
|
||||||
|
shield from unbound interrupt threads as well
|
||||||
|
|
||||||
|
-f, --force::
|
||||||
|
force operation, use with care
|
||||||
|
|
||||||
|
-v, --verbose::
|
||||||
|
prints more detailed output, additive
|
||||||
|
|
||||||
|
--sysset=SYSSET::
|
||||||
|
optionally specify system cpuset name
|
||||||
|
|
||||||
|
--userset=USERSET::
|
||||||
|
optionally specify user cpuset name
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This is a supercommand that creates basic cpu shielding. The
|
||||||
|
normal cset commands can of course be used to create this basic
|
||||||
|
shield, but the shield command combines many such commands to
|
||||||
|
create and manage a common type of cpu shielding setup.
|
||||||
|
|
||||||
|
The concept of shielding implies at minimum three cpusets, for
|
||||||
|
example: root, user and system. The root cpuset always exists in
|
||||||
|
all implementations of cpusets and contains all available CPUs on
|
||||||
|
the machine. The system cpuset is so named because normal system
|
||||||
|
tasks are made to run on it. The user cpuset is so named because
|
||||||
|
that is the "shielded" cpuset on which you would run your tasks
|
||||||
|
of interest.
|
||||||
|
|
||||||
|
Usually, CPU zero would be in the system set and the rest of the
|
||||||
|
CPUs would be in the user set. After creation of the cpusets,
|
||||||
|
all processes running in the root cpuset are moved to the system
|
||||||
|
cpuset. Thus any new processes or threads spawned from these
|
||||||
|
processes will also run the system cpuset.
|
||||||
|
|
||||||
|
If the optional --kthread=on option is given to the shield
|
||||||
|
command, then all kernel threads (with exception of the per-CPU
|
||||||
|
bound interrupt kernel threads) are also moved to the system set.
|
||||||
|
|
||||||
|
One executes processes on the shielded user cpuset with the
|
||||||
|
--exec subcommand or moves processes or threads to the shielded
|
||||||
|
cpuset with the --shield subcommand.
|
||||||
|
|
||||||
|
NOTE: You do not need to specify which cpuset a process or thread
|
||||||
|
is running in initially when using the --shield subcommand.
|
||||||
|
|
||||||
|
To create a shield, you would execute the shield command with the
|
||||||
|
--cpu option that specifies CPUSPEC argument that assigns CPUs to
|
||||||
|
be under the shield (this means assigned to the user cpuset, all
|
||||||
|
other cpus will be assigned to the system set).
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
*+# cset shield --cpu=3+*
|
||||||
|
|
||||||
|
On a 4-way machine, this command will dedicate the first
|
||||||
|
3 processors, CPU0-CPU2, for the system set (unshielded)
|
||||||
|
and only the last processor, CPU3, for the user set
|
||||||
|
(shielded).
|
||||||
|
|
||||||
|
The CPUSPEC will accept a comma separated list of CPUs and
|
||||||
|
inclusive range specifications. For example, --cpu=1,3,5-7 will
|
||||||
|
assign CPU1, CPU3, CPU5, CPU6, and CPU7 to the user (or shielded)
|
||||||
|
cpuset.
|
||||||
|
|
||||||
|
If you do not like the names "system" and "user" for the
|
||||||
|
unshielded and shielded sets respectively, or if those names are
|
||||||
|
used already, then use the --sysset and --userset options.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
*+# cset shield --sysset=free --userset=cage --cpu=2,3 --kthread=on+*
|
||||||
|
|
||||||
|
The above command will use the name "free" for the unshielded
|
||||||
|
system cpuset, the name "cage" for the shielded user cpuset,
|
||||||
|
initialize these cpusets and dedicate CPU0 and CPU1 to the "free"
|
||||||
|
set and (on a 4-way machine) dedicate CPU2 and CPU3 to the "cage"
|
||||||
|
set. Further, the command moves all processes and threads,
|
||||||
|
including kernel threads from the root cpuset to the "free"
|
||||||
|
cpuset.
|
||||||
|
|
||||||
|
NOTE: If you do use the --syset/--userset options, then you must
|
||||||
|
continue to use those for every invocation of the shield supercommand.
|
||||||
|
|
||||||
|
After initialization, you can run the process of interest on the
|
||||||
|
shielded cpuset with the --exec subcommand, or move processes or
|
||||||
|
threads already running to the shielded cpuset with the --shield
|
||||||
|
subcommand.
|
||||||
|
|
||||||
|
The PIDSPEC argument taken for the --shield (or -s) subcommand is
|
||||||
|
a comma separated list of PIDs or TIDs. The list can also
|
||||||
|
include brackets of PIDs or TIDs that are inclusive of the
|
||||||
|
endpoints.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
1,2,5 Means processes 1, 2 and 5
|
||||||
|
1,2,600-700 Means processes 1, 2 and from 600 to 700
|
||||||
|
|
||||||
|
*+# cset shield --shield=50-65+*
|
||||||
|
|
||||||
|
The above command moves all processes and threads with PID or
|
||||||
|
TID in the range 50-65 inclusive, from any cpuset they may
|
||||||
|
be running in into the shielded user cpuset.
|
||||||
|
|
||||||
|
NOTE: The range of PIDs or TIDs does not need to have every
|
||||||
|
position populated. In other words, for the example above, if
|
||||||
|
there is only one process, say PID 57, in the range of 50-65,
|
||||||
|
then only that process will be moved.
|
||||||
|
|
||||||
|
CAUTION: Please note that there is no checking of processes you
|
||||||
|
request to move into the shield with the --shield command. This
|
||||||
|
means that the tool will happily move, for example, kernel
|
||||||
|
threads that are bound to specific CPUs with this command. You
|
||||||
|
can hang your system by indiscriminately specifying arbitrary
|
||||||
|
PIDs to the --shield command so please be careful.
|
||||||
|
|
||||||
|
The --unshield (or -u) subcommand will remove the specified
|
||||||
|
processes or threads from the shielded cpuset and move them into
|
||||||
|
the unshielded (or system) cpuset. This option also takes a
|
||||||
|
PIDSPEC argument, the same as for the --shield subcommand.
|
||||||
|
|
||||||
|
Both the --shield and the --unshield commands will also finally
|
||||||
|
output the number of tasks running in the shield and out of the
|
||||||
|
shield. If you do not specify a PIDSPEC to these commands, then
|
||||||
|
just that status is output. By specifying also a --verbose in
|
||||||
|
addition, then you will get a listing of every task that is
|
||||||
|
running in either the shield or out of the shield.
|
||||||
|
|
||||||
|
Using no subcommand, ie. only "cset shield", will output the
|
||||||
|
status of both shield and non-shield. Tasks will be listed if
|
||||||
|
--verbose is used.
|
||||||
|
|
||||||
|
You can adjust which CPUs are in the shielded cpuset by issuing
|
||||||
|
the --cpu subcommand again anytime after the shield has been
|
||||||
|
initialized.
|
||||||
|
|
||||||
|
For example if the original shield contained CPU0 and CPU1 in the
|
||||||
|
system set and CPU2 and CPU3 in the user set, if you then issue
|
||||||
|
the following command:
|
||||||
|
|
||||||
|
*+# cset shield --cpu=1,2,3+*
|
||||||
|
|
||||||
|
then that command will move CPU1 into the shielded "user" cpuset.
|
||||||
|
Any processes or threads that were running on CPU1 that belonged
|
||||||
|
to the unshielded "system" cpuset are migrated to CPU0 by the
|
||||||
|
system.
|
||||||
|
|
||||||
|
The --reset subcommand will in essence destroy the shield. For
|
||||||
|
example, if there was a shield on a 4-way machine with CPU0 in
|
||||||
|
system and CPUs 1-3 in user with processes running on the user
|
||||||
|
cpuset (i.e. in the shield), and a --reset subcommand was issued,
|
||||||
|
then all processes running in both system and user cpusets would
|
||||||
|
be migrated to the root cpuset (which has access to all CPUs and
|
||||||
|
never goes away), after which both system and user cpusets would
|
||||||
|
be destroyed.
|
||||||
|
|
||||||
|
NOTE: Even though you can mix general usage of cpusets with
|
||||||
|
the shielding concepts described here, you generally will not
|
||||||
|
want to. For more complex shielding or usage scenarios, one
|
||||||
|
would generally use the normal cpuset commands (i.e. cset set
|
||||||
|
and proc) directly.
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
-------
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
manlink:cset[1], csetlink:set[], csetlink:proc[], manlink:taskset[1],
|
||||||
|
manlink:chrt[1]
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
@ -0,0 +1,90 @@
|
|||||||
|
.\" ** You probably do not want to edit this file directly **
|
||||||
|
.\" It was generated using the DocBook XSL Stylesheets (version 1.69.1).
|
||||||
|
.\" Instead of manually editing it, you probably should edit the DocBook XML
|
||||||
|
.\" source for it and then use the DocBook XSL Stylesheets to regenerate it.
|
||||||
|
.TH "CSET" "1" "05/30/2008" "" ""
|
||||||
|
.\" disable hyphenation
|
||||||
|
.nh
|
||||||
|
.\" disable justification (adjust text to left margin only)
|
||||||
|
.ad l
|
||||||
|
.SH "NAME"
|
||||||
|
cset \- manage cpusets functions in the Linux kernel
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
.sp
|
||||||
|
.nf
|
||||||
|
\fIcset\fR [\-\-version | \-\-help | \-\-log]
|
||||||
|
\fIcset\fR [help <command> | <command> \-\-help]
|
||||||
|
\fIcset\fR [cset options] <command> [command options] [args]
|
||||||
|
.fi
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
.sp
|
||||||
|
.it 1 an-trap
|
||||||
|
.nr an-no-space-flag 1
|
||||||
|
.nr an-break-flag 1
|
||||||
|
.br
|
||||||
|
\fBNote\fR
|
||||||
|
In general, you need to have root permissions to run cset. The tool mounts the cpusets filesystem and manipulates it. Non\-root users do not have permission for these actions.
|
||||||
|
|
||||||
|
Cpuset is a Python application to make using the cpusets facilities in the Linux kernel easier. The actual included command is called \fIcset\fR 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.
|
||||||
|
.SS "Typical uses of cpuset include"
|
||||||
|
.TP
|
||||||
|
Setting up and managing a simple shielded CPU environment
|
||||||
|
The concept of \fIshielded\fR cpus is that a certain number of cpus are partitioned off on the system and only processes that are of interest are run on these cpus (i.e., inside the shield).
|
||||||
|
|
||||||
|
For a simple shielded configuration, one typically uses three cpusets: the root set, a system set and a user set. \fICset\fR includes a super command that implements this strategy and lets you easily manage it. See \fBcset\-shield\fR(1) for more details.
|
||||||
|
.TP
|
||||||
|
Setting up and managing a comples shielding environment
|
||||||
|
Shielding can be more complex of course where concepts such as priority cpusets and intersecting cpuset can be used. You can use \fIcset\fR to help manage this type of shielding as well. You will need to use the \fBcset\-set\fR(1) and \fBcset\-proc\fR(1) subcommands directly to do that.
|
||||||
|
.TP
|
||||||
|
Managing cpusets on the system
|
||||||
|
The cset subcommand \fBcset\-set\fR(1) allows you to create and destroy arbitrary cpusets on the system and assign arbitrary cpus and memory nodes to them. The cpusets so created have to follow the Linux kernel cpuset rules. See the \fBcset\-set\fR(1) subcommand for more details.
|
||||||
|
.TP
|
||||||
|
Managing processes that run on various system cpusets
|
||||||
|
The cset subcommand \fBcset\-proc\fR(1) allows you to manage processes running on various cpusets created on the system. You can exec new processes in specific cpusets and move tasks around existing cpusets. See the \fBcset\-proc\fR(1) subcommand for more details.
|
||||||
|
.SH "OPTIONS"
|
||||||
|
The following generic option flags are available. Additional options are available per\-command, and documented in the command\-specific documentation.
|
||||||
|
.TP
|
||||||
|
\fIcset\fR \-\-version
|
||||||
|
Prints the cpuset suite version that the \fIcset\fR program came from, as well as version of other components used, such as Python and the kernel.
|
||||||
|
.TP
|
||||||
|
\fIcset\fR \-\-help
|
||||||
|
Prints the synopsis and a list of all commands.
|
||||||
|
.TP
|
||||||
|
\fIcset\fR \-\-log <filename>
|
||||||
|
Creates a log file for the current run. All manner of useful information is stored in this file. This is usually used to debug cpuset when things don't go as planned.
|
||||||
|
.TP
|
||||||
|
\fIcset\fR help \fIcommand\fR
|
||||||
|
Although not strictly an "option", this is a very helpful way to execute help with cpuset. The command prints out a lengthy summary of how the specified subcommand works.
|
||||||
|
.SH "CPUSET COMMANDS"
|
||||||
|
The cpuset commands are divided into groups, according to the primary purpose of those commands. Following is a short description of each command. A more detailed description is available in individual command manpages. Those manpages are named \fIcset\-<command>(1)\fR. The first command, \fIhelp\fR, is especially useful as it prints out a long summary of what a particular command does.
|
||||||
|
.TP
|
||||||
|
\fIcset help\fR
|
||||||
|
print the detailed command usage
|
||||||
|
.TP
|
||||||
|
\fIcset version\fR
|
||||||
|
display version information
|
||||||
|
.TP
|
||||||
|
\fIcset copyright\fR
|
||||||
|
display copyright information
|
||||||
|
.TP
|
||||||
|
\fIcset shield\fR
|
||||||
|
supercommand to set up and manage basic shielding (see \fBcset\-shield\fR(1))
|
||||||
|
.TP
|
||||||
|
\fIcset set\fR
|
||||||
|
create, modify and destroy cpusets (see \fBcset\-set\fR(1))
|
||||||
|
.TP
|
||||||
|
\fIcset proc\fR
|
||||||
|
create and manage processes within cpusets (see \fBcset\-proc\fR(1))
|
||||||
|
.SH "LICENSE"
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
.SH "COPYRIGHT"
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
.SH "AUTHOR"
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked GIT (stgit) v0.13 (see http://gna.org/projects/stgit and http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
\fBcset\-set\fR(1), \fBcset\-proc\fR(1), \fBcset\-shield\fR(1), \fBtaskset\fR(1), \fBchrt\fR(1)
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
||||||
|
|
@ -0,0 +1,517 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta name="generator" content="AsciiDoc 8.1.0" />
|
||||||
|
<style type="text/css">
|
||||||
|
/* Debug borders */
|
||||||
|
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
|
||||||
|
/*
|
||||||
|
border: 1px solid red;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 1em 5% 1em 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: blue;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
a:visited {
|
||||||
|
color: fuchsia;
|
||||||
|
}
|
||||||
|
|
||||||
|
em {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
tt {
|
||||||
|
color: navy;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
margin-top: 1.2em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
border-bottom: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sectionbody {
|
||||||
|
font-family: serif;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border: 1px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
span#author {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
span#email {
|
||||||
|
}
|
||||||
|
span#revision {
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: small;
|
||||||
|
border-top: 2px solid silver;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
margin-top: 4.0em;
|
||||||
|
}
|
||||||
|
div#footer-text {
|
||||||
|
float: left;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div#footer-badges {
|
||||||
|
float: right;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#preamble,
|
||||||
|
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
|
||||||
|
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-right: 10%;
|
||||||
|
margin-top: 1.5em;
|
||||||
|
margin-bottom: 1.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock {
|
||||||
|
margin-top: 2.5em;
|
||||||
|
margin-bottom: 2.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.content { /* Block element content. */
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Block element titles. */
|
||||||
|
div.title, caption.title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
div.title + * {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
td div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content div.title:first-child {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
div.content + div.title {
|
||||||
|
margin-top: 0.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sidebarblock > div.content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock {
|
||||||
|
margin-right: 0%;
|
||||||
|
}
|
||||||
|
div.listingblock > div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock > div.content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.attribution {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
div.verseblock + div.attribution {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.admonitionblock .icon {
|
||||||
|
vertical-align: top;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #527bbd;
|
||||||
|
padding-right: 0.5em;
|
||||||
|
}
|
||||||
|
div.admonitionblock td.content {
|
||||||
|
padding-left: 0.5em;
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock > div.content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.verseblock div.content {
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.imageblock div.content { padding-left: 0; }
|
||||||
|
div.imageblock img { border: 1px solid silver; }
|
||||||
|
span.image img { border-style: none; }
|
||||||
|
|
||||||
|
dl {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
dt {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
dd > *:first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul, ol {
|
||||||
|
list-style-position: outside;
|
||||||
|
}
|
||||||
|
ol.olist2 {
|
||||||
|
list-style-type: lower-alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.tableblock > table {
|
||||||
|
border: 3px solid #527bbd;
|
||||||
|
}
|
||||||
|
thead {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
tfoot {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.hlist {
|
||||||
|
margin-top: 0.8em;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist1 {
|
||||||
|
vertical-align: top;
|
||||||
|
font-style: italic;
|
||||||
|
padding-right: 0.8em;
|
||||||
|
}
|
||||||
|
td.hlist2 {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
div#footer-badges { display: none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
div#toctitle {
|
||||||
|
color: #527bbd;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 1.0em;
|
||||||
|
margin-bottom: 0.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.toclevel1, div.toclevel2 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
div.toclevel2 {
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
include1::./stylesheets/xhtml11-manpage.css[]
|
||||||
|
/* Workarounds for IE6's broken and incomplete CSS2. */
|
||||||
|
|
||||||
|
div.sidebar-content {
|
||||||
|
background: #ffffee;
|
||||||
|
border: 1px solid silver;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
div.sidebar-title, div.image-title {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 0.0em;
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.listingblock div.content {
|
||||||
|
border: 1px solid silver;
|
||||||
|
background: #f4f4f4;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.quoteblock-content {
|
||||||
|
padding-left: 2.0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.exampleblock-content {
|
||||||
|
border-left: 2px solid silver;
|
||||||
|
padding-left: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IE6 sets dynamically generated links as visited. */
|
||||||
|
div#toc a:visited { color: blue; }
|
||||||
|
</style>
|
||||||
|
<title>cset(1)</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="header">
|
||||||
|
<h1>
|
||||||
|
cset(1) Manual Page
|
||||||
|
</h1>
|
||||||
|
<h2>NAME</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>cset -
|
||||||
|
manage cpusets functions in the Linux kernel
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2>SYNOPSIS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<div class="verseblock">
|
||||||
|
<div class="content"><em>cset</em> [--version | --help | --log]
|
||||||
|
<em>cset</em> [help <command> | <command> --help]
|
||||||
|
<em>cset</em> [cset options] <command> [command options] [args]</div></div>
|
||||||
|
</div>
|
||||||
|
<h2>DESCRIPTION</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<div class="admonitionblock">
|
||||||
|
<table><tr>
|
||||||
|
<td class="icon">
|
||||||
|
<div class="title">Note</div>
|
||||||
|
</td>
|
||||||
|
<td class="content">In general, you need to have root permissions to run cset. The
|
||||||
|
tool mounts the cpusets filesystem and manipulates it. Non-root users
|
||||||
|
do not have permission for these actions.</td>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
<p>Cpuset is a Python application to make using the cpusets facilities in
|
||||||
|
the Linux kernel easier. The actual included command is called <em>cset</em>
|
||||||
|
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.</p>
|
||||||
|
<h3>Typical uses of cpuset include</h3>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
Setting up and managing a simple shielded CPU environment
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
The concept of <em>shielded</em> cpus is that a certain number of
|
||||||
|
cpus are partitioned off on the system and only processes that
|
||||||
|
are of interest are run on these cpus (i.e., inside the shield).
|
||||||
|
</p>
|
||||||
|
<p>For a simple shielded configuration, one typically uses three cpusets:
|
||||||
|
the root set, a system set and a user set. <em>Cset</em> includes a super
|
||||||
|
command that implements this strategy and lets you easily manage it.
|
||||||
|
See <a href="cset-shield.html">cset-shield(1)</a> for more details.</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
Setting up and managing a comples shielding environment
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Shielding can be more complex of course where concepts such as
|
||||||
|
priority cpusets and intersecting cpuset can be used. You can
|
||||||
|
use <em>cset</em> to help manage this type of shielding as well. You
|
||||||
|
will need to use the <a href="cset-set.html">cset-set(1)</a> and <a href="cset-proc.html">cset-proc(1)</a>
|
||||||
|
subcommands directly to do that.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
Managing cpusets on the system
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
The cset subcommand <a href="cset-set.html">cset-set(1)</a> allows you to create and
|
||||||
|
destroy arbitrary cpusets on the system and assign arbitrary
|
||||||
|
cpus and memory nodes to them. The cpusets so created have to
|
||||||
|
follow the Linux kernel cpuset rules. See the <a href="cset-set.html">cset-set(1)</a>
|
||||||
|
subcommand for more details.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
Managing processes that run on various system cpusets
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
The cset subcommand <a href="cset-proc.html">cset-proc(1)</a> allows you to manage
|
||||||
|
processes running on various cpusets created on the system.
|
||||||
|
You can exec new processes in specific cpusets and move tasks
|
||||||
|
around existing cpusets. See the <a href="cset-proc.html">cset-proc(1)</a> subcommand
|
||||||
|
for more details.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<h2>OPTIONS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>The following generic option flags are available. Additional options
|
||||||
|
are available per-command, and documented in the command-specific
|
||||||
|
documentation.</p>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
<em>cset</em> --version
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Prints the cpuset suite version that the <em>cset</em> program came
|
||||||
|
from, as well as version of other components used, such as
|
||||||
|
Python and the kernel.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset</em> --help
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Prints the synopsis and a list of all commands.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset</em> --log <filename>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Creates a log file for the current run. All manner of useful
|
||||||
|
information is stored in this file. This is usually used to
|
||||||
|
debug cpuset when things don't go as planned.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset</em> help <em>command</em>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
Although not strictly an "option", this is a very helpful way
|
||||||
|
to execute help with cpuset. The command prints out a lengthy
|
||||||
|
summary of how the specified subcommand works.
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<h2>CPUSET COMMANDS</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>The cpuset commands are divided into groups, according to the primary
|
||||||
|
purpose of those commands. Following is a short description of each
|
||||||
|
command. A more detailed description is available in individual
|
||||||
|
command manpages. Those manpages are named <em>cset-<command>(1)</em>. The
|
||||||
|
first command, <em>help</em>, is especially useful as it prints out a long
|
||||||
|
summary of what a particular command does.</p>
|
||||||
|
<dl>
|
||||||
|
<dt>
|
||||||
|
<em>cset help</em>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
print the detailed command usage
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset version</em>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
display version information
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset copyright</em>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
display copyright information
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset shield</em>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
supercommand to set up and manage basic shielding (see
|
||||||
|
<a href="cset-shield.html">cset-shield(1)</a>)
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset set</em>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
create, modify and destroy cpusets (see <a href="cset-set.html">cset-set(1)</a>)
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<em>cset proc</em>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
create and manage processes within cpusets (see
|
||||||
|
<a href="cset-proc.html">cset-proc(1)</a>)
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<h2>LICENSE</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Cpuset is licensed under the GNU GPL V2 only.</p>
|
||||||
|
</div>
|
||||||
|
<h2>COPYRIGHT</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Copyright (c) 2008 Novell Inc.</p>
|
||||||
|
</div>
|
||||||
|
<h2>AUTHOR</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p>Written by Alex Tsariounov <alext@novell.com>.</p>
|
||||||
|
<p>Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.</p>
|
||||||
|
</div>
|
||||||
|
<h2>SEE ALSO</h2>
|
||||||
|
<div class="sectionbody">
|
||||||
|
<p><a href="cset-set.html">cset-set(1)</a>, <a href="cset-proc.html">cset-proc(1)</a>, <a href="cset-shield.html">cset-shield(1)</a>, <a href="taskset.html">taskset(1)</a>,
|
||||||
|
<a href="chrt.html">chrt(1)</a></p>
|
||||||
|
<p>/usr/src/linux/Documentation/cpusets.txt</p>
|
||||||
|
</div>
|
||||||
|
<div id="footer">
|
||||||
|
<div id="footer-text">
|
||||||
|
Version 1.0<br />
|
||||||
|
Last updated 30-May-2008 14:33:24 MDT
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,132 @@
|
|||||||
|
cset(1)
|
||||||
|
======
|
||||||
|
Alex Tsariounov <alext@novell.com>
|
||||||
|
v1.0, May 2008
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cset - manage cpusets functions in the Linux kernel
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
[verse]
|
||||||
|
'cset' [--version | --help | --log]
|
||||||
|
'cset' [help <command> | <command> --help]
|
||||||
|
'cset' [cset options] <command> [command options] [args]
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
NOTE: In general, you need to have root permissions to run cset. The
|
||||||
|
tool mounts the cpusets filesystem and manipulates it. Non-root users
|
||||||
|
do not have permission for these actions.
|
||||||
|
|
||||||
|
Cpuset is a 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.
|
||||||
|
|
||||||
|
Typical uses of cpuset include
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Setting up and managing a simple shielded CPU environment::
|
||||||
|
The concept of 'shielded' cpus is that a certain number of
|
||||||
|
cpus are partitioned off on the system and only processes that
|
||||||
|
are of interest are run on these cpus (i.e., inside the shield).
|
||||||
|
+
|
||||||
|
For a simple shielded configuration, one typically uses three cpusets:
|
||||||
|
the root set, a system set and a user set. 'Cset' includes a super
|
||||||
|
command that implements this strategy and lets you easily manage it.
|
||||||
|
See csetlink:shield[] for more details.
|
||||||
|
|
||||||
|
Setting up and managing a comples shielding environment::
|
||||||
|
Shielding can be more complex of course where concepts such as
|
||||||
|
priority cpusets and intersecting cpuset can be used. You can
|
||||||
|
use 'cset' to help manage this type of shielding as well. You
|
||||||
|
will need to use the csetlink:set[] and csetlink:proc[]
|
||||||
|
subcommands directly to do that.
|
||||||
|
|
||||||
|
Managing cpusets on the system::
|
||||||
|
The cset subcommand csetlink:set[] allows you to create and
|
||||||
|
destroy arbitrary cpusets on the system and assign arbitrary
|
||||||
|
cpus and memory nodes to them. The cpusets so created have to
|
||||||
|
follow the Linux kernel cpuset rules. See the csetlink:set[]
|
||||||
|
subcommand for more details.
|
||||||
|
|
||||||
|
Managing processes that run on various system cpusets::
|
||||||
|
The cset subcommand csetlink:proc[] allows you to manage
|
||||||
|
processes running on various cpusets created on the system.
|
||||||
|
You can exec new processes in specific cpusets and move tasks
|
||||||
|
around existing cpusets. See the csetlink:proc[] subcommand
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-------
|
||||||
|
The following generic option flags are available. Additional options
|
||||||
|
are available per-command, and documented in the command-specific
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
'cset' --version::
|
||||||
|
Prints the cpuset suite version that the 'cset' program came
|
||||||
|
from, as well as version of other components used, such as
|
||||||
|
Python and the kernel.
|
||||||
|
|
||||||
|
'cset' --help::
|
||||||
|
Prints the synopsis and a list of all commands.
|
||||||
|
|
||||||
|
'cset' --log <filename>::
|
||||||
|
Creates a log file for the current run. All manner of useful
|
||||||
|
information is stored in this file. This is usually used to
|
||||||
|
debug cpuset when things don't go as planned.
|
||||||
|
|
||||||
|
'cset' help 'command'::
|
||||||
|
Although not strictly an "option", this is a very helpful way
|
||||||
|
to execute help with cpuset. The command prints out a lengthy
|
||||||
|
summary of how the specified subcommand works.
|
||||||
|
|
||||||
|
CPUSET COMMANDS
|
||||||
|
---------------
|
||||||
|
The cpuset commands are divided into groups, according to the primary
|
||||||
|
purpose of those commands. Following is a short description of each
|
||||||
|
command. A more detailed description is available in individual
|
||||||
|
command manpages. Those manpages are named 'cset-<command>(1)'. The
|
||||||
|
first command, 'help', is especially useful as it prints out a long
|
||||||
|
summary of what a particular command does.
|
||||||
|
|
||||||
|
'cset help'::
|
||||||
|
print the detailed command usage
|
||||||
|
'cset version'::
|
||||||
|
display version information
|
||||||
|
'cset copyright'::
|
||||||
|
display copyright information
|
||||||
|
'cset shield'::
|
||||||
|
supercommand to set up and manage basic shielding (see
|
||||||
|
csetlink:shield[])
|
||||||
|
'cset set'::
|
||||||
|
create, modify and destroy cpusets (see csetlink:set[])
|
||||||
|
'cset proc'::
|
||||||
|
create and manage processes within cpusets (see
|
||||||
|
csetlink:proc[])
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
-------
|
||||||
|
Cpuset is licensed under the GNU GPL V2 only.
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
Copyright (c) 2008 Novell Inc.
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
Written by Alex Tsariounov <alext@novell.com>.
|
||||||
|
|
||||||
|
Some substrate code and ideas were taken from the excellent Stacked
|
||||||
|
GIT (stgit) v0.13 (see http://gna.org/projects/stgit and
|
||||||
|
http://www.procode.org/stgit). Stacked GIT is under GPL V2 or later.
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
csetlink:set[], csetlink:proc[], csetlink:shield[], manlink:taskset[1],
|
||||||
|
manlink:chrt[1]
|
||||||
|
|
||||||
|
/usr/src/linux/Documentation/cpusets.txt
|
@ -0,0 +1,3 @@
|
|||||||
|
[titles]
|
||||||
|
underlines="##","==","--","~~","^^"
|
||||||
|
|
@ -0,0 +1,51 @@
|
|||||||
|
Cpuset Tutorial
|
||||||
|
###############
|
||||||
|
|
||||||
|
|
||||||
|
Cpuset (cset) is a Python application that provides a command line
|
||||||
|
application front end for the cpusets functionality found in the Linux
|
||||||
|
kernel.
|
||||||
|
|
||||||
|
|
||||||
|
Basic Operation
|
||||||
|
===============
|
||||||
|
|
||||||
|
Help
|
||||||
|
----
|
||||||
|
|
||||||
|
For a full list of cset commands:
|
||||||
|
|
||||||
|
cset help
|
||||||
|
|
||||||
|
For help on individual subcommands:
|
||||||
|
|
||||||
|
cset help <command>
|
||||||
|
|
||||||
|
For options of individual subcommands:
|
||||||
|
|
||||||
|
cset <command> (-h | --help)
|
||||||
|
|
||||||
|
Built-in Super Commands
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Cpuset has some built-in "super commands" that encapsulate common use
|
||||||
|
cases of cpusets and make their interface simple to use.
|
||||||
|
|
||||||
|
cset shield
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
This super command sets up a shielded set of cpus environment.
|
||||||
|
|
||||||
|
Basic cpuset Manipulation Commands
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Advanced Usage
|
||||||
|
==============
|
||||||
|
|
||||||
|
This describes more advanced usage of cpusets.
|
||||||
|
|
||||||
|
Priority Realtime CPU Sets
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
[install]
|
||||||
|
prefix: /usr
|
||||||
|
|
||||||
|
[bdist_rpm]
|
||||||
|
group=System/Management
|
||||||
|
build_requires=python python-devel asciidoc xmlto
|
||||||
|
requires=python
|
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import glob
|
||||||
|
from distutils.core import setup
|
||||||
|
|
||||||
|
from cpuset.version import version
|
||||||
|
|
||||||
|
setup(name = 'cpuset',
|
||||||
|
version = version,
|
||||||
|
license = 'GPLv2',
|
||||||
|
author = 'Alex Tsariounov',
|
||||||
|
author_email = 'alext@novell.com',
|
||||||
|
url = 'http://developer.novell.com/wiki/index.php/Cpuset',
|
||||||
|
description = 'Allows manipluation of cpusets and provides higher level functions.',
|
||||||
|
long_description = \
|
||||||
|
'Cpuset is a Python application to make using the cpusets facilities in the Linux\n'
|
||||||
|
'kernel easier. The actual included command is called cset and it allows\n'
|
||||||
|
'manipulation of cpusets on the system and provides higher level functions such as\n'
|
||||||
|
'implementation and control of a basic cpu shielding setup.',
|
||||||
|
scripts = ['cset'],
|
||||||
|
packages = ['cpuset', 'cpuset.commands'],
|
||||||
|
data_files = [
|
||||||
|
('share/doc/packages/cpuset', ['README', 'COPYING']),
|
||||||
|
('share/doc/packages/cpuset', glob.glob('doc/*.html')),
|
||||||
|
('share/doc/packages/cpuset', glob.glob('doc/*.txt')),
|
||||||
|
]
|
||||||
|
)
|
@ -0,0 +1,27 @@
|
|||||||
|
# Run cpuset tests
|
||||||
|
# Suite design taken from git which is Copyright (c) 2005 Junio C Hamano
|
||||||
|
#
|
||||||
|
# Copyright (C) 2007 Novell Inc.
|
||||||
|
# Author: Alex Tsariounov <alext@novell.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
#CSET_TEST_OPTS=--verbose --debug
|
||||||
|
SHELL_PATH ?= $(SHELL)
|
||||||
|
TAR ?= $(TAR)
|
||||||
|
|
||||||
|
# Shell quote;
|
||||||
|
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
|
||||||
|
|
||||||
|
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
|
||||||
|
|
||||||
|
all: $(T) clean
|
||||||
|
|
||||||
|
$(T):
|
||||||
|
@echo "*** $@ ***"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -fr trash
|
||||||
|
|
||||||
|
.PHONY: $(T) clean
|
||||||
|
.NOPARALLEL:
|
||||||
|
|
Loading…
Reference in New Issue