HomeFreeBSD

sched: separate out schedinit_ap()

Description

sched: separate out schedinit_ap()

schedinit_ap() sets up an AP for a later call to sched_throw(NULL).

Currently, ULE sets up some pcpu bits and fixes the idlethread lock with
a call to sched_throw(NULL); this results in a window where curthread is
setup in platforms' init_secondary(), but it has the wrong td_lock.
Typical platform AP startup procedure looks something like:

  • Setup curthread
  • ... other stuff, including cpu_initclocks_ap()
  • Signal smp_started
  • sched_throw(NULL) to enter the scheduler

cpu_initclocks_ap() may have callouts to process (e.g., nvme) and
attempt to sched_add() for this AP, but this attempt fails because
of the noted violated assumption leading to locking heartburn in
sched_setpreempt().

Interrupts are still disabled until cpu_throw() so we're not really at
risk of being preempted -- just let the scheduler in on it a little
earlier as part of setting up curthread.

(cherry picked from commit 589aed00e36c22733d3fd9c9016deccf074830b1)

Details

Provenance
kevansAuthored on Nov 2 2021, 6:06 PM
Parents
rGbf2a85f4e304: Fix a memory leak when ip_output_send() returns EAGAIN due to send tag issues
Branches
Unknown
Tags
Unknown