Merge branch 'night/stream' into local/next
This commit is contained in:
commit
57a8ff2214
5 files changed
+505
-29
No files matched your search
@@ -919,6 +919,15 @@ extern "system" fn copy_page_mappings(
|
||||
unsafe { std::slice::from_raw_parts(batches, count as usize) }
|
||||
});
|
||||
let mut ok = true;
|
||||
let many = crate::resource::many_page_mapper();
|
||||
let mut gathered: Vec<(u64, u64, u64)> = Vec::new();
|
||||
let mut map = |to: u64, from: u64, len: u64| match many {
|
||||
Some(_) => {
|
||||
gathered.push((to, from, len));
|
||||
true
|
||||
}
|
||||
None => map(to, from, len),
|
||||
};
|
||||
for b in batches.into_iter().flatten() {
|
||||
if b.ranges.is_null() {
|
||||
continue;
|
||||
@@ -940,6 +949,9 @@ extern "system" fn copy_page_mappings(
|
||||
at += len;
|
||||
}
|
||||
}
|
||||
if let Some(many) = many {
|
||||
ok &= many(&gathered);
|
||||
}
|
||||
if !ok {
|
||||
static ONCE: std::sync::Once = std::sync::Once::new();
|
||||
ONCE.call_once(|| tracing::warn!(pool = format_args!("{pool:#x}"), "a page mapping failed"));
|
||||
|
||||
@@ -961,6 +961,20 @@ pub fn use_page_mapper(mapper: PageMapper) {
|
||||
let _ = PAGE_MAPPER.set(mapper);
|
||||
}
|
||||
|
||||
/// As a [`PageMapper`], many at once: `(to, from, len)` each, in order.
|
||||
pub type ManyPageMapper = fn(&[(u64, u64, u64)]) -> bool;
|
||||
|
||||
static MANY_PAGE_MAPPER: std::sync::OnceLock<ManyPageMapper> = std::sync::OnceLock::new();
|
||||
|
||||
/// The runtime's mapper of many pages at once.
|
||||
pub fn use_many_page_mapper(mapper: ManyPageMapper) {
|
||||
let _ = MANY_PAGE_MAPPER.set(mapper);
|
||||
}
|
||||
|
||||
pub(crate) fn many_page_mapper() -> Option<ManyPageMapper> {
|
||||
MANY_PAGE_MAPPER.get().copied()
|
||||
}
|
||||
|
||||
pub(crate) fn page_mapper() -> Option<PageMapper> {
|
||||
PAGE_MAPPER.get().copied()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user