linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: jiel@marvell.com
Cc: rjw@rjwysocki.net, viresh.kumar@linaro.org,
	cpufreq@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] cpufreq: Fix timer/workqueue corruption by protecting reading governor_enabled
Date: Thu, 2 Jan 2014 15:26:38 -0800	[thread overview]
Message-ID: <20140102232638.GA21548@core.coreip.homeip.net> (raw)
In-Reply-To: <1388632482-16921-1-git-send-email-jiel@marvell.com>

Hi Jane:

On Thu, Jan 02, 2014 at 11:14:42AM +0800, jiel@marvell.com wrote:
> @@ -119,8 +121,11 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
>  {
>  	int i;
>  
> -	if (!policy->governor_enabled)
> +	mutex_lock(&cpufreq_governor_lock);
> +	if (!policy->governor_enabled) {
> +		mutex_unlock(&cpufreq_governor_lock);
>  		return;
> +	}
>  
>  	if (!all_cpus) {
>  		/*
> @@ -135,6 +140,7 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
>  		for_each_cpu(i, policy->cpus)
>  			__gov_queue_work(i, dbs_data, delay);
>  	}
> +	mutex_unlock(&cpufreq_governor_lock);

Unlocking in different branches is not the best practice IMO, I'd
recommend doing:

	mutex_lock(&cpufreq_governor_lock);

	if (!policy->governor_enabled)
		goto out_unlock;

	...

out_unlock:
	mutex_unlock(&cpufreq_governor_lock);

Thanks!

-- 
Dmitry

  parent reply	other threads:[~2014-01-02 23:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-02  3:14 [PATCH v2] cpufreq: Fix timer/workqueue corruption by protecting reading governor_enabled jiel
2014-01-02  5:34 ` Viresh Kumar
2014-01-02 23:26 ` Dmitry Torokhov [this message]
2014-01-03  6:44   ` Jane Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140102232638.GA21548@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=jiel@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).