hermit-os / uhyve

A specialized hypervisor for Hermit.
Apache License 2.0
254 stars 29 forks source link

sysinfo: Add new frequency detection method #701

Closed n0toose closed 2 months ago

n0toose commented 3 months ago

This is a proof-of-concept, there is some more testing necessary and some questions as to how this feature should be implemented: https://github.com/hermit-os/uhyve/issues/690

TODOs

I don't think that there's a "serious" case where it would return a zero, so this would technically turn the alternatives (e.g. CPUID) into dead code 99.99% of the time.

Nice-to-haves


Fixes: https://github.com/hermit-os/uhyve/issues/690

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 71.73913% with 13 lines in your changes missing coverage. Please review.

Project coverage is 67.03%. Comparing base (f8b1426) to head (11f5a44).

Files Patch % Lines
src/vm.rs 71.42% 12 Missing :warning:
src/arch/mod.rs 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #701 +/- ## ========================================== - Coverage 68.17% 67.03% -1.15% ========================================== Files 20 21 +1 Lines 2319 2357 +38 ========================================== - Hits 1581 1580 -1 - Misses 738 777 +39 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

n0toose commented 3 months ago

Oops, test fails because I forgot to move the proof-of-concept sysinfo function into the aarch64 variant. It should work locally on x86_64.

n0toose commented 3 months ago

I'm not sure if "Draft" PRs in the context of hermit-os are interpreted as "Please don't look at this / review this PR (yet)" or "This needs some extra work before it can be merged" (as I've seen both in the context of OSS projects before). In my case, this PR needs some extra work and could benefit from feedback. I have the following question before finalizing this PR:

How do we deal with sysinfo on x86_64? (Do we use sysinfo instead of CPUID, or should it be exclusively an aarch64 thing? If yes, do we throw out the CPUID code?)

This is not urgent or a call for attention - just a clarification of my intentions and why the PR has stalled. I'll work on something else in the meantime :)

jounathaen commented 3 months ago
  • [ ] Does this work on aarch64 (Raspberry Pi)?

I assume it does. Looks like your approach is fine.

  • [ ] How do we deal with sysinfo on x86_64? (Do we use sysinfo instead of CPUID, or should it be exclusively an aarch64 thing? If yes, do we throw out the CPUID code?)

I like the current approach you've taken

I don't see a conflict here.

  • [ ] FrequencyDetectionFailed duplication?

True. You should create an error outside of the arch mods and import it in arch::x86...

  • [ ] Better design, so that we don't have to convert u64 into u32?
    • Possibly negligible, the current test suite does not expect frequencies over

As written above, this is fine as is

n0toose commented 3 months ago

Apparently, the example of "would it brake on macos-latest" was not a hypothetical - the test would fail in that case, because the frequency value is not OK (see action). This should have been fixed here and perhaps warrants some further investigation before merging: https://github.com/GuillaumeGomez/sysinfo/pull/1023

https://github.com/hermit-os/uhyve/pull/701#discussion_r1662674228