From patchwork Mon Nov 25 11:27:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 11260253 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 D51CF1393 for ; Mon, 25 Nov 2019 11:29:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BAD5B20740 for ; Mon, 25 Nov 2019 11:29:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BAD5B20740 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZCXI-00012M-B4; Mon, 25 Nov 2019 11:28:08 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZCXG-00012H-TM for xen-devel@lists.xenproject.org; Mon, 25 Nov 2019 11:28:06 +0000 X-Inumbo-ID: a56c455a-0f76-11ea-a38f-12813bfff9fa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id a56c455a-0f76-11ea-a38f-12813bfff9fa; Mon, 25 Nov 2019 11:28:04 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF11E55D; Mon, 25 Nov 2019 03:28:03 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CA1163F52E; Mon, 25 Nov 2019 03:27:57 -0800 (PST) From: Qais Yousef To: Thomas Gleixner , Greg Kroah-Hartman Date: Mon, 25 Nov 2019 11:27:40 +0000 Message-Id: <20191125112754.25223-1-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH v2 00/14] Convert cpu_up/down to device_online/offline X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , x86@kernel.org, linux-ia64@vger.kernel.org, "Rafael J. Wysocki" , "Peter Zijlstra \(Intel\)" , Benjamin Herrenschmidt , Ram Pai , linux-kernel@vger.kernel.org, "James E.J. Bottomley" , Richard Fontana , Nadav Amit , "H. Peter Anvin" , sparclinux@vger.kernel.org, Will Deacon , Ingo Molnar , Davidlohr Bueso , Michael Ellerman , Helge Deller , Daniel Lezcano , Russell King , Qais Yousef , Eiichi Tsukata , Catalin Marinas , xen-devel@lists.xenproject.org, Fenghua Yu , Juergen Gross , "Paul E. McKenney" , Josh Triplett , Nicholas Piggin , Lorenzo Pieralisi , Borislav Petkov , Josh Poimboeuf , Bjorn Helgaas , Boris Ostrovsky , Pavankumar Kondeti , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Tony Luck , linux-parisc@vger.kernel.org, Steve Capper , Jiri Kosina , linuxppc-dev@lists.ozlabs.org, Zhenzhong Duan , Armijn Hemel , James Morse , Stefano Stabellini , Sakari Ailus , Paul Mackerras , Enrico Weigelt , "David S. Miller" , Thiago Jung Bauermann MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Changes in v2: * Add 2 new patches that create smp_shutdown_nonboot_cpus() to be used in machine_shutdown() in ia64, arm and arm64 * Use proper kernel-doc for the newly introduced functions * Renamed a function * Removed a stale comment in a function * Rebased on top of 5.4-rc8 git clone git://linux-arm.org/linux-qy.git -b cpu-hp-cleanup-v2 Using cpu_up/down directly to bring cpus online/offline loses synchronization with sysfs and could suffer from a race similar to what is described in commit a6717c01ddc2 ("powerpc/rtas: use device model APIs and serialization during LPM"). cpu_up/down seem to be more of a internal implementation detail for the cpu subsystem to use to boot up cpus, perform suspend/resume and low level hotplug operations. Users outside of the cpu subsystem would be better using the device core API to bring a cpu online/offline which is the interface used to hotplug memory and other system devices. Several users have already migrated to use the device core API, this series converts the remaining users and hides cpu_up/down from internal users at the end. I noticed this problem while working on a hack to disable offlining a particular CPU but noticed that setting the offline_disabled attribute in the device struct isn't enough because users can easily bypass the device core. While my hack isn't a valid use case but it did highlight the inconsistency in the way cpus are being onlined/offlined and this attempt hopefully improves on this. The first 8 patches fix arch users. The remaining 6 patches fix generic code users. Particularly creating a new special exported API for the device core to use instead of cpu_up/down. The last patch removes cpu_up/down from cpu.h and unexport the functions. In some cases where the use of cpu_up/down seemed legitimate, I encapsulated the logic in a higher level - special purposed function; and converted the code to use that instead. I did re-run the rcu torture, lock torture and psci checker tests and no problem was noticed. I did perform build tests on all arch affected except for parisc. Hopefully I got the CC list right for all the patches. Apologies in advance if some people were omitted from some patches but they should have been CCed. CC: Armijn Hemel CC: Benjamin Herrenschmidt CC: Bjorn Helgaas CC: Borislav Petkov CC: Boris Ostrovsky CC: Catalin Marinas CC: Christophe Leroy CC: Daniel Lezcano CC: Davidlohr Bueso CC: "David S. Miller" CC: Eiichi Tsukata CC: Enrico Weigelt CC: Fenghua Yu CC: Greg Kroah-Hartman CC: Helge Deller CC: "H. Peter Anvin" CC: Ingo Molnar CC: "James E.J. Bottomley" CC: James Morse CC: Jiri Kosina CC: Josh Poimboeuf CC: Josh Triplett CC: Juergen Gross CC: Lorenzo Pieralisi CC: Mark Rutland CC: Michael Ellerman CC: Nadav Amit CC: Nicholas Piggin CC: "Paul E. McKenney" CC: Paul Mackerras CC: Pavankumar Kondeti CC: "Peter Zijlstra (Intel)" CC: "Rafael J. Wysocki" CC: Ram Pai CC: Richard Fontana CC: Russell King CC: Sakari Ailus CC: Stefano Stabellini CC: Steve Capper CC: Thiago Jung Bauermann CC: Thomas Gleixner CC: Tony Luck CC: Will Deacon CC: Zhenzhong Duan CC: linux-arm-kernel@lists.infradead.org CC: linux-ia64@vger.kernel.org CC: linux-kernel@vger.kernel.org CC: linux-parisc@vger.kernel.org CC: linuxppc-dev@lists.ozlabs.org CC: sparclinux@vger.kernel.org CC: x86@kernel.org CC: xen-devel@lists.xenproject.org Qais Yousef (14): smp: create a new function to shutdown nonboot cpus ia64: Replace cpu_down with smp_shutdown_nonboot_cpus() arm: arm64: Don't use disable_nonboot_cpus() arm64: hibernate.c: create a new function to handle cpu_up(sleep_cpu) x86: Replace cpu_up/down with devcie_online/offline powerpc: Replace cpu_up/down with device_online/offline sparc: Replace cpu_up/down with device_online/offline parisc: Replace cpu_up/down with device_online/offline driver: base: cpu: export device_online/offline driver: xen: Replace cpu_up/down with device_online/offline firmware: psci: Replace cpu_up/down with device_online/offline torture: Replace cpu_up/down with device_online/offline smp: Create a new function to bringup nonboot cpus online cpu: Hide cpu_up/down arch/arm/kernel/reboot.c | 4 +- arch/arm64/kernel/hibernate.c | 13 ++-- arch/arm64/kernel/process.c | 4 +- arch/ia64/kernel/process.c | 8 +-- arch/parisc/kernel/processor.c | 4 +- arch/powerpc/kernel/machine_kexec_64.c | 4 +- arch/sparc/kernel/ds.c | 8 ++- arch/x86/kernel/topology.c | 4 +- arch/x86/mm/mmio-mod.c | 8 ++- arch/x86/xen/smp.c | 4 +- drivers/base/core.c | 4 ++ drivers/base/cpu.c | 4 +- drivers/firmware/psci/psci_checker.c | 6 +- drivers/xen/cpu_hotplug.c | 2 +- include/linux/cpu.h | 8 ++- kernel/cpu.c | 85 ++++++++++++++++++++++++-- kernel/smp.c | 9 +-- kernel/torture.c | 15 +++-- 18 files changed, 143 insertions(+), 51 deletions(-)