From: Qais Yousef <qais.yousef@arm.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Qais Yousef <qais.yousef@arm.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Nicholas Piggin <npiggin@gmail.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Jiri Kosina <jkosina@suse.cz>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Eiichi Tsukata <devel@etsukata.com>,
Zhenzhong Duan <zhenzhong.duan@oracle.com>,
Ingo Molnar <mingo@kernel.org>,
Pavankumar Kondeti <pkondeti@codeaurora.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 14/14] cpu: Hide cpu_up/down
Date: Mon, 25 Nov 2019 11:27:54 +0000 [thread overview]
Message-ID: <20191125112754.25223-15-qais.yousef@arm.com> (raw)
In-Reply-To: <20191125112754.25223-1-qais.yousef@arm.com>
Provide a special exported function for the device core to bring a cpu
up/down and hide the real cpu_up/down as they are treated as private
functions. cpu_up/down are lower level API and users outside the cpu
subsystem should use device_online/offline which will take care of extra
housekeeping work like keeping sysfs in sync.
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: "Rafael J. Wysocki" <rafael@kernel.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Josh Poimboeuf <jpoimboe@redhat.com>
CC: Nicholas Piggin <npiggin@gmail.com>
CC: "Peter Zijlstra (Intel)" <peterz@infradead.org>
CC: Jiri Kosina <jkosina@suse.cz>
CC: Daniel Lezcano <daniel.lezcano@linaro.org>
CC: Eiichi Tsukata <devel@etsukata.com>
CC: Zhenzhong Duan <zhenzhong.duan@oracle.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: Pavankumar Kondeti <pkondeti@codeaurora.org>
CC: linux-kernel@vger.kernel.org
---
drivers/base/cpu.c | 4 ++--
include/linux/cpu.h | 4 ++--
kernel/cpu.c | 32 ++++++++++++++++++++++++++++----
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 6265871a4af2..9a134cd362ee 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -55,7 +55,7 @@ static int cpu_subsys_online(struct device *dev)
if (from_nid == NUMA_NO_NODE)
return -ENODEV;
- ret = cpu_up(cpuid);
+ ret = cpu_subsys_up(dev);
/*
* When hot adding memory to memoryless node and enabling a cpu
* on the node, node number of the cpu may internally change.
@@ -69,7 +69,7 @@ static int cpu_subsys_online(struct device *dev)
static int cpu_subsys_offline(struct device *dev)
{
- return cpu_down(dev->id);
+ return cpu_subsys_down(dev);
}
void unregister_cpu(struct cpu *cpu)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index b5d9287899d1..bd9c5870c26f 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -88,7 +88,7 @@ extern ssize_t arch_cpu_release(const char *, size_t);
#ifdef CONFIG_SMP
extern bool cpuhp_tasks_frozen;
-int cpu_up(unsigned int cpu);
+int cpu_subsys_up(struct device *dev);
void notify_cpu_starting(unsigned int cpu);
extern void cpu_maps_update_begin(void);
extern void cpu_maps_update_done(void);
@@ -119,7 +119,7 @@ extern void lockdep_assert_cpus_held(void);
extern void cpu_hotplug_disable(void);
extern void cpu_hotplug_enable(void);
void clear_tasks_mm_cpumask(int cpu);
-int cpu_down(unsigned int cpu);
+int cpu_subsys_down(struct device *dev);
extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu);
#else /* CONFIG_HOTPLUG_CPU */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 3631184a284f..8b29e0aa95ba 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1052,11 +1052,23 @@ static int do_cpu_down(unsigned int cpu, enum cpuhp_state target)
return err;
}
-int cpu_down(unsigned int cpu)
+static int cpu_down(unsigned int cpu)
{
return do_cpu_down(cpu, CPUHP_OFFLINE);
}
-EXPORT_SYMBOL(cpu_down);
+
+/**
+ * cpu_subsys_down - Bring down a cpu device
+ * @dev: Pointer to the cpu device to offline
+ *
+ * This function is meant to be used by device core cpu subsystem only.
+ *
+ * Other subsystems should use device_offline(get_cpu_device(cpu)) instead.
+ */
+int cpu_subsys_down(struct device *dev)
+{
+ return cpu_down(dev->id);
+}
void smp_shutdown_nonboot_cpus(unsigned int primary_cpu)
{
@@ -1215,11 +1227,23 @@ static int do_cpu_up(unsigned int cpu, enum cpuhp_state target)
return err;
}
-int cpu_up(unsigned int cpu)
+static int cpu_up(unsigned int cpu)
{
return do_cpu_up(cpu, CPUHP_ONLINE);
}
-EXPORT_SYMBOL_GPL(cpu_up);
+
+/**
+ * cpu_subsys_up - Bring up a cpu device
+ * @dev: Pointer to the cpu device to online
+ *
+ * This function is meant to be used by device core cpu subsystem only.
+ *
+ * Other subsystems should use device_online(get_cpu_device(cpu)) instead.
+ */
+int cpu_subsys_up(struct device *dev)
+{
+ return cpu_up(dev->id);
+}
/**
* bringup_hibernate_cpu - Bring up the CPU that we hibernated on
--
2.17.1
prev parent reply other threads:[~2019-11-25 11:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191125112754.25223-1-qais.yousef@arm.com>
2019-11-25 11:27 ` [PATCH v2 01/14] smp: Create a new function to shutdown nonboot cpus Qais Yousef
2020-01-21 17:03 ` Russell King - ARM Linux admin
2020-01-21 17:47 ` Qais Yousef
2020-01-21 18:09 ` Russell King - ARM Linux admin
2020-01-22 10:32 ` Qais Yousef
2019-11-25 11:27 ` [PATCH v2 02/14] ia64: Replace cpu_down with smp_shutdown_nonboot_cpus() Qais Yousef
2019-11-25 11:27 ` [PATCH v2 03/14] arm: arm64: Don't use disable_nonboot_cpus() Qais Yousef
2020-01-21 16:50 ` Qais Yousef
2020-01-21 16:53 ` Russell King - ARM Linux admin
2020-01-21 16:58 ` Qais Yousef
2020-01-21 17:05 ` Russell King - ARM Linux admin
2019-11-25 11:27 ` [PATCH v2 04/14] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Qais Yousef
2019-11-25 11:27 ` [PATCH v2 05/14] x86: Replace cpu_up/down with devcie_online/offline Qais Yousef
2019-11-25 11:27 ` [PATCH v2 06/14] powerpc: Replace cpu_up/down with device_online/offline Qais Yousef
2019-11-25 11:27 ` [PATCH v2 07/14] sparc: " Qais Yousef
2019-11-25 11:27 ` [PATCH v2 08/14] parisc: " Qais Yousef
2019-11-25 11:27 ` [PATCH v2 09/14] driver: base: cpu: Export device_online/offline Qais Yousef
2019-11-25 11:27 ` [PATCH v2 10/14] driver: xen: Replace cpu_up/down with device_online/offline Qais Yousef
2019-12-09 6:25 ` Jürgen Groß
2019-11-25 11:27 ` [PATCH v2 11/14] firmware: psci: " Qais Yousef
2019-11-25 11:27 ` [PATCH v2 12/14] torture: " Qais Yousef
2019-11-27 21:47 ` Paul E. McKenney
2019-11-28 16:56 ` Qais Yousef
2019-11-28 17:00 ` Qais Yousef
2019-11-28 21:02 ` Paul E. McKenney
2019-11-29 9:13 ` Qais Yousef
2019-11-29 20:38 ` Paul E. McKenney
2020-02-20 15:31 ` Qais Yousef
2020-02-21 0:26 ` Paul E. McKenney
2020-02-21 9:35 ` Qais Yousef
2020-02-21 20:39 ` Paul E. McKenney
2019-11-25 11:27 ` [PATCH v2 13/14] smp: Create a new function to bringup nonboot cpus online Qais Yousef
2019-11-25 11:27 ` Qais Yousef [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191125112754.25223-15-qais.yousef@arm.com \
--to=qais.yousef@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=devel@etsukata.com \
--cc=gregkh@linuxfoundation.org \
--cc=jkosina@suse.cz \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=pkondeti@codeaurora.org \
--cc=rafael@kernel.org \
--cc=tglx@linutronix.de \
--cc=zhenzhong.duan@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).