Files
mac_linuxgpu/scripts/test-shmem-driverkit-alias.sh
geramyloveless 077dd61aeb linuxu: page descriptors grow with use, up to the machine's RAM
The page pool was fixed at 131072 descriptors (2 GiB of 16 KiB pages),
sized for a 1.5 GiB DART budget test. Descriptors now come in chunks of
16384 pages as allocations need them, for at most hw.memsize in pages.
A chunk never moves, so struct page pointers stay valid; the chunk
array is sized once for the maximum, so lockless readers (page_address)
index it safely. In the dext the VA lookup is rebuilt as chunks are
added. A block lies within one chunk; orders above a chunk fail, as
Linux cannot give that much contiguous memory either.

What bounds pages now is the platform: in the dext each non-CPU page is
DMA-mapped, so the DART refuses first (logged by the seam); CPU-only
pages are bounded by RAM. test_page_alloc holds 2176 MiB of pages at
once. Host builds of DriverKit-mode sources get IOSysCtlByName from
linuxu/tests/iosysctl_host.c.
2026-10-04 09:29:20 -07:00

32 lines
1.6 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
work=$(mktemp -d "${TMPDIR:-/tmp}/shmem-driverkit.XXXXXX")
trap 'rm -rf "$work"' EXIT
mkdir -p "$work/include/DriverKit" "$work/include/PCIDriverKit"
for header in IOService IOBufferMemoryDescriptor IODMACommand IOMemoryMap IOLib; do
printf '#include "driverkit_dma_mocks.h"\n' > "$work/include/DriverKit/$header.h"
done
printf '#include "driverkit_dma_mocks.h"\n' > "$work/include/PCIDriverKit/IOPCIDevice.h"
common=(-g -O1 -fsanitize=address,undefined -fno-sanitize-recover=all
-ffunction-sections -fdata-sections)
objects=()
for source in linuxu/src/mm/{page,shmem}.c linuxu/src/kmem/{vmalloc,kmemalloc,kmemcheck}.c \
linuxu/src/shims/{fd,task,kthread,printk}.c linuxu/src/dart/dart.c \
linuxu/src/{xarray,rcu,sync,bug}.c linuxu/tests/test_shmem_driverkit_alias.c \
linuxu/tests/iosysctl_host.c; do
flags=()
case "$source" in
*/mm/page.c|*/kmem/vmalloc.c|*/dart/dart.c) flags=(-DLINUXU_DEXT_DK=1) ;;
esac
object="$work/$(basename "$source" .c).o"
clang -w -std=gnu11 "${common[@]}" "${flags[@]}" -Ilinuxu/headers -c "$source" -o "$object"
objects+=("$object")
done
clang++ -x objective-c++ -std=c++17 -fno-exceptions -fno-objc-exceptions "${common[@]}" \
-DLINUXU_DEXT=1 -I"$work/include" -Ilinuxu/tests -idirafter linuxu/headers \
-c linuxu/tests/shmem_driverkit_backend.cpp -o "$work/backend.o"
clang++ "${common[@]}" "${objects[@]}" "$work/backend.o" \
-Wl,-dead_strip -lpthread -o "$work/test_shmem_driverkit_alias"
"$work/test_shmem_driverkit_alias"