Skip to content

Commit fee0aed

Browse files
committed
cpu/hotplug: Set CPU_SMT_NOT_SUPPORTED early
The CPU_SMT_NOT_SUPPORTED state is set (if the processor does not support SMT) when the sysfs SMT control file is initialized. That was fine so far as this was only required to make the output of the control file correct and to prevent writes in that case. With the upcoming l1tf command line parameter, this needs to be set up before the L1TF mitigation selection and command line parsing happens. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Jiri Kosina <jkosina@suse.cz> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lkml.kernel.org/r/20180713142323.121795971@linutronix.de
1 parent 8e1b706 commit fee0aed

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ void __init check_bugs(void)
5858
{
5959
identify_boot_cpu();
6060

61+
/*
62+
* identify_boot_cpu() initialized SMT support information, let the
63+
* core code know.
64+
*/
65+
cpu_smt_check_topology();
66+
6167
if (!IS_ENABLED(CONFIG_SMP)) {
6268
pr_info("CPU: ");
6369
print_cpu_info(&boot_cpu_data);

include/linux/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,11 @@ enum cpuhp_smt_control {
178178
#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
179179
extern enum cpuhp_smt_control cpu_smt_control;
180180
extern void cpu_smt_disable(bool force);
181+
extern void cpu_smt_check_topology(void);
181182
#else
182183
# define cpu_smt_control (CPU_SMT_ENABLED)
183184
static inline void cpu_smt_disable(bool force) { }
185+
static inline void cpu_smt_check_topology(void) { }
184186
#endif
185187

186188
#endif /* _LINUX_CPU_H_ */

kernel/cpu.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@ void __init cpu_smt_disable(bool force)
361361
}
362362
}
363363

364+
/*
365+
* The decision whether SMT is supported can only be done after the full
366+
* CPU identification. Called from architecture code.
367+
*/
368+
void __init cpu_smt_check_topology(void)
369+
{
370+
if (!topology_smt_supported())
371+
cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
372+
}
373+
364374
static int __init smt_cmdline_disable(char *str)
365375
{
366376
cpu_smt_disable(str && !strcmp(str, "force"));
@@ -2115,9 +2125,6 @@ static const struct attribute_group cpuhp_smt_attr_group = {
21152125

21162126
static int __init cpu_smt_state_init(void)
21172127
{
2118-
if (!topology_smt_supported())
2119-
cpu_smt_control = CPU_SMT_NOT_SUPPORTED;
2120-
21212128
return sysfs_create_group(&cpu_subsys.dev_root->kobj,
21222129
&cpuhp_smt_attr_group);
21232130
}

0 commit comments

Comments
 (0)