Linux-rt-users Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] rt: cpufreq: Fix cpu hotplug hang
@ 2021-02-19  8:44 Ran Wang
  2021-02-22 14:01 ` Sebastian Siewior
  0 siblings, 1 reply; 7+ messages in thread
From: Ran Wang @ 2021-02-19  8:44 UTC (permalink / raw)
  To: Sebastian Siewior, Thomas Gleixner
  Cc: Jiafei Pan, linux-rt-users, Ingo Molnar, Peter Zijlstra,
	Rafael J . Wysocki, Viresh Kumar, Ran Wang

When selecting PREEMPT_RT, cpufreq_driver->stop_cpu(policy) might got
stuck due to irq_work_sync() pending for work on lazy_list. That’s
because lazy_list may have no chance to be served in softirq context
sometimes. Below is one of scenarios that was captured:

...
ret_from_fork
 kthread
  smpboot_thread_fn
   cpuhp_thread_fun
    cpuhp_invoke_callback: state: 193
     cpuhp_cpufreq_online
      cpufreq_online
       cpufreq_driver->stop_cpu(policy);
        cpufreq_dbs_governor_stop
         sugov_stop  // kernel/sched/cpufreq_schedutil.c
          irq_work_sync(&sg_policy->irq_work);

This is observed on LX2160ARDB (16 A72 cores) with cpufreq governor of
‘schedutil’ or ‘ondemand’.

Configure related irqwork to run on raw-irq context could fix this.

Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 drivers/cpufreq/cpufreq_governor.c | 2 +-
 kernel/sched/cpufreq_schedutil.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 63f7c219062b..731a7b1434df 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -360,7 +360,7 @@ static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *poli
 	policy_dbs->policy = policy;
 	mutex_init(&policy_dbs->update_mutex);
 	atomic_set(&policy_dbs->work_count, 0);
-	init_irq_work(&policy_dbs->irq_work, dbs_irq_work);
+	policy_dbs->irq_work = IRQ_WORK_INIT_HARD(dbs_irq_work);
 	INIT_WORK(&policy_dbs->work, dbs_work_handler);
 
 	/* Set policy_dbs for all CPUs, online+offline */
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 6931f0cdeb80..054a01ef4f57 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -719,7 +719,7 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
 
 	sg_policy->thread = thread;
 	kthread_bind_mask(thread, policy->related_cpus);
-	init_irq_work(&sg_policy->irq_work, sugov_irq_work);
+	sg_policy->irq_work = IRQ_WORK_INIT_HARD(sugov_irq_work);
 	mutex_init(&sg_policy->work_lock);
 
 	wake_up_process(thread);
-- 
2.25.1


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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19  8:44 [PATCH] rt: cpufreq: Fix cpu hotplug hang Ran Wang
2021-02-22 14:01 ` Sebastian Siewior
2021-02-23  2:26   ` Ran Wang
2021-02-23  3:13     ` Viresh Kumar
2021-02-24 16:37       ` Sebastian Siewior
2021-02-25  2:31         ` Ran Wang
2021-03-23  7:00         ` Ran Wang

Linux-rt-users Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rt-users/0 linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ https://lore.kernel.org/linux-rt-users \
		linux-rt-users@vger.kernel.org
	public-inbox-index linux-rt-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rt-users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git