Issue #3489 has been reported by tuxillo.
----------------------------------------
Bug #3489: drm: queue_work() drops a work item that is running on another cpu
http://bugs.dragonflybsd.org/issues/3489
* Author: tuxillo
* Status: New
* Priority: Normal
* Target version: 6.6
* Start date: 2026-11-29
----------------------------------------
As of master 98c93bc104, a work item queued with queue_work() or
schedule_work() while it runs on another cpu's worker never runs again,
although queue_work() returns true. system_wq and every workqueue without
@WQ_UNBOUND@ have a worker per cpu. A driver that queues work from an interrupt
to pick up new completions can lose a wakeup when the interrupt comes on
another cpu while the previous run is finishing.
queue_work() in sys/dev/drm/linux_workqueue.c puts the item on the calling
cpu's worker, whose process_all_work() then sees @work->running@ and skips it.
On Linux the item runs again after the current run. queue_work() also takes
only the calling cpu's worker lock, so two cpus queueing the same idle item can
both put it on their lists, and it returns true for an item that is already
queued.
The attached patch gives a work item to one worker from the time it is queued
until it has run (@work->worker@, claimed with a compare-and-set). Queueing it
again meanwhile goes to that worker, so it runs again after the current run and
never on two workers at once. queue_work() returns true only when it queued the
item, and INIT_WORK() clears @work->worker@.
The attached wqtest.c module queues an item on system_wq from chosen cpus, 100
trials per test. In an 8-vCPU QEMU guest and on a 12-thread desktop:
<pre>
master patch
queued from another cpu while it ran ran again 0 ran again 100
two cpus queue it at once 20-40 queues none lost
lost
ran on two cpus at once 2 (desktop) 0
</pre>
A requeue from the same cpu, cancel_work_sync() and flush_work() behave as
before, and radeon still loads and initializes on the desktop. I found this by
reading the code and haven't caught a driver losing a wakeup.
---Files--------------------------------
wqtest.c (7.72 KB)
Makefile (247 Bytes)
0001-drm-run-a-work-item-queued-while-it-runs-and-queue-i.patch (5.34 KB)
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://bugs.dragonflybsd.org/my/account