Coder Social home page Coder Social logo

Comments (15)

SuperQ avatar SuperQ commented on May 13, 2024 1

@jberryman Yes, it's very complicated, as there's a lot of trickery going on under the hood in the hardware to perform power and thermal envelope management between cores and other parts of the chip. I don't have any specific documentation links off the top of my head. But I would look around for documentation on the various kernel modules that implement the changes. Things like intel_cstate.

from procfs.

mjtrangoni avatar mjtrangoni commented on May 13, 2024

@fbegyn I checked it out, and found that cpuinfo_cur_freq is only readable by root, which is not allowed here, as the node_exporter should be run as user.

See,

# ll /sys/devices/system/cpu/cpu0/cpufreq/*
-r--r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/affected_cpus
-r--------. 1 root root 4096 Dec  6 09:42 /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
-r--r--r--. 1 root root 4096 Dec  6 09:42 /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
-r--r--r--. 1 root root 4096 Dec  6 09:42 /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
-r--r--r--. 1 root root 4096 Dec  6 09:42 /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency
-r--r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/related_cpus
-r--r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
-r--r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
-r--r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
-rw-r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
-rw-r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
-rw-r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
-rw-r--r--. 1 root root 4096 Dec  6 09:46 /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# grep . /sys/devices/system/cpu/cpu0/cpufreq/{cpuinfo_cur_freq,scaling_cur_freq}
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq:1200103
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:1200103

from procfs.

SuperQ avatar SuperQ commented on May 13, 2024

Interesting, honestly, I didn't look that closely at the documentation. I assumed they were the same, just a rename between different kernel versions. We originally changed the reading preference to work around bugs in the RHEL kernel permissions for the proc file.

@mjtrangoni That's an old redhat kernel bug, on the upstream kernel and more recent patch versions of the RHEL kernel, the permission problem is fixed.

I guess we need to re-read the kernel docs more carefully.

/cc @rtreffer

from procfs.

fbegyn avatar fbegyn commented on May 13, 2024

Discovered it while comparing node-exporter metrics from a few months ago with the current ones because we couldn't make sense of it. We changed cpu goverenor to perormance but didn't see the change on the metrics. While the expected behaviour did show up in the data a from a few months ago, it didn't now.
Couldn't wrap my head around it, so dove into the kernel a bit and found this out.

I'm not fully comprehending the use for scaling_cur_freq, but definitely see a usecase for cpuinfo_cur_freq.

from procfs.

SuperQ avatar SuperQ commented on May 13, 2024

I'll have to review the docs, but after first glance, you're probably right. We shouldn't be using the scaling_ files. sigh

Totally unrelated, performance on Intel doesn't really do what you expect on modern cores. It still uses sleep states to throttle down the CPU. Basically it's a noop on sandy bridge and newer from my testing.

from procfs.

mjtrangoni avatar mjtrangoni commented on May 13, 2024

@SuperQ This is read-only upstream now. See,

$ nl -b a drivers/cpufreq/cpufreq.c|grep -B5 -A5 "cpuinfo_cur_freq, 0400"
   868                          return sprintf(buf, "%u\n", limit);
   869          }
   870          return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
   871  }
   872
   873  cpufreq_freq_attr_ro_perm(cpuinfo_cur_freq, 0400);
   874  cpufreq_freq_attr_ro(cpuinfo_min_freq);
   875  cpufreq_freq_attr_ro(cpuinfo_max_freq);
   876  cpufreq_freq_attr_ro(cpuinfo_transition_latency);
   877  cpufreq_freq_attr_ro(scaling_available_governors);
   878  cpufreq_freq_attr_ro(scaling_driver);

And here Dave Jones says why,

Reading this file causes reads from hardware on some cpufreq drivers.
This can be a slow operation, so a user could degrade system performance
for everyone else by repeatedly cat'ing it.

from procfs.

SuperQ avatar SuperQ commented on May 13, 2024

@mjtrangoni I think a number of distributions patch that file.

Looking at a couple of my machines, it appears cpuinfo_cur_freq doesn't even exist on on them (>= 4.15).

It seems like my systems have the pcc_cpufreq0 module loaded.

from procfs.

knweiss avatar knweiss commented on May 13, 2024

@SuperQ FWIW, quoting Documentation/admin-guide/pm/cpufreq.rst:

cpuinfo_cur_freq
        Current frequency of the CPUs belonging to this policy as obtained from
        the hardware (in KHz).

        This is expected to be the frequency the hardware actually runs at.
!       If that frequency cannot be determined, this attribute should not
!       be present.

from procfs.

SuperQ avatar SuperQ commented on May 13, 2024

@fbegyn Out of curiosity, what platform/driver are you using?

from procfs.

SuperQ avatar SuperQ commented on May 13, 2024

Since the scaling_cur_freq and cpuinfo_cur_freq contain different data, I think we should change the library to read both, and return float pointers if values are found.

from procfs.

SuperQ avatar SuperQ commented on May 13, 2024

I've created #123 as a possible solution.

from procfs.

fbegyn avatar fbegyn commented on May 13, 2024

@fbegyn Out of curiosity, what platform/driver are you using?

@SuperQ Westmere CPUs and Debian 9 (I believe on 4.18 kernel). Personal system is Dell XPS13 9360 on 4.19

from procfs.

pgier avatar pgier commented on May 13, 2024

Is there anything more to do on this issue since #123 has been merged?

from procfs.

fbegyn avatar fbegyn commented on May 13, 2024

@pgier I don't think so. I lost track of this issue, but I'm closing it in relation to #123

from procfs.

jberryman avatar jberryman commented on May 13, 2024

@SuperQ

Totally unrelated, performance on Intel doesn't really do what you expect on modern cores. It still uses sleep states to throttle down the CPU. Basically it's a noop on sandy bridge and newer from my testing.

This is OT but do you have any more details here? On Ivy Bridge I've been trying to figure out how to get a stable cpu frequency for benchmarking (or even figure out how to know if I'm getting a stable clock speed).

I found setting the governor to performance stabilized performance somewhat in my benchmarks (and made things significantly faster), but the various metrics from /sys/... or /proc/cpuinfo are showing cpu frequency bouncing around wildly still.

There seems to be a lot of misinformation about all of this out there...

from procfs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.