2020-05-25 10:22:26

by Zhang, Qiang

[permalink] [raw]
Subject: Re: [PATCH v2] workqueue: Fix double kfree for rescuer

I see, kfree does nothing with null pointers and direct return.
but again kfree is not a good suggestion.

On 5/25/20 5:50 PM, Markus Elfring wrote:
>> The duplicate memory release should be deleted from the implementation
>> of the callback function "rcu_free_wq".
>
> I tried to help with the selection of a better commit message.
> I have taken another look also at the implementation of the function “destroy_workqueue”.
>
> * The function call “destroy_workqueue” can be performed there in an if branch
> after the statement “wq->rescuer = NULL” was executed.
>
> * This data processing is independent from a possible call of the
> function “call_rcu(&wq->rcu, rcu_free_wq)” in another if branch.
> Thus it seems that a null pointer is intentionally passed by a data structure
> member to this callback function on demand.
> The corresponding call of the function “kfree” can tolerate this special case.
>
>
> Now I find that the proposed change can be inappropriate.
>
> Regards,
> Markus
>


2020-05-25 10:43:10

by Markus Elfring

[permalink] [raw]
Subject: Re: [v2] workqueue: Fix double kfree for rescuer

> I see, kfree does nothing with null pointers and direct return.
> but again kfree is not a good suggestion.

I have got the impression that the implementation detail is important here
if non-null pointers (according to valid rescuer objects) are occasionally
passed by the corresponding data structure member for the callback
function “rcu_free_wq”.
Can another clarification attempt reduce unwanted confusion for this patch review?

Regards,
Markus

2020-05-26 02:08:18

by Zhang, Qiang

[permalink] [raw]
Subject: Re: [v2] workqueue: Fix double kfree for rescuer

Thanks for your advice.
The rescuer null pointer is intentionally passed by a data structure?
and also I read the code of workqueue again, when destroy_workqueue is
called, after "wq->rescuer = NULL" was executed, The scenario described
below does not happen

"if non-null pointers (according to valid rescuer objects) are
occasionally passed by the corresponding data structure member
for the callback function "rcu_free_wq"."


On 5/25/20 6:40 PM, Markus Elfring wrote:
>> I see, kfree does nothing with null pointers and direct return.
>> but again kfree is not a good suggestion.
>
> I have got the impression that the implementation detail is important here
> if non-null pointers (according to valid rescuer objects) are occasionally
> passed by the corresponding data structure member for the callback
> function “rcu_free_wq”.
> Can another clarification attempt reduce unwanted confusion for this patch review?
>
> Regards,
> Markus
>