Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05736e4a authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

cpu/hotplug: Provide knobs to control SMT



Provide a command line and a sysfs knob to control SMT.

The command line options are:

 'nosmt':	Enumerate secondary threads, but do not online them
 		
 'nosmt=force': Ignore secondary threads completely during enumeration
 		via MP table and ACPI/MADT.

The sysfs control file has the following states (read/write):

 'on':		 SMT is enabled. Secondary threads can be freely onlined
 'off':		 SMT is disabled. Secondary threads, even if enumerated
 		 cannot be onlined
 'forceoff':	 SMT is permanentely disabled. Writes to the control
 		 file are rejected.
 'notsupported': SMT is not supported by the CPU

The command line option 'nosmt' sets the sysfs control to 'off'. This
can be changed to 'on' to reenable SMT during runtime.

The command line option 'nosmt=force' sets the sysfs control to
'forceoff'. This cannot be changed during runtime.

When SMT is 'on' and the control file is changed to 'off' then all online
secondary threads are offlined and attempts to online a secondary thread
later on are rejected.

When SMT is 'off' and the control file is changed to 'on' then secondary
threads can be onlined again. The 'off' -> 'on' transition does not
automatically online the secondary threads.

When the control file is set to 'forceoff', the behaviour is the same as
setting it to 'off', but the operation is irreversible and later writes to
the control file are rejected.

When the control status is 'notsupported' then writes to the control file
are rejected.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: default avatarIngo Molnar <mingo@kernel.org>
parent cc1fe215
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -487,3 +487,23 @@ Description: Information about CPU vulnerabilities
		"Not affected"	  CPU is not affected by the vulnerability
		"Vulnerable"	  CPU is affected and no mitigation in effect
		"Mitigation: $M"  CPU is affected and mitigation $M is in effect

What:		/sys/devices/system/cpu/smt
		/sys/devices/system/cpu/smt/active
		/sys/devices/system/cpu/smt/control
Date:		June 2018
Contact:	Linux kernel mailing list <linux-kernel@vger.kernel.org>
Description:	Control Symetric Multi Threading (SMT)

		active:  Tells whether SMT is active (enabled and siblings online)

		control: Read/write interface to control SMT. Possible
			 values:

			 "on"		SMT is enabled
			 "off"		SMT is disabled
			 "forceoff"	SMT is force disabled. Cannot be changed.
			 "notsupported" SMT is not supported by the CPU

			 If control status is "forceoff" or "notsupported" writes
			 are rejected.
+8 −0
Original line number Diff line number Diff line
@@ -2687,6 +2687,14 @@
	nosmt		[KNL,S390] Disable symmetric multithreading (SMT).
			Equivalent to smt=1.

			[KNL,x86] Disable symmetric multithreading (SMT).
			nosmt=force: Force disable SMT, similar to disabling
				     it in the BIOS except that some of the
				     resource partitioning effects which are
				     caused by having SMT enabled in the BIOS
				     cannot be undone. Depending on the CPU
				     type this might have a performance impact.

	nospectre_v2	[X86] Disable all mitigations for the Spectre variant 2
			(indirect branch prediction) vulnerability. System may
			allow data leaks with this option, which is equivalent
+3 −0
Original line number Diff line number Diff line
@@ -13,6 +13,9 @@ config KEXEC_CORE
config HAVE_IMA_KEXEC
	bool

config HOTPLUG_SMT
	bool

config OPROFILE
	tristate "OProfile system profiling"
	depends on PROFILING
+1 −0
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ config X86
	select HAVE_SYSCALL_TRACEPOINTS
	select HAVE_UNSTABLE_SCHED_CLOCK
	select HAVE_USER_RETURN_NOTIFIER
	select HOTPLUG_SMT			if SMP
	select IRQ_FORCED_THREADING
	select NEED_SG_DMA_LENGTH
	select PCI_LOCKLESS_CONFIG
+13 −0
Original line number Diff line number Diff line
@@ -168,4 +168,17 @@ void cpuhp_report_idle_dead(void);
static inline void cpuhp_report_idle_dead(void) { }
#endif /* #ifdef CONFIG_HOTPLUG_CPU */

enum cpuhp_smt_control {
	CPU_SMT_ENABLED,
	CPU_SMT_DISABLED,
	CPU_SMT_FORCE_DISABLED,
	CPU_SMT_NOT_SUPPORTED,
};

#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
extern enum cpuhp_smt_control cpu_smt_control;
#else
# define cpu_smt_control		(CPU_SMT_ENABLED)
#endif

#endif /* _LINUX_CPU_H_ */
Loading