All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] Convert cpu_up/down to device_online/offline
@ 2019-10-30 15:38 ` Qais Yousef
  0 siblings, 0 replies; 55+ messages in thread
From: Qais Yousef @ 2019-10-30 15:38 UTC (permalink / raw)
  To: Thomas Gleixner, Greg Kroah-Hartman
  Cc: Mark Rutland, x86, linux-ia64, Rafael J. Wysocki,
	Peter Zijlstra (Intel),
	Ram Pai, linux-kernel, James E.J. Bottomley, Richard Fontana,
	Nadav Amit, H. Peter Anvin, sparclinux, Will Deacon, Ingo Molnar,
	Davidlohr Bueso, Helge Deller, Daniel Lezcano, Qais Yousef,
	Eiichi Tsukata, Catalin Marinas, xen-devel, 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, Tony Luck, linux-parisc, Steve Capper,
	Jiri Kosina, linuxppc-dev, Zhenzhong Duan, Armijn Hemel,
	James Morse, Stefano Stabellini, Sakari Ailus, Paul Mackerras,
	Enrico Weigelt, David S. Miller, Thiago Jung Bauermann

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 still need to update the documentation to remove references to cpu_up/down
and advocate for device_online/offline instead if this series will make its way
through.

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 6 patches fixes arch users.

The next 5 patches fixes generic code users. Particularly creating a new
special exported API for the device core to use instead of cpu_up/down.
Maybe we can do something more restrictive than that.

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 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 <armijn@tjaldur.nl>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Bjorn Helgaas <bhelgaas@google.com>
CC: Borislav Petkov <bp@alien8.de>
CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Christophe Leroy <christophe.leroy@c-s.fr>
CC: Daniel Lezcano <daniel.lezcano@linaro.org>
CC: Davidlohr Bueso <dave@stgolabs.net>
CC: "David S. Miller" <davem@davemloft.net>
CC: Eiichi Tsukata <devel@etsukata.com>
CC: Enrico Weigelt <info@metux.net>
CC: Fenghua Yu <fenghua.yu@intel.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Helge Deller <deller@gmx.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
CC: James Morse <james.morse@arm.com>
CC: Jiri Kosina <jkosina@suse.cz>
CC: Josh Poimboeuf <jpoimboe@redhat.com>
CC: Josh Triplett <josh@joshtriplett.org>
CC: Juergen Gross <jgross@suse.com>
CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
CC: Mark Rutland <mark.rutland@arm.com>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Nadav Amit <namit@vmware.com>
CC: Nicholas Piggin <npiggin@gmail.com>
CC: "Paul E. McKenney" <paulmck@kernel.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Pavankumar Kondeti <pkondeti@codeaurora.org>
CC: "Peter Zijlstra (Intel)" <peterz@infradead.org>
CC: "Rafael J. Wysocki" <rafael@kernel.org>
CC: Ram Pai <linuxram@us.ibm.com>
CC: Richard Fontana <rfontana@redhat.com>
CC: Sakari Ailus <sakari.ailus@linux.intel.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Steve Capper <steve.capper@arm.com>
CC: Thiago Jung Bauermann <bauerman@linux.ibm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Tony Luck <tony.luck@intel.com>
CC: Will Deacon <will@kernel.org>
CC: Zhenzhong Duan <zhenzhong.duan@oracle.com>
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 (12):
  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
  ia64: Replace cpu_down with freeze_secondary_cpus
  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/arm64/kernel/hibernate.c          | 13 +++----
 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                    |  6 ++-
 kernel/cpu.c                           | 53 ++++++++++++++++++++++++--
 kernel/smp.c                           |  9 +----
 kernel/torture.c                       | 15 ++++++--
 16 files changed, 106 insertions(+), 46 deletions(-)

-- 
2.17.1


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

end of thread, other threads:[~2019-11-24 10:20 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 15:38 [PATCH 00/12] Convert cpu_up/down to device_online/offline Qais Yousef
2019-10-30 15:38 ` [Xen-devel] " Qais Yousef
2019-10-30 15:38 ` [PATCH 01/12] arm64: hibernate.c: create a new function to handle cpu_up(sleep_cpu) Qais Yousef
2019-10-30 15:38   ` Qais Yousef
2019-11-19 22:31   ` Thomas Gleixner
2019-11-19 22:31     ` Thomas Gleixner
2019-11-19 22:51     ` Qais Yousef
2019-11-19 22:51       ` Qais Yousef
2019-11-19 23:01       ` Thomas Gleixner
2019-11-19 23:01         ` Thomas Gleixner
2019-11-19 23:21         ` Qais Yousef
2019-11-19 23:21           ` Qais Yousef
2019-10-30 15:38 ` [PATCH 02/12] x86: Replace cpu_up/down with devcie_online/offline Qais Yousef
2019-10-30 15:38 ` [PATCH 03/12] powerpc: Replace cpu_up/down with device_online/offline Qais Yousef
2019-10-30 15:38   ` Qais Yousef
2019-11-19  1:19   ` Michael Ellerman
2019-11-19  1:19     ` Michael Ellerman
2019-11-19  9:47     ` Qais Yousef
2019-11-19  9:47       ` Qais Yousef
2019-10-30 15:38 ` [PATCH 04/12] ia64: Replace cpu_down with freeze_secondary_cpus Qais Yousef
2019-11-02  4:59   ` kbuild test robot
2019-11-02  4:59     ` kbuild test robot
2019-11-02  4:59     ` kbuild test robot
2019-11-19 22:21   ` Thomas Gleixner
2019-11-19 22:21     ` Thomas Gleixner
2019-11-19 22:32     ` Qais Yousef
2019-11-19 22:59       ` Thomas Gleixner
2019-11-19 22:59         ` Thomas Gleixner
2019-11-19 23:19         ` Qais Yousef
2019-11-20  8:46           ` Thomas Gleixner
2019-11-20  8:46             ` Thomas Gleixner
2019-11-20 10:49             ` Qais Yousef
2019-10-30 15:38 ` [PATCH 05/12] sparc: Replace cpu_up/down with device_online/offline Qais Yousef
2019-10-30 19:33   ` David Miller
2019-10-30 19:33     ` David Miller
2019-10-30 15:38 ` [PATCH 06/12] parisc: " Qais Yousef
2019-11-20 11:09   ` Qais Yousef
2019-11-22 19:51     ` Helge Deller
2019-11-24 10:20       ` Qais Yousef
2019-10-30 15:38 ` [PATCH 07/12] driver: base: cpu: export device_online/offline Qais Yousef
2019-11-02 17:17   ` Greg Kroah-Hartman
2019-10-30 15:38 ` [PATCH 08/12] driver: xen: Replace cpu_up/down with device_online/offline Qais Yousef
2019-10-30 15:38   ` [Xen-devel] " Qais Yousef
2019-10-30 15:38 ` [PATCH 09/12] firmware: psci: " Qais Yousef
2019-10-30 15:38   ` Qais Yousef
2019-10-30 15:38 ` [PATCH 10/12] torture: " Qais Yousef
2019-10-30 15:38 ` [PATCH 11/12] smp: Create a new function to bringup nonboot cpus online Qais Yousef
2019-11-19 22:42   ` Thomas Gleixner
2019-10-30 15:38 ` [PATCH 12/12] cpu: Hide cpu_up/down Qais Yousef
2019-11-19 22:25   ` Thomas Gleixner
2019-11-19 22:36     ` Qais Yousef
2019-11-18 16:04 ` [PATCH 00/12] Convert cpu_up/down to device_online/offline Qais Yousef
2019-11-18 16:04   ` [Xen-devel] " Qais Yousef
2019-11-18 20:27   ` Thomas Gleixner
2019-11-18 20:27     ` [Xen-devel] " Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.