freebsd-nq/sys/kern
John Baldwin fdce57a042 Add an EARLY_AP_STARTUP option to start APs earlier during boot.
Currently, Application Processors (non-boot CPUs) are started by
MD code at SI_SUB_CPU, but they are kept waiting in a "pen" until
SI_SUB_SMP at which point they are released to run kernel threads.
SI_SUB_SMP is one of the last SYSINIT levels, so APs don't enter
the scheduler and start running threads until fairly late in the
boot.

This change moves SI_SUB_SMP up to just before software interrupt
threads are created allowing the APs to start executing kernel
threads much sooner (before any devices are probed).  This allows
several initialization routines that need to perform initialization
on all CPUs to now perform that initialization in one step rather
than having to defer the AP initialization to a second SYSINIT run
at SI_SUB_SMP.  It also permits all CPUs to be available for
handling interrupts before any devices are probed.

This last feature fixes a problem on with interrupt vector exhaustion.
Specifically, in the old model all device interrupts were routed
onto the boot CPU during boot.  Later after the APs were released at
SI_SUB_SMP, interrupts were redistributed across all CPUs.

However, several drivers for multiqueue hardware allocate N interrupts
per CPU in the system.  In a system with many CPUs, just a few drivers
doing this could exhaust the available pool of interrupt vectors on
the boot CPU as each driver was allocating N * mp_ncpu vectors on the
boot CPU.  Now, drivers will allocate interrupts on their desired CPUs
during boot meaning that only N interrupts are allocated from the boot
CPU instead of N * mp_ncpu.

Some other bits of code can also be simplified as smp_started is
now true much earlier and will now always be true for these bits of
code.  This removes the need to treat the single-CPU boot environment
as a special case.

As a transition aid, the new behavior is available under a new kernel
option (EARLY_AP_STARTUP).  This will allow the option to be turned off
if need be during initial testing.  I plan to enable this on x86 by
default in a followup commit in the next few days and to have all
platforms moved over before 11.0.  Once the transition is complete,
the option will be removed along with the !EARLY_AP_STARTUP code.

These changes have only been tested on x86.  Other platform maintainers
are encouraged to port their architectures over as well.  The main
things to check for are any uses of smp_started in MD code that can be
simplified and SI_SUB_SMP SYSINITs in MD code that can be removed in
the EARLY_AP_STARTUP case (e.g. the interrupt shuffling).

PR:		kern/199321
Reviewed by:	markj, gnn, kib
Sponsored by:	Netflix
2016-05-14 18:22:52 +00:00
..
bus_if.m Add a new bus method to fetch device-specific CPU sets. 2016-05-09 20:50:21 +00:00
capabilities.conf
clock_if.m
cpufreq_if.m
device_if.m
genassym.sh
imgact_aout.c
imgact_binmisc.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
imgact_elf32.c
imgact_elf64.c
imgact_elf.c sys: use our roundup2/rounddown2() macros when param.h is available. 2016-04-21 19:57:40 +00:00
imgact_gzip.c
imgact_shell.c
inflate.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
init_main.c sys: use our roundup2/rounddown2() macros when param.h is available. 2016-04-21 19:57:40 +00:00
init_sysent.c
kern_acct.c
kern_alq.c
kern_clock.c Add an EARLY_AP_STARTUP option to start APs earlier during boot. 2016-05-14 18:22:52 +00:00
kern_clocksource.c Add an EARLY_AP_STARTUP option to start APs earlier during boot. 2016-05-14 18:22:52 +00:00
kern_condvar.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_conf.c
kern_cons.c
kern_context.c
kern_cpu.c Add an EARLY_AP_STARTUP option to start APs earlier during boot. 2016-05-14 18:22:52 +00:00
kern_cpuset.c
kern_ctf.c
kern_descrip.c fd: assert dropped filedesc lock in fdcloseexec 2016-05-08 03:26:12 +00:00
kern_dtrace.c
kern_dump.c kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
kern_environment.c
kern_et.c
kern_event.c
kern_exec.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_exit.c
kern_fail.c
kern_ffclock.c kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
kern_fork.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_gzio.c
kern_hhook.c
kern_idle.c
kern_intr.c
kern_jail.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_khelp.c
kern_kthread.c kern: for pointers replace 0 with NULL. 2016-04-15 16:10:11 +00:00
kern_ktr.c
kern_ktrace.c kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
kern_linker.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_lock.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_lockf.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_lockstat.c
kern_loginclass.c
kern_malloc.c
kern_mbuf.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_mib.c
kern_module.c
kern_mtxpool.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_mutex.c
kern_ntptime.c
kern_numa.c
kern_osd.c osd(9): Change array pointer to array pointer type from void* 2016-04-26 19:57:35 +00:00
kern_physio.c
kern_pmc.c
kern_poll.c
kern_priv.c
kern_proc.c Use a loop instead of a goto in sysctl_kern_proc_kstack(). 2016-04-17 23:22:32 +00:00
kern_procctl.c
kern_prot.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_racct.c Get rid of rctl_lock; use racct_lock where appropriate. The fast paths 2016-04-21 16:22:52 +00:00
kern_rangelock.c
kern_rctl.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_resource.c
kern_rmlock.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_rwlock.c
kern_sdt.c
kern_sema.c
kern_sendfile.c
kern_sharedpage.c
kern_shutdown.c Add 4Kn kernel dump support 2016-04-15 17:45:12 +00:00
kern_sig.c
kern_switch.c
kern_sx.c
kern_synch.c sys: extend use of the howmany() macro when available. 2016-04-26 15:38:17 +00:00
kern_syscalls.c
kern_sysctl.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_tc.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_thr.c
kern_thread.c
kern_time.c sys: extend use of the howmany() macro when available. 2016-04-26 15:38:17 +00:00
kern_timeout.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
kern_umtx.c Fix umtx lock/trylock for compat32. 2016-04-19 11:37:43 +00:00
kern_uuid.c
kern_xxx.c
ksched.c
link_elf_obj.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
link_elf.c kern: for pointers replace 0 with NULL. 2016-04-15 16:10:11 +00:00
linker_if.m sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
Make.tags.inc
Makefile
makesyscalls.sh
md4c.c
md5c.c
p1003_1b.c
pic_if.m
posix4_mib.c posix4_mib: Don't overrun facility_initialized array 2016-04-27 00:10:32 +00:00
sched_4bsd.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
sched_ule.c The struct thread td_estcpu member is only used by the 4BSD scheduler. 2016-04-17 11:04:27 +00:00
serdev_if.m
stack_protector.c
subr_acl_nfs4.c
subr_acl_posix1e.c
subr_autoconf.c
subr_blist.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_bufring.c
subr_bus_dma.c
subr_bus.c Add a new bus method to fetch device-specific CPU sets. 2016-05-09 20:50:21 +00:00
subr_busdma_bufalloc.c
subr_capability.c
subr_clock.c
subr_counter.c
subr_devmap.c Add support for RISC-V. 2016-04-26 12:29:47 +00:00
subr_devstat.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_disk.c
subr_dummy_vdso_tc.c
subr_eventhandler.c
subr_fattime.c
subr_firmware.c
subr_hash.c kern: Factor out function to convert hash flags to malloc(9) flags 2016-05-04 03:07:52 +00:00
subr_hints.c
subr_intr.c Check malloc succeeded in pic_create, with M_NOWAIT it may return NULL. 2016-05-09 12:24:39 +00:00
subr_kdb.c
subr_kobj.c
subr_lock.c
subr_log.c
subr_mbpool.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_mchain.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_module.c
subr_msgbuf.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_param.c
subr_pcpu.c
subr_pctrie.c sys: extend use of the howmany() macro when available. 2016-04-26 15:38:17 +00:00
subr_power.c
subr_prf.c
subr_prof.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_rman.c s/struct device */device_t/g 2016-05-04 23:31:52 +00:00
subr_rtc.c rtc: fix inverted resolution check 2016-05-04 13:48:59 +00:00
subr_sbuf.c
subr_scanf.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_sfbuf.c
subr_sglist.c
subr_sleepqueue.c
subr_smp.c
subr_stack.c
subr_syscall.c
subr_taskqueue.c
subr_terminal.c
subr_trap.c
subr_turnstile.c
subr_uio.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
subr_unit.c Add explicit cast to fix mips and powerpc build after r299090 2016-05-05 15:21:33 +00:00
subr_vmem.c subr_vmem: Fix double-free in error case of vmem_create 2016-05-11 23:16:11 +00:00
subr_witness.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
sys_capability.c
sys_generic.c
sys_pipe.c sys: extend use of the howmany() macro when available. 2016-04-26 15:38:17 +00:00
sys_procdesc.c
sys_process.c
sys_socket.c Expose soaio_enqueue(). 2016-04-29 20:12:45 +00:00
syscalls.c
syscalls.master
systrace_args.c
sysv_ipc.c
sysv_msg.c osd(9): Change array pointer to array pointer type from void* 2016-04-26 19:57:35 +00:00
sysv_sem.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
sysv_shm.c osd(9): Change array pointer to array pointer type from void* 2016-04-26 19:57:35 +00:00
tty_compat.c
tty_info.c
tty_inq.c
tty_outq.c
tty_pts.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
tty_tty.c
tty_ttydisc.c
tty.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
uipc_accf.c
uipc_debug.c
uipc_domain.c Introduce a new protocol hook pru_aio_queue. 2016-04-29 20:11:09 +00:00
uipc_mbuf2.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
uipc_mbuf.c kern: for pointers replace 0 with NULL. 2016-04-15 16:10:11 +00:00
uipc_mbufhash.c
uipc_mqueue.c Use the new PR_METHOD_REMOVE to clean up jail handling in POSIX 2016-04-25 04:36:54 +00:00
uipc_sem.c
uipc_shm.c sys: extend use of the howmany() macro when available. 2016-04-26 15:38:17 +00:00
uipc_sockbuf.c kern: for pointers replace 0 with NULL. 2016-04-15 16:10:11 +00:00
uipc_socket.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
uipc_syscalls.c kern: for pointers replace 0 with NULL. 2016-04-15 16:10:11 +00:00
uipc_usrreq.c kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
vfs_acl.c
vfs_aio.c
vfs_bio.c sys/kern: spelling fixes. 2016-04-29 21:54:28 +00:00
vfs_cache.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
vfs_cluster.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
vfs_default.c
vfs_export.c kern: for pointers replace 0 with NULL. 2016-04-15 16:10:11 +00:00
vfs_extattr.c
vfs_hash.c Add vfs_hash_ref(9) function, which finds a vnode by the hash value 2016-05-11 06:32:22 +00:00
vfs_init.c
vfs_lookup.c sys/kern: spelling fixes in comments. 2016-04-29 22:15:33 +00:00
vfs_mount.c
vfs_mountroot.c Stop hiding errors that result in failure to mount /dev. Otherwise, 2016-05-12 07:38:10 +00:00
vfs_subr.c Add EVFILT_VNODE open, read and close notifications. 2016-05-03 15:17:43 +00:00
vfs_syscalls.c
vfs_vnops.c sys/kern: spelling fixes. 2016-04-29 21:54:28 +00:00
vnode_if.src Add EVFILT_VNODE open, read and close notifications. 2016-05-03 15:17:43 +00:00