HomeFreeBSD

Ensure "init" (PID 1) also executes userret() initially

Description

Ensure "init" (PID 1) also executes userret() initially

Calling userret() from fork_return() misses the first return to
userspace of the "init" (PID 1) process. The latter is indeed created
by fork1() followed by a call to cpu_fork_kthread_handler() call that
replaces fork_return() by start_init() as the function to execute after
fork.

A new process' initial return to userspace in the end always happens
through returning from fork_exit(), so move userret() there instead to
fix the omission.

This problem was discovered as part of a revamp of scheduling priorities
that lead to experimenting with asserting and sometimes resetting
priorities in sched_userret(), in the course of which the author
stumbled on panics being triggered only in init() or only in other
processes, depending on the modifications to sched_userret(). This
change currently has no practical effect but will have some in the near
future.

Reviewed by: markj, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42257

(cherry picked from commit eac624207ccf3a16225368d226861b06e3631d0d)

Approved by: markj (mentor)

Details

Provenance
olceAuthored on Oct 10 2023, 5:36 PM
Reviewer
markj
Differential Revision
D42257: Ensure "init" (PID 1) also executes userret() initially
Parents
rGa10630ef818f: pdinit(): Fix comment
Branches
Unknown
Tags
Unknown