dragonfly.git
4 years agohier.7: Adjust for binutils234.
Sascha Wildner [Thu, 27 Feb 2020 16:32:15 +0000 (17:32 +0100)]
hier.7: Adjust for binutils234.

4 years agokernel: Fix kernel build with 'options KTR' after 2ff21866646c375554d6.
Sascha Wildner [Wed, 26 Feb 2020 19:40:46 +0000 (20:40 +0100)]
kernel: Fix kernel build with 'options KTR' after 2ff21866646c375554d6.

While here, indent the KTR_COND_LOG() macro like the KTR_LOG() macro,
which looks slightly better.

4 years agokernel - Add kern.usched_dfly.poll_ticks
Matthew Dillon [Wed, 26 Feb 2020 06:15:11 +0000 (22:15 -0800)]
kernel - Add kern.usched_dfly.poll_ticks

* Add kern.usched_dfly.poll_ticks (default 0, same as previous
  operation) for testing a more aggressive scheduler 'pulling'
  mode.

4 years agokernel - Code path optimization for kmalloc/kfree
Matthew Dillon [Wed, 26 Feb 2020 06:07:22 +0000 (22:07 -0800)]
kernel - Code path optimization for kmalloc/kfree

* Use __read_frequently for numerous variables.

* Increase the pcpu slab cache on high-memory machines.  This reduces
  kernel_map and smpinvltlb interactions.

* Get rid of the ZoneGenAlloc and ZoneBigAlloc sysctl tracking
  variables.  These were causing unnecessary frequent cache line
  bouncing between cpus.

  Also get rid of SlabsFreed and SlabsAllocated.

* Get rid of unused sysctl variables.

* Make the on-kfree bcopy of weirdary optional (default OFF now).
  It was previously unconditional and on by default.

4 years agokernel - Simple code path optimizations
Matthew Dillon [Wed, 26 Feb 2020 06:05:43 +0000 (22:05 -0800)]
kernel - Simple code path optimizations

* Add __read_mostly and __read_frequently to numerous variables as
  appropriate to reduce unnecessary cache line ping-ponging.

* Adjust conditionals in the syscall code with __predict_true/false
  to clean up the execution path.

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/options: Fix wrong LINT->LINT64 replacement in a comment.
Sascha Wildner [Tue, 25 Feb 2020 15:48:03 +0000 (16:48 +0100)]
kernel/options: Fix wrong LINT->LINT64 replacement in a comment.

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 agoboot/loader: Small improvement to merge_help.awk.
Sascha Wildner [Mon, 24 Feb 2020 14:13:47 +0000 (15:13 +0100)]
boot/loader: Small improvement to merge_help.awk.

FreeBSD's r162742:

Ignore a sub-topic match if it is inside the command description.
Otherwise, merge-help can get confused by a command description that
includes a word that starts with a capital S.

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 agokernel and world - Replace bcmp/bcopy/bzero/memcmp/memcpy/memmove/memset
Matthew Dillon [Mon, 17 Feb 2020 08:09:37 +0000 (00:09 -0800)]
kernel and world - Replace bcmp/bcopy/bzero/memcmp/memcpy/memmove/memset

* Replace bcmp/bcopy/bzero/memcmp/memcpy/memmove/memset with mjg's
  code, with some minor adjustments.

* mjg's code has been given its own header file,
  <machine/asm_mjgmacros.h>

* Also replaces copyin and copyout.

* Around a 1.7% improvement in bulk-build performance.

4 years agosbin/fsck_msdosfs: Use humanize_number to format available and bad space sizes
Tomohiro Kusumi [Sun, 23 Feb 2020 16:43:00 +0000 (01:43 +0900)]
sbin/fsck_msdosfs: Use humanize_number to format available and bad space sizes

from freebsd/freebsd@996c6aefcf2ed50629407b6ad8794ebfce8ac794

4 years agodrm/i915: Update base driver to 20160808
François Tigeot [Sun, 23 Feb 2020 14:51:19 +0000 (15:51 +0100)]
drm/i915: Update base driver to 20160808

4 years agodrm/linux: Implement more parts of prepare_to_wait() and finish_wait()
François Tigeot [Sun, 23 Feb 2020 14:45:57 +0000 (15:45 +0100)]
drm/linux: Implement more parts of prepare_to_wait() and finish_wait()

4 years agodrm/linux: Add RCU functions
François Tigeot [Sun, 23 Feb 2020 14:21:40 +0000 (15:21 +0100)]
drm/linux: Add RCU functions

4 years agodrm: Add linux/vt.h
François Tigeot [Sun, 23 Feb 2020 14:07:00 +0000 (15:07 +0100)]
drm: Add linux/vt.h

4 years agodrm: Add linux/pnp.h
François Tigeot [Sun, 23 Feb 2020 14:06:19 +0000 (15:06 +0100)]
drm: Add linux/pnp.h

4 years agodrm: Add linux/oom.h
François Tigeot [Sun, 23 Feb 2020 14:05:58 +0000 (15:05 +0100)]
drm: Add linux/oom.h

4 years agodrm/linux: Add dev_notice()
François Tigeot [Sun, 23 Feb 2020 13:54:34 +0000 (14:54 +0100)]
drm/linux: Add dev_notice()

4 years agodrm/linux: Add prefetchw()
François Tigeot [Sun, 23 Feb 2020 13:53:14 +0000 (14:53 +0100)]
drm/linux: Add prefetchw()

4 years agodrm/linux: Add pagefault_disabled
François Tigeot [Sun, 23 Feb 2020 13:52:33 +0000 (14:52 +0100)]
drm/linux: Add pagefault_disabled

4 years agorealpath.3: Sort SEE ALSO.
Sascha Wildner [Sat, 22 Feb 2020 07:52:20 +0000 (08:52 +0100)]
realpath.3: Sort SEE ALSO.

4 years agogcore(1): Don't include <sys/user.h>. Only <errno.h> is needed.
Sascha Wildner [Sat, 22 Feb 2020 07:39:45 +0000 (08:39 +0100)]
gcore(1): Don't include <sys/user.h>. Only <errno.h> is needed.

4 years agoRemove <sys/user.h> inclusion from a few files that don't need it.
Sascha Wildner [Sat, 22 Feb 2020 06:50:26 +0000 (07:50 +0100)]
Remove <sys/user.h> inclusion from a few files that don't need it.

4 years ago<sys/user.h>: Restrict inclusion to userland and fix a comment typo.
Sascha Wildner [Sat, 22 Feb 2020 06:50:06 +0000 (07:50 +0100)]
<sys/user.h>: Restrict inclusion to userland and fix a comment typo.

4 years agoboot: Small indent fix.
Sascha Wildner [Sat, 22 Feb 2020 04:26:39 +0000 (05:26 +0100)]
boot: Small indent fix.

4 years agonfssvc.2/quotactl.2: Fix includes.
Sascha Wildner [Fri, 21 Feb 2020 17:18:13 +0000 (18:18 +0100)]
nfssvc.2/quotactl.2: Fix includes.

4 years agodrm/i915: Use stop_machine()
François Tigeot [Thu, 20 Feb 2020 13:08:10 +0000 (14:08 +0100)]
drm/i915: Use stop_machine()

4 years agodrm/linux: Add stop_machine()
François Tigeot [Thu, 20 Feb 2020 13:06:06 +0000 (14:06 +0100)]
drm/linux: Add stop_machine()

4 years agodrm: Add linux/mempolicy.h
François Tigeot [Thu, 20 Feb 2020 13:00:10 +0000 (14:00 +0100)]
drm: Add linux/mempolicy.h

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 agoRemove old binutils225 manual pages via 'make upgrade'.
Sascha Wildner [Sun, 16 Feb 2020 21:05:47 +0000 (22:05 +0100)]
Remove old binutils225 manual pages via 'make upgrade'.

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 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.9 setup v5.9.0
Justin C. Sherrill [Sat, 15 Feb 2020 22:01:30 +0000 (17:01 -0500)]
5.9 setup

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 agokernel - Micro-optimization, only set v_lastwrite_ts for regular files
Matthew Dillon [Sat, 15 Feb 2020 19:44:57 +0000 (11:44 -0800)]
kernel - Micro-optimization, only set v_lastwrite_ts for regular files

* When mmap()ing a file SHARED/RW, only update v_lastwrite_ts
  for regular files.   This avoids an unnecessary exclusive lock
  and related SMP contention on devices (such as /dev/lpmap).

4 years agokernel - Micro optimization for vnode exclusive lock
Matthew Dillon [Sat, 15 Feb 2020 19:43:10 +0000 (11:43 -0800)]
kernel - Micro optimization for vnode exclusive lock

* Micro-optimize open(... O_RDWR) by allowing a shared vnode lock for
  this case when opening a file which is not an executable.

  We used to unconditionally get an exclusive lock to deal with VTEXT vs
  O_RDWR races against executables, but this can cause unnecessary SMP
  contention on normal files and devices opened O_RDWR which are not
  executables.

4 years agoobjformat(1): Remove incremental-dump handling.
zrj [Mon, 3 Feb 2020 11:11:12 +0000 (13:11 +0200)]
objformat(1): Remove incremental-dump handling.

 Utility is incremental linking test/debug tool and no longer installed
 in binutils-2.34.  Remove handling for consistency.

4 years agoRetire the binutils-2.25.
zrj [Sat, 15 Feb 2020 16:22:13 +0000 (18:22 +0200)]
Retire the binutils-2.25.

4 years agobinutils225: Unhook from the build.
zrj [Mon, 3 Feb 2020 10:22:06 +0000 (12:22 +0200)]
binutils225: Unhook from the build.

 Remove makefiles and installed parts.

4 years agobinutils234: Hook to the buildworld as alternative set.
zrj [Mon, 3 Feb 2020 10:19:37 +0000 (12:19 +0200)]
binutils234: Hook to the buildworld as alternative set.

 Requires changes in kernel and sys/boot/efi.

4 years agobinutils234: Add pregenerated manpages.
zrj [Mon, 3 Feb 2020 09:29:13 +0000 (11:29 +0200)]
binutils234: Add pregenerated manpages.

 Only ld.1 and gprof.1 are now provided in tarball.  Add all locally.

4 years agobinutils234: Add configs and pregenerated headers.
zrj [Mon, 3 Feb 2020 09:25:41 +0000 (11:25 +0200)]
binutils234: Add configs and pregenerated headers.

4 years agobinutils234: Add build makefiles.
zrj [Mon, 3 Feb 2020 09:20:45 +0000 (11:20 +0200)]
binutils234: Add build makefiles.

4 years agobinutils234: Add DF READMEs and local modifications.
zrj [Mon, 3 Feb 2020 08:55:39 +0000 (10:55 +0200)]
binutils234: Add DF READMEs and local modifications.

4 years agoMerge remote-tracking branch 'origin/vendor/BINUTILS234'
zrj [Sat, 15 Feb 2020 16:10:26 +0000 (18:10 +0200)]
Merge remote-tracking branch 'origin/vendor/BINUTILS234'

4 years agoInitial import of binutils 2.34 on vendor branch vendor/BINUTILS234
zrj [Mon, 3 Feb 2020 08:54:31 +0000 (10:54 +0200)]
Initial import of binutils 2.34 on vendor branch

4 years agodrm/i915: Update base driver to 20160725
François Tigeot [Sat, 15 Feb 2020 13:28:39 +0000 (14:28 +0100)]
drm/i915: Update base driver to 20160725

4 years agodrm/linux: Add drain_workqueue()
François Tigeot [Sat, 15 Feb 2020 13:27:35 +0000 (14:27 +0100)]
drm/linux: Add drain_workqueue()

4 years agodrm/linux: Add boot_cpu_data
François Tigeot [Sat, 15 Feb 2020 13:23:33 +0000 (14:23 +0100)]
drm/linux: Add boot_cpu_data

4 years agodrm/linux: Improve linux/bug.h
François Tigeot [Sat, 15 Feb 2020 12:52:46 +0000 (13:52 +0100)]
drm/linux: Improve linux/bug.h

4 years agodrm/linux: Improve linux/fence.h
François Tigeot [Sat, 15 Feb 2020 12:52:05 +0000 (13:52 +0100)]
drm/linux: Improve linux/fence.h

4 years agodrm/linux: Add jiffies_to_nsecs()
François Tigeot [Sat, 15 Feb 2020 12:51:31 +0000 (13:51 +0100)]
drm/linux: Add jiffies_to_nsecs()

4 years agodrm/linux: Fix DEFINE_SPINLOCK()
François Tigeot [Sat, 15 Feb 2020 12:49:49 +0000 (13:49 +0100)]
drm/linux: Fix DEFINE_SPINLOCK()

4 years agoStop passing "-s labels" to vnconfig(4).
Sascha Wildner [Sat, 15 Feb 2020 10:45:24 +0000 (11:45 +0100)]
Stop passing "-s labels" to vnconfig(4).

The option is deprecated and has no effect.

4 years agorcorder(8): Import rcorder-visualize.sh from FreeBSD
Aaron LI [Sat, 15 Feb 2020 07:56:21 +0000 (15:56 +0800)]
rcorder(8): Import rcorder-visualize.sh from FreeBSD

This script draws the dependency graph for rc scripts using dot(1).
This script was imported to FreeBSD from NetBSD.

4 years agomtree.8: Add examples to create /var and /usr/include hierarchies
Aaron LI [Sat, 15 Feb 2020 07:44:17 +0000 (15:44 +0800)]
mtree.8: Add examples to create /var and /usr/include hierarchies

These two examples are actually used in the Makefiles and installer.

While there, fix a markup in the COMPATIBILITY section.

Suggested-by: noob237 (Gonzalo Nemmi)
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 agokernel - Recode the namecache mount transition cache
Matthew Dillon [Sat, 15 Feb 2020 00:04:14 +0000 (16:04 -0800)]
kernel - Recode the namecache mount transition cache

* DragonFlyBSD uses (mp, ncp/vp) tuples to track mount recursions,
  which allows nullfs to not have to create shadow vnodes.  However,
  this means that mount points cannot be stored in the vnode structure.
  Instead, DFly relies on a (mp, ncp) -> targetmp translation cache
  to avoid having to scan the mountlist.

* Increase the size of this cache and convert it from a straight
  single-entry prime-number mod hash to a 4-way set-associative
  power-of-2 hash, and improve the hash algorithm.

* This SIGNIFICANTLY reduces lock stalls during heavliy concurrent
  filesystem operations (aka bulk builds) when in the presence of
  a large number of mounts (again bulk builds with [d]synth).

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 - Rejigger mount code to add vfs_flags in struct vfsops
Matthew Dillon [Fri, 14 Feb 2020 23:58:22 +0000 (15:58 -0800)]
kernel - Rejigger mount code to add vfs_flags in struct vfsops

* Rejigger the mount code so we can add a vfs_flags field to vfsops,
  which mount_init() has visibility to.

* Allows nullfs to flag that its mounts do not need a syncer thread.
  Previously nullfs would destroy the syncer thread after the
  fact.

* Improves dsynth performance (it does lots of nullfs mounts).

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 agodsynth - return max_load to 5.0x, reduce PkgDepMemoryTarget
Matthew Dillon [Fri, 14 Feb 2020 23:48:10 +0000 (15:48 -0800)]
dsynth - return max_load to 5.0x, reduce PkgDepMemoryTarget

* Restore the max_load cap to 5.0x.  Instead, reduce the estimated
  package dependency storage cap from PhysMem / 2 to PhysMem / 3.

* Document the effects of adding t_pw to the load calculation.

4 years agokernel - Start work on a better burst page-fault mechanic
Matthew Dillon [Fri, 14 Feb 2020 06:43:21 +0000 (22:43 -0800)]
kernel - Start work on a better burst page-fault mechanic

* The vm.fault_quick sysctl is now a burst count.  It still
  defaults to 1 which is the same operation as before.

  Performance is roughly the same with it set to 1 to 8 as
  more work needs to be done to optimize pmap_enter().

4 years agoUse <fcntl.h> instead of <sys/file.h> for open()'s prototype and flags.
Sascha Wildner [Fri, 14 Feb 2020 22:32:25 +0000 (23:32 +0100)]
Use <fcntl.h> instead of <sys/file.h> for open()'s prototype and flags.

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 agoSync ACPICA with Intel's version 20200214.
Sascha Wildner [Fri, 14 Feb 2020 22:27:33 +0000 (23:27 +0100)]
Sync ACPICA with Intel's version 20200214.

Not much to see:

* Some improvements to sleep button handling when resuming from sleep
  (which we don't support).

* New AcpiAnyGpeStatusSet() function.

* Improvements to iASL.

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

4 years agodrm: Use the Linux version of DRM_WAIT_ON()
François Tigeot [Fri, 14 Feb 2020 06:57:14 +0000 (07:57 +0100)]
drm: Use the Linux version of DRM_WAIT_ON()

Avoid sleeping for vblank events when not required.

4 years agodrm/linux: Rework wait_event_xxx and finish_wait functions
François Tigeot [Fri, 14 Feb 2020 06:50:45 +0000 (07:50 +0100)]
drm/linux: Rework wait_event_xxx and finish_wait functions

* Add required task state change in finish_wait()

* Move some formerly inline code to linux_wait.c in order to avoid
  problematic header interactions

4 years agosys/boot: Unbreak efi build with WORLD_LDVER=ld.bfd.
zrj [Thu, 13 Feb 2020 11:59:17 +0000 (13:59 +0200)]
sys/boot: Unbreak efi build with WORLD_LDVER=ld.bfd.

 Adjust 64-bit libstand.a location to use full path if available as it is
 done for 32-bit loaders already.

 The ld.bfd when invoked with -ffreestanding will not look for /usr/lib.

 Match ldscript.x86_64 to sys/platform/pc64/conf/ldscript.x86_64.
 Our ld.bfd does not support freebsd emulation target.  Generic target is
 enough to convert boot1.sym and loader.sym intermediates to PE32+.

 While there, use something sane for section padding in ldscript.x86_64.

4 years agogcc80: Unbreak ctools on OpenBSD.
zrj [Thu, 13 Feb 2020 11:52:39 +0000 (13:52 +0200)]
gcc80: Unbreak ctools on OpenBSD.

 For some reason cpp(1) has --traditional-cpp enforced in clang-cpp, that
 does not expand macros with spaces like "FOO (blah);".
 Use plain cc -E -P for compat in NXCC for now (both headers do not
 depend on arch specific code or external headers, so it should be safe.

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 - 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 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 - Improve tmpfs support
Matthew Dillon [Thu, 13 Feb 2020 03:39:12 +0000 (19:39 -0800)]
kernel - Improve tmpfs support

* When a file in tmpfs is truncated to a size that is not on a block
  boundary, or extended (but not written) to a size that is not on a
  block boundary, the nvextendbuf() and nvtruncbuf() functions must
  modify the contents of the straddling buffer and bdwrite().

  However, a bdwrite() for a tmpfs buffer will result in a dirty buffer
  cache buffer and likely force it to be cycled out to swap relatively
  soon under a modest load.  This is not desirable if there is no memory
  pressure present to force it out.

  Tmpfs almost always uses buwrite() in order to leave the buffer 'clean'
  (the underlying VM pages are dirtied instead), to prevent unecessary
  paging of tmpfs data to swap when the buffer gets recycled or the vnode
  cycles out.

* Add support for calling buwrite() in these functions by changing the
  'trivial' boolean into a flags variable.

* Tmpfs now passes the appropriate flag, preventing the undesirable
  behavior.

4 years agodrm/linux: Add framebuffer_alloc() and framebuffer_release()
François Tigeot [Thu, 13 Feb 2020 19:04:51 +0000 (20:04 +0100)]
drm/linux: Add framebuffer_alloc() and framebuffer_release()

4 years agowait.2: Fix markup and comment out some references.
Sascha Wildner [Thu, 13 Feb 2020 18:01:09 +0000 (19:01 +0100)]
wait.2: Fix markup and comment out some references.

4 years agodrm/linux: Implement outb()
François Tigeot [Thu, 13 Feb 2020 06:58:07 +0000 (07:58 +0100)]
drm/linux: Implement outb()

4 years agoMakefile.inc1: Pass _SHLIBDIRPREFIX for btools too.
zrj [Sun, 2 Feb 2020 11:35:20 +0000 (13:35 +0200)]
Makefile.inc1: Pass _SHLIBDIRPREFIX for btools too.

 Allow to to link in with crossworld target built libraries if available.

 These are not needed for DragonFly crossworld target, however helps with
 bootstrapping on OpenBSD or glibc based systems where static versions
 are not available or mismatches the lex(1) too much.

4 years agogrep(1): Disable use of unlocked IO in btools.
zrj [Sun, 2 Feb 2020 11:14:22 +0000 (13:14 +0200)]
grep(1): Disable use of unlocked IO in btools.

 Our use of grep during bootstrapping process does not require it and
 solves issues when bootstrapping utility on OpenBSD.

4 years agofind(1): Disable use of getvfsbyname(3) in btools.
zrj [Sun, 2 Feb 2020 11:05:16 +0000 (13:05 +0200)]
find(1): Disable use of getvfsbyname(3) in btools.

 Not needed by our buildworld/buildkernel infrastructure.
 This allows utility to be used on OpenBSD host.

4 years agofind(1): Reduce bootstrap locale specific requirements.
zrj [Sun, 2 Feb 2020 11:03:09 +0000 (13:03 +0200)]
find(1): Reduce bootstrap locale specific requirements.

 The F_TIME2_T functionality is not available on all OSes.

 While there, check for D_MD_ORDER availability and fallback to month
 first if not available.

4 years agofind(1): Check for _ST_FLAGS_PRESENT_ availability.
zrj [Sun, 2 Feb 2020 10:55:34 +0000 (12:55 +0200)]
find(1): Check for _ST_FLAGS_PRESENT_ availability.

4 years agofind(1): Check for FTS_CONST just like mtree(8).
zrj [Sun, 2 Feb 2020 10:53:58 +0000 (12:53 +0200)]
find(1): Check for FTS_CONST just like mtree(8).

 For compatibility with OpenBSD.

4 years agocp(1): Check for FTS_CONST just like mtree(8).
zrj [Sun, 2 Feb 2020 10:36:09 +0000 (12:36 +0200)]
cp(1): Check for FTS_CONST just like mtree(8).

 For compatibility with OpenBSD.

4 years agocp(1): Check for _ST_FLAGS_PRESENT_ availability.
zrj [Sun, 2 Feb 2020 10:33:39 +0000 (12:33 +0200)]
cp(1): Check for _ST_FLAGS_PRESENT_ availability.