workqueue: introduce BPF iterators for workqueues, worker pools and pending work - #8523
workqueue: introduce BPF iterators for workqueues, worker pools and pending work#8523kernel-patches-daemon-bpf-rc[bot] wants to merge 6 commits into
Conversation
|
Upstream branch: fdec474 |
83cca4d to
be1f432
Compare
|
Upstream branch: fdec474 |
edd2313 to
9a724ed
Compare
be1f432 to
67a9448
Compare
|
Upstream branch: fdec474 |
9a724ed to
6362f62
Compare
67a9448 to
5e1e840
Compare
|
Upstream branch: 2659f94 |
6362f62 to
f912fcb
Compare
5e1e840 to
d018663
Compare
|
Upstream branch: 863f3dd |
f912fcb to
83a9a1b
Compare
d018663 to
3329cd8
Compare
|
Upstream branch: f0e80de |
83a9a1b to
6b0fbf9
Compare
3329cd8 to
563d02d
Compare
|
Upstream branch: 682b1c1 |
6b0fbf9 to
cc266e7
Compare
563d02d to
1e559bd
Compare
|
Upstream branch: 28e911d |
cc266e7 to
72b96d2
Compare
1e559bd to
f56dfc5
Compare
|
Upstream branch: 8f876c7 |
72b96d2 to
acdfc4d
Compare
28abc40 to
1824cf2
Compare
|
Upstream branch: 7d008cd |
adc6315 to
ee34697
Compare
1824cf2 to
6ac2541
Compare
|
Upstream branch: 8c7f55d |
ee34697 to
2942fda
Compare
6ac2541 to
bbe1ae8
Compare
|
Upstream branch: 41c129f |
2942fda to
3784b38
Compare
bbe1ae8 to
dd2acb0
Compare
|
Upstream branch: 2b1f9f6 |
3784b38 to
7428531
Compare
dd2acb0 to
75f1c0e
Compare
|
Upstream branch: e1d9b82 |
7428531 to
4064a2e
Compare
75f1c0e to
f776207
Compare
|
Upstream branch: 51476f6 |
4064a2e to
32f275f
Compare
f776207 to
b882df0
Compare
|
Upstream branch: 8b365b3 |
32f275f to
094818f
Compare
b882df0 to
818432c
Compare
…ues list
Add bpf_iter_workqueue_{new,next,destroy} kfuncs so BPF programs can walk
every workqueue on the global workqueues list.
The workqueues list is RCU-protected for reads and each workqueue_struct
is freed via call_rcu(), so the iterator is KF_RCU_PROTECTED i.e. the
caller must hold bpf_rcu_read_lock() across new()..destroy(), which keeps
the list and each returned wq alive between next() calls.
The kfuncs live in kernel/workqueue.c because struct workqueue_struct's
list anchor and the workqueues root are local to this file.
Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
Add a 'workqueue' BPF iterator target (bpftool-iter / pinnable) that reuses the open-coded bpf_iter_workqueue_next(). Since the open-coded next() is KF_RCU_PROTECTED, the seq path supplies the RCU section: seq_start() takes rcu_read_lock() and holds it across the read chunk, so the returned workq and the cursor stay alive while the program runs and next() steps; position is re-derived from *pos on each start, so the cursor is never dereferenced across the RCU gap between chunks. Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
Add bpf_iter_worker_pool_{new,next,destroy} kfuncs so BPF programs can
walk every worker_pool in the system via worker_pool_idr, in ascending
pool-id order.
This mirrors the pool enumeration in the drgn tools/workqueue/wq_dump.py
script.
The idr walk (idr_get_next) runs as kernel C, so no BPF-side idr support
is needed. worker_pool_idr is RCU-readable and each worker_pool is freed
via call_rcu(), so the iterator is KF_RCU_PROTECTED, like the workqueue
iterator: the caller holds bpf_rcu_read_lock() across new()..destroy().
Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
Add a 'worker_pool' BPF iterator target, backed by the open-coded bpf_iter_worker_pool_next() via a shared union, using the same RCU-per-chunk scheme as the workqueue seq iterator. Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
Add a seq_file BPF iterator ("workqueue_pending_work") that walks the
pending work items of every worker_pool. Unlike the workqueue and
worker_pool iterators this is deliberately not open-coded because
pool->worklist is protected by pool->lock and struct work_struct has
neither a refcount nor RCU-freeing, so a pending work cannot be kept alive
for a suspended open-coded iterator.
Instead, for each pool a bounded snapshot of its pending works (pool id,
work address, work function) is copied out while pool->lock is held and
the BPF program runs over the stable snapshot with no lock held.
worker_pool(s) are visited in worker_pool_idr order.
Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
Cover both the open-coded and seq_file forms of the workqueue and worker_pool iterators, plus the pending-work seq iterator: - count_workqueues / count_worker_pools drive the open-coded iterators (inside bpf_rcu_read_lock()); userspace checks the counts are non-zero. - dump_workqueues / dump_worker_pools attach the seq forms and drain them, exercising the RCU-per-chunk seq path that reuses the open-coded next(). - dump_pending attaches the workqueue_pending_work seq iterator and drains it, exercising the per-pool snapshot path. - wq_iter_fail.c checks the verifier rejects the RCU-protected open-coded iterators when used outside an RCU critical section. Also declare the open-coded iterator kfuncs in bpf_experimental.h. Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
|
Upstream branch: d114bb9 |
094818f to
039eacf
Compare
Pull request for series with
subject: workqueue: introduce BPF iterators for workqueues, worker pools and pending work
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1135671