kernel - Break up scheduler and loadavg callout
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 12 Aug 2017 19:24:16 +0000 (12:24 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 12 Aug 2017 19:24:16 +0000 (12:24 -0700)
commit586c43085fc900273732f99de6c9ef43f73ded76
tree0c09f93921b7cbaf2cf1a0308445c4019c50912d
parent1b5abfb3c98aa17a9f240fd6e4c15b926b8dc232
kernel - Break up scheduler and loadavg callout

* Change the scheduler and loadavg callouts from cpu 0 to all cpus, and
  adjust the allproc_scan() and alllwp_scan() to segment the hash table
  when asked.

  Every cpu is now tasked with handling the nominal scheduler recalc and
  nominal load calculation for a portion of the process list.  The portion
  is unrelated to which cpu(s) the processes are actually scheduled on,
  it is strictly a way to spread the work around, split up by hash range.

* Significantly reduces cpu 0 stalls when a large number of user processes
  or threads are present (that is, in the tens of thousands or more).  In
  the test below, before this change, cpu 0 was straining under 40%+
  interupt load (from the callout).  After this change the load is spread
  across all cpus, approximately 1.5% per cpu.

* Tested with 400,000 running user processes on a 32-thread dual-socket
  xeon (yes, these numbers are real):

  12:27PM  up 8 mins,  3 users, load avg: 395143.28, 270541.13, 132638.33
  12:33PM  up 14 mins, 3 users, load avg: 399496.57, 361405.54, 225669.14

* NOTE: There are still a number of other non-segmented allproc scans in
the system, particularly related to paging and swapping.

* NOTE: Further spreading-out of the work may be needed, by using a more
   frequent callout and smaller hash index range for each.
16 files changed:
sys/kern/imgact_elf.c
sys/kern/init_main.c
sys/kern/kern_descrip.c
sys/kern/kern_ktrace.c
sys/kern/kern_proc.c
sys/kern/kern_resource.c
sys/kern/kern_sig.c
sys/kern/kern_synch.c
sys/kern/vfs_syscalls.c
sys/sys/globaldata.h
sys/sys/proc.h
sys/vfs/procfs/procfs_vnops.c
sys/vm/vm_glue.c
sys/vm/vm_meter.c
sys/vm/vm_object.c
sys/vm/vm_pageout.c