dragonfly.git
6 years agokernel - Reoptimize sys_pipe
Matthew Dillon [Sat, 14 Oct 2017 04:26:30 +0000 (21:26 -0700)]
kernel - Reoptimize sys_pipe

* Use atomic ops for state updates, allowing us to avoid acquiring
  the other side's token.  This removes all remaining contention.

* Performance boosted by around 35%.  On the ryzen, bulk buffer
  write->read tests between localized cpu cores went from 9.2 GB/sec
  to around 13 GBytes/sec.  Cross-die performance increased from
  2.5 GB/sec to around 4.5 GB/sec (gigabytes/sec).

  1-byte ping-ponging (write-1/read-1/turn-around/write-back-1/
  read-back1) fell from 1.0-2.0uS to 0.7uS to 1.7uS.

* Add kern.pipe.size, allowing the kernel pipe buffer size to be
  changed (effects new pipes only).  The default buffer size has
  been increased to 32KB (it was 16KB).

* Refactor pipelining optimizations, further reducing unnecessary
  tsleep/wakeup IPIs.

* Improve kern.pipe.delay operation (an IPI avoidance mechanism),
  and reduce from 5uS to 4uS.

  Also add cpu_pause() in the TSC loop (suggested-by mjg_).

6 years agokernel - Refactor sys_pipe
Matthew Dillon [Sat, 14 Oct 2017 00:55:41 +0000 (17:55 -0700)]
kernel - Refactor sys_pipe

* Refactor the pipe code in preparation for optimization.  Get rid of
  the dual-pipe structure and instead have one pipe structure with
  two buffers.

* Scrap a ton of global statistics variables that nobody uses any more,
  get rid of pipe_peer, and get rid of the slock.

6 years agokernel - Improve mountlist_scan() performance, track vfs_getvfs()
Matthew Dillon [Fri, 13 Oct 2017 05:59:02 +0000 (22:59 -0700)]
kernel - Improve mountlist_scan() performance, track vfs_getvfs()

* Use a shared token whenever possible, and do not hold the token
  across the callback in the mountlist_scan() call.

* vfs_getvfs() mount_hold()'s the returned mp.  The caller is now
  expected to mount_drop() it when done.  This fixes a very rare
  race.

6 years agokernel - Refactor smp collision statistics (2)
Matthew Dillon [Fri, 13 Oct 2017 03:42:33 +0000 (20:42 -0700)]
kernel - Refactor smp collision statistics (2)

* tsc_uclock_t and tsc_sclock_t need to be exposed for now for
  userland.

6 years agokernel - Refactor smp collision statistics (2)
Matthew Dillon [Thu, 5 Oct 2017 16:09:27 +0000 (09:09 -0700)]
kernel - Refactor smp collision statistics (2)

* Refactor indefinite_info mechanics.  Instead of tracking indefinite
  loops on a per-thread basis for tokens, track them on a scheduler
  basis.  The scheduler records the overhead while it is live-looping
  on tokens, but the moment it finds a thread it can actually schedule
  it stops (then restarts later the next time it is entered), even
  if some of the other threads still have unresolved tokens.

  This gives us a fairer representation of how many cpu cycles are
  actually being wasted waiting for tokens.

* Go back to using a local indefinite_info in the lockmgr*(), mutex*(),
  and spinlock code.

* Refactor lockmgr() by implementing an __inline frontend to
  interpret the directive.  Since this argument is usually a constant,
  the change effectively removes the switch().

  Use LK_NOCOLLSTATS to create a clean recursion to wrap the blocking
  case with the indefinite*() API.

6 years agokernel - Optimize shared -> excl spinlock contention
Matthew Dillon [Thu, 5 Oct 2017 05:04:13 +0000 (22:04 -0700)]
kernel - Optimize shared -> excl spinlock contention

* When exclusive request is spinning waiting for shared holders to
  release, throw in addition cpu_pause()'s based on the number of
  shared holders.

Suggested-by: mjg_
6 years agokernel - Refactor smp collision statistics
Matthew Dillon [Thu, 5 Oct 2017 04:46:57 +0000 (21:46 -0700)]
kernel - Refactor smp collision statistics

* Add an indefinite wait timing API (sys/indefinite.h,
  sys/indefinite2.h).  This interface uses the TSC and will
  record lock latencies to our pcpu stats in microseconds.
  The systat -pv 1 display shows this under smpcoll.

  Note that latencies generated by tokens, lockmgr, and mutex
  locks do not necessarily reflect actual lost cpu time as the
  kernel will schedule other threads while those are blocked,
  if other threads are available.

* Formalize TSC operations more, supply a type (tsc_uclock_t and
  tsc_sclock_t).

* Reinstrument lockmgr, mutex, token, and spinlocks to use the new
  indefinite timing interface.

6 years agokernel - KVABIO allocbuf() optimization
Matthew Dillon [Thu, 5 Oct 2017 03:28:55 +0000 (20:28 -0700)]
kernel - KVABIO allocbuf() optimization

* When using allocbuf() to set bufsize to 0 during buffer reuse,
  do not bother synchronizing the pmap.

6 years agokernel - KVABIO stabilization
Matthew Dillon [Wed, 4 Oct 2017 03:06:04 +0000 (20:06 -0700)]
kernel - KVABIO stabilization

* bp->b_cpumask must be cleared in vfs_vmio_release().

* Generally speaking, it is generally desireable for the kernel to set
  B_KVABIO when flushing or disposing of a buffer, as long as b_cpumask
  is also correct.  This avoids unnecessary synchronization when
  underlying device drivers support KVABIO, even if the filesystem does
  not.

* In findblk() we cannot just gratuitously clear B_KVABIO.  We must issue
  a bkvasync_all() to clear the flag in order to ensure proper
  synchronization with the caller's desired B_KVABIO state.

* It was intended that bkvasync_all() clear the B_KVABIO flag.  Make
  sure it does.

* In contrast, B_KVABIO can always be set at any time, so long as the
  cpumask is cleared whenever the mappings are changed, and also as long
  as the caller's B_KVABIO state is respected if the buffer is later
  returned to the caller in a locked state.  If the buffer will simply
  be disposed of by the kernel instead, the flag can be set.  The
  wrapper (typically a vn_strategy() or dev_dstrategy() call) will clear
  the flag via bkvasync_all() if the target does not support KVABIO.

* Kernel support code outside of filesystem and device drivers is
  expected to support KVABIO.

* nvtruncbuf() and nvextendbuf() now use bread_kvabio() (i.e. they now
  properly support KVABIO).

* The buf_countdeps(), buf_checkread(), and buf_checkwrite() callbacks
  call bkvasync_all() in situations where the vnode does not support
  KVABIO.  This is because the kernel might have set the flag for other
  incidental operations even if the filesystem did not.

* As per above, devfs_spec_strategy() now sets B_KVABIO and properly
  calls bkvasync() when it needs to operate directly on buf->b_data.

* Fix bug in tmpfs().  tmpfs() was using bread_kvabio() as intended,
  but failed to call bkvasync() prior to operating directly on
  buf->b_data (prior to calling uiomovebp()).

* Any VFS function that calls BUF_LOCK*() itself may also have to
  call bkvasync_all() if it wishes to operate directly on buf->b_data,
  even if the VFS is not KVABIO aware.  This is because the VFS bypassed
  the normal buffer cache APIs to obtain a locked buffer.

6 years agokernel - Adjust ipiq execution code a bit
Matthew Dillon [Tue, 3 Oct 2017 01:49:28 +0000 (18:49 -0700)]
kernel - Adjust ipiq execution code a bit

* Remove unnecessary fences

* Adjust documentation

6 years agokernel - Add wakeup() probe sysctl
Matthew Dillon [Tue, 3 Oct 2017 01:48:19 +0000 (18:48 -0700)]
kernel - Add wakeup() probe sysctl

* Add a sysctl to allow us to probe wakeups.

* Add a few assertions in the optimized wakeup() path.

* Adjust documentation.

6 years agokernel - Implement KVABIO API in TMPFS
Matthew Dillon [Mon, 2 Oct 2017 02:42:59 +0000 (19:42 -0700)]
kernel - Implement KVABIO API in TMPFS

* TMPFS now fully supports the KVABIO API.  This removes nearly all
  IPIs from buffer cache operations related to TMPFS.

* In synth tests on 32-way and 48-way servers, the number of IPIs/cpu/sec
  drops from 5000-12000 down to 200-1000.  Needless to say, this is a
  huge win, particularly on VMs.

Recommend-by: mjg_ (Mateusz Guzik)
6 years agokernel - Add KVABIO support to NVMe, disk translation layer, and swap
Matthew Dillon [Mon, 2 Oct 2017 02:39:33 +0000 (19:39 -0700)]
kernel - Add KVABIO support to NVMe, disk translation layer, and swap

* Add KVABIO support to the NVMe driver.  The driver no longer
  requires that buffers be synchronized to all cpus.

* Add KVABIO support to the disk translation layer.  The layer no
  longer requires that buffers besynchronized to all cpus (note
  however that the underlying device may still require such).

* Add KVABIO support to the swap subsystem.  Again, actual avoidance
  of buffer memory synchronization depends on the underlying devices.

6 years agokernel - Add KVABIO API (ability to avoid global TLB syncs)
Matthew Dillon [Mon, 2 Oct 2017 02:28:56 +0000 (19:28 -0700)]
kernel - Add KVABIO API (ability to avoid global TLB syncs)

* Add KVABIO support.  This works as follows:

  (1) Devices can set D_KVABIO in the ops flags to specify that the
      device strategy routine supports the API.
      passed to

      The dev_dstrategy() wrapper will fully synchronize the buffer to
      all cpus prior to dispatch if the device flag is not set.

  (2) Vnodes can set VKVABIO in v_flag to indicate that VOP_STRATEGY
      supports the API.

      The vn_strategy() wrapper will fully synchronize the buffer to
      all cpus prior to dispatch if the vnode flag is not set.

  (3) GETBLK_KVABIO and FINDBLK_KVABIO flags added to allow buffer
      cache consumers (primarily filesystem code) to indicate that
      they support the API.  B_KVABIO flag added to struct buf.

      This occurs on a per-acquisition basis.  For example, a standard
      bread() will clear the flag, indicating no support.  A bread_kvabio()
      will set the flag, indicating support.

* The getblk(), getcacheblk(), and cluster*() interfaces set the flag for
  any I/O they dispatch, and then adjust the flag as necessary upon return
  according to the caller's wishes.

6 years agokernel - Remove geteblk()
Matthew Dillon [Sun, 1 Oct 2017 22:11:21 +0000 (15:11 -0700)]
kernel - Remove geteblk()

* Remove geteblk(), the last B_MALLOC buffer cache API.  Generally
  use getpbuf_mem() instead.

6 years agokernel - Add pmap_qenter_noinval()
Matthew Dillon [Sun, 1 Oct 2017 22:09:52 +0000 (15:09 -0700)]
kernel - Add pmap_qenter_noinval()

* Add pmap_qenter_noinval() API

6 years agokernel - Remove repurposebuf
Matthew Dillon [Sun, 1 Oct 2017 19:11:10 +0000 (12:11 -0700)]
kernel - Remove repurposebuf

* Remove the repurposebuf hack to prepare for the buffer cache
  KVABIO API, which is a better solution.

6 years agokernel - Remove B_MALLOC
Matthew Dillon [Sat, 30 Sep 2017 19:14:21 +0000 (12:14 -0700)]
kernel - Remove B_MALLOC

* Remove B_MALLOC buffer support.  All primary buffer cache buffer
  operations should now use pages.  B_VMIO is required for all
  vnode-centric operations like allocbuf(), but does not have to be set
  for nominal I/O.

* Remove vm_hold_load_pages() and vm_hold_free_pages().  This code was
  used to support mapping ad-hoc data buffers into buf structures, but
  the only remaining use case in the CAM periph code can just use
  getpbuf_mem() instead.  So this code is no longer used.

6 years agoipfw: Factor out ipfw_init_args()
Sepherosa Ziehau [Mon, 16 Oct 2017 05:16:18 +0000 (13:16 +0800)]
ipfw: Factor out ipfw_init_args()

6 years agoipfw: Flush the rules before unload the module.
Sepherosa Ziehau [Mon, 16 Oct 2017 04:52:17 +0000 (12:52 +0800)]
ipfw: Flush the rules before unload the module.

6 years agoipfw: Factor out ipfw_defrag_redispatch.
Sepherosa Ziehau [Mon, 16 Oct 2017 04:19:23 +0000 (12:19 +0800)]
ipfw: Factor out ipfw_defrag_redispatch.

Remove no longer needed IP_FW_CONTINUE.

6 years agokern: Remove ncpus2 and friends.
Sepherosa Ziehau [Mon, 16 Oct 2017 04:07:45 +0000 (12:07 +0800)]
kern: Remove ncpus2 and friends.

They were no longer used, after netisr_ncpus was delployed.

Reminded-by: dillon@
6 years agompls: Use netisr_ncpus
Sepherosa Ziehau [Mon, 16 Oct 2017 03:44:45 +0000 (11:44 +0800)]
mpls: Use netisr_ncpus

Reminded-by: dillon@
6 years agoUpdate the pciconf(8) database.
Sascha Wildner [Sun, 15 Oct 2017 20:52:51 +0000 (22:52 +0200)]
Update the pciconf(8) database.

October 12, 2017 snapshot from http://pciids.sourceforge.net/

6 years agoLINT64: Sort vmx a bit better.
Sascha Wildner [Sun, 15 Oct 2017 11:07:04 +0000 (13:07 +0200)]
LINT64: Sort vmx a bit better.

6 years agoRevert "libthread_xu - Wakeup all waiters"
Matthew Dillon [Sun, 15 Oct 2017 07:44:38 +0000 (00:44 -0700)]
Revert "libthread_xu - Wakeup all waiters"

This reverts commit de7ba607e4500e7df6ade3916977cc8a91e1b4e9.

* Didn't intend to push this.

6 years agoipfw: Implement state based "redirect", i.e. without using libalias.
Sepherosa Ziehau [Sat, 30 Sep 2017 06:39:48 +0000 (14:39 +0800)]
ipfw: Implement state based "redirect", i.e. without using libalias.

Redirection creates two states, i.e. one before the translation (xlat0)
and one after the translation (xlat1).  If the hash of the translated
packet indicates that it is owned by a remote CPU:
- If the packet triggers the state pair creation, the 'xlat1' will be
  piggybacked by the translated packet, which will be forwarded to the
  remote CPU for further evalution.  And the 'xlat1' will be installed
  on the remote CPU before the evalution of the translated packet.
- Else only the translated packet will be forwarded to the remote CPU
  for further evalution.

The 'xlat1' is called the slave state, which will be deleted only when
the 'xlat0' (the master state) is deleted.  The state pair is always
deleted on the CPU owning the 'xlat1'; the 'xlat0' will be forwarded
there.

The reference counting of the state pair is maintained independently
in each state, the memory of the state pair will be freed only after
the sum of the counter in each state reaches 0.  This avoids expensive
per-packet atomic ops.

As far as I have tested, this implementation of "redirect" does _not_
introduce any noticeable performance reduction, latency increasing or
latency destability.

This commit makes most of the necessary bits for NAT ready too.

6 years agolibthread_xu - Wakeup all waiters
Matthew Dillon [Sun, 15 Oct 2017 07:13:42 +0000 (00:13 -0700)]
libthread_xu - Wakeup all waiters

* For now punt on trying to wakeup an optimized numbers of waiters.
  Wake up all waiters and let them sort it out.

* This may fix specific count races in threaded programs using
  pthread mutexes.

6 years agohammer2 - Handle error on rename in media out of space case
Matthew Dillon [Sat, 14 Oct 2017 22:28:12 +0000 (15:28 -0700)]
hammer2 - Handle error on rename in media out of space case

* Process the error code from hammer2_chain_delete() in
  hammer2_xop_nrename() to ensure that we do not try to reattach
  the chain under another parent.

Reported-by: arcade (Bug #3055)
6 years agosshd - Disable tunneled clear text passwords by default
Matthew Dillon [Sat, 14 Oct 2017 21:18:39 +0000 (14:18 -0700)]
sshd - Disable tunneled clear text passwords by default

* Reapply 1cb3a32c13b and c866a462b3.  sshd on DragonFlyBSD defaults
  to disabling cleartext passwords by default.

Reminded-by: ivadasz
6 years agocpdup(1): Some improvements.
Sascha Wildner [Sat, 14 Oct 2017 19:06:14 +0000 (21:06 +0200)]
cpdup(1): Some improvements.

* Make cpdup retry failed rmdirs after chflags. It already does this
  for remove().

* When deciding whether to copy a file, cpdup should ignore the
  UF_ARCHIVE file flag. If that flag is supported by the destination
  file system but it's cleared on a source file, then multiple
  invocations of cpdup would all copy the source file because its
  flags wouldn't match. OTOH, if the destination filesystem doesn't
  support UF_ARCHIVE, then there's no point in cpdup setting it.

Submitted-by: Will Andrews <will@firepipe.net>
Dragonfly-bug: https://bugs.dragonflybsd.org/issues/2987
               https://bugs.dragonflybsd.org/issues/2988
               https://bugs.dragonflybsd.org/issues/3067

6 years agohammer2 - Slightly reduce LZ4 output buffer limit
Matthew Dillon [Sat, 14 Oct 2017 17:59:30 +0000 (10:59 -0700)]
hammer2 - Slightly reduce LZ4 output buffer limit

* LZ4_compress_limitedOutput() appears to be able to overrun the
  supplied buffer.

* Slightly reduce the LZ4 output buffer limit from a 4-byte alignment
  to an 8-byte alignment to try to fix the problem.

6 years agoFix additional cases of seg-faults on crypt(3) failure
Lubos Boucek [Fri, 13 Oct 2017 21:33:01 +0000 (21:33 +0000)]
Fix additional cases of seg-faults on crypt(3) failure

* On failure, crypt(3) returns NULL, which is then used as a
  strcmp(3) argument

opieftpd.c and opiesu.c are not actually used anywhere.

6 years agorc.8: Clarify foo.sh behavior.
Sascha Wildner [Sat, 14 Oct 2017 08:48:04 +0000 (10:48 +0200)]
rc.8: Clarify foo.sh behavior.

Improve wording a bit. See NetBSD's revision 1.38.

Reported-by: Aaron LI <aly@aaronly.me>
6 years agodisklabel64: Fix an error message
Aaron LI [Fri, 13 Oct 2017 04:26:29 +0000 (12:26 +0800)]
disklabel64: Fix an error message

6 years agoifconfig(8): Add 'lscan'. Like 'scan', but displays long SSIDs.
Sascha Wildner [Sat, 14 Oct 2017 08:38:45 +0000 (10:38 +0200)]
ifconfig(8): Add 'lscan'. Like 'scan', but displays long SSIDs.

Submitted-by: Max Herrgard <herrgard@gmail.com>
6 years agomkinitrd - Add missing /var/db
Matthew Dillon [Sat, 14 Oct 2017 06:14:31 +0000 (23:14 -0700)]
mkinitrd - Add missing /var/db

* dhclient also needs /var/db to exist, make sure it does.

Reported-by: amonk
6 years agomkinitrd - Add missing /var/empty
Matthew Dillon [Sat, 14 Oct 2017 05:39:31 +0000 (22:39 -0700)]
mkinitrd - Add missing /var/empty

* /var/empty is required by dhclient, which will SIGHUP itself
  without it.

Reported-by: amonk
6 years agokernel - Rearrange namecache globals a bit
Matthew Dillon [Sat, 14 Oct 2017 04:44:06 +0000 (21:44 -0700)]
kernel - Rearrange namecache globals a bit

* Make sure ncspin and ncneglist are in the same cache line, and
  do not overlap other globals in that cache line.

Suggested-by: mjg_
6 years agotest - Cleanup pipe2
Matthew Dillon [Sat, 14 Oct 2017 04:41:46 +0000 (21:41 -0700)]
test - Cleanup pipe2

* Cleanup the pipe2 code a bit

6 years agoImport OpenSSH-7.6p1
Matthew Dillon [Fri, 13 Oct 2017 01:33:48 +0000 (18:33 -0700)]
Import OpenSSH-7.6p1

* Adjust build to match import

6 years agoImport OpenSSH-7.6p1
Matthew Dillon [Fri, 13 Oct 2017 01:32:28 +0000 (18:32 -0700)]
Import OpenSSH-7.6p1

* Import OpeNSSH-7.6p1.  Couldn't really merge from the vendor branch
  so just brought it in.

* Adjustments for WARNS issues

6 years agousr.sbin/fstyp: Update fstyp(8) for HAMMER2
Tomohiro Kusumi [Thu, 12 Oct 2017 20:03:00 +0000 (23:03 +0300)]
usr.sbin/fstyp: Update fstyp(8) for HAMMER2

6 years agosbin/newfs_hammer2: Add missing free() for uuid_to_string'd strings
Tomohiro Kusumi [Thu, 12 Oct 2017 20:08:52 +0000 (23:08 +0300)]
sbin/newfs_hammer2: Add missing free() for uuid_to_string'd strings

6 years agosbin/newfs_hammer2: Fix compile-time warning on Linux distros (gcc6)
Tomohiro Kusumi [Thu, 12 Oct 2017 19:57:45 +0000 (22:57 +0300)]
sbin/newfs_hammer2: Fix compile-time warning on Linux distros (gcc6)

--
warning: pointer targets in passing argument 1 of 'snprintf' differ in signedness [-Wpointer-sign]
warning: pointer targets in passing argument 1 of 'strlen' differ in signedness [-Wpointer-sign]

6 years agosbin/newfs_hammer2: Check S_ISREG()
Tomohiro Kusumi [Thu, 12 Oct 2017 19:48:11 +0000 (22:48 +0300)]
sbin/newfs_hammer2: Check S_ISREG()

The comment says as follows, so check S_ISREG().
/* Allow the formatting of regular files as HAMMER2 volumes */

This is also what the same function in HAMMER1 does.

6 years ago<netdb.h>: Adjust comment a bit.
Sascha Wildner [Thu, 12 Oct 2017 08:16:06 +0000 (10:16 +0200)]
<netdb.h>: Adjust comment a bit.

6 years agolibc/net: Add NI_NUMERICSCOPE flag for getnameinfo().
Sascha Wildner [Thu, 12 Oct 2017 08:13:31 +0000 (10:13 +0200)]
libc/net: Add NI_NUMERICSCOPE flag for getnameinfo().

Code to handle it is already present in getnameinfo() but we
were missing the flag so far.

See http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netdb.h.html

6 years agoMerge commit 'crater/master'
Thomas Nikolajsen [Wed, 11 Oct 2017 23:12:47 +0000 (01:12 +0200)]
Merge commit 'crater/master'

6 years agoMerge commit 'crater/master'
Thomas Nikolajsen [Wed, 11 Oct 2017 23:11:00 +0000 (01:11 +0200)]
Merge commit 'crater/master'

6 years agosystat.1: Update man page: sync to current program & improve markup a bit
Thomas Nikolajsen [Wed, 11 Oct 2017 23:03:46 +0000 (01:03 +0200)]
systat.1: Update man page: sync to current program & improve markup a bit

    Substantial changes has happened, especially for vmstat display.

6 years agokernel/atkbdc: Fix a prototype.
Sascha Wildner [Wed, 11 Oct 2017 20:05:26 +0000 (22:05 +0200)]
kernel/atkbdc: Fix a prototype.

6 years agokernel/cam: Add some missing parameter names.
Sascha Wildner [Wed, 11 Oct 2017 20:04:43 +0000 (22:04 +0200)]
kernel/cam: Add some missing parameter names.

Just like the rest of the file.

6 years ago<vfs/hammer2/hammer2.h>: Fix parameter names in two prototypes.
Sascha Wildner [Wed, 11 Oct 2017 17:31:25 +0000 (19:31 +0200)]
<vfs/hammer2/hammer2.h>: Fix parameter names in two prototypes.

Discussed-with: dillon

6 years agokernel: Simplify various redundant conditions.
Sascha Wildner [Wed, 11 Oct 2017 14:55:23 +0000 (16:55 +0200)]
kernel: Simplify various redundant conditions.

Found-by: cppcheck
One was reported by dcb in <https://bugs.dragonflybsd.org/issues/3078>.

6 years agolibc - Bring in s_ceill.c v1.2 from OpenBSD (2)
Matthew Dillon [Tue, 10 Oct 2017 22:38:08 +0000 (15:38 -0700)]
libc - Bring in s_ceill.c v1.2 from OpenBSD (2)

* Note, correction, v1.3 from OpenBSD, not v1.2

* Restore a cast that we need to compile with our higher WARNS level.

Reported-by: marino, xenu
6 years agokernel/mrsas: Simplify redundant conditions and remove never used variable
Lubos Boucek [Mon, 2 Oct 2017 02:16:10 +0000 (02:16 +0000)]
kernel/mrsas: Simplify redundant conditions and remove never used variable

Reported-by: dcb
6 years agolibc - Bring in s_ceill.c v1.2 from OpenBSD
Matthew Dillon [Tue, 10 Oct 2017 02:17:32 +0000 (19:17 -0700)]
libc - Bring in s_ceill.c v1.2 from OpenBSD

fix a case where ceill() returns 1.0L: in the x86 extended precision format
the fraction part has no implicit bit.

Reported-by: xenu
Taken-from: OpenBSD

6 years agohammer2.8/pthread_attr_setaffinity_np.3: Fix mdoc issues.
Sascha Wildner [Sun, 8 Oct 2017 07:47:58 +0000 (09:47 +0200)]
hammer2.8/pthread_attr_setaffinity_np.3: Fix mdoc issues.

6 years agodisklabel64.8: Add HAMMER2 fstype info.
Thomas Nikolajsen [Sat, 7 Oct 2017 14:14:52 +0000 (16:14 +0200)]
disklabel64.8: Add HAMMER2 fstype info.

6 years agoperiodic.conf.5: Add hammer2 variables.
Thomas Nikolajsen [Sat, 7 Oct 2017 14:09:36 +0000 (16:09 +0200)]
periodic.conf.5: Add hammer2 variables.

    Add description for periodic HAMMER2 script variables: 161.clean_hammer2.
    While here add HAMMER man pages to SEE ALSO section.

6 years agoetc/periodic/daily/161.clean-hammer2: Fix typo
Thomas Nikolajsen [Sat, 7 Oct 2017 13:53:37 +0000 (15:53 +0200)]
etc/periodic/daily/161.clean-hammer2: Fix typo

    pfslist variable for HAMMER, not HAMMER2 was used.
    This will typically have no effect, as pfslist is typically empty.

6 years agoperiodic.conf: Fix typo in comment
Thomas Nikolajsen [Sat, 7 Oct 2017 13:19:41 +0000 (15:19 +0200)]
periodic.conf: Fix typo in comment

6 years agomount_hammer2(8): Add man page.
Thomas Nikolajsen [Sat, 7 Oct 2017 13:13:11 +0000 (15:13 +0200)]
mount_hammer2(8): Add man page.

6 years agokernel - Refuse to swapoff under certain conditions
Matthew Dillon [Fri, 6 Oct 2017 05:59:40 +0000 (22:59 -0700)]
kernel - Refuse to swapoff under certain conditions

* Both tmpfs and vn can't handle swapoff's method of bringing pages
  back in from the swap partition being decomissioned.

* Fixing this properly is fairly involved. The normal swapoff procedure
  is to page swap into the related VM object, but tmpfs and vn use their
  VM objects ONLY to track swap blocks and not for vm_page manipulation,
  so that just won't work.  In addition, the swap code may associate
  a swap block with a VM object before issuing the write I/O to page
  out the data, and the swapoff code's asynchronous pagein might cause
  problems.

  For now, just make sure that swapoff refuses to remove the partition
  under these conditions, so it doesn't blow up tmpfs or vn.

6 years agotmpfs - Fix bug in call to vinitvmio()
Matthew Dillon [Fri, 6 Oct 2017 01:57:33 +0000 (18:57 -0700)]
tmpfs - Fix bug in call to vinitvmio()

* TMPFS_BLKMASK was being passed to vinitvmio() instead of
  TMPFS_BLKSIZE.  It is unclear if this caused any particular
  issue other than an occasional console warning.  Fixed.

6 years agokernel - Change index fields from unsigned to signed
Matthew Dillon [Thu, 5 Oct 2017 20:46:54 +0000 (13:46 -0700)]
kernel - Change index fields from unsigned to signed

* We use a signed trick for (j), fix the code so it actually works.

* The chipset field used to index (i) cannot exceed 1024 anyway.

Reported-by: lubos Bug #3020
6 years agoFix seg-faults on crypt(3) failure
Lubos Boucek [Sat, 23 Sep 2017 07:12:28 +0000 (07:12 +0000)]
Fix seg-faults on crypt(3) failure

6 years agoImprove kdump.1 and ktrace.1
Lubos Boucek [Fri, 22 Sep 2017 22:27:18 +0000 (22:27 +0000)]
Improve kdump.1 and ktrace.1

6 years agonologin(8): Sync with FreeBSD; Symlink as /usr/sbin/nologin
Aaron LI [Wed, 27 Sep 2017 10:24:05 +0000 (18:24 +0800)]
nologin(8): Sync with FreeBSD; Symlink as /usr/sbin/nologin

* Sync "nologin.c" with FreeBSD.  Login attempts are logged into syslog.
* Create symlink "/usr/sbin/nologin" to "/sbin/nologin".  FreeBSD
  (and Linux) installs "nologin" at  "/usr/sbin/nologin", and the users
  created by DPorts/packages also use "/usr/sbin/nologin" (see
  "/usr/dports/UIDs").
* Statically link "nologin" as done by FreeBSD.

6 years agocamcontrol(8): Check scsiserial()'s error, too.
Sascha Wildner [Thu, 5 Oct 2017 18:16:24 +0000 (20:16 +0200)]
camcontrol(8): Check scsiserial()'s error, too.

After some testing with devices that have no serial number, it looks
like this is safe to add nowadays.

Reported-by: dcb
Submitted-by: Lubos Boucek <bouceklubos@gmail.com>
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3059>

6 years agosocket: Limit the number of accepted sockets that kevent reports.
Sepherosa Ziehau [Thu, 5 Oct 2017 06:06:11 +0000 (14:06 +0800)]
socket: Limit the number of accepted sockets that kevent reports.

By default it is limited to 32.  It can be changed through:
sysctl kern.ipc.soavailconn=X

This change does _not_ affect userland using accept(2) in the following
way:
    for (;;) {
        s = accept();
        if (s < 0 && errno == EAGAIN)
            break;
        /* Processing accepted socket. */
    }

This change only affects optimized userland using kevent.data to avoid
extra accept(2) syscall:
    for (i = 0; i < kevent.data; ++i) {
        s = accept();
        /* Processing accepted socket. */
    }

The above logic is applied by nginx.  However, due to the cost of the
"Processing accepted socket" parts, this kinda of loop can increase
latency and destablize latency.

The comparison w/ 30K concurrent connections, 1 request/connection.

 1K web object
         |  performance |  lat-avg | lat-stdev |  lat-99%
---------+--------------+----------+-----------+----------
no limit | 210279.88tps |  59.19ms |    4.60ms |  69.02ms
---------+--------------+----------+-----------+----------
32 limit | 217599.01tps |  32.00ms |    2.35ms |  35.59ms

========

 8K web object
         |  performance |  lat-avg | lat-stdev |  lat-99%
---------+--------------+----------+-----------+----------
no limit | 180627.61tps |  70.53ms |    4.95ms |  80.61ms
---------+--------------+----------+-----------+----------
32 limit | 186324.41tps |  37.41ms |    4.81ms |  48.69ms

========

16K web object
         |  performance |  lat-avg | lat-stdev |  lat-99%
---------+--------------+----------+-----------+----------
no limit | 138667.84tps |  95.93ms |   14.90ms | 135.47ms
---------+--------------+----------+-----------+----------
32 limit | 138778.11tps |  60.90ms |   11.80ms |  92.07ms

This change significantly reduces average latency and .99 latency,
and performance is improved slightly.

6 years agoBring in vmx(4) (VMware virtual network driver, aka vmxnet3).
Sascha Wildner [Wed, 4 Oct 2017 17:01:17 +0000 (19:01 +0200)]
Bring in vmx(4) (VMware virtual network driver, aka vmxnet3).

Some features are still disabled, namely LRO, TSO, VLAN_HWFILTER,
and MSI-X support. That being said, it works and seems stable.

Tested-by: swildner (VMware Player 7.1.4 build-3848939)
            tuxillo (VMware ESXi 6.5.0 (Build 4887370))
Taken-from: FreeBSD (in turn based on OpenBSD's driver)

6 years agokernel - Fix GCC reordering problem with td_critcount
Matthew Dillon [Tue, 3 Oct 2017 01:42:34 +0000 (18:42 -0700)]
kernel - Fix GCC reordering problem with td_critcount

* Wrap all ++td->td_critcount and --td->td_critcount use cases
  with an inline which executes cpu_ccfence() before and after,
  to guarantee that GCC does not try to reorder the operation around
  critical memory changes.

* This fixes a race in lockmgr() and possibly a few other places
  too.

6 years agokernel - Fix rare lockmgr() state transition (2)
Matthew Dillon [Sun, 1 Oct 2017 18:18:49 +0000 (11:18 -0700)]
kernel - Fix rare lockmgr() state transition (2)

* Fix two lock timeout cases for LK_EXCLUPGRADE and LK_UPGRADE, and
  fix a bug in undo_upreq().

* A tsleep failure (such as the LK_TIMELOCK case via
  vm_map_lock_read_to()) was not properly backing-out a LKC_UPREQ,
  resulting in a situation where the lock becomes exclusively owned
  by nobody and deadlocks against all-comers.  Fix by properly
  calling undo_upreq().

* Fix a bug in undo_upreq() itself.  When undoing a granted UPREQ,
  the lockholder must be set prior to releasing the now-granted
  exclusive lock in order to avoid an assertion panic.

* While we are at it, replace a weird cmpset count,count with a
  fetchadd(count, 0).

6 years agosbin/hammer: Fix compile-time warning by some Linux distros
Tomohiro Kusumi [Sun, 1 Oct 2017 12:37:54 +0000 (15:37 +0300)]
sbin/hammer: Fix compile-time warning by some Linux distros

--
test_dupkey.c: In function 'main':
test_dupkey.c:54:1: warning: control reaches end of non-void function [-Wreturn-type]
 }

6 years agoFix some minor issues in several manual pages.
Sascha Wildner [Sun, 1 Oct 2017 10:09:02 +0000 (12:09 +0200)]
Fix some minor issues in several manual pages.

6 years agoX86_64_GENERIC: Fix indent.
Sascha Wildner [Sun, 1 Oct 2017 09:35:59 +0000 (11:35 +0200)]
X86_64_GENERIC: Fix indent.

6 years agokernel - Improve tsleep/wakeup queue collisions (3)
Matthew Dillon [Sun, 1 Oct 2017 01:17:55 +0000 (18:17 -0700)]
kernel - Improve tsleep/wakeup queue collisions (3)

* Doh, fix variable declaration.

6 years agokernel - Improve tsleep/wakeup queue collisions (2)
Matthew Dillon [Sun, 1 Oct 2017 01:11:08 +0000 (18:11 -0700)]
kernel - Improve tsleep/wakeup queue collisions (2)

* Fix SMP race.  When testing ident0 against -1 or the ident value
  as stored in a remote cpu's structure, ident0 must be loaded from memory
  once to avoid a cross-over race.

6 years agokernel - Fix rare lockmgr() state transition
Matthew Dillon [Sat, 30 Sep 2017 22:12:30 +0000 (15:12 -0700)]
kernel - Fix rare lockmgr() state transition

* When lockmgr() is releasing the last count on an exclusive lock
  with an upgrade request pending, and the atomic op fails, the
  code fails to properly retry.  Fixed by properly retrying.

* This situation should not be possible to even get into, hence 'rare'.
  It requires UPREQ to be set while the lock is being held exclusively,
  which should never be possible because there is no shared lock holder
  in that case who might attempt to upgrade.

  I checked race conditions when multiple shared holders attempt
  to upgrade but all that happens is that one will release and
  acquire a normal exclusive lock instead.

6 years agomandoc(1): Changed OSNAME to match 5.1.
Sascha Wildner [Sat, 30 Sep 2017 21:31:36 +0000 (23:31 +0200)]
mandoc(1): Changed OSNAME to match 5.1.

6 years agoFix some Xr punctuation issues in several manual pages.
Sascha Wildner [Sat, 30 Sep 2017 21:18:41 +0000 (23:18 +0200)]
Fix some Xr punctuation issues in several manual pages.

6 years agoUse standard section name 'AUTHORS' in several manual pages.
Sascha Wildner [Sat, 30 Sep 2017 21:12:11 +0000 (23:12 +0200)]
Use standard section name 'AUTHORS' in several manual pages.

6 years agoRevert "Update drm/radeon to Linux 4.7.10 as much as possible..."
Imre Vadász [Sat, 30 Sep 2017 19:08:51 +0000 (21:08 +0200)]
Revert "Update drm/radeon to Linux 4.7.10 as much as possible..."

This caused severe issues on some modern radeon models (e.g. Kaveri APUs).
Not reverting the 62dc643ef61b347c4c2e60ad9ea68dd766741c90 commit, it's just
a 2 character diff that was conflicting with this change.

This reverts commit a7a95252afec8bfcc34ee5b8725136b17b77043f.

Tested-By: ivadasz
Reported-By: several people on #dragonflybsd
6 years agosbin/mount_hammer: Remove redundant test_volumes() on mount(2) failure
Tomohiro Kusumi [Sat, 30 Sep 2017 11:21:25 +0000 (14:21 +0300)]
sbin/mount_hammer: Remove redundant test_volumes() on mount(2) failure

This code was originally added by 1a607e3e which added signature check
when mount(2) failed, and later modified by several commits including
1e297b34 which copied code from sbin/hammer/ondisk.c. But as mentioned
in 1e297b34, this entire checking wasn't needed (as it's in dmesg),
or it may even show the wrong reason of failure.

The correct way is to just type dmesg, and see what the kernel said,
instead of resorting to wild guess in userspace by reading volume header
*after* mount(2) failure (If you really want this it should be done
*before* mount(2)).

This originally didn't exist till 2009 and that was better.

6 years agosys/vfs/hammer: Check root voume# is 0 on mount(2)
Tomohiro Kusumi [Sat, 30 Sep 2017 11:17:32 +0000 (14:17 +0300)]
sys/vfs/hammer: Check root voume# is 0 on mount(2)

We could check this in addition to the existing conditional to
know the volume is the root volume. /sbin/hammer and /sbin/mount_hammer
do this, so why not.

If failed here, the volume which has just been inserted to the rbtree
(and other volumes already inserted) are going to be removed by
hammer_free_hmp().

6 years agosbin/hammer: Add UUID string on error and blockmap,show
Tomohiro Kusumi [Sat, 30 Sep 2017 10:12:51 +0000 (13:12 +0300)]
sbin/hammer: Add UUID string on error and blockmap,show

to make clear whether ondisk vol_fstype UUID is simply wrong or
due to byte order of the first 8 bytes (4-2-2 part).

6 years agosbin/hammer: Minor cleanup
Tomohiro Kusumi [Sat, 30 Sep 2017 09:29:07 +0000 (12:29 +0300)]
sbin/hammer: Minor cleanup

The prototype was originally brought (copied) from uuid(3).

6 years agotmpfs - Conditionalize atomic adds on mount structure
Matthew Dillon [Sat, 30 Sep 2017 18:06:49 +0000 (11:06 -0700)]
tmpfs - Conditionalize atomic adds on mount structure

* Conditionalize tracking of the total pages allocated to avoid
  the atomic op when the delta change is 0.

Suggested-by: mjg_
6 years ago<sys/param.h>: Fix __DragonFly_version.
Sascha Wildner [Sat, 30 Sep 2017 17:45:42 +0000 (19:45 +0200)]
<sys/param.h>: Fix __DragonFly_version.

Reported-by: zrj
6 years agoUpdate UPDATING a bit for the disabling of FFS_ROOT.
Sascha Wildner [Sat, 30 Sep 2017 17:29:42 +0000 (19:29 +0200)]
Update UPDATING a bit for the disabling of FFS_ROOT.

6 years agorc.conf.5: Improve moused_type description a bit more.
Sascha Wildner [Sat, 30 Sep 2017 14:47:04 +0000 (16:47 +0200)]
rc.conf.5: Improve moused_type description a bit more.

6 years ago5.1 commit. v5.1.0
Justin C. Sherrill [Sat, 30 Sep 2017 00:11:33 +0000 (20:11 -0400)]
5.1 commit.

6 years agorc.conf.5: Improve wording of the moused_type variable description.
Sascha Wildner [Fri, 29 Sep 2017 19:03:36 +0000 (21:03 +0200)]
rc.conf.5: Improve wording of the moused_type variable description.

Especially, point out that the default is 'auto' and if that is
what the user wants, they need not set it explicitly in their
/etc/rc.conf.

Reported-by: htse (Harald Brinkhof)
6 years agoarp: Allocate context memory on owner cpu.
Sepherosa Ziehau [Fri, 29 Sep 2017 06:38:35 +0000 (14:38 +0800)]
arp: Allocate context memory on owner cpu.

6 years agosyncache: Timer queue iteration is MPsafe; no need to use marker.
Sepherosa Ziehau [Fri, 29 Sep 2017 01:30:46 +0000 (09:30 +0800)]
syncache: Timer queue iteration is MPsafe; no need to use marker.

6 years agosyncache: Move local variables close their usage.
Sepherosa Ziehau [Fri, 29 Sep 2017 01:03:46 +0000 (09:03 +0800)]
syncache: Move local variables close their usage.

6 years agosyncache: inpcb will never be NULL.
Sepherosa Ziehau [Fri, 29 Sep 2017 01:02:03 +0000 (09:02 +0800)]
syncache: inpcb will never be NULL.

6 years agosyncache: Resurrect net.inet.tcp.syncache.count
Sepherosa Ziehau [Fri, 29 Sep 2017 00:11:18 +0000 (08:11 +0800)]
syncache: Resurrect net.inet.tcp.syncache.count