dragonfly.git
5 years agolibc: Add strsuftoll{,x}()
Sascha Wildner [Sat, 5 May 2018 20:07:33 +0000 (22:07 +0200)]
libc: Add strsuftoll{,x}()

In preparation for makefs(8).

Various dports (such as ftp/tnftpd) will also pick it up.

Taken-from:     NetBSD
Dports-testing: zrj

5 years agolibc/{un,}vis: Remove some useless junk. _DIAGASSERT() is defined.
Sascha Wildner [Mon, 30 Apr 2018 11:04:39 +0000 (13:04 +0200)]
libc/{un,}vis: Remove some useless junk. _DIAGASSERT() is defined.

5 years agoFix a few typos across the tree.
Sascha Wildner [Sat, 5 May 2018 18:39:20 +0000 (20:39 +0200)]
Fix a few typos across the tree.

5 years agoMakefile_upgrade.inc: Move dot.rhosts to the right place.
Sascha Wildner [Sat, 5 May 2018 12:11:45 +0000 (14:11 +0200)]
Makefile_upgrade.inc: Move dot.rhosts to the right place.

5 years agolibc/stdtime: Avoid signed overflow in mktime.
zrj [Fri, 4 May 2018 14:10:08 +0000 (17:10 +0300)]
libc/stdtime: Avoid signed overflow in mktime.

Fixes runtime issue with gcc80 -O2 constant folding. We need to use
__generic() macro to properly detect and set LONG_MIN/LONG_MAX here.

5 years agoboot/pc32: Avoid issues at -O2.
zrj [Fri, 4 May 2018 11:29:02 +0000 (14:29 +0300)]
boot/pc32: Avoid issues at -O2.

The 32-bit Legacy boot loader is intended to be compiled at -O1
optimization level. It is easy to forget this when overriding cflags.
For now do not use of frame pointer register as a general register.

5 years agolibstand/quad.h: Rename __qdivrem() to __udivmoddi4().
zrj [Thu, 26 Apr 2018 09:38:18 +0000 (12:38 +0300)]
libstand/quad.h: Rename __qdivrem() to __udivmoddi4().

The gcc80 at -O2 emits calls to __udivmoddi4() in loader.

Boot-tested.

5 years agocalloc - Work around gcc-8 bug (2).
zrj [Sat, 28 Apr 2018 05:30:03 +0000 (08:30 +0300)]
calloc - Work around gcc-8 bug (2).

GCC-8 at -O2 improperly tries to optimize calloc() replacement even for
malloc+bzero sequence back to calloc from calloc itself. This affects
both main root's shell (tcsh as default) and ld-elf.so dynamic linker.

Explicitly use -fno-builtin-malloc to prevent that at any -Ox level.

5 years agowatch(8): Add fallthrough.
zrj [Thu, 26 Apr 2018 07:25:53 +0000 (10:25 +0300)]
watch(8): Add fallthrough.

Mainly to suppress the warning.

5 years agortadvd(8): Suppress implicit-fallthrough.
zrj [Thu, 26 Apr 2018 07:23:41 +0000 (10:23 +0300)]
rtadvd(8): Suppress implicit-fallthrough.

For now don't change logic and just suppress the warning.

5 years agotset(1): Suppress implicit-fallthrough.
zrj [Thu, 26 Apr 2018 07:16:56 +0000 (10:16 +0300)]
tset(1): Suppress implicit-fallthrough.

It looks like ESC character should be followed by space code.
For now don't change logic and just suppress the warning.

5 years agolimits(1): Add fallthrough.
zrj [Thu, 26 Apr 2018 07:10:28 +0000 (10:10 +0300)]
limits(1): Add fallthrough.

In case of end of string fallthrough straight to default.

5 years agoident(1): Suppress implicit-fallthrough warnings.
zrj [Thu, 26 Apr 2018 07:08:02 +0000 (10:08 +0300)]
ident(1): Suppress implicit-fallthrough warnings.

Logic looks to be OK.

5 years agops(1): Add fallthrough.
zrj [Thu, 26 Apr 2018 07:02:30 +0000 (10:02 +0300)]
ps(1): Add fallthrough.

Fallthrough is intended here, check
4e1c727bebeb810ba7a97614113c24690d2da5e3.

5 years agosed(1): Suppress implicit-fallthrough.
zrj [Thu, 26 Apr 2018 06:53:22 +0000 (09:53 +0300)]
sed(1): Suppress implicit-fallthrough.

The enum in C is really an int in size and space and gcc80 warns on
switch default. Add explict errx() to avoid that. If compiler can prove
that default case would not be reached in linked script->type, then
statement will be optimized out.

5 years agodma(8): Use FALLTHROUGH consistently.
zrj [Thu, 26 Apr 2018 06:36:34 +0000 (09:36 +0300)]
dma(8): Use FALLTHROUGH consistently.

Avoids -Wimplicit-fallthrough warnings.

5 years agomount_smbfs(8): Mark usage() as dead.
zrj [Thu, 26 Apr 2018 06:29:58 +0000 (09:29 +0300)]
mount_smbfs(8): Mark usage() as dead.

5 years ago[skel] chase previous commit with file removal
Eitan Adler [Sat, 5 May 2018 07:11:14 +0000 (07:11 +0000)]
[skel] chase previous commit with file removal

Don't forget to remove the file in upgrade case.

5 years agoRemove rhosts from default template
Eitan Adler [Sat, 5 May 2018 06:59:11 +0000 (06:59 +0000)]
Remove rhosts from default template

The 'rcmds' were removed in 2458c6f4cb6284cf8c259e0e5bf12ff74ff41952.

5 years agokernel - Remove kthread exit debug kprintf()s
Matthew Dillon [Fri, 4 May 2018 18:28:10 +0000 (11:28 -0700)]
kernel - Remove kthread exit debug kprintf()s

* Remove TDF_VERBOSE and debugging kprintf()s on kthread exit.
  We don't need this debugging any more.

Reported-by: zrj
5 years agokernel - Fix spinlock bug introduced with windowing (2)
Matthew Dillon [Fri, 4 May 2018 17:46:02 +0000 (10:46 -0700)]
kernel - Fix spinlock bug introduced with windowing (2)

* Fix the fix for the spinlock bug to be the actual fix and not
  a bad dream.

Reported-by: zrj
5 years agosbin/mount_autofs: Use __DECONST() instead of local __UNCONST()
Tomohiro Kusumi [Thu, 3 May 2018 06:51:02 +0000 (23:51 -0700)]
sbin/mount_autofs: Use __DECONST() instead of local __UNCONST()

5 years agokernel - Fix spinlock bug introduced with windowing
Matthew Dillon [Wed, 2 May 2018 17:19:01 +0000 (10:19 -0700)]
kernel - Fix spinlock bug introduced with windowing

* The exclusive spinlock contention code was improperly assuming that
  non-zero EXCLWAIT bits prevented the SHARED bit from being set.  This
  is no longer true, shared locks can sometimes override EXCLWAIT.
  This assumption could result in spin_lock() returning with a shared
  lock instead of an exclusive lock.

* Fixed by ensuring that the SHARED bit is cleared when resolving the
  contended exclusive lock.

* Should hopefully fix the pmap pv == NULL assertion.

Reported-by: dillon, zrj
5 years agoigb: Bring in WOL configuration from FreeBSD.
Sepherosa Ziehau [Tue, 1 May 2018 12:11:33 +0000 (20:11 +0800)]
igb: Bring in WOL configuration from FreeBSD.

This does _not_ fix rebooting issue on certain LOM.

Tested-by: dillon
Obtained-from: FreeBSD

5 years agonetgraph7: Protect so_rcv properly
Sepherosa Ziehau [Tue, 1 May 2018 11:49:59 +0000 (19:49 +0800)]
netgraph7: Protect so_rcv properly

Reported-by: Markus Pfeiffer <markus.pfeiffer@morphism.de>
Tested-by: Markus Pfeiffer <markus.pfeiffer@morphism.de>

5 years agokernel - Refactor machdep.cpu_idle_hlt
Matthew Dillon [Sun, 29 Apr 2018 01:06:19 +0000 (18:06 -0700)]
kernel - Refactor machdep.cpu_idle_hlt

* Refactor machdep.cpu_idle_hlt.  Operation works essentially the
  same way as before but the code is a lot easier to read.

* Refactor mode 3 to have ACPI call back into machdep when entering
  a C1 halt.  Continue using HLT for this situation as we aren't
  really sure what ACPI may or may not have done.  MONITOR/MWAIT
  might not be appropriate.

* Fix bug in cpu_smp_stopped().  Just because cpu_mwait_hints is
  non-zero does not mean that there is an index entry for CPU_MWAIT_C1.
  Use the last entry based on cpu_mwait_hints instead.

* Note that machdep.cpu_idle_hlt mode 2 still doesn't work as intended.

5 years agosystat - Enhance -pv display
Matthew Dillon [Sat, 28 Apr 2018 18:10:38 +0000 (11:10 -0700)]
systat - Enhance -pv display

* Enhance systat -pv.  Add a delimeter between the totals rows and
  the cpu rows, add average user, sys, intr, and idle% over all cpus,
  add total collisions, and include a percentage of total system eaten
  up by collisions.

5 years agoAvoid absolute SYMLINKS in cpio(1), tar(1) and mailwrapper(8).
Sascha Wildner [Sat, 28 Apr 2018 16:13:16 +0000 (18:13 +0200)]
Avoid absolute SYMLINKS in cpio(1), tar(1) and mailwrapper(8).

5 years agohammer - Add missing lock
Matthew Dillon [Sat, 28 Apr 2018 03:55:34 +0000 (20:55 -0700)]
hammer - Add missing lock

* Add missing lock around hammer_redo_fifo_end_flush().  The missing
  lock could result in an assertion under heavy loads.

5 years agokernel - Adjust the scheduler to fix nice +N glitches
Matthew Dillon [Sat, 28 Apr 2018 03:21:46 +0000 (20:21 -0700)]
kernel - Adjust the scheduler to fix nice +N glitches

* Swap the DIDYIELD and steal code.  The steal code needs to
  go first, allowing a more desirable thread to steal the uschedcp
  designation from a less desirable thread.

* The DIDYIELD code also needs a need_user_resched() to interrupt the
  currently running less desirable thread.

* Set a half-queue default for usched_dfly_fast_resched instead of 0.
  This should reduce unnecessary ping-ponging of user threads that
  belong to the same queue.

* Increase the dynamic priority range from 12 to 20 queues.
  This ensures that a cpu-bound nice -20 process cannot completely
  override a nice +0 process, and ensures that a nice +20 process
  does not complete stall against a nice +0 cpu-bound process.
  That would be '16'.  We set it to 20 to give ourselves some headroom.

* Remove some dead code.

* These changes fix relative priority glitches.  More desirable
  threads no longer glitch waiting for a significantly less desirable
  thread to switch away on the current cpu, reducing the switch
  latency from 1+ scheduler ticks to a few microseconds.

  This allows nice +N processes and dynamic priority adjustments
  to run in the background fully cpu-bound.

5 years agokernel - Improve indefinite macros a bit
Matthew Dillon [Fri, 27 Apr 2018 18:41:12 +0000 (11:41 -0700)]
kernel - Improve indefinite macros a bit

* Delay saving SMP collision info and label string for a few loops
  so we don't lose performance by doing it after the contested lock has
  been resolved.

5 years agotermios.4: Improve markup.
Sascha Wildner [Fri, 27 Apr 2018 15:05:14 +0000 (17:05 +0200)]
termios.4: Improve markup.

5 years agokernel - Add two debug variables to struct globaldata
Matthew Dillon [Fri, 27 Apr 2018 06:43:15 +0000 (23:43 -0700)]
kernel - Add two debug variables to struct globaldata

* Add two debug variables to struct globaldata.  These variables
  can be used in assembly to debug difficult issues and accessed
  in kgdb or by IPI failure alerts.

5 years agokernel - Fix several usched nits
Matthew Dillon [Fri, 27 Apr 2018 06:11:07 +0000 (23:11 -0700)]
kernel - Fix several usched nits

* Fix an issue where a usched-restricted process is pulled onto a
  cpu that is outside of its mask.  The process will immediately
  push itself back onto a cpu in its mask, but this bug leads to
  unwanted cpu ping ponging.

* Fix an issue where cpu-bound usched-restricted processes can
  cause other processes to be misscheduled at a lower priority
  than their actual priority, resulting in unexpected stuttering.

* With these changes, nice +/- priorities should work considerably
  better.  In the normal case, alotted cpu time will be as shown
  below.  This is intended to be non-linear:

     1   RQ0N    1:42.11 forever
     2   R0N     1:22.55 forever
     3   R0N     0:51.46 forever
     4   RQ0N    0:24.23 forever
     5   R0N     0:23.12 forever
     6   RQ0N    0:19.91 forever
     7   RQ0N    0:09.08 forever
     8   RQ0N    0:08.38 forever
     9   RQ0N    0:06.46 forever
    10   RQ0N    0:06.72 forever
    11   RQ0N    0:04.65 forever
    12   RQ0N    0:04.60 forever
    13   RQ0N    0:03.04 forever
    14   RQ0N    0:02.53 forever
    15   RQ0N    0:02.16 forever
    16   RQ0N    0:01.55 forever
    17   RQ0N    0:01.25 forever
    18   RQ0N    0:00.81 forever
    19   RQ0N    0:00.76 forever
    20   RQ0N    0:00.32 forever

* In addition, dynamic priority operation should also work better with
  these changes.

* WARNING!  With this change, nice values actually work as intended.  A
  nice +20 process will get very little cpu in the face of a cpu-bound
  nice +0 process on a cpu.  Similarly, a cpu-bound nice -20 process will
  allow nice +0 processes to barely function on a cpu.

  And if you use an even larger spread, a cpu-bound nice -20 process
  will not allow a nice +1 or higher process any cpu time at all.

  Having multiple cores mitigations this somewhat, but users must be
  careful especially when specifying negative nice values for processes.

* If you run X and have jerkiness issues due to process load, you may want
  to give the X server itself around a nice -5.  You can fiddle, but in
  basic testing with everything running at nice 0, the scheduler appears
  to do a pretty good just generally.  For example, if your browser is
  so overloaded that it has essentially become cpu bound, it will get cpu
  on an equal basis with batch jobs like bulk builds.

5 years agolib/i18n_module: Fix out of bounds bug.
zrj [Thu, 26 Apr 2018 11:49:16 +0000 (14:49 +0300)]
lib/i18n_module: Fix out of bounds bug.

Taken-from: NetBSD

5 years agogcore(1): Mark as breaking strict aliasing.
zrj [Thu, 26 Apr 2018 10:55:13 +0000 (13:55 +0300)]
gcore(1): Mark as breaking strict aliasing.

IS_ELF(*(Elf_Ehdr *)&exec).

5 years agotip(1): Mark as breaking strict aliasing.
zrj [Thu, 26 Apr 2018 10:49:33 +0000 (13:49 +0300)]
tip(1): Mark as breaking strict aliasing.

The boolean(v) macro uses type-punned pointers.

5 years agogcc50: Fix false positive for -Walloc-size-large-than.
zrj [Thu, 26 Apr 2018 10:38:01 +0000 (13:38 +0300)]
gcc50: Fix false positive for -Walloc-size-large-than.

Backport fix for PR 79132, prevent using alloca(-1).

5 years agogcc47: Fix false positive for -Walloc-size-large-than.
zrj [Thu, 26 Apr 2018 10:35:33 +0000 (13:35 +0300)]
gcc47: Fix false positive for -Walloc-size-large-than.

Backport fix for PR 79132, prevent using alloca(-1).

5 years agompsutil(8): Add missing braces.
Sascha Wildner [Thu, 26 Apr 2018 16:17:33 +0000 (18:17 +0200)]
mpsutil(8): Add missing braces.

Reported-by: zrj
5 years agobsd.sys.mk: Implement WARNS framework for HOST_CCVER.
zrj [Wed, 25 Apr 2018 16:22:13 +0000 (19:22 +0300)]
bsd.sys.mk: Implement WARNS framework for HOST_CCVER.

Previously we were handling just a CCVER only.

5 years agoworld: Mark all build-tools.
zrj [Wed, 25 Apr 2018 16:21:40 +0000 (19:21 +0300)]
world: Mark all build-tools.

5 years agocsh(1): Separate hostprog.
zrj [Wed, 25 Apr 2018 16:20:33 +0000 (19:20 +0300)]
csh(1): Separate hostprog.

5 years agoawk(1): Separate hostprog.
zrj [Wed, 25 Apr 2018 16:20:06 +0000 (19:20 +0300)]
awk(1): Separate hostprog.

5 years agolibmagic(3): Separate hostprog.
zrj [Wed, 25 Apr 2018 16:19:40 +0000 (19:19 +0300)]
libmagic(3): Separate hostprog.

Set WARNS=1 for mkmagic.nx so as not to use -w.

5 years agophantasia(6): Separate hostprog.
zrj [Wed, 25 Apr 2018 16:19:07 +0000 (19:19 +0300)]
phantasia(6): Separate hostprog.

Make substantial effort to reduce dependencies for setup.nx.
While there install monsters file as 640.

5 years agohack(6): Separate hostprog.
zrj [Wed, 25 Apr 2018 16:18:29 +0000 (19:18 +0300)]
hack(6): Separate hostprog.

5 years agoadventure(6): Separate hostprog.
zrj [Wed, 25 Apr 2018 16:18:06 +0000 (19:18 +0300)]
adventure(6): Separate hostprog.

5 years agodrm: Implement parts of the Linux irq subsystem
François Tigeot [Wed, 25 Apr 2018 09:52:23 +0000 (11:52 +0200)]
drm: Implement parts of the Linux irq subsystem

* Allowing to reuse more drm drivers code as-is from Linux

* Also allowing Linux irq functions to return expected status
  codes, increasing general driver robustness

Tested-with: many i915 devices, Radeon HD6450

5 years agokernel/mpr: Remove unused malloc type.
Sascha Wildner [Tue, 24 Apr 2018 20:03:51 +0000 (22:03 +0200)]
kernel/mpr: Remove unused malloc type.

5 years agoRemove <sys/ioctl_compat.h>.
Sascha Wildner [Tue, 24 Apr 2018 20:03:51 +0000 (22:03 +0200)]
Remove <sys/ioctl_compat.h>.

Now that tkusumi's fix for benchmarks/fio for the name and location
change of the IOCTLTRIM ioctl is in DeltaPorts, remove the header
entirely.

Fixes for stty(1) and pstat(8) are from FreeBSD.

Dports-checking: zrj

5 years agoAdd FreeBSD's mpr(4) driver for LSI Fusion-MPT 3/3.5 SAS controllers.
Sascha Wildner [Tue, 24 Apr 2018 18:45:47 +0000 (20:45 +0200)]
Add FreeBSD's mpr(4) driver for LSI Fusion-MPT 3/3.5 SAS controllers.

This commit also includes a userland utility for mps(4) and mpr(4)
(mprutil(8) aka mpsutil(8)).

After porting bug fixing, testing shows that it seems to be stable,
therefore I have added it to our X64_64_GENERIC as well.

Thanks to zrj for testing and to sephe for some porting clues.

Taken-from: FreeBSD

5 years ago<sys/proc.h>: Fix unused macro name (number == bit number) and comment.
Sascha Wildner [Tue, 24 Apr 2018 12:49:10 +0000 (14:49 +0200)]
<sys/proc.h>: Fix unused macro name (number == bit number) and comment.

5 years agoevtranalyze.1: Fix typo.
Sascha Wildner [Tue, 24 Apr 2018 07:14:57 +0000 (09:14 +0200)]
evtranalyze.1: Fix typo.

5 years agox86_64/ioapic: Make sure that legacy IRQ only appears on one CPU.
Sepherosa Ziehau [Mon, 23 Apr 2018 14:15:44 +0000 (22:15 +0800)]
x86_64/ioapic: Make sure that legacy IRQ only appears on one CPU.

The legacy IRQ lookup assumes only one CPU has a given legacy IRQ.

On system w/ large number of IOAPIC, GSI96 could be mapped to IRQ17
on CPU0 (since IRQ96 is used by SYSCALL), while GSI17 is mapped to
IRQ17 on another CPU.  This breaks later IRQ lookup.

Reported-by: Imre Vadasz
Tested-by: Imre Vadasz

5 years agokernel - Remove cache ping-pong on common scheduler operations
Matthew Dillon [Mon, 23 Apr 2018 07:27:21 +0000 (00:27 -0700)]
kernel - Remove cache ping-pong on common scheduler operations

* Reflect dfly_curprocmask and dfly_rdyprocmask bits in the
  scheduler's pcpu structures.  This allows us to reduce global
  atomic ops that are virtually guaranteed to cause cache ping
  ponging.

* sched_yield and token-based yield operations no longer clear
  the bit in the curprocmask, since they are just yielding
  (XXX needs work, a later blocking op then might not pull a
  new process from another cpu).

5 years agokernel - More deterministic systat -pv lock name output
Matthew Dillon [Mon, 23 Apr 2018 07:23:15 +0000 (00:23 -0700)]
kernel - More deterministic systat -pv lock name output

* Update the lock name in the globaldata structure for any
  contended lock that bumps the SMP collision count (basically,
  any lock which contends for more than 1uS).

* Improved systat -pv accuracy at very little cost.

5 years agokernel - Improve lockf performance
Matthew Dillon [Mon, 23 Apr 2018 07:19:46 +0000 (00:19 -0700)]
kernel - Improve lockf performance

* Improve fcntl lockf performance with two small optimizations.
  Together these add a little over 10% in non-contended
  performance.

* Add a 2-entry-per-cpu range lock allocation cache.  This
  covers the most typical lock/unlock situations.

* Conditionalize the setting of VMAYHAVELOCKS to avoid unnecessary
  atomic ops.

* Remove the clearing of VMAYHAVELOCKS.  The cost in close() is
  basically nothing while the cost in the lockf critical path
  is several branches and an atomic op.

5 years agolibthread_xu - Improve contended mutex code
Matthew Dillon [Mon, 23 Apr 2018 02:29:58 +0000 (19:29 -0700)]
libthread_xu - Improve contended mutex code

* Retry a few times in a loop before using the umtx*() system
  calls to sleep.

  This significantly reduces IPI traffic and improves performance
  when a mutex is heavily contended.

5 years agokernel - Improve namecache performance
Matthew Dillon [Mon, 23 Apr 2018 02:26:58 +0000 (19:26 -0700)]
kernel - Improve namecache performance

* Improve performance for the edge case where a process is
  deleting a large number of files.  In this situation,
  NCF_DESTROYED ncp entries can build up in the hash table
  and slow things down until the system quiets down, then
  the tables get cleaned up.

  Improve by recycling such entries into new entries when
  possible.

* Refactor the hash calculation again.  The big-prime idea
  actually has some trivially obvious problems, scrap it
  for the moment.

5 years agokernel - Improve kern_dup() performance
Matthew Dillon [Mon, 23 Apr 2018 02:25:23 +0000 (19:25 -0700)]
kernel - Improve kern_dup() performance

* Run the operation with a single exclusive spinlock instead of
  acquiring and releasing it twice.  Improves thread-concurent
  dup() performance.

5 years agokernel - Carefully refactor contended tokens and spinlocks (2)
Matthew Dillon [Mon, 23 Apr 2018 02:24:07 +0000 (19:24 -0700)]
kernel - Carefully refactor contended tokens and spinlocks (2)

* After testing, increasing the exponential cap from 1024 to
  4096 appears to produce better results, so the previous comment
  is wrong.  Adjust the default and the comment.

* Forgot to commit the changes to spinlock.h, fixed.

5 years agokernel - Fix statistics accounting bug in kfree()
Matthew Dillon [Mon, 23 Apr 2018 02:16:24 +0000 (19:16 -0700)]
kernel - Fix statistics accounting bug in kfree()

* kfree() was bumping the statistics counters for the wrong cpu.
  This could lead to kmalloc statistics slowly becoming inaccurate.

* This also fixes some significant cache line bouncing under
  heavy threaded loaded.

5 years agokernel - Carefully refactor contended tokens and spinlocks
Matthew Dillon [Mon, 23 Apr 2018 01:56:14 +0000 (18:56 -0700)]
kernel - Carefully refactor contended tokens and spinlocks

* Carefully put the exponential backoff back in for spinlocks, and
  implement for tokens.  Only applicable to exclusive locks, capped
  via sysctl (mjg).  Tested on dual-socket xeon.

* Exclusive priority for shared locks reduces the shared/exclusive
  starvation that can occur when exclusive locks use exponential
  backoff.

* Exponential backoff significantly improves performance for
  heavily contended exclusive locks by allowing some degree of burst
  operation.

* Implement TSC windowing for shared locks (and a little for
  exclusive locks too).  This prevents heavily contended exclusive
  locks from completely starving shared locks by using windowing
  to disable the exclusive-priority mechanic for shared locks.

  This allows a few contending shared locks to compete on equal
  ground with exclusive locks.

Suggested-by: mjg
5 years agokernel - Remove performance pessimization with INVARIANTS
Matthew Dillon [Mon, 23 Apr 2018 01:55:03 +0000 (18:55 -0700)]
kernel - Remove performance pessimization with INVARIANTS

* Remove lf_global_counter under INVARIANTS, fixes cache pessimization.
  We want performance scaling to continue to work with INVARIANTS since
  that is how we ship the kernel by default.

5 years agokernel - cleanup kern_descrip.c
Matthew Dillon [Sun, 22 Apr 2018 19:29:55 +0000 (12:29 -0700)]
kernel - cleanup kern_descrip.c

* Cleanup long lines, syntax

* fsetfd_locked() does not have to call fclearcache().

5 years agokernel - Localize [in]activevnodes globals, improve allocvnode
Matthew Dillon [Sun, 22 Apr 2018 19:12:33 +0000 (12:12 -0700)]
kernel - Localize [in]activevnodes globals, improve allocvnode

* Move to globaldata, keep globals as rollup statistics.

* We already solved normal active->inactive->active issues
  in prior work, this change primarily effects vnode termination,
  such as for unlink operations.

* Enhance allocvnode to reuse a convenient reclaimed vnode
  if we can find one on the pcpu's inactive list and lock it
  non-blocking.  This reduces unnecessary vnode count bloating.

5 years agotmpfs - Move dnode lock to improve unlink performance
Matthew Dillon [Sun, 22 Apr 2018 18:57:07 +0000 (11:57 -0700)]
tmpfs - Move dnode lock to improve unlink performance

* Unlock the directory node a little earlier in tmpfs_vop_nremove().

5 years agokernel - Minor rollup cleanup
Matthew Dillon [Sun, 22 Apr 2018 17:41:52 +0000 (10:41 -0700)]
kernel - Minor rollup cleanup

* Collect count and apply once at the end of the loop.

5 years agoLINT64: Fix typo.
Sascha Wildner [Sun, 22 Apr 2018 20:17:21 +0000 (22:17 +0200)]
LINT64: Fix typo.

5 years agokernel - Remove SMP bottlenecks on uidinfo, descriptors, and lockf (2)
Matthew Dillon [Sun, 22 Apr 2018 17:34:22 +0000 (10:34 -0700)]
kernel - Remove SMP bottlenecks on uidinfo, descriptors, and lockf (2)

* Fix lost fp bug, a file pointer would sometimes not get dropped,
  leading to disconnection problems (e.g. sftp).

5 years agorpc: Add support for NO_WCAST_FUNCTION_TYPE make variables.
zrj [Tue, 30 Jan 2018 11:38:27 +0000 (13:38 +0200)]
rpc: Add support for NO_WCAST_FUNCTION_TYPE make variables.

It is unfortunate that <rpc/xdr.h> has the "bool_t xdr_void(void);"
without the XDR* parameter even if it is unused. Since we do not want to
change public symbol interface, suppressing the warning is a better way.

While there, add suppression to acpiexec/inetd for function cast too.

5 years agoworld: Mark utilities that use out of bounds copies.
zrj [Wed, 24 Jan 2018 17:29:16 +0000 (19:29 +0200)]
world: Mark utilities that use out of bounds copies.

5 years agobsd.kern.mk: Handle gcc80 better in buildkernel.
zrj [Mon, 22 Jan 2018 13:24:11 +0000 (15:24 +0200)]
bsd.kern.mk: Handle gcc80 better in buildkernel.

5 years agolibc - Remove incorrect sched_yield() stub
Matthew Dillon [Sun, 22 Apr 2018 00:48:43 +0000 (17:48 -0700)]
libc - Remove incorrect sched_yield() stub

* sched_yield() is a system call, and libthread_xu does not
  override it.  Remove the empty stub so the system call is
  properly called.

* Now sched_yield() is no longer a NOP.

5 years agokernel - Remove SMP bottlenecks on uidinfo, descriptors, and lockf
Matthew Dillon [Sun, 22 Apr 2018 00:30:42 +0000 (17:30 -0700)]
kernel - Remove SMP bottlenecks on uidinfo, descriptors, and lockf

* Use an eventcounter and the per-thread fd cache to fix
  bottlenecks in checkfdclosed().  This will work well for
  the vast majority of applications and test benches.

* Batch holdfp*() operations on kqueue collections when implementing
  poll() and select().  This significant improves performance.
  Full scaling not yet achieved, however.

* Increase copyin item batching from 8 to 32 for select() and poll().

* Give the uidinfo structure a pcpu array to hold the posixlocks
  and openfiles count fields, with a rollup contained in the uidinfo
  structure itself.

  This removes numerous global bottlenecks related to open(),
  close(), dup*(), and lockf operations (posixlocks count).

  ui_openfiles will force a rollup on limit reached to be sure
  that the limit was actually reached.  ui_posixlocks stays fairly
  loose.  Each cpu rolls up generally only when the pcpu count exceeds
  +32 or goes below -32.

* Give the proc structure a pcpu array for the same counts, in order
  to properly support seteuid() and such.

* Replace P_ADVLOCK with a char field proc->p_advlock_flag, and
  remove token operations around the field.

5 years agokernel - Refactor lwkt_token pool hash
Matthew Dillon [Sun, 22 Apr 2018 00:23:23 +0000 (17:23 -0700)]
kernel - Refactor lwkt_token pool hash

* Refactor the lwkt_token pool hash to a better hash algorithm
  using large primes.

5 years agokernel - per-thread fd cache, p_fd lock bypass
Matthew Dillon [Fri, 20 Apr 2018 15:44:32 +0000 (08:44 -0700)]
kernel - per-thread fd cache, p_fd lock bypass

* Implement a per-thread (fd,fp) cache.  Cache hits can keep fp's
  in a held state (avoiding the need to fhold()/fdrop() the ref count),
  and bypasses the p_fd spinlock.  This allows the file pointer structure
  to generally be shared across cpu caches.

* Can cache up to four descriptors in each thread, LRU.  This is the common
  case.  Highly threaded programs tend to focus work on a distinct
  file descriptors in each thread.

* One file descriptor can be cached in up to four threads.  This is
  a significant limitation, though relatively uncommon.  On a cache miss
  the code drops into the normal shared p_fd spinlock lookup.

5 years agosbin/hammer: Drop _X macro for hammer show
Tomohiro Kusumi [Sat, 21 Apr 2018 21:58:36 +0000 (14:58 -0700)]
sbin/hammer: Drop _X macro for hammer show

Also reduce supported indent levels from 17 to 10.

17 levels with 62 fanouts for internal nodes seems way more than
needed even considering max capacity of HAMMER1.

5 years agoFix up UPGRADING.
Sascha Wildner [Sat, 21 Apr 2018 21:39:24 +0000 (23:39 +0200)]
Fix up UPGRADING.

5 years agoRemove IPsec and related code from the system.
Sascha Wildner [Sat, 21 Apr 2018 21:26:37 +0000 (23:26 +0200)]
Remove IPsec and related code from the system.

It was unmaintained ever since we inherited it from FreeBSD 4.8.

In fact, we had two implementations from that time: IPSEC and FAST_IPSEC.
FAST_IPSEC is the implementation to which FreeBSD has moved since, but
it didn't even build in DragonFly.

Fixes for dports have been committed to DeltaPorts.

Requested-by: dillon
Dports-testing-and-fixing: zrj

5 years agokernel: Disable TCP_SIGNATURE in preparation for removing IPSEC.
Sascha Wildner [Tue, 17 Apr 2018 17:10:55 +0000 (19:10 +0200)]
kernel: Disable TCP_SIGNATURE in preparation for removing IPSEC.

Keep the code around until it gets fixed at a later date.

Requested-by: sephe
5 years ago<sys/mbuf.h>: Fix packet tag comments.
Sascha Wildner [Sat, 21 Apr 2018 18:56:40 +0000 (20:56 +0200)]
<sys/mbuf.h>: Fix packet tag comments.

5 years agokernel - Fix duplicate da0 or da* and locked up boot
Matthew Dillon [Sat, 21 Apr 2018 01:18:52 +0000 (18:18 -0700)]
kernel - Fix duplicate da0 or da* and locked up boot

* Fix duplicate da* reporting at boot which usually results in
  the boot locking up.

* The diskinfo was being installed while before CAM's softc->state
  normalized, potentially allowing I/O to occur during the probe
  sequence and causing the probe state to be repeated.

  Delay calling disk_setdiskinfo() until after softc->state is
  normalized.

5 years agosys/vfs/autofs: Use ksnprintf() (sync with NetBSD)
Tomohiro Kusumi [Fri, 20 Apr 2018 15:01:30 +0000 (08:01 -0700)]
sys/vfs/autofs: Use ksnprintf() (sync with NetBSD)

FreeBSD and DragonFly had strcpy()+strcat().
NetBSD changed it to snprintf().

5 years agosys/vfs/autofs: Fix a comment
Tomohiro Kusumi [Fri, 20 Apr 2018 15:00:57 +0000 (08:00 -0700)]
sys/vfs/autofs: Fix a comment

This isn't really a FALLTHROUGH. Not sure why I even originally
added this since this had never existed in FreeBSD too.

5 years agoipfw3nat: remove the state from the proper tree
Bill Yuan [Thu, 19 Apr 2018 19:06:43 +0000 (19:06 +0000)]
ipfw3nat: remove the state from the proper tree

5 years agokernel - Increase vm_object hash table
Matthew Dillon [Fri, 20 Apr 2018 02:32:30 +0000 (19:32 -0700)]
kernel - Increase vm_object hash table

* Increase table from 64 to 256 entries.

* Improve the hash algorithm considerably for better coverage.

5 years agokernel - Implement td_limit reflection of p_limit
Matthew Dillon [Fri, 20 Apr 2018 00:52:53 +0000 (17:52 -0700)]
kernel - Implement td_limit reflection of p_limit

* Reflect proc->p_limit onto thread->td_limit to allow lockless
  rlimits testing.

* Significantly improves performance for rlimits-testing-centric
  operations such as for dup() and dup2().

* Also fixes performance issues across processes when the plimit
  structure is shared across many processes.  In this situation,
  unnecessary locking conflicts developed due to the high level
  of sharing across what would normally be considered distinct
  processes.

Suggested-by: mjg
5 years agorc.d - Be quiet when check if modules are loaded
Antonio Huete Jimenez [Thu, 19 Apr 2018 23:07:46 +0000 (16:07 -0700)]
rc.d - Be quiet when check if modules are loaded

5 years agokernel - Handle spinlock indefinite wait edge case
Matthew Dillon [Wed, 18 Apr 2018 18:38:30 +0000 (11:38 -0700)]
kernel - Handle spinlock indefinite wait edge case

* The spinlock exclusive priority mechanism can cause an indefinite
  wait situation for shared locks to arise when a large number of cpu
  cores are cycling the same spinlock both shared and exclusive.

  This situation just won't happen for any real workload, but it
  can come up in benchmarks.

* Introduce a quick hack to ensure that this situation does not lead
  to a panic.  The exclusive priority mechanism is ignored once a
  shared spinlock has spun for greater than one second.

5 years agokernel/LINT64: Fix comment.
Sascha Wildner [Wed, 18 Apr 2018 18:12:50 +0000 (20:12 +0200)]
kernel/LINT64: Fix comment.

6 years agoRemove some old tty related code, such as <sgtty.h>, old ioctls etc.
Sascha Wildner [Wed, 18 Apr 2018 16:49:47 +0000 (18:49 +0200)]
Remove some old tty related code, such as <sgtty.h>, old ioctls etc.

It is replaced by POSIX termios on modern systems. Also, remove related
code in libcompat.

<sys/ioctl_compat.h> is now just a few lines. This header will eventually
be removed completely.

Two ports, devel/xxgdb and editors/aee, were still using <sgtty.h> and
have since been fixed. But let's bump __DragonFly_version anyway.

Dports-checking-and-fixing: zrj

6 years agobpf - Add BIOC{S,G}FEEDBACK ioctls
Antonio Huete Jimenez [Wed, 18 Apr 2018 09:39:21 +0000 (02:39 -0700)]
bpf - Add BIOC{S,G}FEEDBACK ioctls

- When set it allows reinjecting packets that were written to the bpf device
  as input to the interface when the output is successful.
- Add an alias to BIOCFEEDBACK which is the name of the
  of the 'set' ioctl in FreeBSD.

Partially-taken-from: NetBSD
Reviewed-by: sephe
Closes: #3126

6 years ago<net/dlt.h> - Remove a comment which is no longer applicable
Antonio Huete Jimenez [Wed, 18 Apr 2018 08:30:33 +0000 (01:30 -0700)]
<net/dlt.h> - Remove a comment which is no longer applicable

6 years ago<net/dlt.h> - Add some more DLTs
Antonio Huete Jimenez [Wed, 18 Apr 2018 08:08:34 +0000 (01:08 -0700)]
<net/dlt.h> - Add some more DLTs

- The DLT_USER* dlts are reserved for private use, they won't be
  used ever by libpcap/tcpdump themselves.
- net/wireshark-qt5 (and probably others) use it

6 years agohammer2 - Add vfs.hammer2.limit_dirty_inodes
Matthew Dillon [Wed, 18 Apr 2018 06:10:02 +0000 (23:10 -0700)]
hammer2 - Add vfs.hammer2.limit_dirty_inodes

* Add vfs.hammer2.limit_dirty_inodes which causes hammer2 to
  immediately begin fsync()ing dirty inodes when the count exceeds
  the limit.  Set a reasonable limit.

* Fixes issues on slower storage when the syncer is unable to
  keep up with the userland frontend, causing the number of
  dirty inodes to increase almost unbounded (limited only by
  kern.maxvnodes).

  Allowing a large number of dirty inodes to accumulate can
  can result in a situation where the clean device buffer
  underpinning the dirty inode is discarded by the kernel before
  the filesystem is able to flush it, forcing additional disk reads
  and slowing things down even more.

* Improve the operation of speedup_syncer() by limiting the
  rate at which we call the function.  It is now called a maximum
  of approximately once per tick (each call speeding up a sync
  by one second).

6 years agokernel - Add dirty vnode management facility
Matthew Dillon [Wed, 18 Apr 2018 06:06:18 +0000 (23:06 -0700)]
kernel - Add dirty vnode management facility

* Keep track of how many vnodes are queued to the syncer, which
  is basically the number of dirty vnodes.  The syncer vnode is
  included so the idle count is usually 1 and not 0.

* vn_syncer_count() returns the count.

* vn_syncer_one() attempts to fsync the next dirty vnode immediately,
  if it can acquire it non-blocking.  The special syncer vnode is
  ignored.  On failure the vnode will be requeued for 1 second,
  so this routine can be cycled.

6 years agoinet6/pim: Return IPPROTO_DONE if the mbuf is freed.
Sepherosa Ziehau [Tue, 17 Apr 2018 13:33:59 +0000 (21:33 +0800)]
inet6/pim: Return IPPROTO_DONE if the mbuf is freed.

This prevents the caller from using the freed mbuf.

Obtained-from: NetBSD via FreeBSD

6 years agokernel - Improve spinlock performance a bit
Matthew Dillon [Tue, 17 Apr 2018 04:27:14 +0000 (21:27 -0700)]
kernel - Improve spinlock performance a bit

* Rearrange indefinite_init() and cpu_pause() in _spin_lock_contested()
  and _spin_lock_shared_contested() to improve performance.

* Fix conditional clearing the SHARED bit to use ovalue intead of
  value.  After review, either can be used but ovalue is more
  appropriate and give us an interlock against SPINLOCK_EXCLWAIT.

Reported-by: mjg_