freebsd-skq/sys/dev/hwpmc
jhb bcc5b0c55d 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
..
hwpmc_amd.c sys: use our nitems() macro when param.h is available. 2016-04-21 19:40:10 +00:00
hwpmc_amd.h
hwpmc_arm64_md.c Add Performance Monitoring Counters support for AArch64. 2015-05-19 15:25:47 +00:00
hwpmc_arm64.c Add Performance Monitoring Counters support for AArch64. 2015-05-19 15:25:47 +00:00
hwpmc_arm64.h Add Performance Monitoring Counters support for AArch64. 2015-05-19 15:25:47 +00:00
hwpmc_arm.c Rather than defining our own magic checks here use INKERNEL() for 2015-03-27 08:47:16 +00:00
hwpmc_armv7.c o Rework ARMv7 events list using aliases - same way as we have for arm64. 2015-06-10 12:42:30 +00:00
hwpmc_armv7.h o Rework ARMv7 events list using aliases - same way as we have for arm64. 2015-06-10 12:42:30 +00:00
hwpmc_core.c Remove slightly used const values that can be replaced with nitems(). 2016-04-21 15:38:28 +00:00
hwpmc_core.h sys/dev: minor spelling fixes. 2016-05-03 03:41:25 +00:00
hwpmc_e500.c Remove unused e500_event_codes_size. 2016-04-20 20:37:58 +00:00
hwpmc_intel.c Add support for Intel Skylake and Intel Broadwell PMC's. The Broadwell PMC's have been 2015-11-30 17:35:49 +00:00
hwpmc_logging.c Fix the tunable in logging so that if its pre-11 we have the proper 2015-12-09 22:46:40 +00:00
hwpmc_mips24k.c sys: use our nitems() macro when param.h is available. 2016-04-21 19:40:10 +00:00
hwpmc_mips74k.c sys: use our nitems() macro when param.h is available. 2016-04-21 19:40:10 +00:00
hwpmc_mips.c Cleanup unnecessary semicolons from the kernel. 2016-04-10 23:07:00 +00:00
hwpmc_mod.c Add an EARLY_AP_STARTUP option to start APs earlier during boot. 2016-05-14 18:22:52 +00:00
hwpmc_mpc7xxx.c Remove slightly used const values that can be replaced with nitems(). 2016-04-21 15:38:28 +00:00
hwpmc_octeon.c sys: use our nitems() macro when param.h is available. 2016-04-21 19:40:10 +00:00
hwpmc_pentium.c
hwpmc_pentium.h
hwpmc_piv.c Remove misc NULL checks after M_WAITOK allocations. 2016-05-10 10:26:07 +00:00
hwpmc_piv.h
hwpmc_powerpc.c e5500 HWPMC is identical to e500mc, so add support check for it. 2016-01-17 00:14:22 +00:00
hwpmc_powerpc.h Implement hwpmc(4) for Freescale e500 core. 2015-04-18 21:39:17 +00:00
hwpmc_ppc970.c Convert hwpmc(4) debug printfs over to KTR. 2015-05-08 19:40:00 +00:00
hwpmc_ppro.c Convert hwpmc(4) debug printfs over to KTR. 2015-05-08 19:40:00 +00:00
hwpmc_ppro.h
hwpmc_riscv.h Welcome the RISC-V 64-bit kernel. 2016-01-29 15:12:31 +00:00
hwpmc_soft.c Convert hwpmc(4) debug printfs over to KTR. 2015-05-08 19:40:00 +00:00
hwpmc_soft.h
hwpmc_sparc64.c
hwpmc_tsc.c Convert hwpmc(4) debug printfs over to KTR. 2015-05-08 19:40:00 +00:00
hwpmc_tsc.h
hwpmc_uncore.c Remove slightly used const values that can be replaced with nitems(). 2016-04-21 15:38:28 +00:00
hwpmc_uncore.h
hwpmc_x86.c Update the hwpmc driver to have the new type HASWELL_XEON. Also 2015-01-14 12:46:58 +00:00
hwpmc_xscale.c Remove slightly used const values that can be replaced with nitems(). 2016-04-21 15:38:28 +00:00
hwpmc_xscale.h
pmc_events.h sys/dev: minor spelling fixes. 2016-05-03 03:41:25 +00:00