Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-667: Modify message when using amd-pstate-epp #674

Merged
merged 6 commits into from
Apr 9, 2024

Conversation

corona10
Copy link
Contributor

@corona10 corona10 commented Apr 7, 2024

Hi, First of all, auto-cpufreq is super useful for my laptop, thank you for working on this.

While I read the relevant threads, it looks like setting turbo can be delegated to the amd-pstate-epp.
Please let me know if I knew wrong :)

@corona10
Copy link
Contributor Author

corona10 commented Apr 7, 2024

cc @LDprg

@corona10
Copy link
Contributor Author

corona10 commented Apr 7, 2024

Screenshot from 2024-04-07 13-12-22

if amd_value == "active" and scaling_driver_value == "amd-pstate-epp":
print("CPU turbo is controlled by amd-pstate-epp driver")
else:
print("Warning: CPU turbo is not available")
Copy link
Contributor Author

@corona10 corona10 Apr 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if more status can exist at this moment which can set the turbo.
FYI, I am not the AMD expert :)

If "yes," we should make it to set the turbo if the user wants.

Copy link
Collaborator

@shadeyg56 shadeyg56 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, but I think this is good in terms of making it more clear as to what is actually happening in the background

@@ -267,13 +267,23 @@ def turbo(value: bool = None):
"""
p_state = Path("/sys/devices/system/cpu/intel_pstate/no_turbo")
cpufreq = Path("/sys/devices/system/cpu/cpufreq/boost")
amd_pstate = Path("/sys/devices/system/cpu/amd_pstate/status")
scaling_driver = Path("/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to check scaling_driver. Just amd_pstate/status is enough


if p_state.exists():
inverse = True
f = p_state
elif cpufreq.exists():
f = cpufreq
inverse = False
elif amd_pstate.exists() and scaling_driver.exists():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove scaling_driver.exists()

Comment on lines 284 to 285
else:
print("Warning: CPU turbo is not available")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be removed since this else statement will never be reached. the cpufreq Path does exist on amd-pstate so it would be caught by the preceding elif statement

Comment on lines 281 to 282
scaling_driver_value = scaling_driver.read_text().strip()
if amd_value == "active" and scaling_driver_value == "amd-pstate-epp":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the scaling_driver check since if amd_pstate/status equals "active", then the loaded driver must be amd-pstate-epp

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this isn't really important but I think this entire if statement doesn't actually do anything since the cpufreq Path only doesn't exist on amd-pstate-epp but I think we should leave the if statement since it makes it more clear what is actually happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, by the way, what for amd_pstate == guided or amd_pstate == passive?

Copy link
Contributor Author

@corona10 corona10 Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-reply for guided mode: #602 (comment)
if amd_pstate=guided is set, then /sys/devices/system/cpu/cpufreq/boost is set.

@corona10 corona10 requested a review from shadeyg56 April 8, 2024 17:14
@shadeyg56
Copy link
Collaborator

Looks good, but still since /sys/devices/system/cpu/cpufreq/boost is set on both amd_pstate=guided and amd_pstate=passive, the else statement can be removed since this is handled by elif cpufreq.exists()

Also i forgot to mention, the return False should be indented into the if statement

if value == "active":
print("CPU turbo is controlled by amd-pstate-epp driver")
return False
# Should not reach here.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to raise error here, but not sure about this project convention :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because following code will require f, but f is None at this moment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get what you're saying. Its true but since it never reaches there, it shouldn't matter, but I suppose for future proofing, we can unindent the return False

@shadeyg56 shadeyg56 linked an issue Apr 9, 2024 that may be closed by this pull request
@shadeyg56
Copy link
Collaborator

Thanks for the changes.

You'll be credited as part of the next release.

@shadeyg56 shadeyg56 merged commit 2df634b into AdnanHodzic:master Apr 9, 2024
2 checks passed
@corona10 corona10 deleted the gh-667 branch April 10, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No "Warning: CPU turbo is not available" when using amd-pstate-epp
2 participants