On Mon, Nov 17, 2025 at 12:09 AM Nadav Tasher <[email protected]> wrote:
>
> Using xfork() instead of xvfork() on MMU targets improves
> security and stability.

> Memory efficiency differences are negligable since most
> kernels implement fork() with CoW.

In fact, you should go into opposite direction:
whenever it's not incurring difficulties, you should use vfork().

fork() is much slower.
Especially if forking a process with large memory footprint.
It can take something like 50-100 milliseconds even on lightly loaded machine.

Yes, CoW means that the dirtied pages of the process do not need to be copied,
but the whole kernel-side paging structure needs to be. If you examine
in the kernel what fork() does with the paging structures, you'll realize that
fork() essentially flushes the entire TLB, and the amount of newly allocated and
updated pages in new paging data structures (at least a dozen pages)
is large enough to flush today's CPUs L1 data cache (<=64 kbytes).

In comparison, vfork() does not touch paging structures at all, it barely needs
any kernel-side allocations: essentially, it only allocates new task_struct
and associated small structures.
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to