Page 1 of 1

[Solved] AMD laptop is sometimes very slow until next boot

Posted: 2024-05-16 00:00
by diziet_sma
So this is an interesting mystery...

Every once in a while, my Lenovo IdeaPad 1 14ALC7 (running Debian Bookworm with KDE) becomes sluggish after boot. Apps take 10x longer than usual to launch, touchpad input lags, the desktop takes ages to start. And, this is the most interesting thing, programs take MUCH more CPU time than they should. Normally htop uses about 5% of one core; in this sluggish state, it cranks away at 20-30% (and lags).

Reboot always fixes it. Never even takes more than one try. Reboot once and the laptop is good as new.

I haven't remembered to get logs or system info yet - it's somewhat hampered by the machine being barely possible to use in that state. My guess is either a kernel oops or some kind of frequency scaling issue. But I'm curious if anyone else with a recent-ish AMD system has seen this behavior and/or knows a mechanism.

Re: AMD laptop is sometimes very slow until next boot

Posted: 2024-05-16 01:05
by ruwolf
Is journal (of systemd) empty during those intervals?
(It should be not emptied after reboot.)

Re: AMD laptop is sometimes very slow until next boot

Posted: 2024-05-16 22:16
by diziet_sma
Thanks ruwolf, that is helpful. A few odd things appear:

Code: Select all

May 15 19:19:31 chinchilla kernel: pci 0000:00:00.2: can't derive routing for PCI INT A
May 15 19:19:31 chinchilla kernel: pci 0000:00:00.2: PCI INT A: not connected

Code: Select all

May 15 19:19:31 chinchilla kernel: Unstable clock detected, switching default tracing clock to "global"
                                   If you want to keep using the local clock, then add:
                                     "trace_clock=local"
                                   on the kernel command line

Code: Select all

May 15 19:19:31 chinchilla kernel: [drm] psp gfx command LOAD_TA(0x1) failed and response status is (0x7)
May 15 19:19:31 chinchilla kernel: [drm] psp gfx command INVOKE_CMD(0x3) failed and response status is (0x4)
May 15 19:19:31 chinchilla kernel: amdgpu 0000:04:00.0: amdgpu: Secure display: Generic Failure.
May 15 19:19:31 chinchilla kernel: amdgpu 0000:04:00.0: amdgpu: SECUREDISPLAY: query securedisplay TA failed. ret 0x0
None of these are unique to the bad boot though.

Re: AMD laptop is sometimes very slow until next boot

Posted: 2024-05-17 10:57
by fabien
diziet_sma wrote: 2024-05-16 22:16

Code: Select all

May 15 19:19:31 chinchilla kernel: Unstable clock detected, switching default tracing clock to "global"
                                   If you want to keep using the local clock, then add:
                                     "trace_clock=local"
                                   on the kernel command line
Maybe

Code: Select all

#> journalctl -b -g "lock|hpet|tsc|time" --no-pager
will give more clues when this happens.

If you add trace_clock=global to the GRUB command line, does it triggers the problem?
You can also check if trace_clock=local prevents the problem. In this case, the question would be why is the clock unstable?

Re: AMD laptop is sometimes very slow until next boot

Posted: 2024-05-18 00:31
by diziet_sma
Specifying either seems to cause the issue invariably. Leaving it unset results in global being preferred every time, but the sluggishness doesn't always appear.

I'm also seeing a new behavior now with trace_clock being unspecified, where the behavior occurs for the first minute or so of boot and then goes away.

Re: AMD laptop is sometimes very slow until next boot

Posted: 2024-05-18 00:40
by diziet_sma
Got it. All cores are stuck at the minimum of 400 MHz since the last set of updates, no idea why. The variability is probably from variation in system load.

Re: AMD laptop is sometimes very slow until next boot

Posted: 2024-05-18 00:51
by diziet_sma
Setting amd_pstate=passive on the kernel cmdline is a functional workaround (and WOW this laptop is fast when the brakes aren't stuck on). Not sure if this is a bug in the amd_pstate driver on this hardware, or something about my system configuration conflicting with the driver.

Re: [Solved] AMD laptop is sometimes very slow until next boot

Posted: 2024-05-18 01:20
by diziet_sma
Turns out I was getting this issue on my AMD desktop too, even! I just didn't notice other than occasional sound lag. Wild.

Re: [Solved] AMD laptop is sometimes very slow until next boot

Posted: 2024-05-18 10:22
by fabien
Thank you for sharing your findings.
It might be helpful to others in the same situation if you gave more information about your hardware, especially your CPU (on both of your systems if possible).
You can use inxi for this, e.g.

Code: Select all

$> inxi -afCMGz
Thanks

Re: [Solved] AMD laptop is sometimes very slow until next boot

Posted: 2024-05-18 12:11
by diziet_sma
Desktop:

Code: Select all

Machine:
  Type: Desktop Mobo: ASRock model: B550M-ITX/ac serial: <superuser required>
    UEFI: American Megatrends LLC. v: P2.20 date: 12/27/2022
CPU:
  Info: model: AMD Ryzen 5 5600G with Radeon Graphics bits: 64 type: MT MCP
    arch: Zen 3 gen: 4 level: v3 note: check built: 2021-22
    process: TSMC n7 (7nm) family: 0x19 (25) model-id: 0x50 (80) stepping: 0
    microcode: 0xA50000D
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB desc: 6x512 KiB
    L3: 16 MiB desc: 1x16 MiB
  Speed (MHz): avg: 2495 high: 3218 min/max: 400/4464 boost: enabled
    scaling: driver: amd-pstate governor: schedutil cores: 1: 2366 2: 3070
    3: 2366 4: 3218 5: 2366 6: 2366 7: 2366 8: 2366 9: 2366 10: 2366 11: 2366
    12: 2366 bogomips: 93421
  Flags: 3dnowprefetch abm adx aes aperfmperf apic arat avic avx avx2 bmi1
    bmi2 bpext cat_l3 cdp_l3 clflush clflushopt clwb clzero cmov cmp_legacy
    constant_tsc cpb cppc cpuid cqm cqm_llc cqm_mbm_local cqm_mbm_total
    cqm_occup_llc cr8_legacy cx16 cx8 de debug_swap decodeassists erms
    extapic extd_apicid f16c flushbyasid fma fpu fsgsbase fsrm fxsr fxsr_opt
    ht hw_pstate ibpb ibrs ibs invpcid irperf lahf_lm lbrv lm mba mca mce
    misalignsse mmx mmxext monitor movbe msr mtrr mwaitx nonstop_tsc nopl npt
    nrip_save nx ospke osvw overflow_recov pae pat pausefilter pclmulqdq
    pdpe1gb perfctr_core perfctr_llc perfctr_nb pfthreshold pge pku pni
    popcnt pse pse36 rapl rdpid rdpru rdrand rdseed rdt_a rdtscp rep_good sep
    sha_ni skinit smap smca smep ssbd sse sse2 sse4_1 sse4_2 sse4a ssse3
    stibp succor svm svm_lock syscall tce topoext tsc tsc_scale umip
    v_spec_ctrl v_vmsave_vmload vaes vgif vmcb_clean vme vmmcall vpclmulqdq
    wbnoinvd wdt x2apic xgetbv1 xsave xsavec xsaveerptr xsaveopt xsaves
  Vulnerabilities:
  Type: gather_data_sampling status: Not affected
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: mmio_stale_data status: Not affected
  Type: retbleed status: Not affected
  Type: spec_rstack_overflow status: Vulnerable: Safe RET, no microcode
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW,
    STIBP: always-on, RSB filling, PBRSB-eIBRS: Not affected
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: AMD Ellesmere [Radeon RX 470/480/570/570X/580/580X/590]
    vendor: XFX Pine driver: amdgpu v: kernel arch: GCN-4 code: Arctic Islands
    process: GF 14nm built: 2016-20 pcie: gen: 3 speed: 8 GT/s lanes: 16
    ports: active: DP-1 empty: DP-2, DP-3, DVI-D-1, HDMI-A-1 bus-ID: 01:00.0
    chip-ID: 1002:67df class-ID: 0300 temp: 33.0 C
  Device-2: Logitech C920 HD Pro Webcam type: USB
    driver: snd-usb-audio,uvcvideo bus-ID: 5-2.3.1:6 chip-ID: 046d:0892
    class-ID: 0102 serial: <filter>
  Display: wayland server: X.org v: 1.21.1.7 with: Xwayland v: 22.1.9
    compositor: kwin_wayland driver: X: loaded: amdgpu
    unloaded: fbdev,modesetting,vesa dri: radeonsi gpu: amdgpu display-ID: 0
  Monitor-1: DP-1 model: Lenovo LEN Q27h-10 serial: <filter> built: 2022
    res: 2560x1440 dpi: 109 gamma: 1.2 size: 598x336mm (23.54x13.23")
    diag: 686mm (27") ratio: 16:9 modes: max: 2560x1440 min: 720x400
  API: OpenGL v: 4.6 Mesa 22.3.6 renderer: AMD Radeon RX 580 Series
    (polaris10 LLVM 15.0.6 DRM 3.54 6.6.13+bpo-amd64) direct-render: Yes
Should also mention I'm using the BPO 6.6.13 kernel on both systems.

Re: [Solved] AMD laptop is sometimes very slow until next boot

Posted: 2024-05-18 13:00
by diziet_sma
And the laptop:

Code: Select all

Machine:
  Type: Laptop System: LENOVO product: 82R3 v: IdeaPad 1 14ALC7
    serial: <superuser required> Chassis: type: 10 v: IdeaPad 1 14ALC7
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0T76473WIN
    serial: <superuser required> UEFI: LENOVO v: JTCN49WW date: 09/18/2023
CPU:
  Info: model: AMD Ryzen 5 5500U with Radeon Graphics bits: 64 type: MT MCP
    arch: Zen 2 gen: 3 level: v3 note: check built: 2020-22
    process: TSMC n7 (7nm) family: 0x17 (23) model-id: 0x68 (104) stepping: 1
    microcode: 0x8608103
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB desc: 6x512 KiB L3: 8 MiB
    desc: 2x4 MiB
  Speed (MHz): avg: 1116 high: 1317 min/max: 400/4056 boost: enabled
    scaling: driver: amd-pstate governor: schedutil cores: 1: 1317 2: 1113
    3: 1113 4: 1034 5: 1113 6: 1035 7: 1113 8: 1113 9: 1113 10: 1113 11: 1113
    12: 1113 bogomips: 50307
  Flags: 3dnowprefetch abm adx aes aperfmperf apic arat avic avx avx2 bmi1
    bmi2 bpext cat_l3 cdp_l3 clflush clflushopt clwb clzero cmov cmp_legacy
    constant_tsc cpb cppc cpuid cqm cqm_llc cqm_mbm_local cqm_mbm_total
    cqm_occup_llc cr8_legacy cx16 cx8 de decodeassists extapic extd_apicid
    f16c flushbyasid fma fpu fsgsbase fxsr fxsr_opt ht hw_pstate ibpb ibrs
    ibs irperf lahf_lm lbrv lm mba mca mce misalignsse mmx mmxext monitor
    movbe msr mtrr mwaitx nonstop_tsc nopl npt nrip_save nx osvw
    overflow_recov pae pat pausefilter pclmulqdq pdpe1gb perfctr_core
    perfctr_llc perfctr_nb pfthreshold pge pni popcnt pse pse36 rapl rdpid
    rdpru rdrand rdseed rdt_a rdtscp rep_good sep sha_ni skinit smap smca
    smep ssbd sse sse2 sse4_1 sse4_2 sse4a ssse3 stibp succor svm svm_lock
    syscall tce topoext tsc tsc_scale umip v_spec_ctrl v_vmsave_vmload vgif
    vmcb_clean vme vmmcall wbnoinvd wdt xgetbv1 xsave xsavec xsaveerptr
    xsaveopt
  Vulnerabilities:
  Type: gather_data_sampling status: Not affected
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: mmio_stale_data status: Not affected
  Type: retbleed mitigation: untrained return thunk; SMT enabled with STIBP
    protection
  Type: spec_rstack_overflow mitigation: Safe RET
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, STIBP:
    always-on, RSB filling, PBRSB-eIBRS: Not affected
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: AMD Lucienne vendor: Lenovo driver: amdgpu v: kernel arch: GCN-5
    code: Vega process: GF 14nm built: 2017-20 pcie: gen: 3 speed: 8 GT/s
    lanes: 16 link-max: gen: 4 speed: 16 GT/s ports: active: eDP-1
    empty: DP-1,HDMI-A-1 bus-ID: 04:00.0 chip-ID: 1002:164c class-ID: 0300
    temp: 29.0 C
  Device-2: Chicony Integrated Camera type: USB driver: uvcvideo
    bus-ID: 1-3:2 chip-ID: 04f2:b725 class-ID: fe01 serial: <filter>
  Display: wayland server: X.org v: 1.21.1.7 with: Xwayland v: 22.1.9
    compositor: kwin_wayland driver: X: loaded: amdgpu
    unloaded: fbdev,modesetting,vesa dri: radeonsi gpu: amdgpu display-ID: 0
  Monitor-1: eDP-1 model: BOE Display 0x08f2 built: 2019 res: 1920x1080
    dpi: 157 gamma: 1.2 size: 310x174mm (12.2x6.85") diag: 355mm (14")
    ratio: 16:9 modes: max: 1920x1080 min: 640x480
  API: OpenGL v: 4.6 Mesa 22.3.6 renderer: AMD Radeon Graphics (renoir LLVM
    15.0.6 DRM 3.54 6.6.13+bpo-amd64) direct-render: Yes

Re: [Solved] AMD laptop is sometimes very slow until next boot

Posted: 2024-05-27 16:31
by diziet_sma
Seems to be fixed in kernel BPO kernel 6.7.12; CPU scaling behavior is normal again with amd_pstate=active, and performance reflects this.