workqueue: Fix table in wq_dump.py for large number of workqueues
cover workqueue: Fix table in wq_dump.py for large number of workqueues
On larger machines (e.g. 316 CPUs, 2 NUMA nodes), the "Unbound workqueue -> node_nr/max_active" section of wq_dump.py has column alignment issues.
Values like max_active=2048 exceed the hardcoded minimum field width of 3, causing the header and data rows to misalign.
This series cleans up the formatting:
1. Remove the backslash separator from the header
2. Widen format specifiers for 4-digit values and right-align nr/max as a single string
3. Add "NODE" prefix to all node columns for clarity.
* Although the original code intentionally only labeled the first column, the bare numbers for subsequent nodes create more confusion than they help. Labeling all columns makes the output self-explanatory.
Before:
[ workqueue \ min max NODE 0 1 dfl ]
events_unbound 8 2048 0/2048 0/ 8 0/2048
netns 1 1 0/ 1 0/ 1 0/ 1 async 1024 1024 0/1024 0/1024 0/1024 cpuset_migrate_mm 1 1 0/ 1 0/ 1 0/ 1
After:
[ workqueue min max NODE 0 NODE 1 dfl ]
events_unbound 8 2048 0/2048 0/8 0/2048 netns 1 1 0/1 0/1 0/1
async 1024 1024 0/1024 0/1024 0/1024
cpuset_migrate_mm 1 1 0/1 0/1 0/1
---
Breno Leitao (3):
tools/workqueue/wq_dump.py: remove backslash separator from node_nr/max_active header tools/workqueue/wq_dump.py: fix column alignment in node_nr/max_active section tools/workqueue/wq_dump.py: add NODE prefix to all node columns
tools/workqueue/wq_dump.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
---
base-commit: 5ee8dbf54602dc340d6235b1d6aa17c0f283f48c
change-id: 20260307-wqdump-33fd85802b92
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
PATCH 1/3 tools/workqueue/wq_dump.py: remove backslash separator from node_nr/max_active header
Remove the backslash separator between the workqueue name and the data columns in the "Unbound workqueue -> node_nr/max_active" header for cleaner output.
--- tools/workqueue/wq_dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/workqueue/wq_dump.py +1 -1
@@ -227,7 +227,7 @@ if 'node_to_cpumask_map' in prog: print(f'NODE[{node:02}]={cpumask_str(node_to_cpumask_map[node])}') print('') - print(f'[{"workqueue":^{WQ_NAME_LEN-2}}\\ min max', end='') + print(f'[{"workqueue":^{WQ_NAME_LEN-1}} min max', end='') first = True for node in for_each_node(): if first:
Signature · 1 line
2.47.3
PATCH 2/3 tools/workqueue/wq_dump.py: fix column alignment in node_nr/max_active section
In reply to Breno LeitaoOn larger machines with many CPUs, max_active values such as 2048 exceed the hardcoded minimum field width of 3 characters, causing the header and data columns to misalign.
Widen the format specifiers to accommodate 4-digit values and right-align each nr/max as a single string to keep the output compact.
--- tools/workqueue/wq_dump.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/workqueue/wq_dump.py +7 -7
@@ -227,15 +227,15 @@ if 'node_to_cpumask_map' in prog: print(f'NODE[{node:02}]={cpumask_str(node_to_cpumask_map[node])}') print('') - print(f'[{"workqueue":^{WQ_NAME_LEN-1}} min max', end='') + print(f'[{"workqueue":^{WQ_NAME_LEN-1}} {"min":>4} {"max":>4}', end='') first = True for node in for_each_node(): if first: - print(f' NODE {node}', end='') + print(f' {"NODE " + str(node):>8}', end='') first = False else: - print(f' {node:7}', end='') - print(f' {"dfl":>7} ]') + print(f' {node:>9}', end='') + print(f' {"dfl":>9} ]') print('') for wq in list_for_each_entry('struct workqueue_struct', workqueues.address_of_(), 'list'):
@@ -243,11 +243,11 @@ if 'node_to_cpumask_map' in prog: continue print(f'{wq.name.string_().decode():{WQ_NAME_LEN}} ', end='') - print(f'{wq.min_active.value_():3} {wq.max_active.value_():3}', end='') + print(f'{wq.min_active.value_():4} {wq.max_active.value_():4}', end='') for node in for_each_node(): nna = wq.node_nr_active[node] - print(f' {nna.nr.counter.value_():3}/{nna.max.value_():3}', end='') + print(f' {f"{nna.nr.counter.value_()}/{nna.max.value_()}":>9}', end='') nna = wq.node_nr_active[nr_node_ids] - print(f' {nna.nr.counter.value_():3}/{nna.max.value_():3}') + print(f' {f"{nna.nr.counter.value_()}/{nna.max.value_()}":>9}') else: printf(f'node_to_cpumask_map not present, is NUMA enabled?')
Signature · 1 line
2.47.3
PATCH 3/3 tools/workqueue/wq_dump.py: add NODE prefix to all node columns
In reply to Breno LeitaoPreviously only the first node column showed "NODE 0" while subsequent columns showed just the bare node number, making it unclear what the numbers refer to.
Add the "NODE" prefix to all node columns and remove the now-unnecessary first/else branching.
--- tools/workqueue/wq_dump.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
tools/workqueue/wq_dump.py +1 -6
@@ -228,13 +228,8 @@ if 'node_to_cpumask_map' in prog: print('') print(f'[{"workqueue":^{WQ_NAME_LEN-1}} {"min":>4} {"max":>4}', end='') - first = True for node in for_each_node(): - if first: - print(f' {"NODE " + str(node):>8}', end='') - first = False - else: - print(f' {node:>9}', end='') + print(f' {"NODE " + str(node):>9}', end='') print(f' {"dfl":>9} ]') print('')
Signature · 1 line
2.47.3
Quoted 4 lines
Breno Leitao (3):
tools/workqueue/wq_dump.py: remove backslash separator from node_nr/max_active headertools/workqueue/wq_dump.py: fix column alignment in node_nr/max_active sectiontools/workqueue/wq_dump.py: add NODE prefix to all node columns
Applied 1-3 to wq/for-7.1.
Thanks.
--
tejun