Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311323 > unrolled thread

Re: [RFC PATCH 08/19] cpufreq: fix warning for cpufreq_init_policy unlocked access to cpufreq_governor_list

Started byViresh Kumar <viresh.kumar@linaro.org>
First post2016-01-18 06:30 +0100
Last post2016-01-18 16:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [RFC PATCH 08/19] cpufreq: fix warning for cpufreq_init_policy  unlocked access to cpufreq_governor_list Viresh Kumar <viresh.kumar@linaro.org> - 2016-01-18 06:30 +0100
    Re: [RFC PATCH 08/19] cpufreq: fix warning for cpufreq_init_policy  unlocked access to cpufreq_governor_list Juri Lelli <juri.lelli@arm.com> - 2016-01-18 16:20 +0100

#1311323 — Re: [RFC PATCH 08/19] cpufreq: fix warning for cpufreq_init_policy unlocked access to cpufreq_governor_list

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-01-18 06:30 +0100
SubjectRe: [RFC PATCH 08/19] cpufreq: fix warning for cpufreq_init_policy unlocked access to cpufreq_governor_list
Message-ID<qSay7-4yP-1@gated-at.bofh.it>
On 14-01-16, 16:35, Juri Lelli wrote:
> But, don't we have to guarantee consinstency between multiple operations
> on cpufreq_governor_list?
> 
> In cpufreq_register_governor() we have:
> 
>  mutex_lock(&cpufreq_governor_mutex);
>  
>  governor->initialized = 0;
>  err = -EBUSY;
>  if (!find_governor(governor->name)) {
>  	err = 0;
>  	list_add(&governor->governor_list, &cpufreq_governor_list);
>  }
>  
>  mutex_unlock(&cpufreq_governor_mutex);
> 
> IIUC, find_governor and list_add have to be atomic. Couldn't someone
> slip in right after find_governor and add the same governor to the list?

Yeah, I was wrong that cpufreq_register_governor() doesn't need a
lock. We already have that in place ..

But most of the other places are really useless and shows that we
haven't implemented it well.

I would suggest that we move the lock within find_governor() and
create another find_governor_unlocked() or __find_governor() that will
be used only from cpufreq_register_governor(), with an outer lock.

Looks reasonable ?

-- 
viresh

[toc] | [next] | [standalone]


#1311605

FromJuri Lelli <juri.lelli@arm.com>
Date2016-01-18 16:20 +0100
Message-ID<qSjL3-2rS-5@gated-at.bofh.it>
In reply to#1311323
On 18/01/16 10:53, Viresh Kumar wrote:
> On 14-01-16, 16:35, Juri Lelli wrote:
> > But, don't we have to guarantee consinstency between multiple operations
> > on cpufreq_governor_list?
> > 
> > In cpufreq_register_governor() we have:
> > 
> >  mutex_lock(&cpufreq_governor_mutex);
> >  
> >  governor->initialized = 0;
> >  err = -EBUSY;
> >  if (!find_governor(governor->name)) {
> >  	err = 0;
> >  	list_add(&governor->governor_list, &cpufreq_governor_list);
> >  }
> >  
> >  mutex_unlock(&cpufreq_governor_mutex);
> > 
> > IIUC, find_governor and list_add have to be atomic. Couldn't someone
> > slip in right after find_governor and add the same governor to the list?
> 
> Yeah, I was wrong that cpufreq_register_governor() doesn't need a
> lock. We already have that in place ..
> 
> But most of the other places are really useless and shows that we
> haven't implemented it well.
> 
> I would suggest that we move the lock within find_governor() and
> create another find_governor_unlocked() or __find_governor() that will
> be used only from cpufreq_register_governor(), with an outer lock.
> 
> Looks reasonable ?
> 

Yes it does. I'll look into doing that.

Thanks,

- Juri

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web