All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Qais Yousef" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Qais Yousef <qais.yousef@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>, x86 <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [tip: smp/core] cpu/hotplug: Hide cpu_up/down()
Date: Wed, 25 Mar 2020 12:05:59 -0000	[thread overview]
Message-ID: <158513795997.28353.5521691179310825679.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200323135110.30522-18-qais.yousef@arm.com>

The following commit has been merged into the smp/core branch of tip:

Commit-ID:     33c3736ec88811b9b6f6ce2cc8967f6b97c3db5e
Gitweb:        https://git.kernel.org/tip/33c3736ec88811b9b6f6ce2cc8967f6b97c3db5e
Author:        Qais Yousef <qais.yousef@arm.com>
AuthorDate:    Mon, 23 Mar 2020 13:51:10 
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 25 Mar 2020 12:59:38 +01:00

cpu/hotplug: Hide cpu_up/down()

Use separate functions for the device core to bring a CPU up and down.

Users outside the device core must use add/remove_cpu() which will take
care of extra housekeeping work like keeping sysfs in sync.

Make cpu_up/down() static and replace the extra layer of indirection.

[ tglx: Removed the extra wrapper functions and adjusted function names ]

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200323135110.30522-18-qais.yousef@arm.com
---
 drivers/base/cpu.c  |  4 ++--
 include/linux/cpu.h |  4 ++--
 kernel/cpu.c        | 42 ++++++++++++++++++++++++++++--------------
 3 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 6265871..b93a8f8 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_device_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_device_down(dev);
 }
 
 void unregister_cpu(struct cpu *cpu)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 8b295f7..9ead281 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -88,8 +88,8 @@ 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 add_cpu(unsigned int cpu);
+int cpu_device_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);
@@ -120,8 +120,8 @@ 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 remove_cpu(unsigned int cpu);
+int cpu_device_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 4783d81..3084849 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1041,7 +1041,7 @@ static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target)
 	return _cpu_down(cpu, 0, target);
 }
 
-static int do_cpu_down(unsigned int cpu, enum cpuhp_state target)
+static int cpu_down(unsigned int cpu, enum cpuhp_state target)
 {
 	int err;
 
@@ -1051,11 +1051,18 @@ static int do_cpu_down(unsigned int cpu, enum cpuhp_state target)
 	return err;
 }
 
-int cpu_down(unsigned int cpu)
+/**
+ * cpu_device_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 remove_cpu() instead.
+ */
+int cpu_device_down(struct device *dev)
 {
-	return do_cpu_down(cpu, CPUHP_OFFLINE);
+	return cpu_down(dev->id, CPUHP_OFFLINE);
 }
-EXPORT_SYMBOL(cpu_down);
 
 int remove_cpu(unsigned int cpu)
 {
@@ -1178,8 +1185,8 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
 	}
 
 	/*
-	 * The caller of do_cpu_up might have raced with another
-	 * caller. Ignore it for now.
+	 * The caller of cpu_up() might have raced with another
+	 * caller. Nothing to do.
 	 */
 	if (st->state >= target)
 		goto out;
@@ -1223,7 +1230,7 @@ out:
 	return ret;
 }
 
-static int do_cpu_up(unsigned int cpu, enum cpuhp_state target)
+static int cpu_up(unsigned int cpu, enum cpuhp_state target)
 {
 	int err = 0;
 
@@ -1257,11 +1264,18 @@ out:
 	return err;
 }
 
-int cpu_up(unsigned int cpu)
+/**
+ * cpu_device_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 add_cpu() instead.
+ */
+int cpu_device_up(struct device *dev)
 {
-	return do_cpu_up(cpu, CPUHP_ONLINE);
+	return cpu_up(dev->id, CPUHP_ONLINE);
 }
-EXPORT_SYMBOL_GPL(cpu_up);
 
 int add_cpu(unsigned int cpu)
 {
@@ -1289,7 +1303,7 @@ int bringup_hibernate_cpu(unsigned int sleep_cpu)
 
 	if (!cpu_online(sleep_cpu)) {
 		pr_info("Hibernated on a CPU that is offline! Bringing CPU up.\n");
-		ret = cpu_up(sleep_cpu);
+		ret = cpu_up(sleep_cpu, CPUHP_ONLINE);
 		if (ret) {
 			pr_err("Failed to bring hibernate-CPU up!\n");
 			return ret;
@@ -1306,7 +1320,7 @@ void bringup_nonboot_cpus(unsigned int setup_max_cpus)
 		if (num_online_cpus() >= setup_max_cpus)
 			break;
 		if (!cpu_online(cpu))
-			cpu_up(cpu);
+			cpu_up(cpu, CPUHP_ONLINE);
 	}
 }
 
@@ -2129,9 +2143,9 @@ static ssize_t write_cpuhp_target(struct device *dev,
 		goto out;
 
 	if (st->state < target)
-		ret = do_cpu_up(dev->id, target);
+		ret = cpu_up(dev->id, target);
 	else
-		ret = do_cpu_down(dev->id, target);
+		ret = cpu_down(dev->id, target);
 out:
 	unlock_device_hotplug();
 	return ret ? ret : count;

      reply	other threads:[~2020-03-25 12:06 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23 13:50 [PATCH v4 00/17] Convert cpu_up/down to device_online/offline Qais Yousef
2020-03-23 13:50 ` Qais Yousef
2020-03-23 13:50 ` [Xen-devel] " Qais Yousef
2020-03-23 13:50 ` Qais Yousef
2020-03-23 13:50 ` Qais Yousef
2020-03-23 13:50 ` Qais Yousef
2020-03-23 13:50 ` [PATCH v4 01/17] cpu: Add new {add,remove}_cpu() functions Qais Yousef
2020-03-23 13:50   ` [Xen-devel] [PATCH v4 01/17] cpu: Add new {add, remove}_cpu() functions Qais Yousef
2020-03-23 13:50   ` [PATCH v4 01/17] cpu: Add new {add,remove}_cpu() functions Qais Yousef
2020-03-23 13:50   ` Qais Yousef
2020-03-23 13:50   ` Qais Yousef
2020-03-23 15:00   ` Paul E. McKenney
2020-03-23 15:00     ` Paul E. McKenney
2020-03-23 15:00     ` Paul E. McKenney
2020-03-23 15:00     ` Paul E. McKenney
2020-03-23 15:00     ` Paul E. McKenney
2020-03-25 12:06   ` [tip: smp/core] cpu/hotplug: " tip-bot2 for Qais Yousef
2020-03-23 13:50 ` [PATCH v4 02/17] smp: Create a new function to shutdown nonboot cpus Qais Yousef
2020-03-23 13:50   ` Qais Yousef
2020-03-23 13:50   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] cpu/hotplug: " tip-bot2 for Qais Yousef
2020-03-23 13:50 ` [PATCH v4 03/17] ia64: Replace cpu_down with smp_shutdown_nonboot_cpus() Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] ia64: Replace cpu_down() " tip-bot2 for Qais Yousef
2020-03-23 13:50 ` [PATCH v4 04/17] arm: Don't use disable_nonboot_cpus() Qais Yousef
2020-03-23 13:50   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] ARM: " tip-bot2 for Qais Yousef
2020-03-23 13:50 ` [PATCH v4 05/17] arm: Use reboot_cpu instead of hardcoding it to 0 Qais Yousef
2020-03-23 13:50   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] ARM: " tip-bot2 for Qais Yousef
2020-03-23 13:50 ` [PATCH v4 06/17] arm64: Don't use disable_nonboot_cpus() Qais Yousef
2020-03-23 13:50   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] " tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 07/17] arm64: Use reboot_cpu instead of hardconding it to 0 Qais Yousef
2020-03-23 13:51   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] " tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 08/17] arm64: hibernate.c: Create a new function to handle cpu_up(sleep_cpu) Qais Yousef
2020-03-23 13:51   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] arm64: hibernate: Use bringup_hibernate_cpu() tip-bot2 for Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] cpu/hotplug: Provide bringup_hibernate_cpu() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 09/17] x86: Replace cpu_up/down with add/remove_cpu Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] x86/smp: Replace cpu_up/down() with add/remove_cpu() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 10/17] powerpc: Replace cpu_up/down with add/remove_cpu Qais Yousef
2020-03-23 13:51   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] powerpc: Replace cpu_up/down() with add/remove_cpu() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 11/17] sparc: Replace cpu_up/down with add/remove_cpu Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] sparc: Replace cpu_up/down() with add/remove_cpu() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 12/17] parisc: Replace cpu_up/down with add/remove_cpu Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] parisc: Replace cpu_up/down() with add/remove_cpu() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 13/17] driver: xen: Replace cpu_up/down with device_online/offline Qais Yousef
2020-03-23 13:51   ` [Xen-devel] " Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] xen/cpuhotplug: Replace cpu_up/down() with device_online/offline() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 14/17] firmware: psci: Replace cpu_up/down with add/remove_cpu Qais Yousef
2020-03-23 13:51   ` Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] firmware: psci: Replace cpu_up/down() with add/remove_cpu() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 15/17] torture: Replace cpu_up/down with add/remove_cpu Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] torture: Replace cpu_up/down() with add/remove_cpu() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 16/17] smp: Create a new function to bringup nonboot cpus online Qais Yousef
2020-03-25 12:06   ` [tip: smp/core] cpu/hotplug: Move bringup of secondary CPUs out of smp_init() tip-bot2 for Qais Yousef
2020-03-23 13:51 ` [PATCH v4 17/17] cpu: Hide cpu_up/down Qais Yousef
2020-03-25 12:05   ` tip-bot2 for 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=158513795997.28353.5521691179310825679.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=qais.yousef@arm.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 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.