Skip to content

Commit 492ba46

Browse files
committed
Use MSR_IA32_MISC_ENABLE instead
It turned out setting bit 32 of MSR_IA32_PERF_CTL didn't really have any effect, at least on my system. My concern about MSR_IA32_MISC_ENABLE disabling speed step was invalid and so that approach was right after all.
1 parent 8d1af9a commit 492ba46

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

DisableTurboBoost.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@
250250
isa = XCBuildConfiguration;
251251
buildSettings = {
252252
CODE_SIGN_STYLE = Automatic;
253+
CURRENT_PROJECT_VERSION = 2;
253254
INFOPLIST_FILE = DisableTurboBoost/Info.plist;
255+
MARKETING_VERSION = 1.1;
254256
MODULE_NAME = no.vtek.DisableTurboBoost;
255257
MODULE_START = DisableTurboBoost_start;
256258
MODULE_STOP = DisableTurboBoost_stop;
@@ -265,7 +267,9 @@
265267
isa = XCBuildConfiguration;
266268
buildSettings = {
267269
CODE_SIGN_STYLE = Automatic;
270+
CURRENT_PROJECT_VERSION = 2;
268271
INFOPLIST_FILE = DisableTurboBoost/Info.plist;
272+
MARKETING_VERSION = 1.1;
269273
MODULE_NAME = no.vtek.DisableTurboBoost;
270274
MODULE_START = DisableTurboBoost_start;
271275
MODULE_STOP = DisableTurboBoost_stop;

DisableTurboBoost/DisableTurboBoost.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,28 @@ extern void mp_rendezvous_no_intrs(
2525
void (*action_func)(void *),
2626
void *arg);
2727

28-
const uint64_t disableTurboBoost = ((uint64_t)1) << 32;
28+
const uint64_t disableTurboBoost = ((uint64_t)1) << 38;
2929

3030
void disable_tb(__unused void * param_not_used) {
31-
wrmsr64(MSR_IA32_PERF_CTL, rdmsr64(MSR_IA32_PERF_CTL) | disableTurboBoost);
31+
wrmsr64(MSR_IA32_MISC_ENABLE, rdmsr64(MSR_IA32_MISC_ENABLE) | disableTurboBoost);
3232
}
3333

3434
void enable_tb(__unused void * param_not_used) {
35-
wrmsr64(MSR_IA32_PERF_CTL, rdmsr64(MSR_IA32_PERF_CTL) & ~disableTurboBoost);
35+
wrmsr64(MSR_IA32_MISC_ENABLE, rdmsr64(MSR_IA32_MISC_ENABLE) & ~disableTurboBoost);
3636
}
3737

38-
kern_return_t DisableTurboBoost_start(kmod_info_t * ki, void *d);
39-
kern_return_t DisableTurboBoost_stop(kmod_info_t *ki, void *d);
40-
4138
kern_return_t DisableTurboBoost_start(kmod_info_t * ki, void *d)
4239
{
43-
uint64_t prev = rdmsr64(MSR_IA32_PERF_CTL);
40+
uint64_t prev = rdmsr64(MSR_IA32_MISC_ENABLE);
4441
mp_rendezvous_no_intrs(disable_tb, NULL);
45-
printf("Disabled Turbo Boost: %llx -> %llx\n", prev, rdmsr64(MSR_IA32_PERF_CTL));
42+
printf("Disabled Turbo Boost: %llx -> %llx\n", prev, rdmsr64(MSR_IA32_MISC_ENABLE));
4643
return KERN_SUCCESS;
4744
}
4845

4946
kern_return_t DisableTurboBoost_stop(kmod_info_t *ki, void *d)
5047
{
51-
uint64_t prev = rdmsr64(MSR_IA32_PERF_CTL);
48+
uint64_t prev = rdmsr64(MSR_IA32_MISC_ENABLE);
5249
mp_rendezvous_no_intrs(enable_tb, NULL);
53-
printf("Re-enabled Turbo Boost: %llx -> %llx\n", prev, rdmsr64(MSR_IA32_PERF_CTL));
50+
printf("Re-enabled Turbo Boost: %llx -> %llx\n", prev, rdmsr64(MSR_IA32_MISC_ENABLE));
5451
return KERN_SUCCESS;
5552
}

DisableTurboBoost/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<key>CFBundlePackageType</key>
1616
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleVersion</key>
20-
<string>1</string>
20+
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSHumanReadableCopyright</key>
2222
<string>Copyright © 2020 Vegard Løkken. All rights reserved.</string>
2323
<key>OSBundleLibraries</key>

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DisableTurboBoost
22

3-
A MacOS kernel extension (kext) for disabling CPU turbo boost to keep temperature (and fan noise) down.
3+
A macOS kernel extension (kext) for disabling CPU turbo boost to keep temperature (and fan noise) down.
44

55
## Usage
66

@@ -18,11 +18,13 @@ sudo kextload DisableTurboBoost.kext
1818

1919
Run `kextstat |grep DisableTurboBoost` to verify that it's loaded.
2020

21+
Run `sudo kextunload -b no.vtek.DisableTurboBoost` to unload the kext.
22+
2123
## How it works
2224

23-
This small kernel extension will enable bit 32 of the MSR register `MSR_IA32_PERF_CTL`. This causes the CPU to disable turbo boost, while keeping speed step.
25+
This small kernel extension will enable bit 38 of the MSR register `MSR_IA32_MISC_ENABLE` which causes the CPU to disable turbo boost.
2426

25-
Other similar extensions choose to enable bit 38 of `MSR_IA32_MISC_ENABLE`, but this also disables speed step causing the CPU to run at a higher frequency (and drain battery faster) than necessary.
27+
There are some alternatives that enables bit 32 of `MSR_IA32_PERF_CTL`, but that didn't seem to have any impact on my system.
2628

2729
Take a look in the [manual](http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html) for more info.
2830

@@ -42,4 +44,4 @@ It will output something about invalid signatures, but the extension might still
4244

4345
## Credits
4446

45-
The code was written by Vegard Løkken with great inspiration from [nanoant/DisableTurboBoost.kext](https://github.com/nanoant/DisableTurboBoost.kext) and [pyrovski/powertools](https://github.com/pyrovski/powertools).
47+
The code was based on an outdated repo [nanoant/DisableTurboBoost.kext](https://github.com/nanoant/DisableTurboBoost.kext).

0 commit comments

Comments
 (0)