Raise host NOFILE capacity for the guest FD table#204
Conversation
32b48db to
e189210
Compare
Is a 64-descriptor host reserve acceptable, or would another policy better match the project?
It's not just ( Suggested number
When the host hard limit is below the required capacity, should elfuse fail at startup as proposed here, or derive a smaller guest-visible limit?I prefer fail at startup. MacOS shell fd hard limit is much higher. So if the user hit the hard limit, it mostly because they configured some settings that lower hard limit in the past. It better fail at startup so they can debug. |
|
Thanks for the detailed breakdown. Addressed in 50a140a:
I also updated the PR description to record these decisions. Verification after the change:
|
|
Please squash to one commit |
elfuse exposes a 1024-entry guest FD table but inherits the host RLIMIT_NOFILE. With a host soft limit of 256, guests hit host-side EMFILE while the guest table still has free entries. Require host capacity for FD_TABLE_SIZE plus a 256-descriptor reserve. The reserve budgets the bounded two-reference blocking-I/O cost across MAX_THREADS and leaves headroom for elfuse runtime descriptors. Raise only the host soft limit, preserve its hard limit, and fail at startup with a diagnostic when the required capacity cannot be established. Keep this internal capacity separate from a guest-visible 1024/1024 NOFILE limit used by resource-limit syscalls, proc reporting, and FD allocation. Carry the guest limit through fork IPC, restore inherited descriptors before applying a lowered limit, and recheck host capacity in fork helpers. Update the fork protocol identity and add regressions for hidden reserve reporting and fork after lowering the hard limit. PR sysprog21#148 addresses the same low-host-limit failure with a different startup policy and a host-side regression wrapper. Close sysprog21#68
50a140a to
d298609
Compare
|
Done. I squashed the three commits into a single commit, d298609, and updated the PR branch with The resulting tree is identical to the pre-squash head ( |
Problem
elfuse exposes a guest FD table with 1024 entries, but the host process may start with a much smaller soft
RLIMIT_NOFILE. On a host soft limit of 256, the stress test can open only about 248 guest descriptors before the host runs out of descriptors, even though the guest table still has capacity.Host capacity and guest-visible NOFILE state also need to remain separate: exposing the internal reserve reports an unreachable limit, while forwarding guest
setrlimitto the host can remove capacity needed by fork IPC.Change
RLIMIT_NOFILEcapacity forFD_TABLE_SIZEplus a 256-descriptor host reserve.getrlimit,setrlimit,prlimit64, proc reporting, and FD allocation.Design decisions
MAX_THREADS = 64, with up to two host FD references per thread), plus headroom for runtime pipes, fork IPC, debugger sockets, sysroot/FUSE plumbing, and smaller concurrent costs.ppollandpselectcan retain a number of references that scales with their input FD set. That structural issue cannot be covered by a fixed reserve and should be handled separately.Verification
test-stresswith host soft limit 256: passtest-stresswith host soft limit 4096: passmake check: 69 tests passed; BusyBox 82 passed, 0 failed, 2 skippedmake test-matrix-elfuse-aarch64: 235 passed, 0 failed, 4 skippedmake test-matrix-qemu-aarch64: 215 passed, 0 failed, 24 skippedmake lint: pass with existing project warningsclang-formatdry run for all changed C and header files: passgit diff --check: passRelated work
PR #148 addresses the same issue by raising the host limit in fdtable initialization and adding a host-side low-limit regression wrapper. This PR also separates guest-visible NOFILE state from elfuse internal host capacity and preserves that state across fork IPC.
Close #68