All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: race condition on min/max update?
       [not found] <56CE1432.2020409@linaro.org>
@ 2016-02-26  2:53 ` Viresh Kumar
  2016-02-26 14:11   ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2016-02-26  2:53 UTC (permalink / raw)
  To: Steve Muckle; +Cc: Juri Lelli, Rafael J. Wysocki, linux-pm

+Rafael and linux-pm list

On 24-02-16, 12:36, Steve Muckle wrote:
> Hi Viresh,
> 
> A while back you mentioned that it is not required to hold policy->rwsem
> when calling __cpufreq_driver_target. This simplified things for us a
> bit in schedfreq.
> 
> But if policy->rwsem is not held, how does the frequency transition
> process protect itself against policy->min or policy->max changing?
> Don't you have a race there where it'd be possible to end up with the
> frequency being set to a rate lower than min or higher than max?
> 
> I've taken a cursory look through the code and don't see what would
> prevent this from happening.

It seems that we were not being consistent with this stuff and might have
ignored this race altogether. On some cases we do update the frequency with
policy->rwsem and in others we don't.

It requires a closer look and cleanup I believe.

-- 
viresh

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

* Re: race condition on min/max update?
  2016-02-26  2:53 ` race condition on min/max update? Viresh Kumar
@ 2016-02-26 14:11   ` Rafael J. Wysocki
  2016-02-26 14:37     ` Viresh Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2016-02-26 14:11 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: Steve Muckle, Juri Lelli, linux-pm

On Friday, February 26, 2016 08:23:15 AM Viresh Kumar wrote:
> +Rafael and linux-pm list
> 
> On 24-02-16, 12:36, Steve Muckle wrote:
> > Hi Viresh,
> > 
> > A while back you mentioned that it is not required to hold policy->rwsem
> > when calling __cpufreq_driver_target. This simplified things for us a
> > bit in schedfreq.
> > 
> > But if policy->rwsem is not held, how does the frequency transition
> > process protect itself against policy->min or policy->max changing?
> > Don't you have a race there where it'd be possible to end up with the
> > frequency being set to a rate lower than min or higher than max?
> > 
> > I've taken a cursory look through the code and don't see what would
> > prevent this from happening.
> 
> It seems that we were not being consistent with this stuff and might have
> ignored this race altogether. On some cases we do update the frequency with
> policy->rwsem and in others we don't.
> 
> It requires a closer look and cleanup I believe.

A min/max update should trigger ->governor(limits) and then the governor
is responsible for taking care of the race (if it needs to).

At least that's how it should work IMO.

Thanks,
Rafael


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

* Re: race condition on min/max update?
  2016-02-26 14:11   ` Rafael J. Wysocki
@ 2016-02-26 14:37     ` Viresh Kumar
  2016-02-26 21:05       ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2016-02-26 14:37 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Steve Muckle, Juri Lelli, linux-pm

On 26-02-16, 15:11, Rafael J. Wysocki wrote:
> A min/max update should trigger ->governor(limits) and then the governor
> is responsible for taking care of the race (if it needs to).
> 
> At least that's how it should work IMO.

Urg, simple thing.

-- 
viresh

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

* Re: race condition on min/max update?
  2016-02-26 14:37     ` Viresh Kumar
@ 2016-02-26 21:05       ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2016-02-26 21:05 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: Rafael J. Wysocki, Steve Muckle, Juri Lelli, linux-pm

On Fri, Feb 26, 2016 at 3:37 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 26-02-16, 15:11, Rafael J. Wysocki wrote:
>> A min/max update should trigger ->governor(limits) and then the governor
>> is responsible for taking care of the race (if it needs to).
>>
>> At least that's how it should work IMO.
>
> Urg, simple thing.

It's not particularly clean, though, because ->governor(LIMITS) is
called after min/max have been updated, so the governor may end up
using a frequency that's completely off for a little while between
updating min/max and calling ->governor(LIMITS) (the LIMITS call
really is something like a "you have new min and max, fix up yourself"
notification).  That's why I added a check for min <= max to the
schedutil prototype.

Thanks,
Rafael

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

end of thread, other threads:[~2016-02-26 21:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <56CE1432.2020409@linaro.org>
2016-02-26  2:53 ` race condition on min/max update? Viresh Kumar
2016-02-26 14:11   ` Rafael J. Wysocki
2016-02-26 14:37     ` Viresh Kumar
2016-02-26 21:05       ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.