From patchwork Thu Oct 3 14:08:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 11172741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E0EB139A for ; Thu, 3 Oct 2019 14:08:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41BBC21848 for ; Thu, 3 Oct 2019 14:08:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729674AbfJCOIf (ORCPT ); Thu, 3 Oct 2019 10:08:35 -0400 Received: from mga03.intel.com ([134.134.136.65]:64806 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbfJCOIf (ORCPT ); Thu, 3 Oct 2019 10:08:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2019 07:08:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,252,1566889200"; d="scan'208";a="191275044" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga008.fm.intel.com with SMTP; 03 Oct 2019 07:08:29 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 03 Oct 2019 17:08:28 +0300 From: Ville Syrjala To: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, "Paul E . McKenney" , Andi Kleen , "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Subject: [PATCH] cpufreq: Fix RCU reboot regression on x86 PIC machines Date: Thu, 3 Oct 2019 17:08:28 +0300 Message-Id: <20191003140828.14801-1-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Ville Syrjälä Since 4.20-rc1 my PIC machines no longer reboot/shutdown. I bisected this down to commit 45975c7d21a1 ("rcu: Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds"). I traced the hang into -> cpufreq_suspend() -> cpufreq_stop_governor() -> cpufreq_dbs_governor_stop() -> gov_clear_update_util() -> synchronize_sched() -> synchronize_rcu() Only PREEMPT=y is affected for obvious reasons. The problem is limited to PIC machines since they mask off interrupts in i8259A_shutdown() (syscore_ops.shutdown() registered from device_initcall()). I reported this long ago but no better fix has surfaced, hence sending out my initial workaround which I've been carrying around ever since. I just move cpufreq_core_init() to late_initcall() so the syscore_ops get registered in the oppsite order and thus the .shutdown() hooks get executed in the opposite order as well. Not 100% convinced this is safe (especially moving the cpufreq_global_kobject creation to late_initcall()) but I've not had any problems with it at least. Here's the resulting change in initcall_debug: + PM: Calling cpufreq_suspend+0x0/0x100 PM: Calling mce_syscore_shutdown+0x0/0x10 PM: Calling i8259A_shutdown+0x0/0x10 - PM: Calling cpufreq_suspend+0x0/0x100 + reboot: Restarting system + reboot: machine restart Cc: stable@vger.kernel.org Cc: Paul E. McKenney Cc: Andi Kleen Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Cc: linux-pm@vger.kernel.org Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Fixes: 45975c7d21a1 ("rcu: Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds") Signed-off-by: Ville Syrjälä Tested-by: Ville Syrjälä --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index c52d6fa32aac..6a8fb9b08e33 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2761,4 +2761,4 @@ static int __init cpufreq_core_init(void) return 0; } module_param(off, int, 0444); -core_initcall(cpufreq_core_init); +late_initcall(cpufreq_core_init);