linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* livelock with hrtimer cpu_base->lock
@ 2018-10-09 20:56 Sodagudi Prasad
  2018-10-10 16:49 ` Will Deacon
  0 siblings, 1 reply; 4+ messages in thread
From: Sodagudi Prasad @ 2018-10-09 20:56 UTC (permalink / raw)
  To: catalin.marinas, will.deacon, gregkh, ard.biesheuvel,
	robin.murphy, ynorov
  Cc: linux-arm-kernel, linux-kernel

Hi Will,

This is regarding - thread "try to fix contention between expire_timers 
and try_to_del_timer_sync".
https://lkml.org/lkml/2017/7/28/172

I think this live lockup issue was discussed earlier but the final set 
of changes were not concluded.
I would like to check whether you have new updates on this issue or not. 
  This problem is observed with 4.14 .64 stable kernel too.
We see this problem 2 times in overnight testing.

I have to add the following code to avoid live lock. I am thinking that 
fixing this at the cpu_relax() level.

+++ b/kernel/time/hrtimer.c
@@ -52,6 +52,7 @@
  #include <linux/timer.h>
  #include <linux/freezer.h>
  #include <linux/compat.h>
+#include <linux/delay.h>

  #include <linux/uaccess.h>

@@ -152,6 +153,7 @@ struct hrtimer_clock_base *lock_hrtimer_base(const 
struct hrtimer *timer,
                         
raw_spin_unlock_irqrestore(&base->cpu_base->lock, *flags);
                 }
                 cpu_relax();
+               udelay(1);
         }
  }

@@ -1067,6 +1069,7 @@ int hrtimer_cancel(struct hrtimer *timer)
                 if (ret >= 0)
                         return ret;
                 cpu_relax();
+               udelay(1);
         }
  }
  EXPORT_SYMBOL_GPL(hrtimer_cancel);

Note:- Timer event streaming is enabled and still live lock observed.

-Thanks, Prasad

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
Linux Foundation Collaborative Project

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

* Re: livelock with hrtimer cpu_base->lock
  2018-10-09 20:56 livelock with hrtimer cpu_base->lock Sodagudi Prasad
@ 2018-10-10 16:49 ` Will Deacon
  2018-10-12 12:55   ` Sodagudi Prasad
  0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2018-10-10 16:49 UTC (permalink / raw)
  To: Sodagudi Prasad
  Cc: catalin.marinas, gregkh, ard.biesheuvel, robin.murphy, ynorov,
	linux-arm-kernel, linux-kernel

Hi Prasad,

On Tue, Oct 09, 2018 at 01:56:14PM -0700, Sodagudi Prasad wrote:
> This is regarding - thread "try to fix contention between expire_timers and
> try_to_del_timer_sync".
> https://lkml.org/lkml/2017/7/28/172
> 
> I think this live lockup issue was discussed earlier but the final set of
> changes were not concluded.

Well we basically need a way to pick a value for CPU_RELAX_WFE_THRESHOLD.
Do you have any ideas? It could be determined at runtime if necessary.

> I would like to check whether you have new updates on this issue or not.
> This problem is observed with 4.14 .64 stable kernel too.
> We see this problem 2 times in overnight testing.
> 
> I have to add the following code to avoid live lock. I am thinking that
> fixing this at the cpu_relax() level.
> 
> +++ b/kernel/time/hrtimer.c
> @@ -52,6 +52,7 @@
>  #include <linux/timer.h>
>  #include <linux/freezer.h>
>  #include <linux/compat.h>
> +#include <linux/delay.h>
> 
>  #include <linux/uaccess.h>
> 
> @@ -152,6 +153,7 @@ struct hrtimer_clock_base *lock_hrtimer_base(const
> struct hrtimer *timer,
> raw_spin_unlock_irqrestore(&base->cpu_base->lock, *flags);
>                 }
>                 cpu_relax();
> +               udelay(1);
>         }
>  }
> 
> @@ -1067,6 +1069,7 @@ int hrtimer_cancel(struct hrtimer *timer)
>                 if (ret >= 0)
>                         return ret;
>                 cpu_relax();
> +               udelay(1);
>         }
>  }
>  EXPORT_SYMBOL_GPL(hrtimer_cancel);

This is just another bodge and likely to hurt in places where 1us is
excessive because there isn't contention.

Will

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

* Re: livelock with hrtimer cpu_base->lock
  2018-10-10 16:49 ` Will Deacon
@ 2018-10-12 12:55   ` Sodagudi Prasad
  2018-10-12 15:45     ` Will Deacon
  0 siblings, 1 reply; 4+ messages in thread
From: Sodagudi Prasad @ 2018-10-12 12:55 UTC (permalink / raw)
  To: Will Deacon
  Cc: catalin.marinas, gregkh, ard.biesheuvel, robin.murphy, ynorov,
	linux-arm-kernel, linux-kernel

On 2018-10-10 09:49, Will Deacon wrote:
> Hi Prasad,
> 
> On Tue, Oct 09, 2018 at 01:56:14PM -0700, Sodagudi Prasad wrote:
>> This is regarding - thread "try to fix contention between 
>> expire_timers and
>> try_to_del_timer_sync".
>> https://lkml.org/lkml/2017/7/28/172
>> 
>> I think this live lockup issue was discussed earlier but the final set 
>> of
>> changes were not concluded.
> 
> Well we basically need a way to pick a value for 
> CPU_RELAX_WFE_THRESHOLD.
> Do you have any ideas? It could be determined at runtime if necessary.
> 
Hi Will,

Please share what are values need to be tried for 
CPU_RELAX_WFE_THRESHOLD.

  It would be great if it can be determined from runtime.  Please let me 
know
if any testing need to be done with dynamic detection patch.

-Thanks, Prasad

>> I would like to check whether you have new updates on this issue or 
>> not.
>> This problem is observed with 4.14 .64 stable kernel too.
>> We see this problem 2 times in overnight testing.
>> 
>> I have to add the following code to avoid live lock. I am thinking 
>> that
>> fixing this at the cpu_relax() level.
>> 
>> +++ b/kernel/time/hrtimer.c
>> @@ -52,6 +52,7 @@
>>  #include <linux/timer.h>
>>  #include <linux/freezer.h>
>>  #include <linux/compat.h>
>> +#include <linux/delay.h>
>> 
>>  #include <linux/uaccess.h>
>> 
>> @@ -152,6 +153,7 @@ struct hrtimer_clock_base *lock_hrtimer_base(const
>> struct hrtimer *timer,
>> raw_spin_unlock_irqrestore(&base->cpu_base->lock, *flags);
>>                 }
>>                 cpu_relax();
>> +               udelay(1);
>>         }
>>  }
>> 
>> @@ -1067,6 +1069,7 @@ int hrtimer_cancel(struct hrtimer *timer)
>>                 if (ret >= 0)
>>                         return ret;
>>                 cpu_relax();
>> +               udelay(1);
>>         }
>>  }
>>  EXPORT_SYMBOL_GPL(hrtimer_cancel);
> 
> This is just another bodge and likely to hurt in places where 1us is
> excessive because there isn't contention.
> 
> Will

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
Linux Foundation Collaborative Project

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

* Re: livelock with hrtimer cpu_base->lock
  2018-10-12 12:55   ` Sodagudi Prasad
@ 2018-10-12 15:45     ` Will Deacon
  0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2018-10-12 15:45 UTC (permalink / raw)
  To: Sodagudi Prasad
  Cc: catalin.marinas, gregkh, ard.biesheuvel, robin.murphy, ynorov,
	linux-arm-kernel, linux-kernel

On Fri, Oct 12, 2018 at 05:55:28AM -0700, Sodagudi Prasad wrote:
> On 2018-10-10 09:49, Will Deacon wrote:
> >On Tue, Oct 09, 2018 at 01:56:14PM -0700, Sodagudi Prasad wrote:
> >>This is regarding - thread "try to fix contention between expire_timers
> >>and
> >>try_to_del_timer_sync".
> >>https://lkml.org/lkml/2017/7/28/172
> >>
> >>I think this live lockup issue was discussed earlier but the final set
> >>of
> >>changes were not concluded.
> >
> >Well we basically need a way to pick a value for CPU_RELAX_WFE_THRESHOLD.
> >Do you have any ideas? It could be determined at runtime if necessary.
> >
> 
> Please share what are values need to be tried for CPU_RELAX_WFE_THRESHOLD.
> 
>  It would be great if it can be determined from runtime.  Please let me know
> if any testing need to be done with dynamic detection patch.

I was actually hoping you'd have some ideas about how to write the patch. I
don't have a good feel for how to determine this threshold, and you have
hardware that needs it...

One avenue of exploration might be to tune the fallback to WFE based on
what percentage of the eventstream period we've been polling, e.g. 50%.

Will

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

end of thread, other threads:[~2018-10-12 15:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09 20:56 livelock with hrtimer cpu_base->lock Sodagudi Prasad
2018-10-10 16:49 ` Will Deacon
2018-10-12 12:55   ` Sodagudi Prasad
2018-10-12 15:45     ` Will Deacon

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).