From: John Kacur <jkacur@redhat.com>
To: linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Subject: [PATCH 12/23] tuna: Fix show_threads -t and show_irqs -q
Date: Fri, 7 Nov 2025 13:57:21 -0500 [thread overview]
Message-ID: <20251107185732.23992-13-jkacur@redhat.com> (raw)
In-Reply-To: <20251107185732.23992-1-jkacur@redhat.com>
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.51.1
next prev parent reply other threads:[~2025-11-07 18:58 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 18:57 [ANNOUNCE] tuna v0.20 John Kacur
2025-11-07 18:57 ` [PATCH 01/23] Add SPDX license identifiers John Kacur
2025-12-18 2:45 ` Kate Stewart
2025-11-07 18:57 ` [PATCH 02/23] tuna: Remove spec file from git John Kacur
2025-11-07 18:57 ` [PATCH 03/23] tuna: Don't start the gui if a display is not available John Kacur
2025-11-07 18:57 ` [PATCH 04/23] tuna: Fix string syntax warnings with raw strings John Kacur
2025-11-07 18:57 ` [PATCH 05/23] tuna: Fix help.py syntax warnings John Kacur
2025-11-07 18:57 ` [PATCH 06/23] tuna: help.py John Kacur
2025-11-07 18:57 ` [PATCH 07/23] tuna: extract common cpu and nics determination code into a utils.py file John Kacur
2025-11-07 18:57 ` [PATCH 08/23] tuna: Add idle_state control functionality John Kacur
2025-11-07 18:57 ` [PATCH 09/23] tuna: utils: A few tweaks John Kacur
2025-11-07 18:57 ` [PATCH 10/23] tuna: Add Pyright helper John Kacur
2025-11-07 18:57 ` [PATCH 11/23] tuna: Update man page with cpu_power command John Kacur
2025-11-07 18:57 ` John Kacur [this message]
2025-11-07 18:57 ` [PATCH 13/23] tuna: Fix run command failing to apply BATCH policy John Kacur
2025-11-07 18:57 ` [PATCH 14/23] tuna: Add -U and -K to the move command John Kacur
2025-11-07 18:57 ` [PATCH 15/23] tuna: Add -U and -K to the spread command John Kacur
2025-11-07 18:57 ` [PATCH 16/23] tuna: replace match with if statements John Kacur
2025-11-07 18:57 ` [PATCH 17/23] tuna: Proofreading fixes John Kacur
2025-11-07 18:57 ` [PATCH 18/23] tuna: Remove broken testuna John Kacur
2025-11-07 18:57 ` [PATCH 19/23] tuna: Fix setting a realtime scheduling policy John Kacur
2025-11-07 18:57 ` [PATCH 20/23] tuna: Update setup.py with co-author and metadata improvements John Kacur
2025-11-07 18:57 ` [PATCH 21/23] tuna: Add pyproject.toml for modern Python packaging John Kacur
2025-11-07 18:57 ` [PATCH 22/23] tuna: Update version to 0.20 John Kacur
2025-11-07 18:57 ` [PATCH 23/23] tuna: Fix pyproject.toml build issues John Kacur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251107185732.23992-13-jkacur@redhat.com \
--to=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox