membacking: label memory regions for smaps debugging#3041
membacking: label memory regions for smaps debugging#3041jstarks merged 3 commits intomicrosoft:mainfrom
Conversation
Add SparseMapping::set_name() using prctl(PR_SET_VMA_ANON_NAME) on Linux
to label anonymous mappings in /proc/{pid}/smaps. No-op on non-Linux
platforms and Windows. Label the guest memory VA reservation as
'guest-memory' and private RAM allocations as 'guest-ram-private'.
Also add a name parameter to alloc_shared_memory() so memfd_create uses
descriptive names visible as /memfd:<name> in smaps: guest-ram, rom,
vram, page-pool.
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
There was a problem hiding this comment.
Pull request overview
Adds optional, platform-appropriate naming for memory mappings to improve /proc/{pid}/smaps readability during debugging, and threads descriptive names through shared-memory allocation sites.
Changes:
- Add
SparseMapping::set_name()(Linuxprctl(PR_SET_VMA_ANON_NAME); no-op elsewhere) and use it to label guest VA reservations and private RAM allocations. - Extend
alloc_shared_memory()to accept anameso Linuxmemfd_createproduces descriptive/memfd:<name>entries. - Update call sites (tests/fuzz/OpenVMM/petri/page-pool) to pass appropriate mapping names (e.g.,
vram,rom,page-pool,guest-ram).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/page_pool_alloc/src/lib.rs | Passes a descriptive name (page-pool) into shared-memory allocation for smaps visibility. |
| support/sparse_mmap/src/windows.rs | Adds SparseMapping::set_name no-op and updates alloc_shared_memory signature to accept (ignored) name. |
| support/sparse_mmap/src/unix.rs | Implements Linux set_name via prctl, and threads name into memfd_create (and signature updates). |
| support/sparse_mmap/src/lib.rs | Updates tests to use new alloc_shared_memory(size, name) signature. |
| support/sparse_mmap/fuzz/fuzz_sparse_mmap.rs | Updates fuzz target to use new shared-memory allocation signature. |
| petri/src/vm/openvmm/construct.rs | Names VRAM shared memory (vram) for smaps debugging. |
| openvmm/openvmm_entry/src/lib.rs | Names VRAM shared memory (vram) for smaps debugging in CLI-driven VM construction. |
| openvmm/openvmm_core/src/worker/rom.rs | Names ROM shared memory (rom) for smaps debugging. |
| openvmm/membacking/src/memory_manager/mod.rs | Names guest RAM memfd (guest-ram) and private RAM anonymous mappings (guest-ram-private). |
| openvmm/membacking/src/mapping_manager/va_mapper.rs | Labels the guest VA reservation as guest-memory and exposes set_range_name(). |
You can also share your feedback on Copilot code review. Take the survey.
smalis-msft
left a comment
There was a problem hiding this comment.
Windows doesn't offer a similar feature? Unfortunate.
There was a problem hiding this comment.
Pull request overview
Adds smaps-friendly naming for guest memory mappings to improve debugging of OpenVMM memory usage on Linux, while keeping behavior as a no-op on non-Linux/Windows.
Changes:
- Introduce
SparseMapping::set_name()(Linux viaprctl(PR_SET_VMA_ANON_NAME), no-op elsewhere) and apply it to guest VA reservations and private RAM allocations. - Extend
alloc_shared_memory()to accept a descriptivenameand pass it through to Linuxmemfd_create()(ignored on Windows / non-Linux Unix). - Update call sites (OpenVMM, Petri, fuzz/tests) to provide descriptive names (e.g.,
guest-ram,rom,vram,page-pool).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vm/page_pool_alloc/src/lib.rs | Passes "page-pool" into alloc_shared_memory() for clearer memfd naming. |
| support/sparse_mmap/src/windows.rs | Adds no-op set_name() and updates alloc_shared_memory() signature to accept a name (ignored). |
| support/sparse_mmap/src/unix.rs | Implements Linux set_name() via prctl and threads name through memfd_create() / shm_open path. |
| support/sparse_mmap/src/lib.rs | Updates unit test to use new alloc_shared_memory(size, name) API. |
| support/sparse_mmap/fuzz/fuzz_sparse_mmap.rs | Updates fuzz harness to pass a name into alloc_shared_memory(). |
| petri/src/vm/openvmm/construct.rs | Names VRAM shared memory "vram". |
| openvmm/openvmm_entry/src/lib.rs | Names VRAM shared memory "vram" for smaps visibility. |
| openvmm/openvmm_core/src/worker/rom.rs | Names ROM backing shared memory "rom". |
| openvmm/membacking/src/memory_manager/mod.rs | Names guest RAM shared memory "guest-ram" and labels private RAM ranges "guest-ram-private". |
| openvmm/membacking/src/mapping_manager/va_mapper.rs | Labels the VA reservation "guest-memory" and exposes set_range_name(). |
You can also share your feedback on Copilot code review. Take the survey.
chris-oo
left a comment
There was a problem hiding this comment.
other than stevens' comment about the CString conversion should never fail, LGTM. neat stuff
Add SparseMapping::set_name() using prctl(PR_SET_VMA_ANON_NAME) on Linux to label anonymous mappings in /proc/{pid}/smaps. No-op on non-Linux platforms and Windows. Label the guest memory VA reservation as 'guest-memory' and private RAM allocations as 'guest-ram-private'.
Also add a name parameter to alloc_shared_memory() so memfd_create uses descriptive names visible as /memfd: in smaps: guest-ram, rom, vram, page-pool.