From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758048AbcKCOyS (ORCPT ); Thu, 3 Nov 2016 10:54:18 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35434 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757869AbcKCOuu (ORCPT ); Thu, 3 Nov 2016 10:50:50 -0400 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: rt@linutronix.de, Sebastian Andrzej Siewior , Greg Kroah-Hartman , Thomas Gleixner Subject: [PATCH 13/25] drivers base/topology: Convert to hotplug state machine Date: Thu, 3 Nov 2016 15:50:09 +0100 Message-Id: <20161103145021.28528-14-bigeasy@linutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161103145021.28528-1-bigeasy@linutronix.de> References: <20161103145021.28528-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. The removal of the files happens now in the prepare down stage as there is no reason to keep them around until the cpu has actually died. Cc: Greg Kroah-Hartman Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner --- drivers/base/topology.c | 42 +++++------------------------------------- include/linux/cpuhotplug.h | 1 + 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/drivers/base/topology.c b/drivers/base/topology.c index df3c97cb4c99..d6ec1c546f5b 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c @@ -118,51 +118,19 @@ static int topology_add_dev(unsigned int cpu) return sysfs_create_group(&dev->kobj, &topology_attr_group); } =20 -static void topology_remove_dev(unsigned int cpu) +static int topology_remove_dev(unsigned int cpu) { struct device *dev =3D get_cpu_device(cpu); =20 sysfs_remove_group(&dev->kobj, &topology_attr_group); -} - -static int topology_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) -{ - unsigned int cpu =3D (unsigned long)hcpu; - int rc =3D 0; - - switch (action) { - case CPU_UP_PREPARE: - case CPU_UP_PREPARE_FROZEN: - rc =3D topology_add_dev(cpu); - break; - case CPU_UP_CANCELED: - case CPU_UP_CANCELED_FROZEN: - case CPU_DEAD: - case CPU_DEAD_FROZEN: - topology_remove_dev(cpu); - break; - } - return notifier_from_errno(rc); + return 0; } =20 static int topology_sysfs_init(void) { - int cpu; - int rc =3D 0; - - cpu_notifier_register_begin(); - - for_each_online_cpu(cpu) { - rc =3D topology_add_dev(cpu); - if (rc) - goto out; - } - __hotcpu_notifier(topology_cpu_callback, 0); - -out: - cpu_notifier_register_done(); - return rc; + return cpuhp_setup_state(CPUHP_TOPOLOGY_PREPARE, + "base/topology:prepare", topology_add_dev, + topology_remove_dev); } =20 device_initcall(topology_sysfs_init); diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 86b940f19df8..3410d83cc2e2 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -57,6 +57,7 @@ enum cpuhp_state { CPUHP_SH_SH3X_PREPARE, CPUHP_BLK_MQ_PREPARE, CPUHP_NET_FLOW_PREPARE, + CPUHP_TOPOLOGY_PREPARE, CPUHP_TIMERS_DEAD, CPUHP_NOTF_ERR_INJ_PREPARE, CPUHP_MIPS_SOC_PREPARE, --=20 2.10.2