XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)
C
xnu.ko: 16 KB VM pages by default
Heyang Zhoud7a0c1d3444d
diff --git a/docs/production.md b/docs/production.mdindex 09bf229..9191ac4 100644--- a/docs/production.md+++ b/docs/production.md@@ -99,5 +99,5 @@ records, hosted, the caller where interrupts are re-enabled for kernel samples.| Now | Replace with ||---|---|-| 4 KB VM pages: four times the page faults of a native (16 KB) macOS; process spawn about 3x | `vm16k=1` (16 KB VM pages over the 4 KB granule, XNU's PAGE_RATIO 4) boots to the desktop with a quarter of the faults, but WindowServer aborts once per boot waiting in `MTLRegisterDevices`, and a boot has hung once in early VM setup: fix both, then make it the default |+| Done: 16 KB VM pages by default (`xnu.ko vm16k=1`, over the 4 KB granule, XNU's PAGE_RATIO 4): a quarter of the page faults, the desktop ~30% sooner, fork 2-3x faster than 4 KB; the WindowServer abort it seemed to cause was a start-up race with `xnudrmd` (fixed), and the early hang seen once did not come back in ~30 boots | The host's own 16 KB granule (a 16 KB Linux kernel) for the TLB reach native macOS has: memory-bound code is still up to 1.6x slower || The system disk keeps hardware daemons that crash or retry without their hardware | No crash reports after a boot: each crashing daemon fixed (a stand-in service or property) or disabled with a reason |diff --git a/xnu-ko/xnu_main.c b/xnu-ko/xnu_main.cindex 1ba1462..4c67b55 100644--- a/xnu-ko/xnu_main.c+++ b/xnu-ko/xnu_main.c@@ -201,8 +201,9 @@ module_param(model, charp, 0444);static const char *cmdline = "debug=0x8 -v -noprogress serial=0 startup_debug=1";static const char *cmdline_4k = " vm_compression_limit=1572864";static const char *cmdline_16k = " vm_compression_limit=393216 linux64_vm16k=1";-/* vm16k=1: XNU's VM pages are 16 KB over the host's 4 KB translation granule (XNU's PAGE_RATIO 4) */-static int vm16k;+/* vm16k=1 (the default): XNU's VM pages are 16 KB, as on a Mac, over the host's 4 KB translation granule (XNU's+ * PAGE_RATIO 4): a quarter of the page faults of 4 KB pages; vm16k=0 gives 4 KB VM pages */+static int vm16k = 1;module_param(vm16k, int, 0444);