Files
reims-vgpu/guest/kext/tests/queue_limits_test.cpp
T
Anees Iqbal 2d5154b5da 🐛 Watch a process's 2048 queues beside the other processes'
The watch table held 2048 queues of every process but WindowServer's, the
per-process limit, so a process got 2048 only alone: in the guest, with 5
queues of other processes watched, a process's 2044th queue create was refused
("every watched ring is taken"), and the bundle's queue for it never completed
a command buffer (measured, 2048 queues in one process, the last one's wait
timing out; the bundle's handling of a refused create is fix-bundle-queues').

The device-wide tables indexed by queue now hold one process at its limit
beside other processes' 2048, and WindowServer's 64: 4160 watched rings and
lock-table queues.
2026-11-05 21:59:23 -08:00

54 lines
1.9 KiB
C++

// The native test of RgfxQueueLimits.hpp: a process makes as many queues as the device watches,
// and WindowServer can make one however many the others hold.
#include "RgfxQueueLimits.hpp"
#include <cstdio>
#include <cstdlib>
namespace {
int checks = 0;
void check(bool ok, const char *what)
{
checks++;
if (!ok) {
std::fprintf(stderr, "queue_limits_test: FAILED: %s\n", what);
std::exit(1);
}
}
} // namespace
int main()
{
// One process: its 2048th queue is made, its 2049th refused.
check(rgfxQueueAdmitted(0), "a process's first queue");
check(rgfxQueueAdmitted(256), "past the old limit of 256");
check(rgfxQueueAdmitted(2047), "its 2048th queue");
check(!rgfxQueueAdmitted(2048), "not its 2049th");
// The device watches one process at its limit beside others holding as many again, and
// WindowServer beside them.
check(rgfxWatchAdmitted(2047, false), "the device watches a process's 2048th queue");
check(rgfxWatchAdmitted(2047 + 2048, false),
"and its 2048th beside 2048 of other processes'");
check(!rgfxWatchAdmitted(4096, false), "but no other process's queue past 4096 in all");
check(rgfxWatchAdmitted(4096, true), "WindowServer's queue past them");
check(rgfxWatchAdmitted(4096 + 63, true), "to the reserve's last");
check(!rgfxWatchAdmitted(4096 + 64, true), "and not past it");
check(kRgfxMaxWatchedQueues == 2 * kRgfxMaxQueuesPerClient + kRgfxWindowServerQueues,
"the watch table holds a process at its limit, as many others and WindowServer's "
"reserve");
// A process reaches its own limit before the device's, alone or beside others' 2048.
const uint32_t othersHeld[] = {0, 5, 2048};
for (uint32_t others : othersHeld) {
uint32_t made = 0;
while (rgfxQueueAdmitted(made) && rgfxWatchAdmitted(others + made, false))
made++;
check(made == 2048, "a process makes 2048 queues beside the others'");
}
std::printf("queue_limits_test: OK (%d checks)\n", checks);
return 0;
}