elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.41k stars 381 forks source link

[BUG] EWW_CPU freq does not update #542

Closed fufexan closed 2 years ago

fufexan commented 2 years ago

Checklist before submitting an issue

Description of the bug

I use $EWW_CPU.cores[0].freq in my CPU module of my bar. It normally updates fine, but lately it hasn't been doing so.

Upon inspecting the eww state output, I saw that the usage of each core gets updated, whereas the freq remains the same since launching eww itself.

Reproducing the issue

(box
  :class "sys_box"
  :space-evenly "false"
  :halign "start"
  (circular-progress
    :value "${EWW_CPU.avg}"
    :class "sys_cpu"
    :thickness "3"
    (label
      :text ""
      :class "sys_icon_cpu"))
  (box
    :orientation "v"
    :vexpand "false"
    (label
      :text "cpu"
      :halign "start"
      :class "sys_text_cpu")
    (label
      :text "${round(EWW_CPU.avg,2)}%"
      :halign "start"
      :class "sys_text_sub")
    (label
      :text "${EWW_CPU.cores[0].freq} MHz"
      :halign "start"
      :class "sys_text_sub")))

This is my CPU module, but the same info can be seen from:

(box "${EWW_CPU.cores[0].freq}")

Expected behaviour

The freq property updates once every 2 seconds, as mentioned here.

Additional context

No response

elkowar commented 2 years ago

Well, maybe your CPU frequency just isn't changing? Hard to tell what's going on from jus this. EWW relies on the sysinfo crate, which checks /sys/devices/system/cpu/cpu{}/cpufreq/scaling_cur_freq and then /proc/cpuinfo if the values there don't change, your CPU frequency as reported by eww won't, either.

fufexan commented 2 years ago

I forgot to say, but they do change indeed.

Frequency reported by eww: image

Actual frequency:

› cpupower frequency-info
analyzing CPU 0:
  driver: amd-pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 131 us
  hardware limits: 400 MHz - 4.51 GHz
  available cpufreq governors: conservative performance schedutil
  current policy: frequency should be within 400 MHz and 4.51 GHz.
                  The governor "conservative" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 752 MHz (asserted by call to kernel)
elkowar commented 2 years ago

what about the actual values in the files I mentioned?

fufexan commented 2 years ago
› cat /proc/cpuinfo | rg MHz
cpu MHz     : 1613.536
cpu MHz     : 1088.665
cpu MHz     : 1613.480
cpu MHz     : 400.000
cpu MHz     : 1613.606
cpu MHz     : 400.000
cpu MHz     : 1613.697
cpu MHz     : 851.227
cpu MHz     : 1613.770
cpu MHz     : 1356.705
cpu MHz     : 1172.764
cpu MHz     : 1937.422
cpu MHz     : 748.541
cpu MHz     : 1613.723
cpu MHz     : 1612.869
cpu MHz     : 1005.718
› cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
752379
# other values from re-running the command
1736810
1494734
2254349
1613594
elkowar commented 2 years ago

Do other magic variables work as expected? This seems,... very weird. Does restarting eww (or your computer) somehow fix it?

fufexan commented 2 years ago

Yes, I use EWW_BATTERY["BAT0"].capacity and it works as expected. Even EWW_CPU.avg works fine.

I've tried restarting the program, with daemon and without, but no luck.

elkowar commented 2 years ago

There has been an update that seems to relate to this in the sysinfo dependency, try again with latest master

fufexan commented 2 years ago

I can confirm, it works properly now.

Thanks for fixing the issue so fast!