* [PATCH 1/3] tuna: Fix show_threads -t and show_irqs -q
@ 2025-07-25 18:59 John Kacur
2025-07-25 18:59 ` [PATCH 2/3] tuna: Fix run command failing to apply BATCH policy John Kacur
2025-07-25 18:59 ` [PATCH 3/3] tuna: Add -U and -K to the move command John Kacur
0 siblings, 2 replies; 3+ messages in thread
From: John Kacur @ 2025-07-25 18:59 UTC (permalink / raw)
To: linux-rt-users; +Cc: John Wyatt, John Kacur
Fix show_threads -t and show_irqs -q to not match everything if there is
no match.
jkacur@fionn:~/src/tuna$ ./tuna-cmd.py show_threads | wc -l
428
jkacur@fionn:~/src/tuna$ ./tuna-cmd.py show_threads -t "nosuchthread" | wc -l
0
jkacur@fionn:~/src/tuna$ ./tuna-cmd.py show_threads -t "Isolated*" | wc -l
55
jkacur@fionn:~/src/tuna$ ./tuna-cmd.py show_irqs -q "iwlwifi*" | wc -l
14
jkacur@fionn:~/src/tuna$ ./tuna-cmd.py show_irqs | wc -l
58
jkacur@fionn:~/src/tuna$ ./tuna-cmd.py show_irqs -q "nosuchirq" | wc -l
0
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna-cmd.py | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 4997eaa5de92..9496c61f0c2b 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -79,6 +79,7 @@ except:
ps = None
irqs = None
+match_requested = False
class HelpMessageParser(argparse.ArgumentParser):
def error(self, message):
@@ -391,6 +392,8 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
irq_list_numbers, show_uthreads, show_kthreads,
has_ctxt_switch_info, sock_inodes, sock_inode_re, cgroups, compact):
+ global match_requested
+
ps_list = []
for pid in list(ps.keys()):
iskth = tuna.iskthread(pid)
@@ -422,7 +425,11 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
raise e
if cpu_list and not set(cpu_list).intersection(set(affinity)):
continue
- ps_list.append(pid)
+ if match_requested and thread_list and pid in thread_list:
+ ps_list.append(pid)
+ elif not match_requested:
+ ps_list.append(pid)
+
ps_list.sort()
@@ -498,6 +505,7 @@ def find_drivers_by_users(users):
def show_irqs(irq_list, cpu_list):
global irqs
+ global match_requested
if not irqs:
irqs = procfs.interrupts()
@@ -515,7 +523,11 @@ def show_irqs(irq_list, cpu_list):
if cpu_list and not set(cpu_list).intersection(set(affinity)):
continue
- sorted_irqs.append(irqn)
+
+ if match_requested and irq_list and irqn in irq_list:
+ sorted_irqs.append(irqn)
+ elif not match_requested:
+ sorted_irqs.append(irqn)
sorted_irqs.sort()
for irq in sorted_irqs:
@@ -540,6 +552,9 @@ def do_list_op(op, current_list, op_list):
def threadstring_to_list(threadstr):
global ps
+ global match_requested
+ if threadstr:
+ match_requested = True
thread_list = []
thread_strings = list(set(threadstr.split(',')))
for s in thread_strings:
@@ -555,6 +570,9 @@ def threadstring_to_list(threadstr):
def irqstring_to_list(irqstr):
+ global match_requested
+ if irqstr:
+ match_requested = True
irq_list = []
irq_strings = list(set(irqstr.split(',')))
for s in irq_strings:
@@ -636,6 +654,7 @@ def nohz_full_to_cpu():
_(" needs nohz_full=cpulist on the kernel command line"))
sys.exit(2)
+
def main():
global ps
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] tuna: Fix run command failing to apply BATCH policy
2025-07-25 18:59 [PATCH 1/3] tuna: Fix show_threads -t and show_irqs -q John Kacur
@ 2025-07-25 18:59 ` John Kacur
2025-07-25 18:59 ` [PATCH 3/3] tuna: Add -U and -K to the move command John Kacur
1 sibling, 0 replies; 3+ messages in thread
From: John Kacur @ 2025-07-25 18:59 UTC (permalink / raw)
To: linux-rt-users; +Cc: John Wyatt, John Kacur
When using tuna run with -p BATCH the newly spawned process is created
with SCHED_OTHER instead of SCHED_BATCH
Fix this by calling thread_set_priority if the policy is not zero
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tuna/tuna.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tuna/tuna.py b/tuna/tuna.py
index d4c3e2c1a661..1380df0dadba 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -621,7 +621,7 @@ def run_command(cmd, policy, rtprio, cpu_list, background):
if newpid == 0:
cmd_list = shlex.split(cmd)
pid = os.getpid()
- if rtprio:
+ if rtprio or policy:
try:
thread_set_priority(pid, policy, rtprio)
except (SystemError, OSError) as err:
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] tuna: Add -U and -K to the move command
2025-07-25 18:59 [PATCH 1/3] tuna: Fix show_threads -t and show_irqs -q John Kacur
2025-07-25 18:59 ` [PATCH 2/3] tuna: Fix run command failing to apply BATCH policy John Kacur
@ 2025-07-25 18:59 ` John Kacur
1 sibling, 0 replies; 3+ messages in thread
From: John Kacur @ 2025-07-25 18:59 UTC (permalink / raw)
To: linux-rt-users; +Cc: John Wyatt, John Kacur
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@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-25 19:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 18:59 [PATCH 1/3] tuna: Fix show_threads -t and show_irqs -q John Kacur
2025-07-25 18:59 ` [PATCH 2/3] tuna: Fix run command failing to apply BATCH policy John Kacur
2025-07-25 18:59 ` [PATCH 3/3] tuna: Add -U and -K to the move command John Kacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).