* [PATCH] cpu/SMT: fix x86 link error without CONFIG_SYSFS
@ 2019-12-10 19:56 Arnd Bergmann
2019-12-10 20:12 ` Jiri Kosina
2020-01-09 16:36 ` [tip: smp/urgent] cpu/SMT: Fix " tip-bot2 for Arnd Bergmann
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2019-12-10 19:56 UTC (permalink / raw)
To: Thomas Gleixner, Pavel Machek, Josh Poimboeuf, Jiri Kosina,
Rafael J. Wysocki
Cc: Arnd Bergmann, stable, Peter Zijlstra (Intel),
Ingo Molnar, Valentin Schneider, Zhenzhong Duan, Tyler Hicks,
linux-kernel
When CONFIG_SYSFS is disabled, but CONFIG_HOTPLUG_SMT is enabled,
the kernel fails to link:
arch/x86/power/cpu.o: In function `hibernate_resume_nonboot_cpu_disable':
(.text+0x38d): undefined reference to `cpuhp_smt_enable'
arch/x86/power/hibernate.o: In function `arch_resume_nosmt':
hibernate.c:(.text+0x291): undefined reference to `cpuhp_smt_enable'
hibernate.c:(.text+0x29c): undefined reference to `cpuhp_smt_disable'
Move the exported functions out of the #ifdef section into its
own with the correct conditions.
The patch that caused this is marked for stable backports, so
this one may need to be backported as well.
Fixes: ec527c318036 ("x86/power: Fix 'nosmt' vs hibernation triple fault during resume")
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
kernel/cpu.c | 143 ++++++++++++++++++++++++++-------------------------
1 file changed, 72 insertions(+), 71 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index a59cc980adad..4dc279ed3b2d 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1909,6 +1909,78 @@ void __cpuhp_remove_state(enum cpuhp_state state, bool invoke)
}
EXPORT_SYMBOL(__cpuhp_remove_state);
+#ifdef CONFIG_HOTPLUG_SMT
+static void cpuhp_offline_cpu_device(unsigned int cpu)
+{
+ struct device *dev = get_cpu_device(cpu);
+
+ dev->offline = true;
+ /* Tell user space about the state change */
+ kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
+}
+
+static void cpuhp_online_cpu_device(unsigned int cpu)
+{
+ struct device *dev = get_cpu_device(cpu);
+
+ dev->offline = false;
+ /* Tell user space about the state change */
+ kobject_uevent(&dev->kobj, KOBJ_ONLINE);
+}
+
+int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
+{
+ int cpu, ret = 0;
+
+ cpu_maps_update_begin();
+ for_each_online_cpu(cpu) {
+ if (topology_is_primary_thread(cpu))
+ continue;
+ ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
+ if (ret)
+ break;
+ /*
+ * As this needs to hold the cpu maps lock it's impossible
+ * to call device_offline() because that ends up calling
+ * cpu_down() which takes cpu maps lock. cpu maps lock
+ * needs to be held as this might race against in kernel
+ * abusers of the hotplug machinery (thermal management).
+ *
+ * So nothing would update device:offline state. That would
+ * leave the sysfs entry stale and prevent onlining after
+ * smt control has been changed to 'off' again. This is
+ * called under the sysfs hotplug lock, so it is properly
+ * serialized against the regular offline usage.
+ */
+ cpuhp_offline_cpu_device(cpu);
+ }
+ if (!ret)
+ cpu_smt_control = ctrlval;
+ cpu_maps_update_done();
+ return ret;
+}
+
+int cpuhp_smt_enable(void)
+{
+ int cpu, ret = 0;
+
+ cpu_maps_update_begin();
+ cpu_smt_control = CPU_SMT_ENABLED;
+ for_each_present_cpu(cpu) {
+ /* Skip online CPUs and CPUs on offline nodes */
+ if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
+ continue;
+ ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
+ if (ret)
+ break;
+ /* See comment in cpuhp_smt_disable() */
+ cpuhp_online_cpu_device(cpu);
+ }
+ cpu_maps_update_done();
+ return ret;
+}
+#endif
+
#if defined(CONFIG_SYSFS) && defined(CONFIG_HOTPLUG_CPU)
static ssize_t show_cpuhp_state(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -2063,77 +2135,6 @@ static const struct attribute_group cpuhp_cpu_root_attr_group = {
#ifdef CONFIG_HOTPLUG_SMT
-static void cpuhp_offline_cpu_device(unsigned int cpu)
-{
- struct device *dev = get_cpu_device(cpu);
-
- dev->offline = true;
- /* Tell user space about the state change */
- kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
-}
-
-static void cpuhp_online_cpu_device(unsigned int cpu)
-{
- struct device *dev = get_cpu_device(cpu);
-
- dev->offline = false;
- /* Tell user space about the state change */
- kobject_uevent(&dev->kobj, KOBJ_ONLINE);
-}
-
-int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
-{
- int cpu, ret = 0;
-
- cpu_maps_update_begin();
- for_each_online_cpu(cpu) {
- if (topology_is_primary_thread(cpu))
- continue;
- ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
- if (ret)
- break;
- /*
- * As this needs to hold the cpu maps lock it's impossible
- * to call device_offline() because that ends up calling
- * cpu_down() which takes cpu maps lock. cpu maps lock
- * needs to be held as this might race against in kernel
- * abusers of the hotplug machinery (thermal management).
- *
- * So nothing would update device:offline state. That would
- * leave the sysfs entry stale and prevent onlining after
- * smt control has been changed to 'off' again. This is
- * called under the sysfs hotplug lock, so it is properly
- * serialized against the regular offline usage.
- */
- cpuhp_offline_cpu_device(cpu);
- }
- if (!ret)
- cpu_smt_control = ctrlval;
- cpu_maps_update_done();
- return ret;
-}
-
-int cpuhp_smt_enable(void)
-{
- int cpu, ret = 0;
-
- cpu_maps_update_begin();
- cpu_smt_control = CPU_SMT_ENABLED;
- for_each_present_cpu(cpu) {
- /* Skip online CPUs and CPUs on offline nodes */
- if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
- continue;
- ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
- if (ret)
- break;
- /* See comment in cpuhp_smt_disable() */
- cpuhp_online_cpu_device(cpu);
- }
- cpu_maps_update_done();
- return ret;
-}
-
-
static ssize_t
__store_smt_control(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
--
2.20.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cpu/SMT: fix x86 link error without CONFIG_SYSFS
2019-12-10 19:56 [PATCH] cpu/SMT: fix x86 link error without CONFIG_SYSFS Arnd Bergmann
@ 2019-12-10 20:12 ` Jiri Kosina
2019-12-20 22:01 ` Jiri Kosina
2020-01-09 16:36 ` [tip: smp/urgent] cpu/SMT: Fix " tip-bot2 for Arnd Bergmann
1 sibling, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2019-12-10 20:12 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Thomas Gleixner, Pavel Machek, Josh Poimboeuf, Rafael J. Wysocki,
stable, Peter Zijlstra (Intel),
Ingo Molnar, Valentin Schneider, Zhenzhong Duan, Tyler Hicks,
linux-kernel
On Tue, 10 Dec 2019, Arnd Bergmann wrote:
> When CONFIG_SYSFS is disabled, but CONFIG_HOTPLUG_SMT is enabled,
> the kernel fails to link:
I wonder where such kernels are running ... or I rather don't :)
> arch/x86/power/cpu.o: In function `hibernate_resume_nonboot_cpu_disable':
> (.text+0x38d): undefined reference to `cpuhp_smt_enable'
> arch/x86/power/hibernate.o: In function `arch_resume_nosmt':
> hibernate.c:(.text+0x291): undefined reference to `cpuhp_smt_enable'
> hibernate.c:(.text+0x29c): undefined reference to `cpuhp_smt_disable'
>
> Move the exported functions out of the #ifdef section into its
> own with the correct conditions.
>
> The patch that caused this is marked for stable backports, so
> this one may need to be backported as well.
>
> Fixes: ec527c318036 ("x86/power: Fix 'nosmt' vs hibernation triple fault during resume")
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Thanks for fixing my oversight.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cpu/SMT: fix x86 link error without CONFIG_SYSFS
2019-12-10 20:12 ` Jiri Kosina
@ 2019-12-20 22:01 ` Jiri Kosina
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Kosina @ 2019-12-20 22:01 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Thomas Gleixner, Pavel Machek, Josh Poimboeuf, Rafael J. Wysocki,
stable, Peter Zijlstra (Intel),
Ingo Molnar, Valentin Schneider, Zhenzhong Duan, Tyler Hicks,
linux-kernel
On Tue, 10 Dec 2019, Jiri Kosina wrote:
> > When CONFIG_SYSFS is disabled, but CONFIG_HOTPLUG_SMT is enabled,
> > the kernel fails to link:
>
> I wonder where such kernels are running ... or I rather don't :)
>
> > arch/x86/power/cpu.o: In function `hibernate_resume_nonboot_cpu_disable':
> > (.text+0x38d): undefined reference to `cpuhp_smt_enable'
> > arch/x86/power/hibernate.o: In function `arch_resume_nosmt':
> > hibernate.c:(.text+0x291): undefined reference to `cpuhp_smt_enable'
> > hibernate.c:(.text+0x29c): undefined reference to `cpuhp_smt_disable'
> >
> > Move the exported functions out of the #ifdef section into its
> > own with the correct conditions.
> >
> > The patch that caused this is marked for stable backports, so
> > this one may need to be backported as well.
> >
> > Fixes: ec527c318036 ("x86/power: Fix 'nosmt' vs hibernation triple fault during resume")
>
> Reviewed-by: Jiri Kosina <jkosina@suse.cz>
>
> Thanks for fixing my oversight.
Is anyone going to pick this up please?
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: smp/urgent] cpu/SMT: Fix x86 link error without CONFIG_SYSFS
2019-12-10 19:56 [PATCH] cpu/SMT: fix x86 link error without CONFIG_SYSFS Arnd Bergmann
2019-12-10 20:12 ` Jiri Kosina
@ 2020-01-09 16:36 ` tip-bot2 for Arnd Bergmann
[not found] ` <20200114130955.2EAC824685@mail.kernel.org>
1 sibling, 1 reply; 5+ messages in thread
From: tip-bot2 for Arnd Bergmann @ 2020-01-09 16:36 UTC (permalink / raw)
To: linux-tip-commits
Cc: Arnd Bergmann, Thomas Gleixner, Jiri Kosina, stable, x86, LKML
The following commit has been merged into the smp/urgent branch of tip:
Commit-ID: dc8d37ed304eeeea47e65fb9edc1c6c8b0093386
Gitweb: https://git.kernel.org/tip/dc8d37ed304eeeea47e65fb9edc1c6c8b0093386
Author: Arnd Bergmann <arnd@arndb.de>
AuthorDate: Tue, 10 Dec 2019 20:56:04 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 09 Jan 2020 17:31:45 +01:00
cpu/SMT: Fix x86 link error without CONFIG_SYSFS
When CONFIG_SYSFS is disabled, but CONFIG_HOTPLUG_SMT is enabled,
the kernel fails to link:
arch/x86/power/cpu.o: In function `hibernate_resume_nonboot_cpu_disable':
(.text+0x38d): undefined reference to `cpuhp_smt_enable'
arch/x86/power/hibernate.o: In function `arch_resume_nosmt':
hibernate.c:(.text+0x291): undefined reference to `cpuhp_smt_enable'
hibernate.c:(.text+0x29c): undefined reference to `cpuhp_smt_disable'
Move the exported functions out of the #ifdef section into its
own with the correct conditions.
The patch that caused this is marked for stable backports, so
this one may need to be backported as well.
Fixes: ec527c318036 ("x86/power: Fix 'nosmt' vs hibernation triple fault during resume")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20191210195614.786555-1-arnd@arndb.de
---
kernel/cpu.c | 143 +++++++++++++++++++++++++-------------------------
1 file changed, 72 insertions(+), 71 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index a59cc98..4dc279e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1909,6 +1909,78 @@ void __cpuhp_remove_state(enum cpuhp_state state, bool invoke)
}
EXPORT_SYMBOL(__cpuhp_remove_state);
+#ifdef CONFIG_HOTPLUG_SMT
+static void cpuhp_offline_cpu_device(unsigned int cpu)
+{
+ struct device *dev = get_cpu_device(cpu);
+
+ dev->offline = true;
+ /* Tell user space about the state change */
+ kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
+}
+
+static void cpuhp_online_cpu_device(unsigned int cpu)
+{
+ struct device *dev = get_cpu_device(cpu);
+
+ dev->offline = false;
+ /* Tell user space about the state change */
+ kobject_uevent(&dev->kobj, KOBJ_ONLINE);
+}
+
+int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
+{
+ int cpu, ret = 0;
+
+ cpu_maps_update_begin();
+ for_each_online_cpu(cpu) {
+ if (topology_is_primary_thread(cpu))
+ continue;
+ ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
+ if (ret)
+ break;
+ /*
+ * As this needs to hold the cpu maps lock it's impossible
+ * to call device_offline() because that ends up calling
+ * cpu_down() which takes cpu maps lock. cpu maps lock
+ * needs to be held as this might race against in kernel
+ * abusers of the hotplug machinery (thermal management).
+ *
+ * So nothing would update device:offline state. That would
+ * leave the sysfs entry stale and prevent onlining after
+ * smt control has been changed to 'off' again. This is
+ * called under the sysfs hotplug lock, so it is properly
+ * serialized against the regular offline usage.
+ */
+ cpuhp_offline_cpu_device(cpu);
+ }
+ if (!ret)
+ cpu_smt_control = ctrlval;
+ cpu_maps_update_done();
+ return ret;
+}
+
+int cpuhp_smt_enable(void)
+{
+ int cpu, ret = 0;
+
+ cpu_maps_update_begin();
+ cpu_smt_control = CPU_SMT_ENABLED;
+ for_each_present_cpu(cpu) {
+ /* Skip online CPUs and CPUs on offline nodes */
+ if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
+ continue;
+ ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
+ if (ret)
+ break;
+ /* See comment in cpuhp_smt_disable() */
+ cpuhp_online_cpu_device(cpu);
+ }
+ cpu_maps_update_done();
+ return ret;
+}
+#endif
+
#if defined(CONFIG_SYSFS) && defined(CONFIG_HOTPLUG_CPU)
static ssize_t show_cpuhp_state(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -2063,77 +2135,6 @@ static const struct attribute_group cpuhp_cpu_root_attr_group = {
#ifdef CONFIG_HOTPLUG_SMT
-static void cpuhp_offline_cpu_device(unsigned int cpu)
-{
- struct device *dev = get_cpu_device(cpu);
-
- dev->offline = true;
- /* Tell user space about the state change */
- kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
-}
-
-static void cpuhp_online_cpu_device(unsigned int cpu)
-{
- struct device *dev = get_cpu_device(cpu);
-
- dev->offline = false;
- /* Tell user space about the state change */
- kobject_uevent(&dev->kobj, KOBJ_ONLINE);
-}
-
-int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
-{
- int cpu, ret = 0;
-
- cpu_maps_update_begin();
- for_each_online_cpu(cpu) {
- if (topology_is_primary_thread(cpu))
- continue;
- ret = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
- if (ret)
- break;
- /*
- * As this needs to hold the cpu maps lock it's impossible
- * to call device_offline() because that ends up calling
- * cpu_down() which takes cpu maps lock. cpu maps lock
- * needs to be held as this might race against in kernel
- * abusers of the hotplug machinery (thermal management).
- *
- * So nothing would update device:offline state. That would
- * leave the sysfs entry stale and prevent onlining after
- * smt control has been changed to 'off' again. This is
- * called under the sysfs hotplug lock, so it is properly
- * serialized against the regular offline usage.
- */
- cpuhp_offline_cpu_device(cpu);
- }
- if (!ret)
- cpu_smt_control = ctrlval;
- cpu_maps_update_done();
- return ret;
-}
-
-int cpuhp_smt_enable(void)
-{
- int cpu, ret = 0;
-
- cpu_maps_update_begin();
- cpu_smt_control = CPU_SMT_ENABLED;
- for_each_present_cpu(cpu) {
- /* Skip online CPUs and CPUs on offline nodes */
- if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
- continue;
- ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
- if (ret)
- break;
- /* See comment in cpuhp_smt_disable() */
- cpuhp_online_cpu_device(cpu);
- }
- cpu_maps_update_done();
- return ret;
-}
-
-
static ssize_t
__store_smt_control(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [tip: smp/urgent] cpu/SMT: Fix x86 link error without CONFIG_SYSFS
[not found] ` <20200114130955.2EAC824685@mail.kernel.org>
@ 2020-01-14 13:25 ` Arnd Bergmann
0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2020-01-14 13:25 UTC (permalink / raw)
To: Sasha Levin; +Cc: tip-bot2 for Arnd Bergmann, linux-tip-commits, # 3.4.x
On Tue, Jan 14, 2020 at 2:09 PM Sasha Levin <sashal@kernel.org> wrote:
>
> Hi,
>
> [This is an automated email]
>
> This commit has been processed because it contains a "Fixes:" tag,
> fixing commit: ec527c318036 ("x86/power: Fix 'nosmt' vs hibernation triple fault during resume").
>
> The bot has tested the following trees: v5.4.11, v4.19.95, v4.14.164, v4.9.209.
>
> v5.4.11: Build OK!
> v4.19.95: Failed to apply! Possible dependencies:
> 34d66caf251d ("x86/speculation: Remove redundant arch_smt_update() invocation")
> de7b77e5bb94 ("cpu/hotplug: Create SMT sysfs interface for all arches")
>
> v4.14.164: Failed to apply! Possible dependencies:
> 34d66caf251d ("x86/speculation: Remove redundant arch_smt_update() invocation")
> de7b77e5bb94 ("cpu/hotplug: Create SMT sysfs interface for all arches")
>
> v4.9.209: Failed to apply! Possible dependencies:
> 34d66caf251d ("x86/speculation: Remove redundant arch_smt_update() invocation")
> de7b77e5bb94 ("cpu/hotplug: Create SMT sysfs interface for all arches")
>
>
> NOTE: The patch will not be queued to stable trees until it is upstream.
>
> How should we proceed with this patch?
According to the changelog text, the patch is only needed on v5.2 and
higher, so this
is all good.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-14 13:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 19:56 [PATCH] cpu/SMT: fix x86 link error without CONFIG_SYSFS Arnd Bergmann
2019-12-10 20:12 ` Jiri Kosina
2019-12-20 22:01 ` Jiri Kosina
2020-01-09 16:36 ` [tip: smp/urgent] cpu/SMT: Fix " tip-bot2 for Arnd Bergmann
[not found] ` <20200114130955.2EAC824685@mail.kernel.org>
2020-01-14 13:25 ` Arnd Bergmann
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).