Re: [PATCH 2/7] workqueue: Implement disable/enable for (delayed) work items

From: Lai Jiangshan
Date: Wed Feb 21 2024 - 23:35:12 EST


Hello, Tejun

On Thu, Feb 22, 2024 at 1:43 AM Tejun Heo <tj@xxxxxxxxxx> wrote:

> +/**
> + * enable_work - Enable a work item
> + * @work: work item to enable
> + *
> + * Undo disable_work[_sync]() by decrementing @work's disable count. @work can
> + * only be queued if its disable count is 0.
> + *
> + * Must be called from a sleepable context. Returns %true if the disable count
> + * reached 0. Otherwise, %false.
> + */
> +bool enable_work(struct work_struct *work)
> +{
> + struct work_offq_data offqd;
> + unsigned long irq_flags;
> +
> + work_grab_pending(work, 0, &irq_flags);
> +
> + work_offqd_unpack(&offqd, *work_data_bits(work));
> + work_offqd_enable(&offqd);
> + set_work_pool_and_clear_pending(work, offqd.pool_id,
> + work_offqd_pack_flags(&offqd));
> + local_irq_enable();

It can use local_irq_restore() directly or the next patch needs to be fixed.

The next patch making enable_work() able to be called in any context
forgets to change local_irq_enable() to local_irq_restore().

Thanks.
Lai