dragonfly.git
7 years agokernel - Incidental MPLOCK removal
Matthew Dillon [Wed, 11 Jan 2017 17:47:56 +0000 (09:47 -0800)]
kernel - Incidental MPLOCK removal

* Remove misc #include <sys/mplock2.h> statements that are no longer needed.

* Replace mplock with acct_lock in kern_acct.c

* Replace mplock with msg_token in sysv_msg.c

* Replace mplock with p->p_token in the profiling code.

7 years agousched: Fix the returned CPU affinity make by smp_active_mask.
Sepherosa Ziehau [Wed, 11 Jan 2017 16:09:51 +0000 (00:09 +0800)]
usched: Fix the returned CPU affinity make by smp_active_mask.

7 years agolwp: Add two syscalls to set/get lwp's CPU affinity mask.
Sepherosa Ziehau [Mon, 9 Jan 2017 15:48:18 +0000 (23:48 +0800)]
lwp: Add two syscalls to set/get lwp's CPU affinity mask.

7 years agousched: Implement LWP lazy migration support.
Sepherosa Ziehau [Wed, 11 Jan 2017 13:25:57 +0000 (21:25 +0800)]
usched: Implement LWP lazy migration support.

Non-self migration can be achieved by just setting LWP's cpumask,
which is almost costless.  The migration will happen upon next
time the target LWP is scheduled.

Reviewed-by: dillon@
7 years agokernel - Fix recursive module loading (from MPSAFE changes)
Matthew Dillon [Tue, 10 Jan 2017 21:49:00 +0000 (13:49 -0800)]
kernel - Fix recursive module loading (from MPSAFE changes)

* Fix recursive module loading which I broke in the
  recent MPSAFE work.

* Fix firmware loader callback deadlock.

* Fixes radeon drm lockup on startx

Reported-by: mneumann
7 years agodrm/i1915: Disable stolen memory support
François Tigeot [Tue, 10 Jan 2017 21:46:52 +0000 (22:46 +0100)]
drm/i1915: Disable stolen memory support

Some initialization code paths are not yet enabled, making
it crash-prone on some hardware

7 years agommcsd - Wasn't quite MPSAFE, fix startup race (2)
Matthew Dillon [Tue, 10 Jan 2017 03:11:47 +0000 (19:11 -0800)]
mmcsd - Wasn't quite MPSAFE, fix startup race (2)

* Needed to rearrange one more thing to report capacity properly.

7 years agommcsd - Wasn't quite MPSAFE, fix startup race
Matthew Dillon [Tue, 10 Jan 2017 03:08:03 +0000 (19:08 -0800)]
mmcsd - Wasn't quite MPSAFE, fix startup race

* mmcsd was attaching the drive before finishing the softc setup.  Being
  MPSAFE, the system tried to probe the mmcsd before it could finish the
  setup.

* Fixed by shifting things around a little.

7 years agokernel - Remove mplock in process trap/signal code (non-performance)
Matthew Dillon [Mon, 9 Jan 2017 23:23:33 +0000 (15:23 -0800)]
kernel - Remove mplock in process trap/signal code (non-performance)

* Remove the mplock from paths that no longer need it.  This is mostly
  incidental, since processes do not usually recover from traps like
  SIGBUS or SIGSEGV.

7 years agommcsd(4): Declare device D_MPSAFE. Move start_transaction to mmcsd thread.
Imre Vadász [Mon, 9 Jan 2017 22:00:42 +0000 (23:00 +0100)]
mmcsd(4): Declare device D_MPSAFE. Move start_transaction to mmcsd thread.

* SD card commands are issued in the mmcsd thread after it takes the bio
  command from the queue, so we should do the devstat_start_transaction()
  there, instead of directly in mmcsd_strategy().

7 years agokernel - Make misc crypto functions MPSAFE
Matthew Dillon [Mon, 9 Jan 2017 22:38:54 +0000 (14:38 -0800)]
kernel - Make misc crypto functions MPSAFE

* Remove mplock from the crypto device code.

* Implement cryptodev_lock for cryptof_ioctl() and related functions.

* Prevent cryptof functions from imploding on concurrent access.

7 years agobuf - Remove B_ORDERED, Incidental CAM MPSAFE (2)
Matthew Dillon [Mon, 9 Jan 2017 22:38:09 +0000 (14:38 -0800)]
buf - Remove B_ORDERED, Incidental CAM MPSAFE (2)

* Remove bowrite() operation in UFS (use bwrite() instead).

7 years agokernel - Incidental MPLOCK removal (devfs)
Matthew Dillon [Mon, 9 Jan 2017 22:36:07 +0000 (14:36 -0800)]
kernel - Incidental MPLOCK removal (devfs)

* Fix ordering issues for devfs initialization vs libprop that previously
  depended on the MPLOCK.

* Use a private devfs_token for other areas of devfs previously using
  the mplock.

* Make /dev/devfs MPSAFE.

7 years agokernel - Incidental MPLOCK removal
Matthew Dillon [Mon, 9 Jan 2017 22:34:11 +0000 (14:34 -0800)]
kernel - Incidental MPLOCK removal

* A few more mplocks in the moutn and umount paths.  Also fix a rootmount
  case (the latter being non-performance) for completeness.

7 years agokernel - Incidental MPLOCK removal (non-performance)
Matthew Dillon [Mon, 9 Jan 2017 22:28:42 +0000 (14:28 -0800)]
kernel - Incidental MPLOCK removal (non-performance)

* varsym is MPSAFE.

7 years agokernel - Incidental MPLOCK removal (non-performance)
Matthew Dillon [Mon, 9 Jan 2017 22:26:12 +0000 (14:26 -0800)]
kernel - Incidental MPLOCK removal (non-performance)

* proc filterops.

* kernel linkerops and kld code.

* Warn if a non-MPSAFE interrupt is installed.

* Use a private token in the disk messaging core (subr_disk) instead of
  the mp token.

* Use a private token for sysv shm adminstrative calls.

* Cleanup.

7 years agokernel - Remove global debug counters from device path
Matthew Dillon [Mon, 9 Jan 2017 22:22:59 +0000 (14:22 -0800)]
kernel - Remove global debug counters from device path

* Remove global debugging counters from the device path, including
  dev_dstrategy().  Improves performance when heavily concurrent I/O
  is being performed.

7 years agokernel - Incidental mplock removal - NTP support
Matthew Dillon [Mon, 9 Jan 2017 22:22:14 +0000 (14:22 -0800)]
kernel - Incidental mplock removal - NTP support

* Make the NTP support functions MPSAFE.

7 years agokernel - Incidental mplock removal
Matthew Dillon [Mon, 9 Jan 2017 22:20:13 +0000 (14:20 -0800)]
kernel - Incidental mplock removal

* We don't need to acquire the mplock when exec'ing the init program.

7 years agokernel - Make gpio and gpio_led MPSAFE
Matthew Dillon [Mon, 9 Jan 2017 22:03:46 +0000 (14:03 -0800)]
kernel - Make gpio and gpio_led MPSAFE

* Convert to a private lock.

7 years agoacpi - Incidental MPSAFE
Matthew Dillon [Mon, 9 Jan 2017 22:00:48 +0000 (14:00 -0800)]
acpi - Incidental MPSAFE

* Make ACPI devices MPSAFE (use a private token).

* Make the ACPI interupt MPSAFE.

7 years agobuf - Remove B_ORDERED, Incidental CAM MPSAFE
Matthew Dillon [Mon, 9 Jan 2017 21:58:04 +0000 (13:58 -0800)]
buf - Remove B_ORDERED, Incidental CAM MPSAFE

* Remove support for B_ORDERED.  Most drivers ignore it, and it is basically
  unusable.

* The CAM "xpt", "pass", and "sg" devices are MPSAFE, flag them
  appropriately.

7 years agokernel - Incidental MPLOCK removal (non-performance)
Matthew Dillon [Mon, 9 Jan 2017 21:54:05 +0000 (13:54 -0800)]
kernel - Incidental MPLOCK removal (non-performance)

* Remove the MPLOCK in a ton of places that don't need it or can be
  trivially tokenized or locked.

* Mostly non-performance adjustments, though the X server does use
  scmouse or sysmouse.

7 years agosdhci - Use MPSAFE version for the taskqueue and callouts
Matthew Dillon [Mon, 9 Jan 2017 21:47:38 +0000 (13:47 -0800)]
sdhci - Use MPSAFE version for the taskqueue and callouts

* Use the MPSAFE version for the taskqueue and callouts.

7 years agodrm/i915: Revert DisplayPort fast link training feature
François Tigeot [Mon, 9 Jan 2017 22:31:14 +0000 (23:31 +0100)]
drm/i915: Revert DisplayPort fast link training feature

DisplayPort fast link training causes screen flickering on some hw combinations

Obtained-from: Linux 4.6.7, Commit b0f7095f8bd503eddf9a91a258e796da0058f182

7 years agodrm/i915/psr: Try to program link training times correctly
François Tigeot [Mon, 9 Jan 2017 22:22:54 +0000 (23:22 +0100)]
drm/i915/psr: Try to program link training times correctly

Increase link training time to 2.5ms, fixing
flickering issues associated with PSR.

Obtained-from: Linux 4.6.7, commit 69205c5c16df0702870179c8419e89cc954bd311

7 years agosdhci - Fix typo, support bits for drive types A,C,D are in capabilities.
Imre Vadász [Fri, 6 Jan 2017 21:47:28 +0000 (22:47 +0100)]
sdhci - Fix typo, support bits for drive types A,C,D are in capabilities.

* The drive type support flags in the capabilities register (0x40) are for
  drive types A,C,D, drive type B is the default setting (value 0) of the
  drive strength field in the HOST_CONTROL2 register.

7 years agosdhci - Add some missing register constants, and dump some more registers.
Imre Vadász [Thu, 5 Jan 2017 20:17:49 +0000 (21:17 +0100)]
sdhci - Add some missing register constants, and dump some more registers.

* Adds defines for content of SDHCI_ADMA_ERR and SDHCI_HOST_CONTROL2
  registers.

* Add slot type capability bits. These bits should allow recognizing
  removable card slots, embedded cards and shared buses (shared bus
  supposedly is always comprised of non-removable cards).

* Dump CAPABILITIES2, ADMA_ERR, HOST_CONTROL2 and ADMA_ADDRESS_LOW
  registers in sdhci_dumpregs().

7 years agosdhci - Use bus_dmamem_coherent for allocating memory for sdma DMA.
Imre Vadász [Thu, 5 Jan 2017 18:34:24 +0000 (19:34 +0100)]
sdhci - Use bus_dmamem_coherent for allocating memory for sdma DMA.

* While there, rename various constants which are related to SDMA (and not
  going to be used for ADMA2) from *_DMA_* names to *_SDMA_*.

7 years agousched: Add USCHED_SET_CPUMASK.
Sepherosa Ziehau [Mon, 9 Jan 2017 13:33:30 +0000 (21:33 +0800)]
usched: Add USCHED_SET_CPUMASK.

7 years agotest/passdesc: Allow specifying the payload length.
Sepherosa Ziehau [Mon, 9 Jan 2017 05:03:57 +0000 (13:03 +0800)]
test/passdesc: Allow specifying the payload length.

We don't suffer the following bug though.

Inspired-by: FreeBSD https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=181741
7 years agokernel - Further refactor vmstats, adjust page coloring algorithm
Matthew Dillon [Mon, 9 Jan 2017 04:03:38 +0000 (20:03 -0800)]
kernel - Further refactor vmstats, adjust page coloring algorithm

* Further refactor vmstats by tracking adjustments in gd->gd_vmstats_adj
  and doing a copyback of the global vmstats into gd->gd_vmstats.  All
  code critical paths access the localized copy to test VM state, removing
  most global cache ping pongs of the global structure.   The global
  structure 'vmstats' still contains the master copy.

* Bump PQ_L2_SIZE up to 512.  We use this to localized the VM page queues.
  Make some adjustments to the pg_color calculation to reduce (in fact
  almost eliminate) SMP conflicts on the vm_page_queue[] between cpus
  when the VM system is operating normally (not paging).

* This pumps the 4-socket opteron test system up to ~4.5-4.7M page
  faults/sec in testing (using a mmap/bzero/munmap loop on 16MB x N
  processes).

  This pumps the 2-socket xeon test system up to 4.6M page faults/sec
  with 32 threads (250K/sec on one core, 1M on 4 cores, 4M on 16 cores,
  5.6M on 32 threads).  This is near the theoretical maximum possible for
  this test.

* In this particular page fault test, PC sampling indicates *NO* further
  globals are undergoing cache ping-ponging.  The PC sampling predominantly
  indicates pagezero(), which is expected.  The Xeon is zeroing an aggregate
  of 22GBytes/sec at 32 threads running normal vm_fault's.

7 years agokernel - Refactor struct vmstats and vm_zone
Matthew Dillon [Mon, 9 Jan 2017 00:02:59 +0000 (16:02 -0800)]
kernel - Refactor struct vmstats and vm_zone

* These changes significantly improve the simultaneous non-conflicting
  VM fault rate.  On our 4-socket opteron (48 cores, which makes a great
  test case because its cache mastership stalls are so expensive), the
  maximum concurrent VM fault rate increased from ~2.4M/sec to ~3.5M/sec,
  and suffers no degredation after topping out.

* Refactor the fields in struct vmstats to separate out mostly
  read-only variables from nominally modified variables, reducing
  cache mastership stalls.

* Remove vm_shared_hit, vm_shared_count, and vm_shared_miss sysctl
  statistics, removing related cache mastership stalls from the
  critical path.

* Move the spinlock in vpgqueues to the base of the structure.

* Increase the vmstats slop (how large a negative value can accumulate
  in pcpu stats before rolling it up).

* Fix cache mastership stalls in the zalloc() and zfree() paths by
  consolidating pcpus elements into its own cache-aligned structure
  and giving each pcpu its on znalloc counter.

7 years agokernel - Remove most global atomic ops for VM page statistics
Matthew Dillon [Sun, 8 Jan 2017 22:06:37 +0000 (14:06 -0800)]
kernel - Remove most global atomic ops for VM page statistics

* Use a pcpu globaldata->gd_vmstats to update page statistics.

* Hardclock rolls the individual stats into the global vmstats structure.

* Force-roll any pcpu stat that goes below -10, to ensure that the low-memory
  handling algorithms still work properly.

7 years agokernel - Reduce size of struct spinlock
Matthew Dillon [Sun, 8 Jan 2017 18:13:25 +0000 (10:13 -0800)]
kernel - Reduce size of struct spinlock

* Reduce the size of struct spinlock from 16 to 8 bytes.  The description
  field was not being used (we use __func__ instead).  This reduces
  structural bloat for a number of important structures, in particular
  reducing sizeof(struct vm_page) from 136 to 128 bytes.

7 years agokernel - Move vm_page spin locks from pool to vm_page structure
Matthew Dillon [Sun, 8 Jan 2017 18:03:40 +0000 (10:03 -0800)]
kernel - Move vm_page spin locks from pool to vm_page structure

* Move the vm_page spin lock from a pool to per-structure.  This does bloat
  the vm_page structure, but clears up an area of contention under heavy
  VM loads.

7 years agokernel - Change machdep.pmap_dynamic_delete default
Matthew Dillon [Sun, 8 Jan 2017 17:47:29 +0000 (09:47 -0800)]
kernel - Change machdep.pmap_dynamic_delete default

* Enable machdep.pmap_dynamic_delete by default only on machines with
  less than 8G of ram, and disable by default on machines with 8G or more.

  This feature works, but it imposes an unnecessary performance loss for
  workloads which fork/exec/wait/exit a lot (bulk builds), or programs which
  mmap and munmap a lot (browsers, perl, other programs).

7 years agoClean up a bit after the recent CAM work (075c6d38244abd0b0c8).
Sascha Wildner [Sun, 8 Jan 2017 13:33:03 +0000 (14:33 +0100)]
Clean up a bit after the recent CAM work (075c6d38244abd0b0c8).

7 years agopfil.9: Remove references to PFIL_MPSAFE (removed in 48e93b2f5147bacf8).
Sascha Wildner [Sun, 8 Jan 2017 13:14:30 +0000 (14:14 +0100)]
pfil.9: Remove references to PFIL_MPSAFE (removed in 48e93b2f5147bacf8).

7 years agokernel - Fix improper mplock in mount path
Matthew Dillon [Sun, 8 Jan 2017 08:33:11 +0000 (00:33 -0800)]
kernel - Fix improper mplock in mount path

* VFS_MOUNT() was being called before MNTK_ALL_MPSAFE could be set by
  the filesystem, causing the operation to run with the MP token held.

* Add VFCF_MPSAFE to the vfsconf flags and specify it for MPSAFE filesystems
  in their VFS_SET() specification.  This flag causes MNTK_ALL_MPSAFE to
  be set in mount->mnt_kern_flags prior to the VFS_MOUNT() call.  Set this
  flag for devfs, procfs, tmpfs, nullfs, hammer, and hammer2.

* Primarily effects synth or other bulk-builds which do a lot of mounting.

7 years agokernel - CAM cleanup 3/N - Remove unnecessary mplocks
Matthew Dillon [Sun, 8 Jan 2017 07:32:00 +0000 (23:32 -0800)]
kernel - CAM cleanup 3/N - Remove unnecessary mplocks

* Remove some low-hanging fruit.  The mplock is not needed for any
  of these paths, they are protected by other locks.

7 years agokernel - Remove mplock from swapon/swapoff
Matthew Dillon [Sun, 8 Jan 2017 07:29:00 +0000 (23:29 -0800)]
kernel - Remove mplock from swapon/swapoff

* The mplock is no longer applicable here, the code is protected by
  swap_mtx.

7 years agokernel - Cleanup PFIL_MPSAFE
Matthew Dillon [Sun, 8 Jan 2017 07:19:22 +0000 (23:19 -0800)]
kernel - Cleanup PFIL_MPSAFE

* All pfil use cases are MPSAFE, so remove the PFIL_MPSAFE flag entirely
  and remove the old mplock wrappers that tested it.

7 years agokernel - CAM cleanup 2/N - adjust make upgrade
Matthew Dillon [Sun, 8 Jan 2017 07:11:14 +0000 (23:11 -0800)]
kernel - CAM cleanup 2/N - adjust make upgrade

* Remove ncv.ko, nsp.ko, and stg.ko.

7 years agokernel - Remove unused pmap_list
Matthew Dillon [Sun, 8 Jan 2017 07:05:59 +0000 (23:05 -0800)]
kernel - Remove unused pmap_list

* pmap_list was used in the (now removed) 32-bit pmap code because
  expansion of the kernel_pmap potentially required updating the PT
  pages in all existing user pmaps.  The 64-bit pmap code does not
  need to do this so the list can be removed.

* Removes a global spin-lock from the pmap creation and release path.
  Not a major factor for performance but a nice cleanup.

7 years agokernel - CAM cleanup 1/N - Remove ancient scsi pccard drivers ncv, nsp, stg
Matthew Dillon [Sun, 8 Jan 2017 07:02:31 +0000 (23:02 -0800)]
kernel - CAM cleanup 1/N - Remove ancient scsi pccard drivers ncv, nsp, stg

* Remove a number of ancient drivers that nobody could possibly be using
  any more.

* Remove ncv: NCR 53C500 based SCSI host adapters.

* Remove nsp: Workbit Ninja SCSI-3 based PC Card SCSI host adapters.

* Remove stg: TMC 18C30, 18C50 based PC Card SCSI host adapters.

7 years agoifq: Factor out if_classq from altq_classq and use it for default ifq.
Sepherosa Ziehau [Thu, 29 Dec 2016 12:47:10 +0000 (20:47 +0800)]
ifq: Factor out if_classq from altq_classq and use it for default ifq.

This reduces memory foot print for default ifq and could be used
by the upcoming "flow" of FQ-CoDel.

7 years agokernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion (4)
Matthew Dillon [Sat, 7 Jan 2017 03:25:15 +0000 (19:25 -0800)]
kernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion (4)

* Track down and fix another bug.  pmap_dynamic_delete was imploding
  higher level page table pages still being held by higher call levels.
  Add a pv_hold count check to avoid the situation.

7 years agokernel - Implement CPU localization hinting for low level page allocations
Matthew Dillon [Sat, 7 Jan 2017 02:06:14 +0000 (18:06 -0800)]
kernel - Implement CPU localization hinting for low level page allocations

* By default vm_page_alloc() and kmem_alloc*() localize to the calling cpu.

* A cpu override may be passed in the flags to make these functions localize
  differently.

* Currently implemented as a test only for the pcpu globaldata, idle
  thread, and stacks for kernel threads targetted to specific cpus.

7 years agokernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion (3)
Matthew Dillon [Sat, 7 Jan 2017 00:04:32 +0000 (16:04 -0800)]
kernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion (3)

* More pmap fixes.  Fix a bug introduced by the original commit that
  could still create managed PT/PD/PDP page tables in kernel_pmap when
  doing a wiring change.

* Assert that we never create managed PT/PD/PDP page tables in kernel_pmap.
  Managed PTEs can still be created (e.g. for pageable kernel memory).

* Add sysctl pmap_dynamic_delete, which defaults to enabled.  This sysctl
  can be set to 0 to disable dynamic deletion of PT/PD/PDP pages in user
  pmaps.

7 years agokernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion (2)
Matthew Dillon [Fri, 6 Jan 2017 20:48:49 +0000 (12:48 -0800)]
kernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion (2)

* Fix bug in the PT/PD/PDP code.  pmap_allocpte() was improperly trying
  to create managed entities for higher-level kernel page tables, which
  implodes the kernel.  The kernel manages these entities itself.

7 years agokernel - vmm_init() must run after SMP startup
Matthew Dillon [Fri, 6 Jan 2017 16:35:01 +0000 (08:35 -0800)]
kernel - vmm_init() must run after SMP startup

* vmm_init() must run after SMP startup (fix bug introduced by recent
  commits).

* cleanup.

7 years agoifq: Switch to drop-head for default enqueue method.
Sepherosa Ziehau [Fri, 6 Jan 2017 14:51:06 +0000 (22:51 +0800)]
ifq: Switch to drop-head for default enqueue method.

This is consistent w/ upcoming CoDel support.

7 years agodrm/i915: Update to Linux 4.6
François Tigeot [Fri, 6 Jan 2017 08:46:52 +0000 (10:46 +0200)]
drm/i915: Update to Linux 4.6

* Skylake and Kabylake support improvements

* FBC (FrameBuffer Compression) now enabled by default on Haswell and
  Broadwell GPUs

* PSR (Panel Self Refresh) support improved, now enabled by default on
  Valleyview, CherryView, Haswell and Broadwell

* Improved DSI panel support

* HDMI hotplug fixes

* Various bugfixes everywhere

7 years agokernel - Add NUMA awareness to vm_page_alloc() and related functions (2)
Matthew Dillon [Fri, 6 Jan 2017 03:37:27 +0000 (19:37 -0800)]
kernel - Add NUMA awareness to vm_page_alloc() and related functions (2)

* Fix miscellaneous bugs in the recent NUMA commits.

* Add kern.numa_disable, setting this to 1 in /boot/loader.conf will
  disable the NUMA code.  Note that NUMA is only applicable on multi-socket
  systems.

7 years agodrm/linux: Add USEC_PER_MSEC definition
François Tigeot [Fri, 6 Jan 2017 08:08:39 +0000 (09:08 +0100)]
drm/linux: Add USEC_PER_MSEC definition

Commit proofread-by: zrj

7 years agoif: Defer the if_up until the ifnet.if_ioctl is called.
Sepherosa Ziehau [Fri, 6 Jan 2017 07:59:25 +0000 (15:59 +0800)]
if: Defer the if_up until the ifnet.if_ioctl is called.

This ensures the interface is initialized by the interface driver
before it can be used by the rest of the system.

Obtained-from: FreeBSD

7 years agoif: Remove unnecessary critical sections.
Sepherosa Ziehau [Fri, 6 Jan 2017 07:50:10 +0000 (15:50 +0800)]
if: Remove unnecessary critical sections.

7 years agoalc: Add Killer E2500 support.
Sepherosa Ziehau [Fri, 6 Jan 2017 06:42:06 +0000 (14:42 +0800)]
alc: Add Killer E2500 support.

7 years agohyperv/vmbus: Fix interrupt timer detection logic.
Sepherosa Ziehau [Fri, 6 Jan 2017 06:29:50 +0000 (14:29 +0800)]
hyperv/vmbus: Fix interrupt timer detection logic.

7 years agohyperv: Reorder the Hyper-V TSC initialization a bit.
Sepherosa Ziehau [Fri, 6 Jan 2017 05:48:02 +0000 (13:48 +0800)]
hyperv: Reorder the Hyper-V TSC initialization a bit.

This kinda simplifies the initialization logic.

7 years agokernel - Add NUMA awareness to vm_page_alloc() and related functions
Matthew Dillon [Fri, 6 Jan 2017 02:08:40 +0000 (18:08 -0800)]
kernel - Add NUMA awareness to vm_page_alloc() and related functions

* Add NUMA awareness to the kernel memory subsystem.  This first iteration
  will primarily affect user pages.  kmalloc and objcache are not
  NUMA-friendly yet (and its questionable how useful it would be to make
  them so).

* Tested with synth on monster (4-socket opteron / 48 cores) and a 2-socket
  xeon (32 threads).  Appears to dole out localized pages 5:1 to 10:1.

7 years agokernel - Refactor phys_avail[] and dump_avail[]
Matthew Dillon [Fri, 6 Jan 2017 00:33:49 +0000 (16:33 -0800)]
kernel - Refactor phys_avail[] and dump_avail[]

* Refactor phys_avail[] and dump_avail[] into a more understandable
  structure.

7 years agoalc.4: Add Killer E2400 to the list of supported devices.
Sascha Wildner [Thu, 5 Jan 2017 14:20:50 +0000 (15:20 +0100)]
alc.4: Add Killer E2400 to the list of supported devices.

Taken-from: FreeBSD

7 years agoalc: Sync w/ FreeBSD
Sepherosa Ziehau [Thu, 5 Jan 2017 13:45:52 +0000 (21:45 +0800)]
alc: Sync w/ FreeBSD

Mainly
- Fix DMA selection for AR816x family chips.
- Add Killer E2400 support.

Obtained-from: FreeBSD 277907, 295735 (part), 304574, 304584

7 years agopci: Add a quirk for chips w/ broken MSI support.
Sepherosa Ziehau [Thu, 5 Jan 2017 13:15:06 +0000 (21:15 +0800)]
pci: Add a quirk for chips w/ broken MSI support.

These chips (mainly chips supported by alc(4)) will not send MSI,
if INTxDIS is set.

Obtained-from: FreeBSD

7 years ago<sys/vfscache.h>: Sync enum vtagtype with what we have.
Sascha Wildner [Wed, 4 Jan 2017 07:41:18 +0000 (08:41 +0100)]
<sys/vfscache.h>: Sync enum vtagtype with what we have.

7 years agoRemove portal file system, mount_portal and examples.
Sascha Wildner [Wed, 4 Jan 2017 07:39:55 +0000 (08:39 +0100)]
Remove portal file system, mount_portal and examples.

It has been broken for a long time I think.

Approved-by: dillon
7 years agocam - Fix bus registration race
Matthew Dillon [Tue, 3 Jan 2017 02:48:11 +0000 (18:48 -0800)]
cam - Fix bus registration race

* Fix bus registration race.  This race could only occur when
  hw.ahci.synchronous_boot is set to 0 (it defaults to 1).

7 years agovmstat - Make vmstat -m more readable (2)
Matthew Dillon [Tue, 3 Jan 2017 01:54:25 +0000 (17:54 -0800)]
vmstat - Make vmstat -m more readable (2)

* Follow up on first commit.

7 years agokernel - vm_object work
Matthew Dillon [Tue, 3 Jan 2017 01:49:36 +0000 (17:49 -0800)]
kernel - vm_object work

* Adjust OBJT_SWAP object management to be more SMP friendly.  The hash
  table now uses a combined structure to reduce unnecessary cache
  interactions.

* Allocate VM objects via kmalloc() instead of zalloc.  Remove the zalloc
  pool for VM objects and use kmalloc().  Early initialization of the kernel
  does not have to access vm_object allocation functions until after basic
  VM initialization.

* Remove a vm_page_cache console warning that is no longer applicable.
  (It could be triggered by the RSS rlimit handling code).

7 years agokernel - Add kmalloc_set_unlimited()
Matthew Dillon [Tue, 3 Jan 2017 01:47:23 +0000 (17:47 -0800)]
kernel - Add kmalloc_set_unlimited()

* Add kmalloc_set_unlimited() to more trivially unlimit a kmalloc pool.

7 years agovmstat - Make vmstat -m more readable
Matthew Dillon [Tue, 3 Jan 2017 01:46:22 +0000 (17:46 -0800)]
vmstat - Make vmstat -m more readable

* Make vmstat -m more readable by converting to appropriate units.

* Shorten some of the malloc_type pool names.

7 years agonvme - Adjust manual page
Matthew Dillon [Tue, 3 Jan 2017 01:42:55 +0000 (17:42 -0800)]
nvme - Adjust manual page

* Adjust the last paragraph describing EFI booting to match our current
  state of affairs.

7 years agokernel - Fix kmalloc pool accounting for M_NETCRED
Matthew Dillon [Tue, 3 Jan 2017 01:40:50 +0000 (17:40 -0800)]
kernel - Fix kmalloc pool accounting for M_NETCRED

* Some kfree()'s for M_NETCRED should really have been for M_RTABLE.  Fixes
  an accounting error that shows up in 'vmstat -m'.

* Rename the kmalloc pool in  netinet/ip_encap.c to M_IPENCAP.  It was
  previously named M_NETCRED and duplicated another pool's name.

7 years agoSync ACPICA with Intel's version 20161222.
Sascha Wildner [Mon, 2 Jan 2017 02:26:31 +0000 (03:26 +0100)]
Sync ACPICA with Intel's version 20161222.

* Fixed a regression where occasionally a valid resource
  descriptor was incorrectly detected as invalid at runtime,
  and a AE_AML_NO_RESOURCE_END_TAG was returned.

* Fixed a problem with the recently implemented support that
  enables control method invocations as Target operands to
  many ASL operators. Warnings of this form: "Needed type
  [Reference], found [Processor]" were seen at runtime for
  some method invocations.

  This is the proper fix for 72b7bc0a284cc.

* Enhanced iasl(8) output for Switch/Case statements.

For a more detailed list, please see sys/contrib/dev/acpica/changes.txt.

7 years agokernel - Fix TRIM bugs in UFS
Matthew Dillon [Mon, 2 Jan 2017 01:52:23 +0000 (17:52 -0800)]
kernel - Fix TRIM bugs in UFS

* Fix serious bug in devfs's implementation of VOP_FREEBLKS.  devfs was
  running this operation asynchronously, but callers (aka UFS) expect it
  to run synchronously.

* Fix minor bug in CAM related to TRIM failures.

* Enforce block count limitations in NVMe for WRITEZ.

* Mostly applicable to NVMe, which will implement FREEBLKS using the WRITEZ
  command (at least for now).  Trim is disabled on SATA SSDs by default in
  the driver.

  Fixes UEFI booting issues with NVMe when using a UFS /boot.  Writing or
  updating the UFS /boot mounted via NVMe resulted in a corrupt partition due
  to the asynchronous VOP_FREEBLKS that we fixed above.

Reported-by: mneumann.
7 years agokernel - Fix bugs in recent RSS/swap commits
Matthew Dillon [Sun, 1 Jan 2017 21:20:49 +0000 (13:20 -0800)]
kernel - Fix bugs in recent RSS/swap commits

* Refactor the vm_page_try_to_cache() call to take a page already busied,
  and fix a case where it was previously being called improperly that left
  a VM page permanently busy.

7 years agovmstat - (-m) Make large values more readable
Matthew Dillon [Sat, 31 Dec 2016 00:36:29 +0000 (16:36 -0800)]
vmstat - (-m) Make large values more readable

* Display values > 99M in megabytes instead of kilobytes.  Makes everything
  a whole lot easier to read.  For vmstat -m

7 years agoBump copyrights.
Sascha Wildner [Sun, 1 Jan 2017 04:04:17 +0000 (05:04 +0100)]
Bump copyrights.

7 years agohumanize_number.3: Fix typo.
Sascha Wildner [Sat, 31 Dec 2016 00:45:17 +0000 (01:45 +0100)]
humanize_number.3: Fix typo.

7 years agodf, pstat - Use HN_FRACTIONAL
Matthew Dillon [Sat, 31 Dec 2016 00:08:50 +0000 (16:08 -0800)]
df, pstat - Use HN_FRACTIONAL

* Use the new HN_FRACTIONAL to display fractional digits in a better
  way than HN_DECIMAL.  The general problem being solved is that in
  numerous cases HN_DECIMAL would only display two digits, which is
  not enough precision.

  For example, if you have a 32.3G volume it would previously display as
  32G, and will now display as 32.3G.  If I configured 14.6TB of swap it
  would previously display as 14T and will now display as 14.6T.

7 years agolibutil - Add HN_FRACTIONAL to humanize_number()
Matthew Dillon [Sat, 31 Dec 2016 00:07:04 +0000 (16:07 -0800)]
libutil - Add HN_FRACTIONAL to humanize_number()

* Add HN_FRACTIONAL to humanize_number().  This is an expanded HN_DECIMAL
  mode.  Up to two additional fractional digits will be displayed if they
  would fit in the buffer.  Fractional digits are not displayed for small
  numbers (less than 1000 or less than 1024 depending on the mode).

7 years agolibkvm - Interim solution to boost swap statistics fields
Matthew Dillon [Fri, 30 Dec 2016 22:47:16 +0000 (14:47 -0800)]
libkvm - Interim solution to boost swap statistics fields

* Change ksw_used and ksw_total to unsigned, which increases the maximum
  total swap that can be displayed properly from ~8TB to ~16TB.

  This is an interim solution, since DragonFly now supports more than 16TB
  of swap.

* Noticed when the pstat output was mangled after I configured 16TB of
  actual honest to god swap space.

7 years agokernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion
Matthew Dillon [Fri, 30 Dec 2016 20:21:26 +0000 (12:21 -0800)]
kernel - Fix swap issue, implement dynamic pmap PT/PD/PDP deletion

* The pmap code is now able to dynamically destroy PT, PD, and PDP
  page table pages when they become empty.  To do this we had to
  recode the higher-level page tables to wire on creation of a lower-level
  pv_entry instead of wiring on pte entry.

  DragonFly previously left PD and PDP pages intact, and possibly also PTs,
  until process exit.  In normal operation this had no real impact since
  most programs don't bloat up enough for the extra page table pages to
  matter, but its good to finally fix it as it allows the pmap footprint
  to be significantly reduced in the very few situations where a program
  bloats and unbloats during operation.

* Fix an issue with recent swap changes.  We must increase the stripe
  between multiple swap devices to match the number of entries available
  on a radix leaf, which increased from 32 to 64.  This fixes a pstat -s
  accounting error that would sometimes attribute swap frees to the wrong
  device.

* Refactor the RSS limiting code to scan the pmap instead of scan the
  vm_map and related underlying objects.  This greatly enhances performance
  because the underlying objects might have many pages that are not mapped.
  By scanning the pmap, we avoid having to sift through them all.

  Also makes use of the dynamic removal feature in the pmap code to restrict
  the effort required to do the pmap scan, and allows us to avoid most of
  the issues related to stacked VM objects.

7 years agoRaise WARNS to 3 for sftp(1) and sftp-server(8).
Sascha Wildner [Fri, 30 Dec 2016 15:10:22 +0000 (16:10 +0100)]
Raise WARNS to 3 for sftp(1) and sftp-server(8).

7 years agochmod.c: Remove mention of POSIX in a comment.
Sascha Wildner [Fri, 30 Dec 2016 14:46:56 +0000 (15:46 +0100)]
chmod.c: Remove mention of POSIX in a comment.

POSIX doesn't specify -h.

Submitted-by: Sevan Janiyan
Taken-from:    NetBSD
Dragonfly-bug: <http://bugs.dragonflybsd.org/issues/2948>

7 years agozone.9: Adjust for the removal of the 'zalloc' arg to zinit/zinitna.
Sascha Wildner [Thu, 29 Dec 2016 23:10:13 +0000 (00:10 +0100)]
zone.9: Adjust for the removal of the 'zalloc' arg to zinit/zinitna.

7 years agonlookup.9: Adjust for the removal of nlookup_set_cred().
Sascha Wildner [Thu, 29 Dec 2016 23:04:38 +0000 (00:04 +0100)]
nlookup.9: Adjust for the removal of nlookup_set_cred().

7 years agokernel - Add flexibility to the RSS rlimit
Matthew Dillon [Wed, 28 Dec 2016 22:07:02 +0000 (14:07 -0800)]
kernel - Add flexibility to the RSS rlimit

* Add sysctl vm.pageout_memuse_mode, defaulting to 1:

  0 - disable (behavior prior to memoryuse rlimit commits).  RLIMIT_RSS
      is ignored.  Pagedaemon operates normally based on global page
      queues.

  1 - passive mode (default).  Pagedaemon operates normally, but additional
      actions are taken for processes exceeding their RLIMIT_RSS.

      Enforces RSS on a per-process basis by removing pages from the pmap,
      but simply deactivates the page and does not synchronously free it
      or page it out to swap.  The deactivated pages are more likely to be
      cleaned out by the system by the pagedaemon verses what it would
      normally choose from the global page queues.

      This mode has the smoothest results for the process being limited,
      as well as a lower impact on actual paging to swap, but this mode
      has the similar impact on alloctable memory for other unrelated
      processes if the limited process continues to allocate large amounts
      of memory.

  2 - active mode.  Pagedaemon operates normally, but additional actions
      are taken for processes exceeding their RLIMIT_RSS.

      Enforces RSS on a per-process basis by actively freeing clean pages
      and actively paging out dirty pages.  This has the least impact on
      other unrelated processes but can cause the limited process to stall
      for short periods of time.  This mode has the least impact on
      allocatable memory.

      However, this mode can cause excessive paging to swap, and thus is
      not the default.

7 years agokernel - Increase KVM from 128G to 511G, further increase maximum swap
Matthew Dillon [Wed, 28 Dec 2016 20:04:03 +0000 (12:04 -0800)]
kernel - Increase KVM from 128G to 511G, further increase maximum swap

* Increase KVM (Kernel Virtual Memory) to the maximum we currently
  support.  Up to half of it can be used for swblock structures
  (SWAPMETA in vmstat -z).  This allows the following swap maximums.

  128G of ram - 15TB of data can be swapped out.
  256G of ram - 30TB of data can be swapped out.
  512G+ of ram  - 55TB - this is the maximum we can support swapped out.

* We can support > 512G of KVM in the future with only a bit of work on
  how KVM is reserved.

* Remove some debugging code.

7 years agokernel - Cleanup swap comments
Matthew Dillon [Wed, 28 Dec 2016 20:03:36 +0000 (12:03 -0800)]
kernel - Cleanup swap comments

* Cleanup some incorrect comments

7 years agokernel: Fix a -Wundef warning.
Sascha Wildner [Wed, 28 Dec 2016 14:46:54 +0000 (15:46 +0100)]
kernel: Fix a -Wundef warning.

7 years ago<errno.h>: Generally include <sys/cdefs.h>.
Sascha Wildner [Wed, 28 Dec 2016 14:46:06 +0000 (15:46 +0100)]
<errno.h>: Generally include <sys/cdefs.h>.

I forgot this change in 329111df7bb1e6c835b3e1835b384ecf2dd3aaf7.

7 years agotcp: Fix connect to INADDR_ANY.
Sepherosa Ziehau [Wed, 28 Dec 2016 13:02:26 +0000 (21:02 +0800)]
tcp: Fix connect to INADDR_ANY.

Reported-by: mneumann
DragonFly-bug: http://bugs.dragonflybsd.org/issues/2973

7 years agokernel - Implement RLIMIT_RSS, Increase maximum supported swap
Matthew Dillon [Wed, 28 Dec 2016 02:34:26 +0000 (18:34 -0800)]
kernel - Implement RLIMIT_RSS, Increase maximum supported swap

* Implement RLIMIT_RSS by forcing pages out to swap if a process's RSS
  exceeds the rlimit.  Currently the algorith used to choose the pages
  is fairly unsophisticated (we don't have the luxury of a per-process
  vm_page_queues[] array).

* Implement the swap_user_async sysctl, default off.  This sysctl can be
  set to 1 to enable asynchronous paging in the RSS code.  This is mostly
  for testing and is not recommended since it allows the process to eat
  memory more quickly than it can be paged out.

* Reimplement vm.swap_burst_read so the sysctl now specifies the number
  of pages that are allowed to be burst.  Still disabled by default (will
  be enabled in a followup commit).

* Fix an overflow in the nswap_lowat and nswap_hiwat calculations.

* Refactor some of the pageout code to support synchronous direct
  paging, which the RSS code uses.  Thew new code also implements a
  feature that will move clean pages to PQ_CACHE, making them immediately
  reallocatable.

* Refactor the vm_pageout_deficit variable, using atomic ops.

* Fix an issue in vm_pageout_clean() (originally part of the inactive scan)
  which prevented clustering from operating properly on write.

* Refactor kern/subr_blist.c and all associated code that uses to increase
  swblk_t from int32_t to int64_t, and to increase the radix supported from
  31 bits to 63 bits.

  This increases the maximum supported swap from 2TB to some ungodly large
  value.  Remember that, by default, space for up to 4 swap devices
  is preallocated so if you are allocating insane amounts of swap it is
  best to do it with four equal-sized partitions instead of one so kernel
  memory is efficiently allocated.

* There are two kernel data structures associated with swap.  The blmeta
  structure which has approximately a 1:8192 ratio (ram:swap) and is
  pre-allocated up-front, and the swmeta structure whos KVA is reserved
  but not allocated.

  The swmeta structure has a 1:341 ratio.  It tracks swap assignments for
  pages in vm_object's.  The kernel limits the number of structures to
  approximately half of physical memory, meaning that if you have a machine
  with 16GB of ram the maximum amount of swapped-out data you can support
  with that is 16/2*341 = 2.7TB.  Not that you would actually want to eat
  half your ram to do actually do that.

  A large system with, say, 128GB of ram, would be able to support
  128/2*341 = 21TB of swap.  The ultimate limitation is the 512GB of KVM.
  The swap system can use up to 256GB of this so the maximum swap currently
  supported by DragonFly on a machine with > 512GB of ram is going to be
  256/2*341 = 43TB.  To expand this further would require some adjustments
  to increase the amount of KVM supported by the kernel.

* WARNING! swmeta is allocated via zalloc().  Once allocated, the memory
  can be reused for swmeta but cannot be freed for use by other subsystems.
  You should only configure as much swap as you are willing to reserve ram
  for.

7 years agokernel - Do a better job locking CAM ref counts
Matthew Dillon [Wed, 28 Dec 2016 01:30:23 +0000 (17:30 -0800)]
kernel - Do a better job locking CAM ref counts

* Fix some ref-count races inside CAM which can be triggered particularly
  by asynchronous AHCI probing.

7 years agodrm: Invert del_timer_sync return value, to match behaviour in Linux.
Imre Vadász [Tue, 27 Dec 2016 21:46:31 +0000 (22:46 +0100)]
drm: Invert del_timer_sync return value, to match behaviour in Linux.

* DragonFly's callout_drain() returns 1 if the function was executed.
  Linux's del_timer_sync() returns 1 if the timer was pending and got
  cancelled.
  So inverting the callout_drain() return value should make del_timer_sync
  behave a bit more like the correponding function in Linux.

* This fixes the behaviour of the "if (del_timer_sync(&domain->timer) == 0)"
  check in intel_uncore_forcewake_reset() .

7 years agosyncache: Simplify port calculation by reusing ACK's hash for IPv4.
Sepherosa Ziehau [Sun, 25 Dec 2016 13:01:54 +0000 (21:01 +0800)]
syncache: Simplify port calculation by reusing ACK's hash for IPv4.

7 years agoloopback: Allow turning off RSS.
Sepherosa Ziehau [Sun, 25 Dec 2016 12:55:57 +0000 (20:55 +0800)]
loopback: Allow turning off RSS.