Re: [PATCH] kthread: Don't cancel a work that is being cancelled

From: Petr Mladek
Date: Fri Jul 03 2020 - 03:28:21 EST


On Thu 2020-07-02 12:43:24, qiang.zhang@xxxxxxxxxxxxx wrote:
> From: Zhang Qiang <qiang.zhang@xxxxxxxxxxxxx>
>
> When canceling a work, if it is found that the work is in
> the cancelling state, we should directly exit the cancelled
> operation.

No, the function guarantees that the work is not longer running
when it returns. This is why it has the suffix "_sync" in the name.

We would need to add kthread_cancel_work() without the "_sync"
wrappers that would not wait for the work in progress. But it
might be dangerous. The API users usually want to make sure
that the work in not longer running to avoid races.

What is the use case for the non-sync behavior, please?

Best Regards,
Petr