[PATCH 3/3] tuna: Add -U and -K to the move command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add the following options to the move command (like in the show_threads
command)
  -U, --no_uthreads     Operations will not affect user threads
  -K, --no_kthreads     Operations will not affect kernel threads

Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
---
 tuna-cmd.py  | 4 +++-
 tuna/tuna.py | 7 ++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tuna-cmd.py b/tuna-cmd.py
index 9496c61f0c2b..d0a3e6b7dbf8 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -174,6 +174,8 @@ def gen_parser():
     move_group.add_argument('-N', '--nohz_full', **MODS['nohz_full'])
     move.add_argument('-t', '--threads', **MODS['threads'])
     move.add_argument('-q', '--irqs', **MODS['irqs'])
+    move.add_argument('-U', '--no_uthreads', **MODS['no_uthreads'])
+    move.add_argument('-K', '--no_kthreads', **MODS['no_kthreads'])
 
     spread_group = spread.add_mutually_exclusive_group(required=True)
     spread_group.add_argument('-c', '--cpus', **MODS['cpus'])
@@ -746,7 +748,7 @@ def main():
             parser.error(f"tuna: {args.command} requires a thread/irq list!\n")
 
         if args.thread_list:
-            tuna.move_threads_to_cpu(args.cpu_list, args.thread_list, spread=spread)
+            tuna.move_threads_to_cpu(args.cpu_list, args.thread_list, args.uthreads, args.kthreads, spread=spread)
 
         if args.irq_list:
             tuna.move_irqs_to_cpu(args.cpu_list, args.irq_list, spread=spread)
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 1380df0dadba..ef60c033362d 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -174,7 +174,7 @@ def is_hardirq_handler(self, pid):
     except:
         return False
 
-def move_threads_to_cpu(cpus, pid_list, set_affinity_warning=None, spread=False):
+def move_threads_to_cpu(cpus, pid_list, show_uthreads, show_kthreads, set_affinity_warning=None, spread=False):
     changed = False
 
     ps = procfs.pidstats()
@@ -183,6 +183,11 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning=None, spread=False)
     new_affinity = cpus
     last_cpu = max(cpus) + 1
     for pid in pid_list:
+        iskth = iskthread(pid)
+        if not show_uthreads and not iskth:
+            continue
+        if not show_kthreads and iskth:
+            continue
         if spread:
             new_affinity = [cpus[cpu_idx]]
             cpu_idx += 1
-- 
2.49.0





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux