Skip to contentSkip to conversation

New: amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

Bug 219110 [email protected] 1 participant 13 messages Jul 30, 2024 – Aug 26, 2024

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=219110

Bug ID: 219110
Summary: amd-pstate's balance_performance
energy_performance_preference doesn't survive suspend resume
Product: Power Management
Version: 2.5
Hardware: AMD
OS: Linux
Status: NEW
Severity: normal
Priority: P3
Component: cpufreq
Assignee: [email protected]
Reporter: [email protected]
Regression: No

On boot I'm setting /sys/devices/system/cpu/cpufreq/*/energy_performance_preference to balance_performance however after a suspend resume cycle it gets reset to performance despite energy_performance_preference reporting that it's set to balance_performance which is basically a lie.

How do I know it?

Start watching a 1440p/4K VP9/AV1 video with video acceleration on on YouTube.

With default performance I'm looking at more than 14W CPU package consumption on average.

With balance_performance it goes down to roughly 8W.

Upon resume with reportedly balance_performance it's back to > 14W.

Please fix.

That's with kernel 6.9.12. If this has been fixed in 6.10, please let me know.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#1 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

https://bugzilla.kernel.org/show_bug.cgi?id=219110

[email protected] changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #1 from [email protected] ---
So you do one suspend cycle on your device?
I think CPU power status is reset after one suspend cycle.
Yes, it should be a function to restore CPU power register status and governor status after s3/s4/s2idle.
For you case, i think add one more shell script will fix this problem, you know, you are setting cpu enegy policy during booting, then your can add one same action during suspend, any chance for this?

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#2 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #2 from Artem S. Tashkinov ([email protected]) --- (In reply to xiaojian.du from comment #1)

Quoted 1 line

So you do one suspend cycle on your device?

I have to set/restore energy_performance_preference on every resume.

Quoted 6 lines

I think CPU power status is reset after one suspend cycle.
Yes, it should be a function to restore CPU power register status and governor status after s3/s4/s2idle.
For you case, i think add one more shell script will fix this problem, you know, you are setting cpu enegy policy during booting, then your can add one same action during suspend, any chance for this?

I can certainly do that, but with acpi-cpufreq you didn't have to do that :-(

You set performance/powersave/ondemand and it perfectly survives suspend/resume.

I wonder why amd-pstate cannot. A kernel module can keep this state as a simple variable and restore the energy preference on resume.

And secondly it's quite misleading that it reports a wrong value after resuming.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#3 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #3 from [email protected] ---

Quoted 5 lines

I wonder why amd-pstate cannot. A kernel module can keep this state as a simple variable and restore the energy preference on resume.

And secondly it's quite misleading that it reports a wrong value after resuming.

Of course, this should be a function for a complete and robust cpu driver. will discuss it internally. Our team now lacks resources, both human resource and project funding support. So it will take time.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#4 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

Artem S. Tashkinov ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

           Priority|P3                          |P5
           Severity|normal                      |low

--- Comment #4 from Artem S. Tashkinov ([email protected]) ---

Quoted 2 lines

Our team now lacks resources, both human resource and project funding support.

That's really sad to hear.

Quoted 1 line

So it will take time.

Thanks a ton, there's no rush.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#5 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

Mario Limonciello (AMD) ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO

--- Comment #5 from Mario Limonciello (AMD) ([email protected]) --- (I've been OOO a while, but I see this in my inbox as I'm catching up now).

I have a Framework 13 on my desk (Ryzen 7840U), running 6.11-rc4. I stopped power-profiles-daemon before suspend to ensure it doesn't influence the result in any way.

Before suspend I ran:

# systemctl stop power-profiles-daemon.service
# cat /sys/bus/cpu/devices/cpu*/cpufreq/energy_performance_preference

Everything is 'balance_performance'.

I then suspend with:

# systemctl suspend

I then resume and run :

# cat /sys/bus/cpu/devices/cpu*/cpufreq/energy_performance_preference

Everything is the same.
Can you reproduce my result on 6.11-rc4?

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#6 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #6 from Artem S. Tashkinov ([email protected]) ---
Perhaps I didn't make it clear in the bug report, Mario, but the value of the variable is correct after resuming, it's the same as you set it, but the energy preference gets reset to the default value. In other words, the variable no longer represents the state of the system.

I will test 6.11 once it gets released.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#7 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #7 from Artem S. Tashkinov ([email protected]) ---
It's easy to reproduce by e.g. watching YouTube VP9 1440p/4K videos with my Ryzen 7 7840HS with HW acceleration on.

Before suspend:
performance -> ~15W
balance_performance -> ~8-9W

After resuming when it's set to "balance_performance" we are back to ~15W.

Setting it to any other value and then back to balance_performance fixes it.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#8 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #8 from Mario Limonciello (AMD) ([email protected]) --- To me this sounds like a firmware bug. I can't seem to reproduce it.

I just had a try on an AMD reference system with a "AMD Ryzen 5 7640U w/ Radeon 760M Graphics" running PhoenixPI-FP8-FP7 1.1.0.2a.

For my kernel I used 6.11-rc4.
For userspace it's Ubuntu 24.04 userspace.
I ran "mpv bbb_sunflower_2160p_60fps_normal.mp4".

I then SSH'ed in from another system and looked at the average PPT value reported by 'sensors'. It stay in the 8W range the whole time. Here was a snapshot:

amdgpu-pci-c200

Adapter: PCI adapter
vddgfx:      900.00 mV
vddnb:       759.00 mV
edge:         +39.0°C
PPT:           6.00 W  (avg =   8.14 W)

I then stopped the video, suspended and started it back up and looked again. Same ballpark.

You might look at the value for the MSR's that amd-pstate uses by using 'rdmsr MSR' to see if they change in any notable way before or after suspend.

#define MSR_AMD_CPPC_CAP1               0xc00102b0
#define MSR_AMD_CPPC_ENABLE             0xc00102b1
#define MSR_AMD_CPPC_CAP2               0xc00102b2
#define MSR_AMD_CPPC_REQ                0xc00102b3
#define MSR_AMD_CPPC_STATUS             0xc00102b4

The most important one to check is MSR_AMD_CPPC_REQ.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#9 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #9 from Artem S. Tashkinov ([email protected]) --- Could be a firmware bug, not the first one :-)

This command doesn't seem to work here:

# rdmsr MSR
0
Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#10 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #10 from Artem S. Tashkinov ([email protected]) --- It works, I didn't understand how to use it at first.

Before suspend:

0xc00102b0: c4912a10c4912a10
0xc00102b1: 1
0xc00102b2: 0
0xc00102b3: 800010c4
0xc00102b4: 0

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#11 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

--- Comment #11 from Artem S. Tashkinov ([email protected]) --- After resuming:

for i in seq 0 4; do rdmsr "0xc00102b$i"; done

c4912a10c4912a10
1
0
800010c4
0

Looks exactly the same.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.
#12 lore raw

[Bug 219110] amd-pstate's balance_performance energy_performance_preference doesn't survive suspend resume

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=219110

Artem S. Tashkinov ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|NEEDINFO                    |REJECTED
         Resolution|---                         |UNREPRODUCIBLE

--- Comment #12 from Artem S. Tashkinov ([email protected]) ---
I feel like in Linux 6.11.x I cannot reproduce it any longer, i.e. it works as expected.

If I manage to reproduce it, I'll let you know.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are the assignee for the bug.