dragonfly.git
4 years agokernel - Improve cache_fullpath() performance v5.8.0
Matthew Dillon [Sat, 29 Feb 2020 06:10:38 +0000 (22:10 -0800)]
kernel - Improve cache_fullpath() performance

* realpath() now uses cache_fullpath() in the kernel.  This procedure
  was not optimized for performance.

* Fix cache_fullpath() to use a shared ncp lock instead of an exclusive
  one.

* Significantly improves concurrent program executions that use
  realpath() a lot, such as high make -j ops or concurrent makes.

* Change not yet in master but will be soon.

4 years agodsynth - pkg install -U and improve debug support
Matthew Dillon [Sun, 16 Feb 2020 19:57:12 +0000 (11:57 -0800)]
dsynth - pkg install -U and improve debug support

* pkg install now passes the -U option to avoid trying to access remote
  repos.

* Multiple -d's will turn off ncurses and log to stdout, but what we
  really want to do is to log to a file.  Fix thet 'single -d option'
  feature to now log to 07_debug.log.

* Package dependencies on generic flavored ports (i.e. a depdency which
  does not specify the flavor) were sometimes improperly flagged for
  building even when the default flavor had failed.

Reported-by: zrj
4 years agokernel - Microoptimization, avoid dirtying vm_page_hash entry
Matthew Dillon [Sat, 15 Feb 2020 19:46:32 +0000 (11:46 -0800)]
kernel - Microoptimization, avoid dirtying vm_page_hash entry

* Avoid dirtying the vm_page_hash entry unnecessarily with a
  ticks update if the existing field already has the correct value.

  The VM page hash has an extreme level of SMP concurrency, so
  avoiding cache coherency contention is important.

4 years agodsynth - Adjust 'Limit' display in upper right-hand corner
Matthew Dillon [Sat, 15 Feb 2020 05:46:15 +0000 (21:46 -0800)]
dsynth - Adjust 'Limit' display in upper right-hand corner

* Increase the Limit display from 2 to 3 digits, fixing minor
  display corruption when dsynth is run with greater than 99
  worker slots.

4 years agokernel - Reduce SMP contention during low-memory stress
Matthew Dillon [Sat, 15 Feb 2020 05:39:32 +0000 (21:39 -0800)]
kernel - Reduce SMP contention during low-memory stress

* When memory gets low vm_page_alloc() is forced to stray into
  adjacent VM page queues to find free pages.  This search can
  expand to the whole queue and cause massive SMP contention on
  systems with many cores.

  For example, if PQ_FREE has almost no pages but PQ_CACHE has
  plenty of pages, the previous scan code widened its search
  to the entire PQ_FREE queue (causing a ton of SMP contention)
  before beginning a search of PQ_CACHE.

* The new scan code starts in PQ_FREE but once the search widens
  sufficiently it will also simultaneously begin searching PQ_CACHE.

  This allows the system to continue to allocate memory with minimal
  contention as long as PQ_FREE or PQ_CACHE have pages.

* The new mechanism integrated a whole lot better with pageout
  daemon behavior.  The pageout daemon generally triggers off
  the FREE+CACHE total and not (generally) off of low levels
  for one or the other.

4 years agokernel - Fix rare wait*() deadlock
Matthew Dillon [Sat, 15 Feb 2020 05:37:32 +0000 (21:37 -0800)]
kernel - Fix rare wait*() deadlock

* It is possible for the kernel to deadlock two processes or process
  threads attempting to wait*() on the same pid.

* Fix by adding a bit of magic to give ownership of the reaping
  operation to one of the waiters, and causing the other waiters
  to skip/reject that pid.

4 years agodevfs - Clean up some SMP inefficiencies
Matthew Dillon [Sat, 15 Feb 2020 00:01:09 +0000 (16:01 -0800)]
devfs - Clean up some SMP inefficiencies

* We don't need the devfs master lock around a setattr call.  This
  fixes the open(O_CREAT|O_TRUNC) path for redirects to e.g. /dev/null,
  which is used all over the place in ports builds.

* The devfs spec open (open() again) path can obtain the devfs master
  lock shared instead of exclusive, except in the cloning case.
  This significantly reduces stalls during heavily concurrent bulk
  builds.

4 years agokernel - Increase size of the vm_page hash table
Matthew Dillon [Fri, 14 Feb 2020 23:50:48 +0000 (15:50 -0800)]
kernel - Increase size of the vm_page hash table

* Increase the size of the vm_page hash table used to shortcut
  page lookups during a fault.  Improves the hit rate on machines
  with large amounts of memory.

* Adjust the ticks overflow test from < 0 to < -1 in to avoid
  getting tripped up by SMP races on the global 'ticks' variable
  (which is not accessed atomically).  One cpu can conceivably
  update a hash ticks value while another cpu is doing a calculation
  based on a stale copy of ticks.

  Avoids premature vm_page_hash cache evictions due to this race.

4 years agokernel - Offset the stathz systimer by 50% of the hz timer
Matthew Dillon [Fri, 14 Feb 2020 05:48:23 +0000 (21:48 -0800)]
kernel - Offset the stathz systimer by 50% of the hz timer

* Offset the initial starting point of the stathz systimer by
  50% of the hz timer, so they do not interfere with each other
  if they happen to be set to the same frequency.

* Change the default stathz frequency to hz + 1 (101hz) so it
  slides across the tick interval window.

4 years agordrand - Document massive improvement in performance
Matthew Dillon [Fri, 14 Feb 2020 06:13:57 +0000 (22:13 -0800)]
rdrand - Document massive improvement in performance

* Document the huge difference going from 512 to 16 bytes.  General
  system performance is improved by 9.3% on a TR3990X.

  This is not entirely the fault of rdrand.  It is also in a large
  part due to the overhead of add_buffer_randomness().

4 years agokernel - Add more dtypes to sys/dtype.h
Matthew Dillon [Fri, 14 Feb 2020 05:53:04 +0000 (21:53 -0800)]
kernel - Add more dtypes to sys/dtype.h

* Add a few from FreeBSD, and also add some placeholder types for
  "encrypted" and "unspecified" partition types.

4 years agopctrack - Fix symbol table scan
Matthew Dillon [Fri, 14 Feb 2020 05:52:29 +0000 (21:52 -0800)]
pctrack - Fix symbol table scan

* Fix the symbol table scan to properly parse kernel symbols and not
  get confused by non-code symbols.

4 years agokernel - Reduce excessive rdrand harvesting
Matthew Dillon [Fri, 14 Feb 2020 05:39:17 +0000 (21:39 -0800)]
kernel - Reduce excessive rdrand harvesting

* Our rdrand driver harvests 512 bytes on each cpu thread at a rate
  of 10hz.  Ryzen CPUs appear to burn about 0.73uS per word, creating
  an overhead of about 460uS/sec on EACH cpu thread in the system.

  When added to the even higher overhead of the add_buffer_randomness()
  call, the result was a roughly 3% loss of performance across the board.

* Reduce the harvest size to 16 bytes, which honestly is still plenty
  of entropy to inject.

* Change some symbolic branch targets to local branch targets in the
  rdrand and padlock code to avoid generating symbols that can cause
  weird output in our PC sampler (I was getting 'loop+N' and 'out+N'
  while testing the above).

4 years agokernel - Rearrange uidinfo structure a bit
Matthew Dillon [Wed, 26 Feb 2020 05:57:52 +0000 (21:57 -0800)]
kernel - Rearrange uidinfo structure a bit

* Rearrange the structure to move ui_lock and ui_refs
  into a cache-line isolated area of the structure.

4 years agokernel - Simple cache line optimizations
Matthew Dillon [Tue, 25 Feb 2020 05:29:36 +0000 (21:29 -0800)]
kernel - Simple cache line optimizations

* Reorder struct vm_page, struct vnode, and struct vm_object a bit
  to improve cache-line locality.

* Use atomic_fcmpset_*() instead of atomic_cmpset_*() in several
  places to reduce the inter-cpu cache coherency load a bit.

4 years agokernel - Try to fix tcp ISN generator
Matthew Dillon [Mon, 24 Feb 2020 23:00:00 +0000 (15:00 -0800)]
kernel - Try to fix tcp ISN generator

* The ISN generator couldn't stand the test of time.  Very fast port
  reuse can catch the destination host inpcb still in a TIME_WAIT
  state and a bad ISN results in the destination ignoring the new SYN.
  The old ISN generator could wind up returning the same sequence
  number for fast reconnects occuring within the same tick.

  Reimplement the ISN generator and also make it SMP friendly and
  cache friendly.  Because... it really wasn't before.  Also attempt
  to modernize the monotonic sequence space algorithm, reseed the
  secret every 20 seconds, and make the reseeding non-disruptive to
  sequence space monotonicity.

* Change the TH_SYN + TIME_WAIT state handling.  Generally speaking it
  is inteded that a new SYN when the inpcb is in TIME_WAIT recycle the
  port/address pair and allow the new connection.

  The sequence space checks for the TH_SYN may have been too strict.
  Change the check to allow the recycling of the port/address pair
  as long as the SYN has a different sequence number as the previous
  connection.

  I believe this is relatively safe since the recycling can only happen
  if the socket is already in a TIME_WAIT state, but consider the code
  still under test.

4 years agojail - add jail.defaults.allow_listen_override (3)
Matthew Dillon [Mon, 24 Feb 2020 22:56:05 +0000 (14:56 -0800)]
jail - add jail.defaults.allow_listen_override (3)

* Normalize the nominal jail IP conversions to the system call
  interface whenever it is convenient.  Remove conversions that
  were previously in the udp and tcp connect and send code.

* Also do jail IP conversions in bind(), connect(), extconnect(),
  sendto(), sendmsg(), recvfrom(), recvmsg().

* Refactor in_pcbladdr_find() to improve jail bindings, try to find
  the correct interface IP to bind to.  When a route is utilized,
  iterate available interface IPs to locate a jail-acceptable IP
  on the same interface.

4 years agosyscons.4: Mention restrictions on the resolution of ttyv0.
Sascha Wildner [Mon, 24 Feb 2020 10:20:54 +0000 (11:20 +0100)]
syscons.4: Mention restrictions on the resolution of ttyv0.

4 years agojail - add jail.defaults.allow_listen_override (2)
Matthew Dillon [Mon, 24 Feb 2020 08:48:00 +0000 (00:48 -0800)]
jail - add jail.defaults.allow_listen_override (2)

* Also munge the returned sockaddr for accept4() when inside a
  jail.

4 years agojail - add jail.defaults.allow_listen_override
Matthew Dillon [Mon, 24 Feb 2020 07:05:42 +0000 (23:05 -0800)]
jail - add jail.defaults.allow_listen_override

* Add jail.defaults.allow_listen_override (also per-jail settable).
  This feature is disabled by default.

  When enabled, this feature allows both wildcard and non-wildcard listen
  sockets in the jail to override wildcard listen sockets on the host.
  These sockets will be masked by the jail's IP list, meaning that a
  wildcard socket in the jail effectively covers just the jail's IP list.

  Non-wildcard listen sockets on the host are not overriden.

  Use of this feature allows the host to operate normally, without having
  to make its services jail-friendly.  Only those services which bind to
  specific IPs that might conflict with the jail IPs will need modification,
  and only if the jail needs to have that service as well.

* In order to use the feature safely each jail should be given its
  own unique IPs for both localhost and its externally routable IP.
  For example:

  jail -u root / tr3990xJ 127.0.0.2,10.0.0.139 /bin/csh

  ifconfig can be used on the host to create multiple 127.0.0.X aliases
  on lo0 and to assign additional routable IPs to the machine for use
  in its jails.  For example:

  ifconfig lo0 inet 127.0.0.2  alias
  ifconfig lo0 inet 127.0.0.3  alias
  ifconfig lo0 inet6 ::2 alias
  ifconfig lo0 inet6 ::3 alias
  ifconfig em0 inet 10.0.0.139 netmask 255.255.0.0 alias
  ifconfig em0 inet 10.0.0.140 netmask 255.255.0.0 alias
  ...

* Within a jail, use of localhost (127.0.0.1 or ::1) will automatically
  be converted to the jail's localhost IP (such as 127.0.0.2).  Also,
  accept(), getsockname(), and getpeername() will translate the jail's
  localhost IP back to 127.0.0.1 or ::1.  Most services within the
  jail can thus use localhost without being the wiser.

* Listen address/port pairs within a jail can now be overloaded with the
  same address/port pairs on the host, or overloaded verses other jails
  without generating an error.  However, accessibility to these ports is
  governed by the 'jail.deafults.allow_listen_override' sysctl setting
  for the jail (or the jail-specific version of the same sysctl).

  Any jail-to-jail overloading of identical address/port pairs is allowed,
  but operationally undefined.  Only one jail will receive connections.

  It is best to supply each jail with its own unique local and routable
  IPs.

* IPV6 is now fully supported using the same mechanisms.  You can supply
  a mix of IPV4 and IPV6 addresses in the jail command if desired.  The
  overloading feature works the same.

4 years agonfs - Strip out cr_prison from cached creds
Matthew Dillon [Mon, 24 Feb 2020 06:55:13 +0000 (22:55 -0800)]
nfs - Strip out cr_prison from cached creds

* Strip out cr_prison from creds cached in struct nfs_node to
  prevent exited jails from sticking around indefinitely.

4 years agojail - Fix broken port matching code
Matthew Dillon [Sun, 23 Feb 2020 20:02:27 +0000 (12:02 -0800)]
jail - Fix broken port matching code

* in_pcblookup_local() and in_pcblookup_localremote() were trying to
  use the cred to distinguish between jails, but these routines are used
  to locate a free port for bindind purposes and could wind up returning
  a lookup failure for an occupied port.

  The code may have been present in an early isolation attempt for jails.

* Remove the code.  Isolating the IPs for a jail basically requires using
  IP aliases, not by trying to isolate port number sets between jails.

4 years agojail - Allow loopback interface in in_pcbladdr_find()
Matthew Dillon [Sun, 23 Feb 2020 18:11:28 +0000 (10:11 -0800)]
jail - Allow loopback interface in in_pcbladdr_find()

* Prior jail adjustments to allow loopback IPs to be specified in
  the ip-list missed this bit of code which caused the binding
  code to ignore routes to loopback interfaces.

* Adjust the code to accept such routes.  If a loopback IP is in
  the jail's ip-list, it can now be bound to.  If not, and a loopback
  route is returned, it will use the first non-loopback IP in the jail's
  ip-list.

* Note that listen sockets within a jail are not overloaded and so can
  connect to listen sockets on the host or in other jails when a common
  IP (such as 127.0.0.1) is in the ip-list for both.  In this regard,
  shared loopback IPs now work identically to shared NIC IPs.

  IP aliases may be used to create a separation.  If you use e.g. 127.0.0.2
  in a jail, bindings to 127.0.0.1 will automatically be adjusted to
  use 127.0.0.2.

4 years agotmpfs - Fix races in tmpfs_nrename() and tmpfs_nrmdir()
Matthew Dillon [Sat, 22 Feb 2020 19:12:35 +0000 (11:12 -0800)]
tmpfs - Fix races in tmpfs_nrename() and tmpfs_nrmdir()

* Lock all nrename elements before checks.  This is particularly
  important when renaming over a file or empty directory, but other
  manipulations done by this code without locks could also cause
  races which result in corruption, particularly with the link count.

* Lock all nrmdir elements before checks, for the same reason.

4 years agotmpfs - Cleanup, refactor tmpfs_alloc_vp()
Matthew Dillon [Sat, 22 Feb 2020 18:48:50 +0000 (10:48 -0800)]
tmpfs - Cleanup, refactor tmpfs_alloc_vp()

* Refactor tmpfs_alloc_vp() to handle races without having to have
  a weird intermediate TMPFS_VNODE_ALLOCATING state.  This also
  removes the related ALLOCATING/WAIT code which had a totally broken
  tsleep() call in it.

* Properly zero fields in tmpfs_alloc_node().

* Cleanup some comments

4 years agoUse our new partition id (0x6c) in several more places.
Sascha Wildner [Fri, 14 Feb 2020 22:29:00 +0000 (23:29 +0100)]
Use our new partition id (0x6c) in several more places.

Mainly, adjust the USB img's own ID and use it in the installer's
legacy BIOS install.

While here, adjust DragonFly BSD's name in a few places (written with
a space).

Reported-by: zrj
4 years agodsynth - Fix generic flavor scan for the Nth time
Matthew Dillon [Mon, 17 Feb 2020 08:07:56 +0000 (00:07 -0800)]
dsynth - Fix generic flavor scan for the Nth time

* The commit in 4986398e0bafb7 fixed one problem and created another
  because it didn't quite skip past enough of the checks on the dummy
  node.  Skip past the last check as well so we can decend into the
  true dependency.

4 years agoUpdate the pciconf(8) database.
Sascha Wildner [Sun, 16 Feb 2020 09:30:16 +0000 (10:30 +0100)]
Update the pciconf(8) database.

February 12, 2020 snapshot from https://pci-ids.ucw.cz

4 years ago5.8 rc1 changes. v5.8.0rc1
Justin C. Sherrill [Sat, 15 Feb 2020 21:44:30 +0000 (16:44 -0500)]
5.8 rc1 changes.

4 years agovmstat - Change re, pi, po and fr from counts to bytes
Matthew Dillon [Thu, 13 Feb 2020 01:12:29 +0000 (17:12 -0800)]
vmstat - Change re, pi, po and fr from counts to bytes

* Change re, pi, po, and fr to bytes.  re, pi, and po were previously
  paging related transaction counts (not even page counts) which really
  tells us absolutely nothing.

  The values are now displayed in terms of bytes reclaimed, paged in,
  paged out, and freed, with appropriate suffixes (nothing, K, M, or G).

4 years agotmpfs - Improve write clustering
Matthew Dillon [Thu, 13 Feb 2020 00:41:01 +0000 (16:41 -0800)]
tmpfs - Improve write clustering

* Setup bmap and max iosize parameters so the kernel's clustering
  code can actually cluster 16KB tmpfs blocks together into 64KB
  blocks.

* In low-memory situations the pageout daemon will flush tmpfs
  pages via the VM page queues.  This ultimately runs through
  the tmpfs_vop_write() UIO_NOCOPY path which was previously using
  cluster_awrite().  However, because other nearby buffers are
  probably not present (buwrite()'s can allow buffers to be
  dismissed early), there is nothing for cluster_awrite() to
  latch onto to improve write granularity beyond 16KB.

  Go back to using cluster_write() when SYNC and DIRECT are not
  specified.  This allows the clustering code to collect buffers
  and flush them in larger chunks.

* Reduces low-memory tmpfs paging I/O overheads by 4x and
  generally increases paging throughput to SSD-based swap by
  2x-4x.  Tmpfs is now able to issue a lot more 64KB I/Os when under
  memory pressure.

4 years agokernel - Add vm.pageout_allow_active sysctl
Matthew Dillon [Thu, 13 Feb 2020 00:37:56 +0000 (16:37 -0800)]
kernel - Add vm.pageout_allow_active sysctl

* Add vm.pageout_allow_active sysctl and default to 1.  The pageout
  daemon scans inactive pages for work.  This sysctl allows the pageout
  daemon to cluster nearby active OR inactive pages with the inactive
  page it found.

  Default to enabled.

4 years agotmpfs - Flush and recycle pages quickly during heavy paging activity
Matthew Dillon [Wed, 12 Feb 2020 20:47:07 +0000 (12:47 -0800)]
tmpfs - Flush and recycle pages quickly during heavy paging activity

* When the pagedaemon is operating any write()s made via tmpfs will
  be forced to operate through the buffer cache via cluster_write()
  or bdwrite() instead of using buwrite().

  This will cause the pages to be pipelined to backing store (swap)
  under these conditions, making them clean immediately to avoid
  having tmpfs cause further paging pressure on the system when it
  is already under paging pressure.

* In addition, the B_TTC flag is set on these buffers to attempt to
  recycle the pages directly into PQ_CACHE ASAP after they are flushed.

* Implement cluster_write() operation by default to try to improve
  block sizes for physical I/O.

* TMPFS currently must move pages between two VM objects when
  reclaiming a vnode, and back again upon re-use.  The current
  VM mechanism for renaming VM pages dirties them and this can
  potentially cause the paging system to thrash on the same page
  under heavy vnode recycling loads.

  Instead of allowing this to happen, TMPFS now frees any clean
  page that have backing store assigned when moving from the backing
  object, and any clean pages that were instantiated from backing
  store when moving to the backing object.

4 years agokernel - Add B_TTC flag (buffer cache try-to-cache flag)
Matthew Dillon [Wed, 12 Feb 2020 20:46:06 +0000 (12:46 -0800)]
kernel - Add B_TTC flag (buffer cache try-to-cache flag)

* This allows filesystems to set a flag, B_TTC, that causes the
  kernel to attempt to cycle the underlying pages into PQ_CACHE
  when the buffer is disposed of.

4 years agokernel - Improve vm_page_try_to_cache()
Matthew Dillon [Wed, 12 Feb 2020 20:42:36 +0000 (12:42 -0800)]
kernel - Improve vm_page_try_to_cache()

* In situations where this function is not able to cache the
  page due to the page being dirtied, instead of just returning
  at least ensure that it is moved to the inactive queue if it
  is currently on the active queue.

4 years agokernel - Adjust vm.pageout_memuse_mode
Matthew Dillon [Wed, 12 Feb 2020 20:25:32 +0000 (12:25 -0800)]
kernel - Adjust vm.pageout_memuse_mode

* Generally speaking pages in the INACTIVE queue are cycled through
  the queue once if they are clean, and twice if they are dirty
  (cycle, clean, cycle again).

  This could lead to an excessive lack of progress when paging heavily
  and a lot of dirty data is present in INACTIVE, such as when a great
  deal of just-written tmpfs related data is present.

* Change the default to cycle dirty pages through the queue just
  once, same as clean pages.

* Only scan 1/10 of each of the 1024 ACTIVE / INACTIVE queues in
  each pass.  This is particularly important for the INACTIVE queue
  because we want to give pages in this queue a chance to reactivate
  and they might not be given that chance when the full queue is
  scanned.

  This became an issue when we greatly increased the number of queues
  in previous SMP partitioning work (the CPU topology is mapped onto to
  the queue space for initial allocation attempts in order to reduce
  contention).

4 years agokernel - Require pages to be PQ_ACTIVE for quick vm_page soft refs
Matthew Dillon [Wed, 12 Feb 2020 20:20:47 +0000 (12:20 -0800)]
kernel - Require pages to be PQ_ACTIVE for quick vm_page soft refs

* Require the a VM page be ACTIVE when allowing a quick soft ref
  on it for a vm_fault().  If the page is not ACTIVE, the fault will
  access it normally and activate it.

  Previously the page could be ACTIVE or INACTIVE.

* This ensures that pages often-referenced by vm_fault do not accidently
  flow through states and get freed prematurely, causing light paging
  to unnecessarily stall active processes.

4 years agodsynth - Add one more column for 'Lines'
Matthew Dillon [Wed, 12 Feb 2020 20:16:36 +0000 (12:16 -0800)]
dsynth - Add one more column for 'Lines'

* Increase Lines column width from 6 digits to 7.

4 years agovmstat - Adjust format slightly
Matthew Dillon [Wed, 12 Feb 2020 02:43:25 +0000 (18:43 -0800)]
vmstat - Adjust format slightly

* Adjust the format for the "r b w" columns slightly to keep things
  aligned on modern systems.

4 years agodsynth - Adjust load calculations
Matthew Dillon [Tue, 11 Feb 2020 19:20:56 +0000 (11:20 -0800)]
dsynth - Adjust load calculations

* Change the load cap from 5.0 x ncpus to 4.0 x ncpus.

* Add vmtotal.t_pw to the 1-minute load.  This adds in any processes
  waiting on a page-fault in an attempt to not improperly increase the
  job cap due to low swap-thrashing-caused load averages.

4 years agoflock.2: Document the correct header (<fcntl.h>) for flock().
Sascha Wildner [Tue, 11 Feb 2020 15:20:02 +0000 (16:20 +0100)]
flock.2: Document the correct header (<fcntl.h>) for flock().

While here, remove some pointless quotations from the header.

4 years agodsynth - Improve auto SlowStart a bit
Matthew Dillon [Tue, 11 Feb 2020 06:16:57 +0000 (22:16 -0800)]
dsynth - Improve auto SlowStart a bit

* When MaxWorkers is >= 16, set the SlowStart at MaxWorkers / 4 instead
  of at 1 so we do not have to wait forever for it to inch up to a
  stable value.

4 years agokernel - Improve pageout daemon pipelining.
Matthew Dillon [Tue, 11 Feb 2020 06:13:13 +0000 (22:13 -0800)]
kernel - Improve pageout daemon pipelining.

* Improve the pageout daemon's ability to pipeline writes to the
  swap pager.  This deals with a number of low-memory situations
  where the pageout daemon was stopping too early (at the minimum
  free page mark).

* We don't want the pageout daemon to enforce the paging targets
  after a successful pass (as this makes it impossible to actually
  use the memory in question), but we DO want it to continue pipelining
  if the page stats are still below the hysteresis point governed by
  vm_paging_needed().

4 years agotmpfs - Cycle through buffer cache when pageout daemon is running
Matthew Dillon [Tue, 11 Feb 2020 06:11:35 +0000 (22:11 -0800)]
tmpfs - Cycle through buffer cache when pageout daemon is running

* tmpfs usually allocates VM pages directly, but this can overwhelm
  the VM system in low-memory situations, causing processes to make
  very little progress in normal run-time operation if one or more
  of them are doing heavy writing to tmpfs.

* Significantly improves dsynth performance in low-memory situations
  where multiple worker slots are in the install-pkgs phase.

4 years agokernel - Warn/assert on broken ACPI MADT
Matthew Dillon [Tue, 11 Feb 2020 06:09:58 +0000 (22:09 -0800)]
kernel - Warn/assert on broken ACPI MADT

* Add warnings and assertions for broken ACPI MADT tables.  I encountered
  this trying to boot a 3990X on a motherboard with an old BIOS that didn't
  support it.  It tried to boot anyway, but the MADT table was mangled
  and caused a null-pointer indirection in the kernel.  Assert nicely
  instead.

4 years agokernel - Add cpu ident bit ADMSKX (address mask extensions)
Matthew Dillon [Tue, 11 Feb 2020 06:09:15 +0000 (22:09 -0800)]
kernel - Add cpu ident bit ADMSKX (address mask extensions)

* Add cpu ident bit ADMSKX (address mask extensions)

Taken-from: FreeBSD

4 years agoMerge branch 'vendor/OPENBSD_LIBM'
Sascha Wildner [Mon, 10 Feb 2020 16:25:16 +0000 (17:25 +0100)]
Merge branch 'vendor/OPENBSD_LIBM'

4 years agoReally sync <math.h> with OpenBSD on the vendor branch. vendor/OPENBSD_LIBM
Sascha Wildner [Mon, 10 Feb 2020 16:22:59 +0000 (17:22 +0100)]
Really sync <math.h> with OpenBSD on the vendor branch.

4 years agolibm: Remove sincos() and friends from lib/libm.
Sascha Wildner [Mon, 10 Feb 2020 16:08:55 +0000 (17:08 +0100)]
libm: Remove sincos() and friends from lib/libm.

4 years agoMerge branch 'vendor/OPENBSD_LIBM'
Sascha Wildner [Mon, 10 Feb 2020 15:48:10 +0000 (16:48 +0100)]
Merge branch 'vendor/OPENBSD_LIBM'

4 years agoImport sincos() and friends directly to the vendor branch.
Sascha Wildner [Mon, 10 Feb 2020 15:47:40 +0000 (16:47 +0100)]
Import sincos() and friends directly to the vendor branch.

4 years agosincos.3: Add missing MLINKS.
Sascha Wildner [Mon, 10 Feb 2020 15:18:48 +0000 (16:18 +0100)]
sincos.3: Add missing MLINKS.

4 years agoinet6: report RTM_MISS when probing a known address fails
Roy Marples [Sun, 9 Feb 2020 22:03:19 +0000 (22:03 +0000)]
inet6: report RTM_MISS when probing a known address fails

This allows unreachable to hit userland faster.

4 years ago<sys/ttydefaults.h>: Sync up with FreeBSD, mainly for r179567.
Sascha Wildner [Sun, 9 Feb 2020 21:22:25 +0000 (22:22 +0100)]
<sys/ttydefaults.h>: Sync up with FreeBSD, mainly for r179567.

The rest of it was already brought in.

FreeBSD's commit msg:

r179567 | ed | 2008-06-05 19:44:18 +0200 (Thu, 05 Jun 2008) | 13 lines

Fix faulty character to control-character conversion for CTRL().

The CTRL() macro seems to perform character to control-character
conversion (i.e. 'A' to 0x01) to lowercase characters. This is actually
not valid. If we use lowercase characters, conversions such as
CTRL('\\') and CTRL('?') will result to invalid conversions.

Because we must still support old source code that uses CTRL() (bad!),
we make CTRL() accept both forms. When the character is a lowercase
character, we perform the old style conversion.

4 years ago<sys/ttydefaults.h>: Add some includes for self-sufficiency.
Sascha Wildner [Sun, 9 Feb 2020 19:55:01 +0000 (20:55 +0100)]
<sys/ttydefaults.h>: Add some includes for self-sufficiency.

4 years agoroute(4): Remove a leftover closing brace.
Sascha Wildner [Sun, 9 Feb 2020 18:26:15 +0000 (19:26 +0100)]
route(4): Remove a leftover closing brace.

Assuming the opening one was removed for style reasons.

4 years agoinstaller: Silence a kenv(1) warning.
Sascha Wildner [Sun, 9 Feb 2020 17:30:54 +0000 (18:30 +0100)]
installer: Silence a kenv(1) warning.

On non-comconsole systems, this is undefined, so silence any warnings
about it (that would show up briefly when logging in as installer).

4 years agoroute(4): add RO_MISSFILTER socket option.
Roy Marples [Sun, 9 Feb 2020 17:07:41 +0000 (17:07 +0000)]
route(4): add RO_MISSFILTER socket option.

This allows filtering of specific RTM_MISS destination sockaddrs.

4 years agoroute: make INET6 addrs human readable with sockaddr_print
Roy Marples [Sun, 9 Feb 2020 12:01:00 +0000 (12:01 +0000)]
route: make INET6 addrs human readable with sockaddr_print

4 years agoroute: constify sockaddr_print
Roy Marples [Sun, 9 Feb 2020 10:25:29 +0000 (10:25 +0000)]
route: constify sockaddr_print

4 years agokernel/apple_gmux: Add missing opt_ddb.h to the Makefile and sort.
Sascha Wildner [Sun, 9 Feb 2020 10:02:45 +0000 (11:02 +0100)]
kernel/apple_gmux: Add missing opt_ddb.h to the Makefile and sort.

4 years agokernel/vga_switcheroo: Add missing opt_ddb.h to the Makefile.
Sascha Wildner [Sat, 8 Feb 2020 08:48:06 +0000 (09:48 +0100)]
kernel/vga_switcheroo: Add missing opt_ddb.h to the Makefile.

4 years agokernel/drm: Add missing opt_ddb.h to the Makefiles.
Sascha Wildner [Fri, 7 Feb 2020 14:54:10 +0000 (15:54 +0100)]
kernel/drm: Add missing opt_ddb.h to the Makefiles.

While here, adjust some SRCS declaration style with the rest of the
Makefile.

4 years agokernel - Clean up memory leaks and a stack buffer disclosure bug
Matthew Dillon [Fri, 7 Feb 2020 07:43:31 +0000 (23:43 -0800)]
kernel - Clean up memory leaks and a stack buffer disclosure bug

* Clean up memory leaks, a stack buffer disclosure bug, and a
  missing priv check in if_oce (which probably never attaches these
  days).  All in the network subsystem.

Reported-by: Ilja van Sprundel
4 years agosbin/fsck_msdosfs: Diff reduction against FreeBSD against NetBSD
Tomohiro Kusumi [Thu, 6 Feb 2020 15:15:10 +0000 (00:15 +0900)]
sbin/fsck_msdosfs: Diff reduction against FreeBSD against NetBSD

from freebsd/freebsd@28bbeac80931cc14571ef4b6455d8da7466411a2

4 years agosbin/fsck_msdosfs: Tighten FAT checks and fix off-by-one error in corner case
Tomohiro Kusumi [Thu, 6 Feb 2020 15:12:08 +0000 (00:12 +0900)]
sbin/fsck_msdosfs: Tighten FAT checks and fix off-by-one error in corner case

See below for details.
https://reviews.freebsd.org/D23065

from freebsd/freebsd@b60894b10adb071a8dc2b6fea5f9867c24bc9c47

4 years agolibm: Bring in sincos, sincosf, and sincosl from OpenBSD
François Tigeot [Thu, 6 Feb 2020 12:15:57 +0000 (13:15 +0100)]
libm: Bring in sincos, sincosf, and sincosl from OpenBSD

4 years agodrm/linux: fix a bug in DEFINE_WAIT()
François Tigeot [Thu, 6 Feb 2020 06:16:13 +0000 (07:16 +0100)]
drm/linux: fix a bug in DEFINE_WAIT()

The wake-up function was not properly set up.

4 years agosbin/fsck_msdosfs: Document -M
Tomohiro Kusumi [Wed, 5 Feb 2020 16:29:45 +0000 (01:29 +0900)]
sbin/fsck_msdosfs: Document -M

from freebsd/freebsd@0371742d8ddb1c53201a1141a58076535e0b2f9c

4 years agosbin/fsck_msdosfs: Reduce memory footprint of fsck_msdosfs
Tomohiro Kusumi [Wed, 5 Feb 2020 16:20:08 +0000 (01:20 +0900)]
sbin/fsck_msdosfs: Reduce memory footprint of fsck_msdosfs

See below for details.
https://reviews.freebsd.org/D22965

from freebsd/freebsd@41655e1cf1451b788f6437c91ec74bcecd2192b7

4 years agodrm: Improve drm_can_sleep()
François Tigeot [Wed, 5 Feb 2020 10:28:43 +0000 (11:28 +0100)]
drm: Improve drm_can_sleep()

4 years agodrm - Remove some of the linux_sched debugging
Matthew Dillon [Wed, 5 Feb 2020 06:05:48 +0000 (22:05 -0800)]
drm - Remove some of the linux_sched debugging

* Remove some debugging that we no longer need.

4 years agohammer2.8: Fix typo.
Sascha Wildner [Wed, 5 Feb 2020 04:28:57 +0000 (05:28 +0100)]
hammer2.8: Fix typo.

4 years agodsynth - Add HTML support (2)
Matthew Dillon [Tue, 4 Feb 2020 01:44:57 +0000 (17:44 -0800)]
dsynth - Add HTML support (2)

* Fix 'ignored' and 'failed' reason format (the js expects a certain
  format and coughs pop-up errors up if it doesn't get it).

4 years agodsynth - Add HTML support
Matthew Dillon [Tue, 4 Feb 2020 01:05:00 +0000 (17:05 -0800)]
dsynth - Add HTML support

* Bring in progress.css, progress.html, progress.js, and icons from
  the synth project.  Add John's copyright to progress.js.

* dsynth now generates the logs/Report subdirectory, all necessary
  files, and dynamically generates the json.

  The summary.json database is updated every 10 seconds to reduce wear and
  tear.

* Split the history files in 50KB segments to reduce network traffic.

4 years agoetc/defaults/rc.conf: Remove some leftovers from the mrouted(8) removal.
Sascha Wildner [Mon, 3 Feb 2020 21:24:05 +0000 (22:24 +0100)]
etc/defaults/rc.conf: Remove some leftovers from the mrouted(8) removal.

4 years agokernel/iwm: Add back support for IWM_DEBUG (default is inactive).
Sascha Wildner [Mon, 3 Feb 2020 20:45:21 +0000 (21:45 +0100)]
kernel/iwm: Add back support for IWM_DEBUG (default is inactive).

Dunno why it got lost in the last upgrade.

Also, comment it out in the module Makefile.

4 years agogetrandom.2: Use .Dv for defines.
Sascha Wildner [Mon, 3 Feb 2020 20:13:48 +0000 (21:13 +0100)]
getrandom.2: Use .Dv for defines.

4 years agoiso639: Fix some descriptions (from upstream).
Sascha Wildner [Mon, 3 Feb 2020 20:35:57 +0000 (21:35 +0100)]
iso639: Fix some descriptions (from upstream).

4 years agokernel - Fix usb crash on detach
Matthew Dillon [Mon, 3 Feb 2020 19:15:03 +0000 (11:15 -0800)]
kernel - Fix usb crash on detach

* Sometimes a bad usb link can flicker off before the usb bus is able
  to finish attaching it, resulting in an attempt to kfree() a NULL
  pointer.  Check for NULL.

4 years agosysctl.9/sysctl_add_oid.9: Add missing BIT32 and BIT64 MLINKS.
Sascha Wildner [Mon, 3 Feb 2020 16:51:11 +0000 (17:51 +0100)]
sysctl.9/sysctl_add_oid.9: Add missing BIT32 and BIT64 MLINKS.

4 years agorman.9: Fix rman_make_alignment_flags() prototype.
Sascha Wildner [Mon, 3 Feb 2020 16:06:00 +0000 (17:06 +0100)]
rman.9: Fix rman_make_alignment_flags() prototype.

4 years agogetrandom.2: Comment out reference to getentropy.3 and fix date.
Sascha Wildner [Mon, 3 Feb 2020 15:55:51 +0000 (16:55 +0100)]
getrandom.2: Comment out reference to getentropy.3 and fix date.

4 years agovkernel: Include <sys/malloc.h> for malloc_reinit_ncpus() prototype.
Sascha Wildner [Mon, 3 Feb 2020 15:13:54 +0000 (16:13 +0100)]
vkernel: Include <sys/malloc.h> for malloc_reinit_ncpus() prototype.

Fixes the VKERNEL64 build.

4 years agogcc80: Hide NO_WERROR in tools better.
zrj [Sun, 2 Feb 2020 09:12:34 +0000 (11:12 +0200)]
gcc80: Hide NO_WERROR in tools better.

4 years agohostprog: Remove NO_WERROR from btools tic.
zrj [Sun, 2 Feb 2020 09:11:25 +0000 (11:11 +0200)]
hostprog: Remove NO_WERROR from btools tic.

Pointed-out-by: swildner
4 years ago<alloca.h>: Add comment for special handling case.
zrj [Sun, 2 Feb 2020 09:10:47 +0000 (11:10 +0200)]
<alloca.h>: Add comment for special handling case.

4 years agokernel - Make writing to /dev/urandom (to add entropy) faster
Matthew Dillon [Mon, 3 Feb 2020 03:29:30 +0000 (19:29 -0800)]
kernel - Make writing to /dev/urandom (to add entropy) faster

* Speed this up a bit by chunking up 256 byte blocks instead of
  64.  The SHA256 hash eats a lot of time, this should speed the
  boot-time entropy injection up by 4x.

Reported-by: zrj
4 years agolibc - Update manual page for realpath(3) and add page for __realpath(2)
Matthew Dillon [Sun, 2 Feb 2020 20:41:30 +0000 (12:41 -0800)]
libc - Update manual page for realpath(3) and add page for __realpath(2)

* Add a manual page for __realpath(2) which clarifies differences
  between realpath(3) and __realpath(2).

4 years agolibc - Update for realpath() system call support (2)
Matthew Dillon [Sun, 2 Feb 2020 20:21:59 +0000 (12:21 -0800)]
libc - Update for realpath() system call support (2)

* Fix bug last commit, on failure if a buffer is supplied we copy
  the source path to the target buffer before returning.

Reported-by: zrj
4 years agoboot/pxe: Fix some typos in comments and (unused, as it seems) type names.
Sascha Wildner [Sun, 2 Feb 2020 10:15:51 +0000 (11:15 +0100)]
boot/pxe: Fix some typos in comments and (unused, as it seems) type names.

While here, use our __packed.

4 years agokernel - Rejigger random number generator to be per-cpu 2/2
Matthew Dillon [Sun, 2 Feb 2020 07:45:16 +0000 (23:45 -0800)]
kernel - Rejigger random number generator to be per-cpu 2/2

* The initializer tries to diverge each cpu's csprng a bit more
  now.  These initial conditions are not intended to produce secure
  random numbers, but they should be reasonably secure by the time the
  kernel is finished booting.

* Once the csprng is operational, do not always inject the same
  entropy into both csprngs since that would make having two and
  XOR'ing the results together kinda worthless.

* If RDRAND is available the csprng will get new injections 25 times
  a second on each cpu.  Without it, however, entropy injection is
  relatively slow.

4 years agokernel - Rejigger random number generator to be per-cpu 1/2
Matthew Dillon [Sun, 2 Feb 2020 06:55:12 +0000 (22:55 -0800)]
kernel - Rejigger random number generator to be per-cpu 1/2

* Refactor all the kernel random number generation code to
  operate on a per-cpu basis.  The csprng, ibaa, and l15
  structures are now per-cpu.

* RDRAND now runs a periodic timer callback on all available cpus
  rather than just on cpu 0, allowing rdrand data to mix on
  each cpu's rng independently.

* The nrandom helper thread now chains state with an iteration
  between cpus, injecting a random data buffer generated from
  the previous cpu into the mix of the current.

4 years agokernel - Add __realpath() and getrandom() system calls (2)
Matthew Dillon [Sun, 2 Feb 2020 06:48:20 +0000 (22:48 -0800)]
kernel - Add __realpath() and getrandom() system calls (2)

* Move GRND_* defines to the right spot in sys/random.h

4 years agomake(1): Add OpenBSD support.
zrj [Sat, 1 Feb 2020 12:48:03 +0000 (14:48 +0200)]
make(1): Add OpenBSD support.

 OpenBSD does not have 'A' support in malloc_options.  Use supported 'S'
 to prevent a lot of warnings during every bmake invoke.

4 years agotic(1): Explicitly disable WERROR in hostprog tic.
zrj [Sat, 1 Feb 2020 12:43:08 +0000 (14:43 +0200)]
tic(1): Explicitly disable WERROR in hostprog tic.

 This special version is used during buildworld.
 Helps with bootstrapping on OpenBSD.

4 years agoworld: Explicitly disable WERROR for hostprog and hostlib.
zrj [Sat, 1 Feb 2020 12:36:25 +0000 (14:36 +0200)]
world: Explicitly disable WERROR for hostprog and hostlib.

 Explicit tracking of currently toolchain is too fragile for c++.
 Add CROSS_CFLAGS helper in NXFLAGS for bootstrapping on OpenBSD.

4 years agogcc80: Make bootstrapping more permissive.
zrj [Sat, 1 Feb 2020 12:32:40 +0000 (14:32 +0200)]
gcc80: Make bootstrapping more permissive.

 To allow boostrapping on OpenBSD/Linux hosts:
 * provide CROSS_LIBDL knob when needed;
 * disable use of iconv in support libs;
 * disable werror in hostlibs.

4 years agobinutils227: Explicitly include <stdint.h> and add CROSS_LIBDL.
zrj [Sat, 1 Feb 2020 12:22:46 +0000 (14:22 +0200)]
binutils227: Explicitly include <stdint.h> and add CROSS_LIBDL.

 On glibc based systems dlopen() functionality is not in libc.

4 years agogdb(1): Explicitly include <stdint.h>.
zrj [Sat, 1 Feb 2020 12:21:18 +0000 (14:21 +0200)]
gdb(1): Explicitly include <stdint.h>.