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

From: Zhang, Qiang
Date: Fri Jul 03 2020 - 04:58:00 EST


Thank you for your advice, if add kthread_cancel_work() without the "_sync"
it is be dangerous, But I think it is unnecessary to cancel work which is be canceling.
________________________________________
发件人: linux-kernel-owner@xxxxxxxxxxxxxxx <linux-kernel-owner@xxxxxxxxxxxxxxx> 代表 Petr Mladek <pmladek@xxxxxxxx>
发送时间: 2020年7月3日 15:28
收件人: Zhang, Qiang
抄送: ben.dooks@xxxxxxxxxxxxxxx; bfields@xxxxxxxxxx; cl@xxxxxxxxxxxxxx; peterz@xxxxxxxxxxxxx; tj@xxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
主题: Re: [PATCH] kthread: Don't cancel a work that is being cancelled

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