2024-01-16 16:25:42

by Juri Lelli

[permalink] [raw]
Subject: [RFC PATCH 0/4] Fix handling of rescuers affinity

Hello,

Recently I've been pointed at the fact that workqueue rescuers seem not
to follow unbound workqueues cpumask changes. This small series is a
first stab at possibly fixing what I considered to be different from
what I expected (it might very well be the case that my expectations are
wrong :). Long story short, it seems to me that we currently have
several cases where a change of the general unbound cpumask or a change
of the per-workqueue cpumask (for WQ_SYSFS workqueues) is not reflected
into the corresponding rescuer affinity (if a rescuer is present).

In the following:

Patch 01/04 - Adds debug information to wq_dump.py script so that we
can more easily check workqueues and rescuers cpumasks
02/04 - Fixes cpumask discrepancies when rescuers are created
03/04 - Streamlines behavior of general unbound vs. WQ_SYSFS
cpumask changes
04/04 - Makes sure existing rescuers affinity follows their
workqueue cpumask changes

Please take a look, I'm all for feedback and better understanding of the
details I'm certainly missing.

For additional context, a related discussion can be found at

https://lore.kernel.org/lkml/um77hym4t6zyypfbhwbaeqxpfdzc657oa7vgowdfah7cuctjak@pexots3mfb24/

Branch for testing available at

[email protected]:jlelli/linux.git workqueue/rescuers-cpumask

Best,
Juri

Juri Lelli (4):
workqueue: Add rescuers printing to wq_dump.py
kernel/workqueue: Bind rescuer to unbound cpumask for WQ_UNBOUND
kernel/workqueue: Distinguish between general unbound and WQ_SYSFS
cpumask changes
kernel/workqueue: Let rescuers follow unbound wq cpumask changes

kernel/workqueue.c | 28 +++++++++++++++++++++-------
tools/workqueue/wq_dump.py | 29 +++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 7 deletions(-)

--
2.43.0



2024-01-16 16:31:31

by Juri Lelli

[permalink] [raw]
Subject: [RFC PATCH 1/4] tools/workqueue: Add rescuers printing to wq_dump.py

Retrieving rescuers information (e.g., affinity and name) is quite
useful when debugging workqueues configurations.

Add printing of such information to the existing wq_dump.py script.

Signed-off-by: Juri Lelli <[email protected]>
---
tools/workqueue/wq_dump.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/tools/workqueue/wq_dump.py b/tools/workqueue/wq_dump.py
index d0df5833f2c18..6da621989e210 100644
--- a/tools/workqueue/wq_dump.py
+++ b/tools/workqueue/wq_dump.py
@@ -175,3 +175,32 @@ for wq in list_for_each_entry('struct workqueue_struct', workqueues.address_of_(
if wq.flags & WQ_UNBOUND:
print(f' {wq.dfl_pwq.pool.id.value_():{max_pool_id_len}}', end='')
print('')
+
+print('')
+print('Workqueue -> rescuer')
+print('=====================')
+print(f'wq_unbound_cpumask={cpumask_str(wq_unbound_cpumask)}')
+print('')
+print('[ workqueue \ type unbound_cpumask rescuer pid cpumask]')
+
+for wq in list_for_each_entry('struct workqueue_struct', workqueues.address_of_(), 'list'):
+ print(f'{wq.name.string_().decode()[-24:]:24}', end='')
+ if wq.flags & WQ_UNBOUND:
+ if wq.flags & WQ_ORDERED:
+ print(' ordered ', end='')
+ else:
+ print(' unbound', end='')
+ if wq.unbound_attrs.affn_strict:
+ print(',S ', end='')
+ else:
+ print(' ', end='')
+ print(f' {cpumask_str(wq.unbound_attrs.cpumask):24}', end='')
+ else:
+ print(' percpu ', end='')
+ print(' ', end='')
+
+ if wq.flags & WQ_MEM_RECLAIM:
+ print(f' {wq.rescuer.task.comm.string_().decode()[-24:]:24}', end='')
+ print(f' {wq.rescuer.task.pid.value_():5}', end='')
+ print(f' {cpumask_str(wq.rescuer.task.cpus_ptr)}', end='')
+ print('')
--
2.43.0