Skip to content

Commit 215af54

Browse files
committed
cpu/hotplug: Online siblings when SMT control is turned on
Writing 'off' to /sys/devices/system/cpu/smt/control offlines all SMT siblings. Writing 'on' merily enables the abilify to online them, but does not online them automatically. Make 'on' more useful by onlining all offline siblings. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 390d975 commit 215af54

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

‎kernel/cpu.c‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,15 @@ static void cpuhp_offline_cpu_device(unsigned int cpu)
19791979
kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
19801980
}
19811981

1982+
static void cpuhp_online_cpu_device(unsigned int cpu)
1983+
{
1984+
struct device *dev = get_cpu_device(cpu);
1985+
1986+
dev->offline = false;
1987+
/* Tell user space about the state change */
1988+
kobject_uevent(&dev->kobj, KOBJ_ONLINE);
1989+
}
1990+
19821991
static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
19831992
{
19841993
int cpu, ret = 0;
@@ -2011,11 +2020,24 @@ static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
20112020
return ret;
20122021
}
20132022

2014-
static void cpuhp_smt_enable(void)
2023+
static int cpuhp_smt_enable(void)
20152024
{
2025+
int cpu, ret = 0;
2026+
20162027
cpu_maps_update_begin();
20172028
cpu_smt_control = CPU_SMT_ENABLED;
2029+
for_each_present_cpu(cpu) {
2030+
/* Skip online CPUs and CPUs on offline nodes */
2031+
if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
2032+
continue;
2033+
ret = _cpu_up(cpu, 0, CPUHP_ONLINE);
2034+
if (ret)
2035+
break;
2036+
/* See comment in cpuhp_smt_disable() */
2037+
cpuhp_online_cpu_device(cpu);
2038+
}
20182039
cpu_maps_update_done();
2040+
return ret;
20192041
}
20202042

20212043
static ssize_t
@@ -2046,7 +2068,7 @@ store_smt_control(struct device *dev, struct device_attribute *attr,
20462068
if (ctrlval != cpu_smt_control) {
20472069
switch (ctrlval) {
20482070
case CPU_SMT_ENABLED:
2049-
cpuhp_smt_enable();
2071+
ret = cpuhp_smt_enable();
20502072
break;
20512073
case CPU_SMT_DISABLED:
20522074
case CPU_SMT_FORCE_DISABLED:

0 commit comments

Comments
 (0)