From 51725ad1e9fe5987c726a84b5417018725e70df7 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 15 Sep 2008 16:34:03 -0300 Subject: 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 --- tuna-cmd.py | 20 +++++++++++++++++--- 1 file 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"): -- cgit 1.2.3-korg