Bug 217853 - Abnormal battery drain with kernel 6.5 (Ryzen 5500u)
Summary: Abnormal battery drain with kernel 6.5 (Ryzen 5500u)
Status: NEW
Alias: None
Product: Linux
Classification: Unclassified
Component: Kernel (show other bugs)
Hardware: AMD Linux
: P3 normal
Assignee: Virtual assignee for kernel bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-01 07:50 UTC by Michele Della Guardia
Modified: 2023-11-28 20:51 UTC (History)
3 users (show)

See Also:
Kernel Version: 6.5
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments

Description Michele Della Guardia 2023-09-01 07:50:37 UTC
After switching from 6.4.x kernel to 6.5 I experienced an abnormal battery drain since my laptop is actually never idle.
I accepted default CPUfreq to schedutil and AMD Processor P-State mode is 3 (active). 

I expected a different behaviour, but am I missing something?
In my boot configuration I had "amd_pstate.shared_mem=1" and tried to remove this switch, but did not affect my power consuption.

Is there something changed from 6.4.x to 6.5 that requires a different configuration to get an optimal power consumption?

Thanks a lot for your attention
Comment 1 Artem S. Tashkinov 2023-09-01 08:52:49 UTC
1. You can try disabling the new driver and using acpi-cpufreq instead though I'm 99.999% sure amd-pstate not the culprit.

Try booting with initcall_blacklist=amd_pstate_init amd_pstate.enable=0

2. If, indeed, switching back to the old driver doesn't help, your best best will be to bisect.

https://docs.kernel.org/admin-guide/bug-bisect.html

3. Before you attempt to do that, you could use powertop under both kernels and see if there's something sticking out.
Comment 2 Artem S. Tashkinov 2023-09-01 08:55:35 UTC
Actually the correct way to disable amd_pstate could be:

module_blacklist=amd-pstate
Comment 3 Michele Della Guardia 2023-09-01 15:02:11 UTC
While checking things I noticed that I can only use "performance" and "powersave" governors, even if I'm sure I compiled and selected "schedutil" as default. Where is "schedutil" governor gone?
"Powersave" is selected instead but in any case, my battery is drained more quickly respect to 6.4.x kernel.

---
cpufreq-info  
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Per favore, comunicare errori e malfunzionamenti a cpufreq@vger.kernel.org.
analisi della CPU 0:
  modulo amd-pstate-epp
  CPU che operano alla stessa frequenza hardware: 0
  CPU che è necessario siano coordinate dal software: 0
  latenza massima durante la transizione: 4294.55 ms.
  limiti hardware: 400 MHz - 4.06 GHz
  gestori disponibili: performance, powersave
  gestore attuale: la frequenza deve mantenersi tra 400 MHz e 4.06 GHz.
                   Il gestore "powersave" può decidere quale velocità usare
                  in questo intervallo.
  la frequenza attuale della CPU è 400 MHz.
---

Powertop gives me this output (here just the first lines) and apparently seems normal to me:

---
La batteria riporta un tasso di scaricamento di 4.70 W
The power consumed was 0.00 J
Il tempo stimato restate è di 1 ore e 36 minuti

Riepilogo: 481,8 wakeup/secondo,  0,0 GPU op/secondo, 0,0 VFS op/secondo e 7,2% uso CPU

Stima consumo              Uso       Eventi/s    Categoria       Descrizione
  508 mW      4,7 ms/s     129,0        Interrupt      [80] amdgpu
  457 mW      2,4 ms/s     116,6        Timer          tick_sched_timer
---

amdgpu is steadily on top of power consumption (about 420mW when PC is idle) but no difference here with the old 6.4.x kernel.
Comment 4 Michele Della Guardia 2023-09-05 14:18:33 UTC
I did some tests and found that what actually drains battery power is not amd-pstate-epp but the governor used and "schedutil" is not sparing my power. 

I've tried a lot of combinations and found that in pstate (no matter if active/passive/guided) if I use an "ondemand" governor, I always have my CPU cores near the lowest clock value while my PC is idle.

When I use "schedutil" I have by far a higher power consumption (with the same work load) because of a higher clock.

Used this to get values:
michele@michele-swift3:~$ cpufreq-info | grep "la frequenza attuale"

***results with schedutil***

  la frequenza attuale della CPU è 1.11 GHz.
  la frequenza attuale della CPU è 2.54 GHz.
  la frequenza attuale della CPU è 2.45 GHz.
  la frequenza attuale della CPU è 2.51 GHz.
  la frequenza attuale della CPU è 4.06 GHz.
  la frequenza attuale della CPU è 3.75 GHz.
  la frequenza attuale della CPU è 1.11 GHz.
  la frequenza attuale della CPU è 1.10 GHz.
  la frequenza attuale della CPU è 1.11 GHz.
  la frequenza attuale della CPU è 1.24 GHz.
  la frequenza attuale della CPU è 1.74 GHz.
  la frequenza attuale della CPU è 1.11 GHz.

***results with ondemand***
  la frequenza attuale della CPU è 437 MHz.
  la frequenza attuale della CPU è 400 MHz.
  la frequenza attuale della CPU è 539 MHz.
  la frequenza attuale della CPU è 510 MHz.
  la frequenza attuale della CPU è 426 MHz.
  la frequenza attuale della CPU è 400 MHz.
  la frequenza attuale della CPU è 400 MHz.
  la frequenza attuale della CPU è 400 MHz.
  la frequenza attuale della CPU è 540 MHz.
  la frequenza attuale della CPU è 437 MHz.
  la frequenza attuale della CPU è 470 MHz.
  la frequenza attuale della CPU è 473 MHz.

These are my switches used to boot:

amd_pstate=active cpuidle.governor=teo workqueue.power_efficient=1 nowatchdog

and changed governor with cpupower-gui utility.
Comment 5 Michele Della Guardia 2023-09-08 07:06:14 UTC
My CPU is AMD Ryzen 5500u:

Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Byte Order:                         Little Endian
Address sizes:                      48 bits physical, 48 bits virtual
CPU(s):                             12
On-line CPU(s) list:                0-11
Thread(s) per core:                 2
Core(s) per socket:                 6
Socket(s):                          1
NUMA node(s):                       1
Vendor ID:                          AuthenticAMD
CPU family:                         23
Model:                              104
Model name:                         AMD Ryzen 5 5500U with Radeon Graphics
Stepping:                           1
Frequency boost:                    enabled
CPU MHz:                            975.888
CPU max MHz:                        4056,0000
CPU min MHz:                        400,0000
BogoMIPS:                           4191.99
Virtualization:                     AMD-V
L1d cache:                          192 KiB
L1i cache:                          192 KiB
L2 cache:                           3 MiB
L3 cache:                           8 MiB
NUMA node0 CPU(s):                  0-11
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Mitigation; untrained return thunk; SMT enab
                                    led with STIBP protection
Vulnerability Spec rstack overflow: Mitigation; safe RET
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disable
                                    d via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __u
                                    ser pointer sanitization
Vulnerability Spectre v2:           Mitigation; Retpolines, IBPB conditional, ST
                                    IBP always-on, RSB filling, PBRSB-eIBRS Not 
                                    affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep 
                                    mtrr pge mca cmov pat pse36 clflush mmx fxsr
                                     sse sse2 ht syscall nx mmxext fxsr_opt pdpe
                                    1gb rdtscp lm constant_tsc rep_good nopl non
                                    stop_tsc cpuid extd_apicid aperfmperf rapl p
                                    ni pclmulqdq monitor ssse3 fma cx16 sse4_1 s
                                    se4_2 movbe popcnt aes xsave avx f16c rdrand
                                     lahf_lm cmp_legacy svm extapic cr8_legacy a
                                    bm sse4a misalignsse 3dnowprefetch osvw ibs 
                                    skinit wdt tce topoext perfctr_core perfctr_
                                    nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l
                                    3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall
                                     fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdse
                                    ed adx smap clflushopt clwb sha_ni xsaveopt 
                                    xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm
                                    _total cqm_mbm_local clzero irperf xsaveerpt
                                    r rdpru wbnoinvd cppc arat npt lbrv svm_lock
                                     nrip_save tsc_scale vmcb_clean flushbyasid 
                                    decodeassists pausefilter pfthreshold avic v
                                    _vmsave_vmload vgif v_spec_ctrl umip rdpid o
                                    verflow_recov succor smca
Comment 6 Bagas Sanjaya 2023-09-22 07:10:59 UTC
Michele, had you done bisection? Any conclusion?
Comment 7 Michele Della Guardia 2023-09-22 08:27:37 UTC
Hi,
I have not done bisection (and don't know how to do that).

I just know that booting with kernel 6.5.x with the following parameters:

amd_pstate=passive cpuidle.governor=teo workqueue.power_efficient=1 nowatchdog

I have a really good battery life, but my default governor is "ondemand" and not "schedutil".

If I switch to "schedutil" I find that this is not giving me a better behaviour and drains more battery.

If I choose amd_pstate=active I cannot even choose "schedutil" as governor, but just "performance" and "powersave", even if "schedutil" should be the default governor as I configured in my kernel before compile it.

Regards
Michele
Comment 8 Bagas Sanjaya 2023-09-22 11:06:28 UTC
On 22/09/2023 15:27, bugzilla-daemon@kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=217853
> 
> --- Comment #7 from Michele Della Guardia (micheledellaguardia@yahoo.it) ---
> Hi,
> I have not done bisection (and don't know how to do that).
> 

Then see Documentation/admin-guide/bug-bisect.rst. Since you have to
compile your own kernel during bisection, see also
Documentation/admin-guide/quickly-build-trimmed-linux.rst.

Bye!
Comment 9 Michele Della Guardia 2023-09-22 12:16:46 UTC
Tried to bisect following docs and I had just this output:

[c8afaa1b0f8bc93d013ab2ea6b9649958af3f1d3] locking: remove spin_lock_prefetch

Bye
Comment 10 Roland Kletzing 2023-11-28 19:38:24 UTC
another report of ryzen idle power growth, probably related :  https://bugzilla.proxmox.com/show_bug.cgi?id=5059

Note You need to log in before you can comment on or make changes to this bug.