Page MenuHomeFreeBSD

Move fork_rfppwait() check into ast()
ClosedPublic

Authored by trasz on Dec 11 2021, 12:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 28 2024, 11:03 AM
Unknown Object (File)
Dec 28 2023, 11:06 PM
Unknown Object (File)
Dec 22 2023, 10:37 PM
Unknown Object (File)
Dec 12 2023, 10:34 AM
Unknown Object (File)
Nov 28 2023, 11:50 AM
Unknown Object (File)
Nov 19 2023, 2:02 PM
Unknown Object (File)
Nov 14 2023, 1:01 AM
Unknown Object (File)
Nov 7 2023, 11:52 PM
Subscribers

Details

Summary

This will always sleep at least once, so it's a slow path by definition.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

(If the patch makes sense I'll also ask pho@ for testing.)

In principle this should work.

Testing requires the functional testing for vfork(2) behavior, and not the stress testing. In particular, you need to ensure that the parent of vfork is suspended, and only continue executing on child doing exec(2) or exit(2). There might be already some tests in the tree, I am not sure.

sys/kern/kern_fork.c
491

!= 0

sys/kern/subr_trap.c
262

__predict_false does not make much sense there.
!= 0

I've tried to write a test program, like this:

#include <err.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>

volatile bool child_done;

int
main(void)
{
pid_t pid;

child_done = false;

pid = vfork();
if (pid < 0)
err(1, "vfork");
if (pid > 0) {
if (!child_done)
errx(1, "child not done");
exit(0);
}

child_done = true;
exit(0);
}

... and then I've tested if the test works by breaking the kernel, by ifdefing out the call to fork_rfppwait(). Turns out this results in a _very_ broken system, it seems everything that calls vfork(2) segfaults, which makes sense, because of the stack. Does that count as tested enough? :-)

This revision is now accepted and ready to land.Dec 28 2021, 6:25 PM
This revision was automatically updated to reflect the committed changes.