Enhance ACPI PPTT with cache topology information - #7893
Conversation
21754e3 to
28bd959
Compare
|
Hi @anirudhrb acpi_tables 0.2.1 is now published for you to consume! |
Awesome! Thanks @rbradford! |
28bd959 to
933b032
Compare
|
please fix the CI so we can move this forward |
895189b to
ef15bf9
Compare
|
@anirudhrb What's blocking on this PR - it's still marked as draft |
ef15bf9 to
34157d9
Compare
It was the CI but I've fixed that now. |
|
|
||
| for core_idx in 0..cores_per_package { | ||
| let core_offset = pptt.len() - pptt_start; | ||
| // let core_offset = pptt.len() - pptt_start; |
| @@ -0,0 +1,125 @@ | |||
| // Copyright 2020 Arm Limited (or its affiliates). All rights reserved. | |||
There was a problem hiding this comment.
Is this copyright header accurate?
There was a problem hiding this comment.
Yeah it's copied from fdt.rs since the code is moved from there.
| src_digits | ||
| * match src_unit { | ||
| "K" => 1024, | ||
| "M" => 1024u32.pow(2), |
| "K" => 1024, | ||
| "M" => 1024u32.pow(2), | ||
| "G" => 1024u32.pow(3), | ||
| _ => 1, |
|
|
||
| let file_path = Path::new(&file_directory); | ||
| if file_path.exists() { | ||
| let src = fs::read_to_string(file_directory).expect("File not exists or file corrupted."); |
There was a problem hiding this comment.
Not allowed to panic for "possible" runtime issues (only for programming or really unexpected issues)- need to raise an error.
There was a problem hiding this comment.
Oh. I see this was in the existing code! Bad - you don't need to fix but if you do - do as a separate commit. Otherwise create an issue.
There was a problem hiding this comment.
Yup, all the code in arch/src/aarch64/cache.rs is existing code just extracted to a new file. I'll fix it anyway.
There was a problem hiding this comment.
Created #8097 for this. We'll need to change multiple places outside this file in order to propagate an Error.
|
Since you've got some changes planned i'll draft this. When you've made your changes please undraft and we can take another look! |
596740b to
36d37eb
Compare
There was a problem hiding this comment.
This struct is now unused - please delete it
| num_private_resources: 0, | ||
| }; | ||
| pptt.append(cluster_hierarchy_node); | ||
| use acpi_tables::pptt::ProcessorNode; |
There was a problem hiding this comment.
Use should be at the top of the file or the top of the test mod if test only.
5b76aaa to
e653eba
Compare
|
I think some reordering of the commits might improve the bisectability/churn: What about: |
e653eba to
f1d642f
Compare
Done! |
rbradford
left a comment
There was a problem hiding this comment.
Really close - just dubious warn!
| // Add cache info. | ||
| let cache_info = read_cache_topology(); | ||
| if cache_info.is_none() { | ||
| warn!("cache sysfs system does not exist."); |
There was a problem hiding this comment.
Nit this warning does not look like anything else in the repo (capitalizatiom, etc. Shouldn't this just error out instead?
There was a problem hiding this comment.
This warning is the same as the one in fdt.rs. I don't think we should error out - we can continue without the cache topology info.
There was a problem hiding this comment.
Okay the style just needs to match the rest of the repo (this may not have been something you introduced but the review made it visible.)
|
@anirudhrb Ping? Any progress update on this? |
I was able to get my hands on the image. Looking into the issue. I'll un-draft when ready. |
|
@anirudhrb Any update on this? |
|
@rbradford I still don't have an environment where I can reproduce this issue. The one KVM box I have is somehow not able to boot the Windows images we use here. I'll try with another one. |
bb8d17c to
063da72
Compare
|
@rbradford some progress finally! I now have a repro environment and I ran some experiments using copilot. Turns out Windows breaks when I use PPTT revision 3 with 28 byte cache nodes. Changing it to revision 2 (with 24 byte cache nodes - no cache ID) makes Windows happy. I suspect we have slightly old build in our CI which doesn't support PPTT revision 3. I'm planning to modify the acpi_tables crate to support rev 2 as well and then update this PR to use rev 2. |
Or we could have a newer Windows image? (I would like a named individual or team to own Windows guest support for CH). I'm happy to just disable that test for ARM64 windows support in the interim. |
Yeah that's one way forward. @weltling what do you think of this? Is it possible to update the Windows image anytime soon? @rbradford are you against the approach of presenting revision 2 PPTT nodes from Cloud Hypervisor? |
No, i'm not against that - I was just offering you alternative options to help you move forward. This PR has been open a long time with not much progress recently. It was obviously an important feature to you since you took the time to open it and implement it. |
@anirudhrb @rbradford Unfortunately I lost the Windows guest image for aarch64 topic from the radar. I will plan to come up with a new image till the end of this month, if it's acceptable. Thanks |
|
@rbradford if we want to temporarily disable tests, we'll have to disable all Windows tests on arm64. Because Windows doesn't boot at all with these changes. |
|
I've rebased as @weltling has updated the windows ARM image. |
Use the helpers from the acpi_tables crate to construct the PPTT. This is in preparation for adding cache hierarchy info to the PPTT which is simpler using the helpers. Signed-off-by: Anirudh Rayabharam <[email protected]>
fdt.rs has helper functions to query host cache details (topology, size etc.). Extract these helpers to a new file cache.rs so that they can be used for PPTT construction as well. No functional change. Signed-off-by: Anirudh Rayabharam <[email protected]>
Replace 1024, 1024u32.pow(2), and 1024u32.pow(3) with 1u32 << 10, 1u32 << 20, and 1u32 << 30 in get_cache_size. The shift form makes the binary (KiB/MiB/GiB) nature of the conversion immediately obvious and is easier to read at a glance. Signed-off-by: Anirudh Rayabharam <[email protected]>
Both arch/src/aarch64/fdt.rs and vmm/src/cpu.rs declared the same ~14 cache info locals (size/line_size/sets for L1D/L1I/L2/L3, plus shared flags for L2/L3), checked for /sys/devices/system/cpu/cpu0/cache, and populated those locals via get_cache_size / get_cache_coherency_line_size / get_cache_number_of_sets / get_cache_shared. Two near-identical ~30-line blocks. Add a CacheTopologyInfo struct in arch/src/aarch64/cache.rs whose field names mirror the existing locals, plus a read_cache_topology() helper that returns None when the sysfs hierarchy is missing and only queries get_cache_shared for L2/L3 when their size is non-zero (preserving current behavior). Both call sites now obtain the info via read_cache_topology() and destructure it back into locals of the same name, so all downstream references are unchanged. Assisted-by: Copilot-CLI:Claude-Opus-4.7 Signed-off-by: Anirudh Rayabharam <[email protected]>
Read the host cache info from sysfs and pass through the same to the guest via the PPTT table. This is the same as the approach taken for FDT. Similar to that, assume that the L3 cache is always shared and the L2 cache is unique per CPU. Signed-off-by: Anirudh Rayabharam <[email protected]>
Add an integration test to verify the newly added code to expose cache topology information in PPTT. Signed-off-by: Anirudh Rayabharam <[email protected]>
Closes #7761
This pull request refactors and enhances the handling of CPU cache topology information for aarch64. It moves cache information utilities into a dedicated module, updates the ACPI PPTT (Processor Properties Topology Table) construction to include detailed cache hierarchy data, and adds an integration test to verify that cache topology is correctly exposed to guests. Additionally, it updates dependencies and improves code organization.
Aarch64 cache topology refactor and enhancements:
CacheLevelenum fromfdt.rsto a newarch/src/aarch64/cache.rsmodule, and updated imports accordingly for better code organization and reuse.CpuManager::create_ppttto use the new cache module, and now populates the PPTT with detailed cache hierarchy (L1d, L1i, L2, L3) information as available from sysfs, using theacpi_tablescrate's PPTT API.Testing and validation:
test_cache_topology) to verify that the guest sees the same cache sizes as the host, ensuring the PPTT and cache information are correctly exposed.Other improvements:
acpi_tablescrate.