Skip to content

Commit 100b2b9

Browse files
committed
self pr feedback
1 parent 268f11e commit 100b2b9

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

openhcl/openhcl_boot/src/host_params/dt/dma_hint.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ const LOOKUP_TABLE: &[(u16, u16, u16); 38] = &[
6666
(64, 924, 68),
6767
(64, 938, 68),
6868
(96, 1030, 64),
69-
(96, 1042, 114), // Can be '64'.
70-
(96, 1058, 114), // Can be '106'.
69+
(96, 1042, 114), // There is another 96vp/1042MB configuration that only requires 64 MB of DMA memory, pick the larger.
70+
(96, 1058, 114), // There is another 96vp/1058MB configuration that only requires 106 MB of DMA memory, pick the larger.
7171
(96, 1340, 102),
7272
(96, 1358, 104),
7373
(96, 1382, 120),
7474
(112, 1566, 288),
7575
(128, 1342, 84),
7676
(128, 1360, 84),
77-
(896, 12912, 0), // (516) Needs to be validated as the vNIC number is unknown.
77+
(896, 12912, 0), // (516) Needs to be validated as the vNIC number is unknown. (TODO, as part of network device keepalive support).
7878
];
7979

8080
const ONE_MB: u64 = 1024 * 1024;
@@ -170,15 +170,15 @@ pub fn vtl2_calculate_dma_hint(vp_count: usize, mem_size: u64) -> u64 {
170170
min_vtl2_memory_mb = min_vtl2_memory_mb.min(*vtl2_memory_mb);
171171
max_vtl2_memory_mb = max_vtl2_memory_mb.max(*vtl2_memory_mb);
172172
min_ratio_1000th =
173-
min_ratio_1000th.min(*vtl2_memory_mb as u32 * 1000 / *dma_hint_mb as u32);
173+
min_ratio_1000th.min(*vtl2_memory_mb as u32 * RATIO / *dma_hint_mb as u32);
174174
max_ratio_1000th =
175-
max_ratio_1000th.max(*vtl2_memory_mb as u32 * 1000 / *dma_hint_mb as u32);
175+
max_ratio_1000th.max(*vtl2_memory_mb as u32 * RATIO / *dma_hint_mb as u32);
176176
});
177177
}
178178

179179
if dma_hint_4k == 0 {
180180
// Didn't find an exact match for vp_count, try to extrapolate.
181-
dma_hint_4k = (mem_size_mb as u64 * 1000u64 * (ONE_MB / PAGE_SIZE_4K))
181+
dma_hint_4k = (mem_size_mb as u64 * RATIO as u64 * (ONE_MB / PAGE_SIZE_4K))
182182
/ ((min_ratio_1000th + max_ratio_1000th) as u64 / 2u64);
183183

184184
// And then round up to 2MiB.

openhcl/openhcl_boot/src/host_params/dt/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,8 @@ fn topology_from_host_dt(
534534

535535
if dt_page_count.is_some() || cmdline_page_count.is_some() {
536536
// Any external source defined the pool size, use the maximum of all external sources.
537-
// todo: make sure that Some(0) is treated correctly
538537
max(dt_page_count.unwrap_or(0), cmdline_page_count.unwrap_or(0))
539538
} else {
540-
// todo mattkur
541-
542539
// No external source defined the pool size, use heuristics to decide.
543540
let mem_size = vtl2_ram.iter().map(|e| e.range.len()).sum();
544541
vtl2_calculate_dma_hint(parsed.cpu_count(), mem_size)

openhcl/openhcl_dma_manager/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,14 @@ impl OpenhclDmaManager {
332332
vtom: u64,
333333
isolation_type: virt::IsolationType,
334334
) -> anyhow::Result<Self> {
335+
tracing::info!(
336+
?shared_ranges,
337+
?private_ranges,
338+
vtom,
339+
?isolation_type,
340+
"create dma manager"
341+
);
342+
335343
let shared_pool = if shared_ranges.is_empty() {
336344
None
337345
} else {

0 commit comments

Comments
 (0)