Skip to content

race condition between cpuhotplug and cpufreq #201

@Ronemisimus

Description

@Ronemisimus

Describe the bug
when cpufreq and cpuhotplug are enabled, hotplug works as expected when unplugging
however when switching to AC cpufreq is changing the governor only in core that aren't hotpluged
meaning online cores change their governor as expected while the rest are reset to the same governor for me it's schedutil

P.s i'd love to help in anyway i can - if you can point me to a direction in the code i'll try to find a solution
but it looks like some race condition to me

To Reproduce
Steps to reproduce the behavior:

  1. enable cpufreq module
  2. enable cpuhotplug module
  3. plug the charger and manually set all cores to performance governor
  4. unplug charger and see 1/4 of core remaining online with schedutil as expected
  5. plug charger again - all cores are online, cores that were disabled are now in schedutil the rest behave correctly

Expected behavior
the cores are switched to the same governor regardless of hotplug state,
meaning all are on performance when the charger is plugged in

Important Information:

  • Distribution: Arch linux
  • Linux Kernel: 6.2.8-zen1-1-zen
  • Laptop Mode Tools version: 1.74-1
  • Desktop Environment: Gnome
  • Relevant System Logs:
    cpupower when plugged in after performance mode is set manually:
sudo cpupower -c 0-15 frequency-info -p
analyzing CPU 0:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 1:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 2:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 3:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 4:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 5:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 6:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 7:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 8:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 9:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 10:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 11:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 12:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 13:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 14:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 15:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.

after unplug:

sudo cpupower -c 0-15 frequency-info -p
analyzing CPU 0:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 1:
 *is offline

analyzing CPU 2:
 *is offline

analyzing CPU 3:
 *is offline

analyzing CPU 4:
 *is offline

analyzing CPU 5:
 *is offline

analyzing CPU 6:
 *is offline

analyzing CPU 7:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 8:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 9:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 10:
 *is offline

analyzing CPU 11:
 *is offline

analyzing CPU 12:
 *is offline

analyzing CPU 13:
 *is offline

analyzing CPU 14:
 *is offline

analyzing CPU 15:
 *is offline

replugging the power we see the error:

sudo cpupower -c 0-15 frequency-info -p
analyzing CPU 0:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 1:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 2:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 3:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 4:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 5:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 6:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 7:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 8:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 9:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
analyzing CPU 10:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 11:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 12:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 13:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 14:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
analyzing CPU 15:
  current policy: frequency should be within 1.20 GHz and 3.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.

Additional context
here are my setting in both modules:
cpufreq:

BATT_CPU_MAXFREQ=3200000
BATT_CPU_MINFREQ=slowest
BATT_CPU_GOVERNOR=schedutil
BATT_CPU_IGNORE_NICE_LOAD=1
LM_AC_CPU_MAXFREQ=fastest
LM_AC_CPU_MINFREQ=slowest
LM_AC_CPU_GOVERNOR=performance
LM_AC_CPU_IGNORE_NICE_LOAD=1
NOLM_AC_CPU_MAXFREQ=fastest
NOLM_AC_CPU_MINFREQ=slowest
NOLM_AC_CPU_GOVERNOR=performance
NOLM_AC_CPU_IGNORE_NICE_LOAD=0

cpuhotplug:

CONTROL_CPU_HOTPLUG=1
DISABLE_AVAILABLE_CPU="3quarter"
BATT_CPU_HOTPLUG=1
LM_AC_CPU_HOTPLUG=0
NOLM_AC_CPU_HOTPLUG=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions