mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] cpufreq: Register with perf domain before
@ 2023-01-18  4:47 Vincent Wang
  2023-01-18  8:49 ` Viresh Kumar
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Wang @ 2023-01-18  4:47 UTC (permalink / raw)
  To: rafael, viresh.kumar, lukasz.luba; +Cc: linux-pm, linux-kernel, Vincent Wang

From: Vincent Wang <vincentwang3@lenovo.com>

We found the following issue during kernel boot on android phone:

[    1.325272][    T1] cpu cpu0: EM: created perf domain
[    1.329317][    T1] cpu cpu4: EM: created perf domain
[    1.337597][   T76] pd_init: no EM found for CPU7
[    1.350849][    T1] cpu cpu7: EM: created perf domain

pd init for cluster2 is executed in a kworker thread and
is earlier than the perf domain creation for cluster2.

pd_init() is called from the cpufreq notification of
CPUFREQ_CREATE_POLICY in cpufreq_online(), which is earlier
than that cpufreq_driver->register_em() is called.

To avoid this issue, register with perf domain should be
earlier than the notification is sent.

Signed-off-by: Vincent Wang <vincentwang3@lenovo.com>
---
v1 -> v2:  based on Rafael's comment, adjust the order of
regitster perf domain. But I think it's no need to be in
advance to the initialization of frequency QoS.

Change the description of this patch.

 drivers/cpufreq/cpufreq.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7e56a42750ea..a715c8323897 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1431,6 +1431,24 @@ static int cpufreq_online(unsigned int cpu)
 			goto out_destroy_policy;
 		}
 
+		/*
+		 * Register with the energy model before
+		 * blocking_notifier_call_chain() is called for
+		 * CPUFREQ_CREATE_POLICY, which will result in rebuilding of the
+		 * sched domains in update_topology_flags_workfn().
+		 *
+		 * Register with the energy model before
+		 * sched_cpufreq_governor_change() is called, which will result
+		 * in rebuilding of the sched domains, which should only be done
+		 * once the energy model is properly initialized for the policy
+		 * first.
+		 *
+		 * Also, this should be called before the policy is registered
+		 * with cooling framework.
+		 */
+		if (cpufreq_driver->register_em)
+			cpufreq_driver->register_em(policy);
+
 		blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
 				CPUFREQ_CREATE_POLICY, policy);
 	}
@@ -1493,19 +1511,6 @@ static int cpufreq_online(unsigned int cpu)
 		write_lock_irqsave(&cpufreq_driver_lock, flags);
 		list_add(&policy->policy_list, &cpufreq_policy_list);
 		write_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
-		/*
-		 * Register with the energy model before
-		 * sched_cpufreq_governor_change() is called, which will result
-		 * in rebuilding of the sched domains, which should only be done
-		 * once the energy model is properly initialized for the policy
-		 * first.
-		 *
-		 * Also, this should be called before the policy is registered
-		 * with cooling framework.
-		 */
-		if (cpufreq_driver->register_em)
-			cpufreq_driver->register_em(policy);
 	}
 
 	ret = cpufreq_init_policy(policy);
-- 
2.25.1


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

end of thread, other threads:[~2023-01-19  8:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18  4:47 [PATCH v2] cpufreq: Register with perf domain before Vincent Wang
2023-01-18  8:49 ` Viresh Kumar
2023-01-18  9:24   ` Lukasz Luba
2023-01-18 10:00     ` Vincent Wang3
2023-01-18 11:55       ` Lukasz Luba
2023-01-19  5:39     ` Viresh Kumar
2023-01-19  7:58       ` Lukasz Luba
2023-01-19  8:32         ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®