🎨 Say once why a device has no Shared pool
A device with no Shared pool offers the guest no POOL, and so no SURFACE_CACHE_EVERY and no MANAGED_AT_COPY. Only one of the ways to lose the pool logged a line: a GPU that answers no memory heap. A host that gave the device no guest addresses for one, which QEMU does on a machine with no room for it, and a Windows host with an arm64 guest logged nothing, so a run's log did not show why the guest went without the pool. The device now writes one warning at its start in each of those cases, saying which of them it is and what the device does not offer. The no-heap warning is folded into it. The tests pin the line of a device given no addresses, and that a device with a pool writes none.
This commit is contained in:
1 parent
85e26b3caf
commit
d844ae9f9f
4 files changed
+103
-9
No files matched your search
@@ -461,13 +461,11 @@ fn pool_host(config: &GraphicsConfig) -> Result<Option<(PoolConfig, PoolHost)>,
|
||||
|
||||
/// The range the device's pool takes of `room`, the addresses the host can give it, on a GPU
|
||||
/// whose memory heaps hold `heaps` bytes, every heap summed ([`PoolConfig::sized`]), logged once
|
||||
/// a device, with the room's size: with a warning where the GPU answers no heap, and so no pool,
|
||||
/// or where the room holds less than the heaps, and the range stops at the room's end.
|
||||
/// a device, with the room's size: with a warning where the room holds less than the heaps, and
|
||||
/// the range stops at the room's end. `None`, and no pool, where the GPU answers no heap, which
|
||||
/// the device's line of no pool says ([`no_pool`]).
|
||||
fn pool_range(room: PoolConfig, heaps: u64) -> Option<PoolConfig> {
|
||||
let Some(range) = room.sized(heaps) else {
|
||||
log::warn!("pool: the GPU answers no memory heap: the guest has no Shared pool");
|
||||
return None;
|
||||
};
|
||||
let range = room.sized(heaps)?;
|
||||
if range.physical_length < heaps {
|
||||
log::warn!(
|
||||
"pool: the guest's {} MiB of addresses at {:#x} hold less than the GPU's {} MiB of \
|
||||
@@ -488,6 +486,26 @@ fn pool_range(room: PoolConfig, heaps: u64) -> Option<PoolConfig> {
|
||||
Some(range)
|
||||
}
|
||||
|
||||
/// Why the device offers the guest no Shared pool, of a device whose host gave it addresses for
|
||||
/// one (`given`, [`GraphicsConfig::pool`]), whose GPU's memory heaps took a range of them
|
||||
/// (`ranged`, [`pool_range`]) and which offers it (`offered`, `POOL`); `None` where it offers one.
|
||||
/// The device writes it once, at its start, at warn: without the pool it offers no `POOL`, and
|
||||
/// so no `SURFACE_CACHE_EVERY` ([`cache_every`]) and no `MANAGED_AT_COPY` ([`managed_at_copy`]).
|
||||
/// QEMU gives no addresses on a machine that is neither a PC machine (an x86 target whose PCI
|
||||
/// host answers `pci-hole64-end`) nor vmapple, on a vmapple machine whose room is 0, and on a PC
|
||||
/// machine where no whole GiB of addresses lies from the end of the PCI host's 64-bit window to
|
||||
/// the top quarter of the guest's physical addresses (under KVM and WHPX, to the host's at most)
|
||||
/// (`reims_graphics_pool_room` and `reims_graphics_pool_room_machine` in
|
||||
/// `hw/display/reims-graphics-pci.c`); a Windows host offers the pool to an x86-64 guest alone.
|
||||
fn no_pool(given: bool, ranged: bool, offered: bool) -> Option<&'static str> {
|
||||
match (given, ranged, offered) {
|
||||
(_, _, true) => None,
|
||||
(false, _, false) => Some("the host gave the device no guest addresses for one"),
|
||||
(true, false, false) => Some("the GPU answers no memory heap"),
|
||||
(true, true, false) => Some("a Windows host offers one to an x86-64 guest alone"),
|
||||
}
|
||||
}
|
||||
|
||||
/// The reims-graphics device.
|
||||
pub struct GraphicsDevice<P: ApiPlatform = DefaultPlatform> {
|
||||
/// The displays' windows, display `i`'s at index `i`, none without them, which close when
|
||||
@@ -596,6 +614,17 @@ impl<P: ApiPlatform> GraphicsDevice<P> {
|
||||
let pool_ledger = (shared_pool.as_ref())
|
||||
.filter(|_| !cfg!(windows) || config.guest_arch == GuestArch::X86_64)
|
||||
.map(Pool::ledger);
|
||||
// The one line of a device with no pool, whatever kept it from one.
|
||||
if let Some(why) = no_pool(
|
||||
config.pool.is_some(),
|
||||
shared_pool.is_some(),
|
||||
pool_ledger.is_some(),
|
||||
) {
|
||||
log::warn!(
|
||||
"pool: the guest has no Shared pool: {why}; the device offers no POOL, \
|
||||
SURFACE_CACHE_EVERY or MANAGED_AT_COPY"
|
||||
);
|
||||
}
|
||||
// `Managed` resources are one copy where the platform answers that the GPU shares the
|
||||
// CPU's memory, else two, which hold Metal's contract on any GPU: the guest's device
|
||||
// answers `hasUnifiedMemory` alike, from the blob.
|
||||
|
||||
@@ -13621,6 +13621,66 @@ fn the_pool_s_range_is_the_gpu_s_memory_heaps_at_most_the_addresses_given() {
|
||||
assert_eq!(headless(&raised).pool_range(), None);
|
||||
}
|
||||
|
||||
/// A device with no Shared pool writes one warning at its start that says why, whatever kept it
|
||||
/// from one; a device with a pool writes none
|
||||
#[test]
|
||||
fn a_device_with_no_pool_warns_once_at_its_start_with_why() {
|
||||
let no_pool_lines = |lines: Vec<reims_vgpu_vulkan::core::testkit::logs::Line>| {
|
||||
(lines.into_iter())
|
||||
.filter(|(level, _, line)| {
|
||||
*level == log::Level::Warn && line.starts_with("pool: the guest has no Shared pool")
|
||||
})
|
||||
.map(|(_, target, line)| (target, line))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
let logs = reims_vgpu_vulkan::core::testkit::logs::capture();
|
||||
let raised = Arc::new(AtomicU32::new(0));
|
||||
let device = headless(&raised);
|
||||
assert_eq!(device.pool_range(), None);
|
||||
assert_eq!(
|
||||
no_pool_lines(logs.take()),
|
||||
[(
|
||||
"reims_vgpu::graphics".to_owned(),
|
||||
"pool: the guest has no Shared pool: the host gave the device no guest addresses for \
|
||||
one; the device offers no POOL, SURFACE_CACHE_EVERY or MANAGED_AT_COPY"
|
||||
.to_owned()
|
||||
)]
|
||||
);
|
||||
let config = GraphicsConfig {
|
||||
callbacks: GraphicsCallbacks {
|
||||
pool_add: Some(Arc::new(|_, _, _| {})),
|
||||
pool_remove: Some(Arc::new(|_, _| {})),
|
||||
..GraphicsCallbacks::default()
|
||||
},
|
||||
pool: Some(PoolConfig {
|
||||
physical_address: 52 << 30,
|
||||
physical_length: 16 << 30,
|
||||
}),
|
||||
..GraphicsConfig::default()
|
||||
};
|
||||
let pooled = GraphicsDevice::with_platform(Arc::new(FakePlatform::new()), config).unwrap();
|
||||
assert!(pooled.pool_range().is_some());
|
||||
assert_eq!(no_pool_lines(logs.take()), []);
|
||||
}
|
||||
|
||||
/// The no-pool line names each reason a device offers no pool for, and none where it offers one
|
||||
#[test]
|
||||
fn the_no_pool_line_names_why_the_device_offers_no_pool() {
|
||||
assert_eq!(no_pool(true, true, true), None);
|
||||
assert_eq!(
|
||||
no_pool(false, false, false),
|
||||
Some("the host gave the device no guest addresses for one")
|
||||
);
|
||||
assert_eq!(
|
||||
no_pool(true, false, false),
|
||||
Some("the GPU answers no memory heap")
|
||||
);
|
||||
assert_eq!(
|
||||
no_pool(true, true, false),
|
||||
Some("a Windows host offers one to an x86-64 guest alone")
|
||||
);
|
||||
}
|
||||
|
||||
/// A `POOL_TAKE` by context `context` of `length` bytes, as the kext posts it.
|
||||
fn pool_take(context: u32, length: u64) -> Vec<u8> {
|
||||
RgfxPoolTake {
|
||||
|
||||
+4
-2
@@ -251,8 +251,10 @@ runtime takes Shared blocks until the driver refuses one. The bound is the heaps
|
||||
`VK_EXT_memory_budget`'s budgets: the range is address space the guest keeps for the VM's life, a
|
||||
budget moves with what other processes hold, and RAM is bounded at each block's take. Where the
|
||||
heaps hold more than the addresses given, the range stops at their end and the device logs a warning
|
||||
once; where the GPU answers no heap, the guest has no pool, and the device logs that too. The device
|
||||
logs the range it took, the addresses it was given and the heaps' total once, at its creation.
|
||||
once; where the GPU answers no heap, the guest has no pool. The device logs the range it took, the
|
||||
addresses it was given and the heaps' total once, at its creation; a device with no pool, whether
|
||||
it was given no addresses, its GPU answers no heap or a Windows host has an arm64 guest, logs one
|
||||
warning there instead, which says why (`pool: the guest has no Shared pool: ...`).
|
||||
`rvg_graphics_device_pool_range` answers the range it took, 0 and 0 for none, and the host reserves
|
||||
that before the guest's firmware runs. The host then maps
|
||||
the device's blocks there as the pool grows
|
||||
|
||||
+4
-1
@@ -252,7 +252,10 @@ is its transport:
|
||||
device offers the library the room the machine answers instead
|
||||
(`x-pool-room-base`, `x-pool-room-size`): from the end of RAM rounded up
|
||||
to 1 GiB to the end of the guest's physical addresses, in whole GiB
|
||||
("arm64 guests"), and reserves nothing. The
|
||||
("arm64 guests"), and reserves nothing. A device left with no pool (no
|
||||
room, a GPU with no memory heap, or a Windows host's arm64 guest) writes
|
||||
one warning at its start that says why (`pool: the guest has no Shared
|
||||
pool: ...`). The
|
||||
library maps its blocks of host memory into the range as the guest's pool
|
||||
grows (`pool_add`, docs/api.md) and takes them out as it shrinks
|
||||
(`pool_remove`). Each block is a RAM region of its own, unmergeable, owned
|
||||
|
||||
Reference in new issue
Block a user