Re: [PATCH] Revert "workqueue: remove unused cancel_work()"

From: Lai Jiangshan
Date: Thu May 19 2022 - 10:52:30 EST


On Thu, May 19, 2022 at 9:57 PM Andrey Grodzovsky
<andrey.grodzovsky@xxxxxxx> wrote:
>
> This reverts commit 6417250d3f894e66a68ba1cd93676143f2376a6f
> and exports the function.
>
> We need this funtion in amdgpu driver to fix a bug.

Hello,

Could you specify the reason why it is needed in amdgpu driver
rather than "fix a bug", please.

And there is a typo: "funtion".

And please avoid using "we" in the changelog. For example, the
sentence can be changed to:

The amdgpu driver needs this function to cancel a work item
in blabla context/situation or for blabla reason.
(I'm not good at Engish, this is just an example of not
using "we". No need to use the sentence.)

Thanks
Lai

>
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@xxxxxxx>
> ---
> include/linux/workqueue.h | 1 +
> kernel/workqueue.c | 9 +++++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
> index 7fee9b6cfede..9e41e1226193 100644
> --- a/include/linux/workqueue.h
> +++ b/include/linux/workqueue.h
> @@ -453,6 +453,7 @@ extern int schedule_on_each_cpu(work_func_t func);
> int execute_in_process_context(work_func_t fn, struct execute_work *);
>
> extern bool flush_work(struct work_struct *work);
> +extern bool cancel_work(struct work_struct *work);
> extern bool cancel_work_sync(struct work_struct *work);
>
> extern bool flush_delayed_work(struct delayed_work *dwork);
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 613917bbc4e7..f94b596ebffd 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -3267,6 +3267,15 @@ static bool __cancel_work(struct work_struct *work, bool is_dwork)
> return ret;
> }
>
> +/*
> + * See cancel_delayed_work()
> + */
> +bool cancel_work(struct work_struct *work)
> +{
> + return __cancel_work(work, false);
> +}
> +EXPORT_SYMBOL(cancel_work);
> +
> /**
> * cancel_delayed_work - cancel a delayed work
> * @dwork: delayed_work to cancel
> --
> 2.25.1
>