disabling turbo-bost

This is just for my notes on how I went about figuring out how disabling Intel’s turboboost on my Mac Book Pro to contain the heat. 2011 MacBook Pro & OSX

Link1 and Link2 have some nice details about turbo-boost.

A nice overview of TurboBoost in Intel Sandy Bridge at HotChips 23

Intel Manuals & MSR:

one can find description of ModelSpecific Register (MSR), Sandy Bridge onwards, in 64-ia-32-architectures-software-developer-vol-3b-part-2-manual.pdf in Power and Thermal Management chapter:

Just look for details on: MSR IA32_MISC_ENABLE in 64-ia-32-architectures-software-developer-vol-3b-part-2-manual.pdf

14.3.2.1 Discover Hardware Support and Enabling of Opportunistic Processor Operation


If an Intel 64 processor has hardware support for opportunistic processor performance operation, the power-on default state of A32_MISC_ENABLE[38] indicates the presence of such hardware support. For Intel 64 processors that support opportunistic processor performance operation, the default value is 1, indicating its presence. For processors that do not support opportunistic processor performance operation, the default value is 0. The power-on default value of IA32_MISC_ENABLE[38] allows BIOS to detect the presence of hardware support of opportunistic processor performance operation.

IA32_MISC_ENABLE[38] is shared across all logical processors in a physical package. It is written by BIOS during platform initiation to enable/disable opportunistic processor operation in conjunction of OS power management capabilities, see Section 14.3.2.2. BIOS can set IA32_MISC_ENABLE[38] with 1 to disable opportunistic processor performance operation; it must clear the default value of IA32_MISC_ENABLE[38] to 0 to enable opportunistic processor performance operation. OS and applications must use CPUID leaf 06H if it needs to detect processors that has opportunistic processor operation enabled.

When CPUID is executed with EAX = 06H on input, Bit 1 of EAX in Leaf 06H (i.e. CPUID.06H:EAX[1]) indicates opportunistic processor performance operation, such as IDA, has been enabled by BIOS.

Opportunistic processor performance operation can be disabled by setting bit 38 of IA32_MISC_ENABLE. This mechanism is intended for BIOS only. If IA32_MISC_ENABLE[38] is set, CPUID.06H:EAX[1] will return 0.


More details can be found in Manual Volume 4: Model-Specific Registers 335592-sdm-vol-4.pdf:

2.1 ARCHITECTURAL MSRS


Many MSRs have carried over from one generation of IA-32 processors to the next and to Intel 64 processors. A subset of MSRs and associated bit fields, which do not change on future processor generations, are now considered architectural MSRs. For historical reasons (beginning with the Pentium 4 processor), these “architectural MSRs” were given the prefix “IA32_”. Table 2-2 lists the architectural MSRs, their addresses, their current names, their names in previous IA-32 processors, and bit fields that are considered architectural. MSR addresses outside Table 2-2 and certain bit fields in an MSR address that may overlap with architectural MSR addresses are model-specific. Code that accesses a model-specific MSR and that is executed on a processor that does not support that MSR will generate an exception.


However, the most interesting note is in Table 2-3. MSRs in Processors Based on Intel® Core™ Microarchitecture:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Register Addr
Hex   Dec     Register Name/BitFields       Shared/Unique   Description
1A0H  416     IA32_MISC_ENABLE                              Enable Misc. Processor Features (R/W)
...
                38                          Shared          IDA Disable (R/W)
                                                            When set to 1 on processors that support IDA, the Intel
                                                            Dynamic Acceleration feature (IDA) is disabled and the
                                                            IDA_Enable feature flag will be cleared (CPUID.06H:
                                                            EAX[1]=0).
                                                            When set to a 0 on processors that support IDA,
                                                            CPUID.06H: EAX[1] reports the processor’s support of IDA
                                                            is enabled.
                                                            Note: The power-on default value is used by BIOS to
                                                            detect hardware support of IDA. If the power-on default
                                                            value is 1, IDA is available in the processor. If the poweron 
                                                            default value is 0, IDA is not available

 

Linux Intel driver:

A nice answer without intel_pstate at stackoverflow

Linux kernel has a driver to just do this: intel_pstate (https://www.kernel.org/doc/html/v4.12/admin-guide/pm/intel_pstate.html), look for no_turbo.

1
echo "1" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo 

These are various settings supported by intel_pstate driver:

1
2
sarang@mbp:~$ ls /sys/devices/system/cpu/intel_pstate/
max_perf_pct  min_perf_pct  no_turbo  num_pstates  status  turbo_pct


Interesting enough, here is some code that points to exactly how things are setup:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

//https://github.com/torvalds/linux/blob/d8924c0d76aaa52e4811b5c64115d9a7f36cc73a/drivers/platform/x86/intel_ips.c

/*
 * Package level MSRs for monitor/control
 */
#define PLATFORM_INFO	0xce
#define   PLATFORM_TDP		(1<<29)
#define   PLATFORM_RATIO	(1<<28)

#define IA32_MISC_ENABLE	0x1a0
#define   IA32_MISC_TURBO_EN	(1ULL<<38)


...
...

/**
 * ips_detect_cpu - detect whether CPU supports IPS
 *
 * Walk our list and see if we're on a supported CPU.  If we find one,
 * return the limits for it.
 */
static struct ips_mcp_limits *ips_detect_cpu(struct ips_driver *ips)
{
	u64 turbo_power, misc_en;

    ...

	rdmsrl(IA32_MISC_ENABLE, misc_en);
	/*
	 * If the turbo enable bit isn't set, we shouldn't try to enable/disable
	 * turbo manually or we'll get an illegal MSR access, even though
	 * turbo will still be available.
	 */
	if (misc_en & IA32_MISC_TURBO_EN)
		ips->turbo_toggle_allowed = true;
	else
		ips->turbo_toggle_allowed = false;


From intel_pstate.c:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
			      const char *buf, size_t count)
{
	unsigned int input;
	int ret;

	ret = sscanf(buf, "%u", &input);
	if (ret != 1)
		return -EINVAL;

	...

	global.no_turbo = clamp_t(int, input, 0, 1);

	if (global.no_turbo) {
		struct cpudata *cpu = all_cpu_data[0];
		int pct = cpu->pstate.max_pstate * 100 / cpu->pstate.turbo_pstate;

		/* Squash the global minimum into the permitted range. */
		if (global.min_perf_pct > pct)
			global.min_perf_pct = pct;
	}
    
    ...

	intel_pstate_update_policies();

    ...
}

A few related articles here

 

OS X driver:

No easy way to do this on OS X. I found this tool github, which wraps the kext/driver.

The kext does the same thing as noted above:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// https://github.com/nanoant/DisableTurboBoost.kext/blob/master/DisableTurboBoost.c

//  expectedFeatures stays unused in this
const uint64_t expectedFeatures  = 0x850089LL;
const uint64_t disableTurboBoost = 0x4000000000LL;

static void disable_tb(__unused void * param_not_used) {
	wrmsr64(MSR_IA32_MISC_ENABLE, rdmsr64(MSR_IA32_MISC_ENABLE) | disableTurboBoost);
}

static void enable_tb(__unused void * param_not_used) {
	wrmsr64(MSR_IA32_MISC_ENABLE, rdmsr64(MSR_IA32_MISC_ENABLE) & ~disableTurboBoost);
}

 

Windows Power config:

With windows, it is quite easy- Just go to power config in power options and control the max freq.

Note: this switches off the Windows Modern Standby feature. I found it to be very cool and decided to not to muck around with these settings on my new laptop.

Some details here at stack overflow:

Adding following key allows you to disable Processor Performance boost mode

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\be337238-0d82-4146-a960-4f3749d470c7]
"Attributes"=dword:00000002

 

Also, one can use tweaking tools like i7 turbo as described here

/images/i7turbogt.png