linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] percpu_counter: Remove debug_object_free call twice
@ 2018-04-13  9:35 Gaurav Kohli
  2018-04-16 21:48 ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Gaurav Kohli @ 2018-04-13  9:35 UTC (permalink / raw)
  To: tj, gregkh, nborisov, akpm; +Cc: linux-arm-msm, linux-kernel, Gaurav Kohli

During percpu_counter destroy, debug_object_free is calling
twice which may create race. So removing once instance of call
from debug_percpu_counter_deactivate.

Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>

diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index c72577e..68ad030 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -48,7 +48,6 @@ static inline void debug_percpu_counter_activate(struct percpu_counter *fbc)
 static inline void debug_percpu_counter_deactivate(struct percpu_counter *fbc)
 {
 	debug_object_deactivate(fbc, &percpu_counter_debug_descr);
-	debug_object_free(fbc, &percpu_counter_debug_descr);
 }
 
 #else	/* CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER */
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] percpu_counter: Remove debug_object_free call twice
  2018-04-13  9:35 [PATCH] percpu_counter: Remove debug_object_free call twice Gaurav Kohli
@ 2018-04-16 21:48 ` Tejun Heo
  2018-04-17  6:29   ` Kohli, Gaurav
  0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2018-04-16 21:48 UTC (permalink / raw)
  To: Gaurav Kohli; +Cc: gregkh, nborisov, akpm, linux-arm-msm, linux-kernel

On Fri, Apr 13, 2018 at 03:05:03PM +0530, Gaurav Kohli wrote:
> During percpu_counter destroy, debug_object_free is calling
> twice which may create race. So removing once instance of call
> from debug_percpu_counter_deactivate.

I don't quite follow.  Can you please elaborate how it can be called
twice?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] percpu_counter: Remove debug_object_free call twice
  2018-04-16 21:48 ` Tejun Heo
@ 2018-04-17  6:29   ` Kohli, Gaurav
  2018-08-27  6:56     ` Kohli, Gaurav
  0 siblings, 1 reply; 4+ messages in thread
From: Kohli, Gaurav @ 2018-04-17  6:29 UTC (permalink / raw)
  To: Tejun Heo; +Cc: gregkh, nborisov, akpm, linux-arm-msm, linux-kernel

On 4/17/2018 3:18 AM, Tejun Heo wrote:

> On Fri, Apr 13, 2018 at 03:05:03PM +0530, Gaurav Kohli wrote:
>> During percpu_counter destroy, debug_object_free is calling
>> twice which may create race. So removing once instance of call
>> from debug_percpu_counter_deactivate.
> I don't quite follow.  Can you please elaborate how it can be called
> twice?

Hi Tejun,

In percpu_counter_fixup_free function, first call is percpu_counter_destroy -> debug_percpu_counter_deactivate (this will set inactive and free the debug object as well for percpu counter) -> free_percpu (finally freeing the counters).

Below is the code snippet:

         case DEBUG_STATE_ACTIVE:

                 percpu_counter_destroy(fbc); -> first call

                 debug_object_free(fbc, &percpu_counter_debug_descr); -> this will again call the same debug object free, if somehow counters will reinitialize between these two calls.

                 

We are seeing one race condition issue where one object of db list is corrupted and just before object of that corrupted node is percpu_counter, Still i am not sure the reason of race as it is very

difficult to reproduce. But i have found this during code review. Please correct me, if i misunderstood this.

>
> Thanks.
>
>
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] percpu_counter: Remove debug_object_free call twice
  2018-04-17  6:29   ` Kohli, Gaurav
@ 2018-08-27  6:56     ` Kohli, Gaurav
  0 siblings, 0 replies; 4+ messages in thread
From: Kohli, Gaurav @ 2018-08-27  6:56 UTC (permalink / raw)
  To: Tejun Heo; +Cc: gregkh, nborisov, akpm, linux-arm-msm, linux-kernel

Hi ,

Sorry for very late reminder, just wanted to know is below understanding 
of code is wrong?

Regards
Gaurav

On 4/17/2018 11:59 AM, Kohli, Gaurav wrote:
> On 4/17/2018 3:18 AM, Tejun Heo wrote:
> 
>> On Fri, Apr 13, 2018 at 03:05:03PM +0530, Gaurav Kohli wrote:
>>> During percpu_counter destroy, debug_object_free is calling
>>> twice which may create race. So removing once instance of call
>>> from debug_percpu_counter_deactivate.
>> I don't quite follow.  Can you please elaborate how it can be called
>> twice?
> 
> Hi Tejun,
> 
> In percpu_counter_fixup_free function, first call is 
> percpu_counter_destroy -> debug_percpu_counter_deactivate (this will set 
> inactive and free the debug object as well for percpu counter) -> 
> free_percpu (finally freeing the counters).
> 
> Below is the code snippet:
> 
>          case DEBUG_STATE_ACTIVE:
> 
>                  percpu_counter_destroy(fbc); -> first call
> 
>                  debug_object_free(fbc, &percpu_counter_debug_descr); -> 
> this will again call the same debug object free, if somehow counters 
> will reinitialize between these two calls.
> 
> 
> We are seeing one race condition issue where one object of db list is 
> corrupted and just before object of that corrupted node is 
> percpu_counter, Still i am not sure the reason of race as it is very
> 
> difficult to reproduce. But i have found this during code review. Please 
> correct me, if i misunderstood this.
> 
>>
>> Thanks.
>>
>>

-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, 
Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-27  6:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-13  9:35 [PATCH] percpu_counter: Remove debug_object_free call twice Gaurav Kohli
2018-04-16 21:48 ` Tejun Heo
2018-04-17  6:29   ` Kohli, Gaurav
2018-08-27  6:56     ` Kohli, Gaurav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).