Re: [PATCH 2/5] workqueue: add support for module-owned work
From: Tejun Heo
Date: Mon Sep 21 2026 - 12:23:40 EST
On Mon, Sep 21, 2026 at 11:38:59PM +0800, Cen Zhang wrote:
> Queueing a callback on a system workqueue does not take a reference to
> the module containing that callback. A caller which releases its last
> module reference after queueing work can therefore leave a callback in
> unloaded text. Releasing the reference from the callback itself also
> leaves its return path unprotected.
>
> Add module_work and schedule_module_work() to hold the callback's owner
> from queueing until the callback returns. Run the dispatch and final
> module_put() in workqueue core, which remains present when the callback's
> module is unloaded. Cache the function and owner before invoking the
> callback so that it can free the containing work item.
>
> 6LoWPAN needs this for deferred network-device deletion after removing
> the last peer.
>
> Assisted-by: LLM
> Signed-off-by: Cen Zhang <zzzccc427@xxxxxxxxx>
Please provide justification on why this needs to be done this way when
everyone else can flush delayed items before unloading.
Thanks.
--
tejun