-
Notifications
You must be signed in to change notification settings - Fork 29
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
Cross-platform CPU frequencies #690
Comments
Hi, I'm just looking around and have one quick question: The result from Given that the fallback option - if all else fails - is guessing a specific frequency of around 2 GHz (when testing P.S. Feel free to assign this issue to me, I'll submit a PR in June. |
Oh, and one more thing: As I'm not sure what the meaning of that value is, I am also not 100% sure if |
Eventually, that number ends up in the kernel (src/arch/x86_64/kernel/processor.rs#L99-L105), where different strategies (src/arch/x86_64/kernel/processor.rs#L478-L496) are used for determining the processor frequency. As far as I know, this is mostly used for determining time durations via the CPU timestamp, which is CPU frequency dependent. So the more accurate the resulting time duration is, the better.
I am not sure which one is better. I don't know if |
It does. I did a rough test by changing my laptop from "Power Saving Mode" to "Performance Mode" and could see the difference in a PoC (hence the Based on Line 216 in 2afc95f
|
- This is a work-in-progress. * This change has not been tested on aarch64, for which it is primarily intended for. (See hermit-os#690) * sysinfo returns a u64 value, which we then try to fit into u32 (because the alternative methods of getting a frequency value return a u32), this may not be clean. * The frequency is not all that useful (after all, if we pass a value of 0, running `rusty_demo` will result in a "guessed" frequency), but sysinfo returns a base frequency that has a completely different "meaning" than the value returned by CPUID on x86_64. * Do we use sysinfo by default on x86_64 as well? The alternative methods of obtaining the frequency would be essentially turned into "dead code". - Add detect_freq_from_sysinfo() Shows a real-time value of the base frequency, similarly to /proc/cpuinfo on Linux. Using sysinfo as an alternative to the CPUID-provided value may be useful for some systems where the CPUID feature is not available. A potential flaw of this implementation is that the frequency is passed once to before the initialization of the kernel and cannot be changed later. If the host system is in "power-saving mode" (e.g. in laptops) and then switches to "performance mode", the application will not have any knowledge of this change. IIRC, Jonathan thinks this is OK for now. - Use sysinfo by default on x86_64 instead of CPUID. Currently for demonstration reasons, we may want to amend this in a later revision. Fixes: hermit-os#690
- This is a work-in-progress. * This change has not been tested on aarch64, for which it is primarily intended for. (See hermit-os#690) * sysinfo returns a u64 value, which we then try to fit into u32 (because the alternative methods of getting a frequency value return a u32), this may not be clean. * The frequency is not all that useful (after all, if we pass a value of 0, running `rusty_demo` will result in a "guessed" frequency), but sysinfo returns a base frequency that has a completely different "meaning" than the value returned by CPUID on x86_64. * Do we use sysinfo by default on x86_64 as well? The alternative methods of obtaining the frequency would be essentially turned into "dead code". - Add detect_freq_from_sysinfo() Shows a real-time value of the base frequency, similarly to /proc/cpuinfo on Linux. Using sysinfo as an alternative to the CPUID-provided value may be useful for some systems where the CPUID feature is not available. A potential flaw of this implementation is that the frequency is passed once to before the initialization of the kernel and cannot be changed later. If the host system is in "power-saving mode" (e.g. in laptops) and then switches to "performance mode", the application will not have any knowledge of this change. IIRC, Jonathan thinks this is OK for now. - Use sysinfo by default on x86_64 instead of CPUID. Currently for demonstration reasons, we may want to amend this in a later revision. Fixes: hermit-os#690
- Add detect_freq_from_sysinfo() Shows a real-time value of the base frequency, similarly to /proc/cpuinfo on Linux. Using sysinfo as an alternative to the CPUID-provided value may be useful for some systems where the CPUID feature is not available. A potential flaw of this implementation is that the frequency is passed once to before the initialization of the kernel and cannot be changed later. If the host system is in "power-saving mode" (e.g. in laptops) and then switches to "performance mode", the application will not have any knowledge of this change. IIRC, Jonathan thinks this is OK for now. - Use sysinfo by default on x86_64 instead of CPUID. Fixes: hermit-os#690
We might want to explore
sysinfo
for getting CPU frequencies from the OS instead of parsing CPUID (x86 only) ourselves. See hermit-os/kernel/xtask/src/ci/qemu.rs#L283-L291 for example.The text was updated successfully, but these errors were encountered: