nuttx/sched/wqueue
raiden00pl 5a209a853e
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
sched/wqueue: restore -ENOENT from work_cancel() for unqueued work
work_cancel() used to return -ENOENT when the work structure was not
in the queue, and callers depend on that: aio_cancel() tears down the
AIO container (file_put() + aioc_free()) only when work_cancel()
reports success, because a work item that is not queued may already be
executing on a worker thread (see the comment in fs/aio/aio_cancel.c).

Since commit 6f72f5481d ("sched/wqueue: Refactor delayed and periodical
workqueue") work_cancel() returns OK unconditionally, and commit
d2e01b9055 ("sched/wqueue: harden custom queue lifecycle") kept that
behaviour and dropped -ENOENT from the function documentation.  Under
SMP the LTP aio_cancel tests then free the aio container and its file
while the lpwork thread is still executing aio_write_worker() on it,
which ends in a page fault in file_write() (f_inode == NULL) and a
panic.

Return -ENOENT again when the work is not queued, and document it.
For the synchronous variant "not queued" alone does not tell whether
the callback is running: the worker scan does, so report OK when a
running callback was found and waited for, and -ENOENT only when the
work was neither queued nor running.

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-13 11:31:41 +08:00
..
CMakeLists.txt sched/wqueue: add configuring the stack of an hpwork/lpwork as static 2026-01-27 10:18:24 +08:00
kwork_cancel.c sched/wqueue: restore -ENOENT from work_cancel() for unqueued work 2026-09-13 11:31:41 +08:00
kwork_inherit.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
kwork_notifier.c sched/wqueue: Replace spinlock/sched_lock with spin_lock_irqsave_nopreempt 2025-10-31 15:02:56 +08:00
kwork_queue.c sched/wqueue: consolidate queue submission paths 2026-09-04 23:02:48 +08:00
kwork_thread.c sched/wqueue: harden custom queue lifecycle 2026-09-04 23:02:48 +08:00
Make.defs sched/wqueue: add configuring the stack of an hpwork/lpwork as static 2026-01-27 10:18:24 +08:00
wqueue.h sched/wqueue: harden custom queue lifecycle 2026-09-04 23:02:48 +08:00