Skip to content

Commit 96754b8

Browse files
committed
Add signal-based dirty page tracker for tracking host-memory-writes into shared memory.
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent ea6be2e commit 96754b8

File tree

7 files changed

+1460
-0
lines changed

7 files changed

+1460
-0
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hyperlight_host/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ anyhow = "1.0"
4444
metrics = "0.24.2"
4545
serde_json = "1.0"
4646
elfcore = "2.0"
47+
lockfree ="0.5"
4748

4849
[target.'cfg(windows)'.dependencies]
4950
windows = { version = "0.61", features = [
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright 2025 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
use tracing::{Span, instrument};
18+
19+
#[cfg(target_os = "linux")]
20+
pub use super::linux_dirty_page_tracker::LinuxDirtyPageTracker as PlatformDirtyPageTracker;
21+
use super::shared_mem::SharedMemory;
22+
#[cfg(target_os = "windows")]
23+
pub use super::windows_dirty_page_tracker::WindowsDirtyPageTracker as PlatformDirtyPageTracker;
24+
use crate::Result;
25+
26+
/// Trait defining the interface for dirty page tracking implementations
27+
pub trait DirtyPageTracking {
28+
fn get_dirty_pages(self) -> Result<Vec<usize>>;
29+
}
30+
31+
/// Cross-platform dirty page tracker that delegates to platform-specific implementations
32+
pub struct DirtyPageTracker {
33+
inner: PlatformDirtyPageTracker,
34+
}
35+
36+
impl DirtyPageTracker {
37+
/// Create a new dirty page tracker for the given shared memory
38+
#[instrument(skip_all, parent = Span::current(), level = "Trace")]
39+
pub fn new<T: SharedMemory>(shared_memory: &T) -> Result<Self> {
40+
let inner = PlatformDirtyPageTracker::new(shared_memory)?;
41+
Ok(Self { inner })
42+
}
43+
}
44+
45+
impl DirtyPageTracking for DirtyPageTracker {
46+
fn get_dirty_pages(self) -> Result<Vec<usize>> {
47+
self.inner.get_dirty_pages()
48+
}
49+
}

0 commit comments

Comments
 (0)