mirror of
https://github.com/RhapsodiOS/RhapsodiOS.git
synced 2026-11-03 22:01:40 -07:00
[GH-ISSUE #83] kernel (ppc): srv boot sizes the buffer map from RAM and can use most of the 1GB kernel address space #76
Labels
No labels
bug
documentation
enhancement
enhancement
good first issue
help wanted
help wanted
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github-starred/RhapsodiOS#76
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @raynorpat on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/RhapsodiOS/RhapsodiOS/issues/83
Summary
On ppc, booting with the
srvboot argument makesbuffer_map_sizer()(src/kernel-7/machdep/ppc/unix_startup.c,MACH_NBCpath) give the buffer cache half of RAM. Above about 470MB that reserves roughly 700MB of the kernel's 1GB address space for the buffer map. Together with the zone map, about 830MB is gone before anything else is allocated.Details
The ppc kernel address space is
0x4000–0x3ffff000(mach/ppc/vm_param.h), about 1GB, separate from user space.buffer_map_sizer()returnsnbuf * MAXBSIZE + niobuf * MAXPHYSIO, whichstartup()carves out ofkernel_map.With
srvset andmem_size > 64MB:bufpages = atop(mem_size) / 2, capped at 60000 pages, which is 234MB of 4KB pages. The cap is reached at about 470MB of RAM.nbuf = bufpages + 64= 60064, atMAXBSIZE(8192) each: about 469MB of address space.niobuf = bufpages / (MAXPHYSIO / page_size)= 3750, atMAXPHYS(64KB) each: about 234MB.zone_map_sizer()addsmem_size / 4, at most 128MB, on ppc.That leaves under 200MB for everything else in
kernel_map, and less once the kernel image is counted:kallocandkmem_alloc, kernel stacks, the mbuf map and driver allocations. Withoutsrvthe cache is 3% of RAM (about 180MB of address space at 2GB), which is fine.Expected failure
A server-mode boot on a ppc machine with 512MB or more of RAM may fail at boot or run out of
kernel_mapspace under load: kernel stack, mbuf or driver allocations fail, or allocation panics. Not reproduced yet; found by reading the code.Suggested fix
Bound the server-mode buffer cache by the kernel address space rather than RAM. For example, cap
bufpagessobuffer_map_sizer()stays under a fixed share ofVM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS. Then confirm a 1GB and a 2GB QEMU mac99 boot withsrv=1.