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

From: Lai Jiangshan
Date: Tue Feb 20 2024 - 21:55:05 EST


On Wed, Feb 21, 2024 at 2:38 AM Tejun Heo <tj@xxxxxxxxxx> wrote:
>
> Hello,
>
> On Tue, Feb 20, 2024 at 03:22:26PM +0800, Lai Jiangshan wrote:
> > > - A work item carries 10bit disable count in work->data while not queued.
> > > The access to the count is synchronized by the PENDING bit like all other
> > > parts of work->data.
> >
> > It is 16bit disable count in the code.
>
> Fixed.
>
> > It misses the same handling at queue_work_node() and queue_rcu_work().
>
> Oops, fixed queued_work_node() but I don't think the latter is an issue
> given that calling work interface functions in the embedded work is not
> supported and rcu_work can't even be canceled.

Hello, Tejun

I think it is better to have the same handling (checking disable count)
in queue_rcu_work().

1) code is consistent with other queuing code
2) known state: no work item is queued with disable count > 0
3) catch wrong usages: some complaining code can be added when adding the check.

Adding checking and complaining in the code is as important as
adding a comment stating rcu work is not allowed to be disabled/canceled.

>
> I'm not quite sure flush_delayed_work() is safe. Will think more about that.

I think the code successfully deleting the timer not only owns the pending bit
but also ensures the disable count is zero.

Thanks
Lai