Issue #3492 has been reported by tuxillo. ---------------------------------------- Bug #3492: kernel: callout_stop() returns 0 when it stops a pending callout http://bugs.dragonflybsd.org/issues/3492
* Author: tuxillo * Status: New * Priority: Normal * Target version: 6.6 * Start date: 2026-12-01 ---------------------------------------- As of master 98c93bc104, callout_stop(), callout_cancel(), callout_drain() and callout_stop_async() return 0 when they stop a callout that is queued and not running. kern_timeout.c documents 1 for that case, and the code returned 1 before the callout rewrite in fac0eb3cf4. _callout_cancel_or_stop() calls _callout_update_spinlocked(), which takes the callout off the wheel and sets CALLOUT_PREVENTED. The callout is then neither INPROG nor SET, so the function takes its early exit and returns 0 without looking at PREVENTED. Only the path that waits for a running callback returns PREVENTED. Callers that use the return value go wrong. ng_l2tp never drops the node reference its timer held, and takes another one when it restarts the timer. ng_pptpgre keeps the timer's allocation and its timer count, so the node's private data is never freed. ng_uncallout() in netgraph7 never frees the item, taskqueue_cancel_timeout() leaves the stopped timeout out of *pendp, and amdgpu_fence_process() doesn't re-arm its fallback timer while fences are outstanding. The first attached patch returns PREVENTED from the early exit too. The second drops the inversion in drm's del_timer_sync(), added in 5abb6f6135 when callout_drain() returned 1 if the function had run; with the first patch it would give the opposite of Linux's answer. Nothing uses that return value yet. I tested in an 8-vCPU QEMU guest with the attached module, which arms a callout for one second and stops it at once, 100 times with each of the four calls. Before, every call returned 0 and no callout ran. After, every call returned 1 and none ran, and a callout that was never armed or had already run still returned 0, in two runs. I didn't test the netgraph nodes or amdgpu. ---Files-------------------------------- Makefile (54 Bytes) costop.c (2.91 KB) 0002-drm-return-callout_drain-s-result-from-del_timer_syn.patch (1.12 KB) 0001-kernel-return-1-from-callout_stop-when-it-stops-a-qu.patch (2.38 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
