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

race condition between cpuhotplug and cpufreq #201

Open
Ronemisimus opened this issue Mar 29, 2023 · 1 comment
Open

race condition between cpuhotplug and cpufreq #201

Ronemisimus opened this issue Mar 29, 2023 · 1 comment

Comments

@Ronemisimus
Copy link

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
@Ronemisimus
Copy link
Author

after another look in the logs it look like maybe the governor is set during unplug to schedutil before hot plugging the cores and when they come back online they are not reset to the correct governor (maybe they are still offline during the governor update)

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

No branches or pull requests

1 participant