Skip to contentSkip to conversation

cpufreq: Judging new_policy before update related_cpus

PATCH In review Xuewen Yan 2 participants 2 messages Feb 2, 2021 CPU frequency scaling framework

lore
Share & tools
lore

Xuewen Yan

author
#0 lore raw

PATCH 1/1 cpufreq: Judging new_policy before update related_cpus

From: Xuewen Yan <[email protected]>

When the policy->related_cpus are all offline, and then bring up one cpu, this time, if the ->online is NULL, the code would update the ->related_cpus with ->cpus, and now ->cpus is only one online cpu, as a result, the ->related_cpus is different from the origion ->related_cpus.

---
 drivers/cpufreq/cpufreq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +4 -2
index d0a3525ce27f..3d512ac463a5 100644
@@ -1374,8 +1374,10 @@ static int cpufreq_online(unsigned int cpu)
 		if (ret)
 			goto out_exit_policy;
 
-		/* related_cpus should at least include policy->cpus. */
-		cpumask_copy(policy->related_cpus, policy->cpus);
+		if (new_policy) {
+			/* related_cpus should at least include policy->cpus. */
+			cpumask_copy(policy->related_cpus, policy->cpus);
+		}
 	}
 
 	down_write(&policy->rwsem);
Signature · 1 line
2.29.0
maintainer
#1 lore raw
Quoted 18 lines · Xuewen Yan

From: Xuewen Yan <[email protected]>

When the policy->related_cpus are all offline, and then bring up one cpu, this time, if the ->online is NULL, the code would update the ->related_cpus with ->cpus, and now ->cpus is only one online cpu, as a result, the ->related_cpus is different from the origion ->related_cpus.

---
 drivers/cpufreq/cpufreq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +0 -0
index d0a3525ce27f..3d512ac463a5 100644

drivers/cpufreq/cpufreq.c static int cpufreq_online(unsigned int cpu) · line 1381

Quoted 10 lines
drivers/cpufreq/cpufreq.c +4 -2
@@ -1374,8 +1374,10 @@ static int cpufreq_online(unsigned int cpu)
 		if (ret)
 			goto out_exit_policy;
 
-		/* related_cpus should at least include policy->cpus. */
-		cpumask_copy(policy->related_cpus, policy->cpus);
+		if (new_policy) {
+			/* related_cpus should at least include policy->cpus. */
+			cpumask_copy(policy->related_cpus, policy->cpus);
+		}
 	}

The driver's ->init() callback is responsible for filling policy->cpus here.

Signature · 1 line
viresh