lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191030153837.18107-13-qais.yousef@arm.com>
Date:   Wed, 30 Oct 2019 15:38:37 +0000
From:   Qais Yousef <qais.yousef@....com>
To:     Thomas Gleixner <tglx@...utronix.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Qais Yousef <qais.yousef@....com>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Nicholas Piggin <npiggin@...il.com>,
        "Peter Zijlstra (Intel)" <peterz@...radead.org>,
        Jiri Kosina <jkosina@...e.cz>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Eiichi Tsukata <devel@...ukata.com>,
        Zhenzhong Duan <zhenzhong.duan@...cle.com>,
        Ingo Molnar <mingo@...nel.org>,
        Pavankumar Kondeti <pkondeti@...eaurora.org>,
        linux-kernel@...r.kernel.org
Subject: [PATCH 12/12] cpu: Hide cpu_up/down

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@....com>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC: "Rafael J. Wysocki" <rafael@...nel.org>
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Josh Poimboeuf <jpoimboe@...hat.com>
CC: Nicholas Piggin <npiggin@...il.com>
CC: "Peter Zijlstra (Intel)" <peterz@...radead.org>
CC: Jiri Kosina <jkosina@...e.cz>
CC: Daniel Lezcano <daniel.lezcano@...aro.org>
CC: Eiichi Tsukata <devel@...ukata.com>
CC: Zhenzhong Duan <zhenzhong.duan@...cle.com>
CC: Ingo Molnar <mingo@...nel.org>
CC: Pavankumar Kondeti <pkondeti@...eaurora.org>
CC: linux-kernel@...r.kernel.org
---
 drivers/base/cpu.c  |  4 ++--
 include/linux/cpu.h |  4 ++--
 kernel/cpu.c        | 26 ++++++++++++++++++++++----
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index cc37511de866..96c69c5fbfff 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 b1c7b788b8e9..6822e676f420 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -83,7 +83,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);
@@ -114,7 +114,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);
 
 #else /* CONFIG_HOTPLUG_CPU */
 
diff --git a/kernel/cpu.c b/kernel/cpu.c
index e16695b841de..087c10dbfb99 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1045,11 +1045,20 @@ 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);
+
+/*
+ * This function is meant to be used by device core cpu subsystem.
+ *
+ * Other subsystems should use device_offline(get_cpu_device(cpu)) instead.
+ */
+int cpu_subsys_down(struct device *dev)
+{
+	return cpu_down(dev->id);
+}
 
 #else
 #define takedown_cpu		NULL
@@ -1191,11 +1200,20 @@ 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);
+
+/*
+ * This function is meant to be used by device core cpu subsystem.
+ *
+ * Other subsystems should use device_online(get_cpu_device(cpu)) instead.
+ */
+int cpu_subsys_up(struct device *dev)
+{
+	return cpu_up(dev->id);
+}
 
 int hibernation_bringup_sleep_cpu(unsigned int sleep_cpu)
 {
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ