From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S945054AbdDTLan (ORCPT ); Thu, 20 Apr 2017 07:30:43 -0400 Received: from terminus.zytor.com ([65.50.211.136]:43171 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S944403AbdDTLae (ORCPT ); Thu, 20 Apr 2017 07:30:34 -0400 Date: Thu, 20 Apr 2017 04:28:04 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: mingo@kernel.org, peterz@infradead.org, bigeasy@linutronix.de, rostedt@goodmis.org, tglx@linutronix.de, hpa@zytor.com, lenb@kernel.org, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org Reply-To: tglx@linutronix.de, rostedt@goodmis.org, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com, lenb@kernel.org, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org In-Reply-To: <20170418170553.964555153@linutronix.de> References: <20170418170553.964555153@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] ACPI/processor: Use cpu_hotplug_disable() instead of get_online_cpus() Git-Commit-ID: 16ab1d27c5040ae369c4652e6ce0a9a82bdbb6c5 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 16ab1d27c5040ae369c4652e6ce0a9a82bdbb6c5 Gitweb: http://git.kernel.org/tip/16ab1d27c5040ae369c4652e6ce0a9a82bdbb6c5 Author: Thomas Gleixner AuthorDate: Tue, 18 Apr 2017 19:05:01 +0200 Committer: Thomas Gleixner CommitDate: Thu, 20 Apr 2017 13:08:56 +0200 ACPI/processor: Use cpu_hotplug_disable() instead of get_online_cpus() Converting the hotplug locking, i.e. get_online_cpus(), to a percpu rwsem unearthed a circular lock dependency which was hidden from lockdep due to the lockdep annotation of get_online_cpus() which prevents lockdep from creating full dependency chains. CPU0 CPU1 ---- ---- lock((&wfc.work)); lock(cpu_hotplug_lock.rw_sem); lock((&wfc.work)); lock(cpu_hotplug_lock.rw_sem); This dependency is established via acpi_processor_start() which calls into the work queue code. And the work queue code establishes the reverse dependency. This is not a problem of get_online_cpus() recursion, it's a possible deadlock undetected by lockdep so far. The cure is to use cpu_hotplug_disable() instead of get_online_cpus() to protect the probing from acpi_processor_start(). There is a side effect to this: cpu_hotplug_disable() makes a concurrent cpu hotplug attempt via the sysfs interfaces fail with -EBUSY, but that probing usually happens during the boot process where no interaction is possible. Any later invocations are infrequent enough and concurrent hotplug attempts are so unlikely that the danger of user space visible regressions is very close to zero. Anyway, thats preferrable over a real deadlock. Signed-off-by: Thomas Gleixner Acked-by: Rafael J. Wysocki Cc: Peter Zijlstra Cc: Sebastian Siewior Cc: Steven Rostedt Cc: linux-acpi@vger.kernel.org Cc: Len Brown Link: http://lkml.kernel.org/r/20170418170553.964555153@linutronix.de --- drivers/acpi/processor_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 8697a82..591d1dd 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -268,9 +268,9 @@ static int acpi_processor_start(struct device *dev) return -ENODEV; /* Protect against concurrent CPU hotplug operations */ - get_online_cpus(); + cpu_hotplug_disable(); ret = __acpi_processor_start(device); - put_online_cpus(); + cpu_hotplug_enable(); return ret; }