summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2008-09-15 16:34:03 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2008-09-15 16:34:03 -0300
commit51725ad1e9fe5987c726a84b5417018725e70df7 (patch)
tree0fdd5e140f31e73627ff223b55978f1e302b4f5d
parent4c7d25d4ba2b0c34f4094c32a19c952ea9f65484 (diff)
downloadtuna-51725ad1e9fe5987c726a84b5417018725e70df7.tar.gz
tuna-cmd: Introduce --sockets/-S
To specify a CPU socket to be isolated, included or to move specific threads to it. To isolate a cpu socket: tuna --sockets 0 --isolate Use --include to include the cores in the socket into the affinity mask of all threads (except kernel threads). To set the affinity mask of threads: tuna --sockets 1 --threads 1,4,200 --move If the children threads are to be moved too use: tuna --affect_children --sockets 1 --threads 1,4,200 --move Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xtuna-cmd.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py
index fd805c4..b90e2de 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -14,7 +14,7 @@
# General Public License for more details.
import getopt, procfs, sys
-from tuna import tuna
+from tuna import tuna, sysfs
try:
from sets import Set as set
@@ -40,6 +40,7 @@ def usage():
-m, --move move selected entities to CPU-LIST
-p, --priority=[POLICY]:RTPRIO set thread scheduler POLICY and RTPRIO
-s, --save=FILENAME save kthreads sched tunables to FILENAME
+ -S, --sockets=CPU-SOCKET-LIST CPU-SOCKET-LIST affected by commands
-t, --threads=THREAD-LIST THREAD-LIST affected by commands
-U, --no_uthreads Operations will not affect user threads
-W, --what_is Provides help about selected entities'''
@@ -77,13 +78,13 @@ def save(cpus, threads, filename):
def main():
try:
opts, args = getopt.getopt(sys.argv[1:],
- "c:CfghiIKmp:s:t:UW",
+ "c:CfghiIKmp:s:S:t:UW",
("cpus=", "affect_children",
"filter", "gui", "help",
"isolate", "include",
"no_kthreads",
"move", "priority",
- "save=", "threads=",
+ "save=", "sockets=", "threads=",
"no_uthreads", "what_is"))
except getopt.GetoptError, err:
usage()
@@ -134,6 +135,19 @@ def main():
tuna.move_threads_to_cpu(cpus, threads)
elif o in ("-s", "--save"):
save(cpus, threads, a)
+ elif o in ("-S", "--sockets"):
+ sockets = map(lambda socket: socket, a.split(","))
+ if not cpus:
+ cpus = []
+ cpu_info = sysfs.cpus()
+ for socket in sockets:
+ if not cpu_info.sockets.has_key(socket):
+ print "tuna: invalid socket %s, sockets available: %s" % \
+ (socket,
+ ", ".join(cpu_info.sockets.keys()))
+ sys.exit(2)
+ cpus += [ int(cpu.name[3:]) for cpu in cpu_info.sockets[socket] ]
+ cpus.sort()
elif o in ("-K", "--no_kthreads"):
kthreads = False
elif o in ("-U", "--no_uthreads"):