Hi, Nageswara R Sastry <rnsastry@linux.vnet.ibm.com> writes:Added Dave Jones to CC. The work seems to be queued twice. Might there be a race in the activation of the governor? proc #0 proc #1 if (this_dbs_info->enable == 0) <PREEMPTED> if (this_dbs_info->enable == 0) mutex_lock() dbs_timer_init() queue_delayed_work_on() mutex_unlock() ... mutex_lock() dbs_timer_init() queue_delayed_work_on() If that might happen, would it be feasible to put the check for ->enable within the mutex-protection? Hannes --- From: Johannes Weiner <hannes@saeurebad.de> Subject: cpufreq: Fix race in enabling ondemand/conservative governors Prevent double activation of the governor if two processes race on the check for whether the governor is already active. Signed-off-by: Johannes Weiner <hannes@saeurebad.de> --- diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 5d3a04b..a4902e4 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -486,10 +486,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, if ((!cpu_online(cpu)) || (!policy->cur)) return -EINVAL; - if (this_dbs_info->enable) /* Already enabled */ - break; - mutex_lock(&dbs_mutex); + if (this_dbs_info->enable) { + mutex_unlock(&dbs_mutex); + break; + } rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); if (rc) { diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index d2af20d..61705e1 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -508,10 +508,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, if ((!cpu_online(cpu)) || (!policy->cur)) return -EINVAL; - if (this_dbs_info->enable) /* Already enabled */ + mutex_lock(&dbs_mutex); + if (this_dbs_info->enable) { + mutex_unlock(&dbs_mutex); break; + } - mutex_lock(&dbs_mutex); dbs_enable++; rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); --
| Al Boldi | Re: [ck] Re: [ANNOUNCE] RSDL completely fair starvation free interactive cpu sched... |
| Ingo Molnar | Re: [patch] sched_clock(): cleanups |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 18/37] dccp: Support for Mandatory options |
| Denys Vlasenko | [PATCH 1/2] bnx2: factor out gzip unpacker |
