* [PATCH] tools/writeback: parse help before importing drgn
@ 2026-06-24 12:35 Yousef Alhouseen
2026-06-25 0:27 ` SeongJae Park
0 siblings, 1 reply; 2+ messages in thread
From: Yousef Alhouseen @ 2026-06-24 12:35 UTC (permalink / raw)
To: willy, jack
Cc: shikemeng, linux-fsdevel, linux-mm, linux-kernel,
Yousef Alhouseen
wb_monitor.py imports drgn before argparse can handle "-h". That makes
help fail on systems where drgn is not installed, even though the script
does not need drgn to print usage text.
Parse arguments before importing drgn so the help path works without the
runtime debugging dependency. While there, fix a typo in the help text.
Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
---
tools/writeback/wb_monitor.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/writeback/wb_monitor.py b/tools/writeback/wb_monitor.py
index 5e3591f1f..e09e00ee2 100644
--- a/tools/writeback/wb_monitor.py
+++ b/tools/writeback/wb_monitor.py
@@ -14,7 +14,7 @@ backing dev. For more info on drgn, visit https://github.com/osandov/drgn.
dirtied(kB) Amount of pages have been dirtied.
- wrttien(kB) Amount of dirty pages have been written back to disk.
+ written(kB) Amount of dirty pages have been written back to disk.
avg_wb(kBps) Smoothly estimated write bandwidth of writing dirty pages
back to disk.
@@ -25,9 +25,6 @@ import re
import time
import json
-import drgn
-from drgn.helpers.linux.list import list_for_each_entry
-
import argparse
parser = argparse.ArgumentParser(description=desc,
formatter_class=argparse.RawTextHelpFormatter)
@@ -41,6 +38,9 @@ parser.add_argument('-c', '--cgroup', action='store_true',
help='show writeback of bdi in cgroup')
args = parser.parse_args()
+import drgn
+from drgn.helpers.linux.list import list_for_each_entry
+
bdi_list = prog['bdi_list']
WB_RECLAIMABLE = prog['WB_RECLAIMABLE']
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] tools/writeback: parse help before importing drgn
2026-06-24 12:35 [PATCH] tools/writeback: parse help before importing drgn Yousef Alhouseen
@ 2026-06-25 0:27 ` SeongJae Park
0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2026-06-25 0:27 UTC (permalink / raw)
To: Yousef Alhouseen
Cc: SeongJae Park, willy, jack, shikemeng, linux-fsdevel, linux-mm,
linux-kernel
On Wed, 24 Jun 2026 14:35:14 +0200 Yousef Alhouseen <alhouseenyousef@gmail.com> wrote:
> wb_monitor.py imports drgn before argparse can handle "-h". That makes
> help fail on systems where drgn is not installed, even though the script
> does not need drgn to print usage text.
But... How do you execute the drgn script on systems not having drgn? I tried
to mimic the situation and reproduce the issue you are saying about, but what I
get is like below:
$ sudo mv /usr/bin/drgn /usr/bin/drgn.bak
$ drgn tools/writeback/wb_monitor.py
-bash: /usr/bin/drgn: No such file or directory
$ python tools/writeback/wb_monitor.py
Traceback (most recent call last):
File "/home/lkhack/linux/tools/writeback/wb_monitor.py", line 44, in <module>
bdi_list = prog['bdi_list']
^^^^
NameError: name 'prog' is not defined
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-25 0:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 12:35 [PATCH] tools/writeback: parse help before importing drgn Yousef Alhouseen
2026-06-25 0:27 ` SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox