dragonfly.git
5 years agoLTO: Few workarounds for gcc80 -flto.
zrj [Tue, 8 May 2018 15:20:05 +0000 (18:20 +0300)]
LTO: Few workarounds for gcc80 -flto.

5 years agobsd.sys.mk: Add handling for gcc80.
zrj [Wed, 2 May 2018 15:34:06 +0000 (18:34 +0300)]
bsd.sys.mk: Add handling for gcc80.

  * Turn off -Wformat-* family of warnings, the -Wformat-truncation and
    -Wformat-overflow is just too noisy for not much benefit.
    Do the same for -Wstringop-* family for now.
    Move these warnings (at their default settings) to WARNS_AUDIT.
  * Disable -Wimplicit-fallthough at WARNS=3, most of contrib is there.

5 years agoworld: Lower WARNS for bmake/tcsh contrib.
zrj [Wed, 2 May 2018 14:26:29 +0000 (17:26 +0300)]
world: Lower WARNS for bmake/tcsh contrib.

Revert this once issues have been solved upstream.

5 years agogcc80: Mark few sources as special for narrowing.
zrj [Wed, 2 May 2018 13:50:54 +0000 (16:50 +0300)]
gcc80: Mark few sources as special for narrowing.

While there, add -Wpragmas suppression for gcc47.

5 years agogcc80: Activate workaround for libgcc_pic.a.
zrj [Wed, 2 May 2018 13:43:22 +0000 (16:43 +0300)]
gcc80: Activate workaround for libgcc_pic.a.

Port 082b455eab27fdd982397abd20137b57c063d594 from gcc50.

5 years agogcc80: Hook into the buildworld as optional compiler.
zrj [Wed, 2 May 2018 13:42:24 +0000 (16:42 +0300)]
gcc80: Hook into the buildworld as optional compiler.

This alternative compiler can be activated by WORLD_ALTCOMPILER variable.
It will not be built by default.

5 years agogcc80: Add pregenerated manpages.
zrj [Wed, 2 May 2018 13:40:58 +0000 (16:40 +0300)]
gcc80: Add pregenerated manpages.

5 years agogcc80: Add pregenerated headers.
zrj [Wed, 2 May 2018 13:36:10 +0000 (16:36 +0300)]
gcc80: Add pregenerated headers.

5 years agogcc80: Bring in makefiles but leave them unhooked.
zrj [Wed, 2 May 2018 13:35:59 +0000 (16:35 +0300)]
gcc80: Bring in makefiles but leave them unhooked.

Makefile infrastructure was reused from gcc50 one writen by John Marino.

5 years agogcc80: Handle TZ specific "%+" format in strftime.
zrj [Wed, 2 May 2018 13:34:50 +0000 (16:34 +0300)]
gcc80: Handle TZ specific "%+" format in strftime.

After removal of %b and %r formats from kernel,
only one extra format remains.

Requested-by: swildner
5 years agogcc80: Remove throw() from protos in libstdc++ headers.
zrj [Wed, 2 May 2018 13:32:23 +0000 (16:32 +0300)]
gcc80: Remove throw() from protos in libstdc++ headers.

The throw() as dynamic exception specificators was deprecated in c++11
and removed in c++17 (empty was made as an alias to noexcept(true)).

Our libc headers does not have the __attribute__(__nothrow__) markups.
To make libstdc++ fully usable for clangs on DragonFly it makes sense
to just remove the throw() additions in c++ language binding headers.
Previously in gcc50 we were excluding them just for __clang__ case as in:
838772be3c028f0cfd9fae5da181858e4199863a

5 years agogcc80: Include <stdlib.h> for alloca() prototype.
zrj [Wed, 2 May 2018 13:19:51 +0000 (16:19 +0300)]
gcc80: Include <stdlib.h> for alloca() prototype.

5 years agogcc80: Add alternative variant of pthread presence checking.
zrj [Wed, 2 May 2018 13:18:32 +0000 (16:18 +0300)]
gcc80: Add alternative variant of pthread presence checking.

Port the 5f76495ba37ea12fb60cf57228cc78b83d889fb from gcc50.

5 years agogcc80: Adjust search paths for base compiler layout.
zrj [Wed, 2 May 2018 13:17:46 +0000 (16:17 +0300)]
gcc80: Adjust search paths for base compiler layout.

All tools are located in a common /usr/libexec/gcc80/ directory.

5 years agogcc80: Adjust default dynamic linker search location.
zrj [Wed, 2 May 2018 13:14:32 +0000 (16:14 +0300)]
gcc80: Adjust default dynamic linker search location.

Needed for split root setups.

5 years agogcc80: Document changes in contrib sources.
zrj [Wed, 2 May 2018 13:13:52 +0000 (16:13 +0300)]
gcc80: Document changes in contrib sources.

5 years agoAdd READMEs for new vendor/GCC80 branch.
zrj [Wed, 2 May 2018 13:08:23 +0000 (16:08 +0300)]
Add READMEs for new vendor/GCC80 branch.

Next planned major gcc version update is gcc-11.0 in next three years.
Roadmap: gcc34 -> gcc41 -> gcc44 -> gcc47 -> gcc50 -> gcc80 [-> gcc11]

5 years agox86_64/lapic: Use function pointer for EOI.
Sepherosa Ziehau [Mon, 14 May 2018 14:35:04 +0000 (22:35 +0800)]
x86_64/lapic: Use function pointer for EOI.

This helps upcoming X2APIC support and virtualization EOI optmization,
e.g. Hyper-V can be configured to do auto-EOI.

Discussed-with: Imre Vadasz

5 years agolibc/termios: #undef TTYDEFCHARS after including <termios.h>.
Sascha Wildner [Mon, 14 May 2018 09:36:05 +0000 (11:36 +0200)]
libc/termios: #undef TTYDEFCHARS after including <termios.h>.

5 years agokernel: Include <sys/ttydefaults.h> where appropriate.
Sascha Wildner [Mon, 14 May 2018 09:35:08 +0000 (11:35 +0200)]
kernel: Include <sys/ttydefaults.h> where appropriate.

This is in preparation for moving <sys/termios.h> to <termios.h>.

5 years agohammer2(8)/svc(8): Include <sys/ttycom.h> for ioctls.
Sascha Wildner [Mon, 14 May 2018 07:04:37 +0000 (09:04 +0200)]
hammer2(8)/svc(8): Include <sys/ttycom.h> for ioctls.

5 years agoMerge remote-tracking branch 'origin/vendor/GCC80'
zrj [Mon, 14 May 2018 04:36:02 +0000 (07:36 +0300)]
Merge remote-tracking branch 'origin/vendor/GCC80'

5 years agoipfw3: Fix kernel building without DEBUG in the config as well.
Sascha Wildner [Sun, 13 May 2018 09:25:54 +0000 (11:25 +0200)]
ipfw3: Fix kernel building without DEBUG in the config as well.

5 years agoFix LINT64 for the recent ipfw3 changes.
Sascha Wildner [Sun, 13 May 2018 08:08:02 +0000 (10:08 +0200)]
Fix LINT64 for the recent ipfw3 changes.

Reported-by: ftigeot
5 years agokernel: Remove vm_zeroidle.c
François Tigeot [Sun, 13 May 2018 07:41:31 +0000 (09:41 +0200)]
kernel: Remove vm_zeroidle.c

Background page zeroing doesn't bring any performance benefit
on modern hardware.

5 years agodrm/linux: Add cond_resched()
François Tigeot [Sun, 13 May 2018 07:13:59 +0000 (09:13 +0200)]
drm/linux: Add cond_resched()

5 years agokernel - pack struct fid
Matthew Dillon [Sat, 12 May 2018 03:50:07 +0000 (20:50 -0700)]
kernel - pack struct fid

* Use __packed for struct fid for correctness.  Does not change generated
  code.

5 years agotmpfs - Fix tmpfs_fid, fix NFS exports
Matthew Dillon [Sat, 12 May 2018 03:48:39 +0000 (20:48 -0700)]
tmpfs - Fix tmpfs_fid, fix NFS exports

* Fix the tmpfs_fid structure, the 64-bit elements made it incompatible
  with the system fid mapping.

  This fixes NFS exports of a tmpfs filesystem.

* Fix tmpfs_fhtovp, the inode number can exceed tmp->tm_nodes_max,
  do not error-out in that case.

5 years agoipfw3_nat: highspeed lockless in-kernel NAT
Bill Yuan [Sat, 12 May 2018 15:26:07 +0000 (15:26 +0000)]
ipfw3_nat: highspeed lockless in-kernel NAT

RB-Tree to stored the state for the outgoing packets, and multidimentional
array of pointers to keep the state for the incoming packets.

5 years agomtree(8): Fix crc() prototype.
Sascha Wildner [Fri, 11 May 2018 10:06:50 +0000 (12:06 +0200)]
mtree(8): Fix crc() prototype.

It is taken from usr.bin/cksum/crc.c. This fixes a -Wlto-type-mismatch
warning reported by zrj. Similar to the fix for ckdist(1) as pushed in
e69bb3d9c4c6d6073c9c9c4a54753458fae55c7e.

5 years agorpc.yppasswdd(8): Fix ok_shell() prototype.
Sascha Wildner [Fri, 11 May 2018 09:46:03 +0000 (11:46 +0200)]
rpc.yppasswdd(8): Fix ok_shell() prototype.

It is taken from usr.bin/chpass/util.c. This fixes a -Wlto-type-mismatch
warning reported by zrj.

5 years agotcp_wrappers: Remove mystdarg.h and simplify code.
Sascha Wildner [Thu, 10 May 2018 17:51:34 +0000 (19:51 +0200)]
tcp_wrappers: Remove mystdarg.h and simplify code.

This fixes an -Wlto-type-mismatch warning (reported by zrj) because
syslog()'s prototype was wrongly setup (using VARARGS but it has to
take 2 arguments).

5 years agomount{,_ufs}(8): Remove unnecessary code to prevent warnings.
Sascha Wildner [Thu, 10 May 2018 07:21:13 +0000 (09:21 +0200)]
mount{,_ufs}(8): Remove unnecessary code to prevent warnings.

5 years agovkernel - Adjust to fix buildkernel
Matthew Dillon [Wed, 9 May 2018 23:51:44 +0000 (16:51 -0700)]
vkernel - Adjust to fix buildkernel

* Adjust to fix buildkernel

5 years agockdist(1): Sync with FreeBSD.
Sascha Wildner [Tue, 8 May 2018 19:22:18 +0000 (21:22 +0200)]
ckdist(1): Sync with FreeBSD.

Not much to see, but it allows us to raise WARNS to 6, and the crc()
prototype adjustment part also fixes a -Wlto-type-mismatch warning
that was..

Reported-by: zrj
5 years agoImport GCC-8 to a new vendor branch
zrj [Wed, 2 May 2018 13:07:02 +0000 (16:07 +0300)]
Import GCC-8 to a new vendor branch

5 years agokernel - Refactor copyin, copyout
Matthew Dillon [Tue, 8 May 2018 16:33:19 +0000 (09:33 -0700)]
kernel - Refactor copyin, copyout

* Conditionalize movsq/movsb sequences to improve performance.

5 years agokernel - Rearrange struct vm_zone slightly
Matthew Dillon [Sun, 6 May 2018 05:47:07 +0000 (22:47 -0700)]
kernel - Rearrange struct vm_zone slightly

* Rearrange struct vm_zone to group cache lines together a bit better.

5 years agokernel - Refactor bcmp, bcopy, bzero, memset
Matthew Dillon [Sun, 6 May 2018 04:52:37 +0000 (21:52 -0700)]
kernel - Refactor bcmp, bcopy, bzero, memset

* For now continue to use stosq/stosb, movsq/movsb, cmpsq/cmpsb sequences
  which are well optimized on AMD and Intel.  Do not just use the '*b'
  string op.  While this is optimized on Intel it is not optimized on
  AMD.

* Note that two string ops in a row result in a serious pessimization.
  To fix this, for now, conditionalize the movsb, stosb, or cmpsb op so
  it is only executed when the remaining count is non-zero.  That is,
  assume nominal 8-byte alignment.

* Refactor pagezero() to use a movq/addq/jne sequence.  This is
  significantly faster than movsq on AMD and only just very slightly
  slower than movsq on Intel.

* Also use the above adjusted kernel code in libc for these functions,
  with minor modifications.  Since we are copying the code wholesale,
  replace the copyright for the related files in libc.

* Refactor libc's memset() to replicate the data to all 64 bits code and
  then use code similar to bzero().

Reported-by: mjg_ (info on pessimizations)
5 years agokernel - Optimize syscall path, remove old unused compat code
Matthew Dillon [Fri, 4 May 2018 17:48:29 +0000 (10:48 -0700)]
kernel - Optimize syscall path, remove old unused compat code

* Use the built-in memcpy with a constant length for the register arg
  copy instead of calling bcopy().  This saves us 25ns.

* Remove several system call compatibility support features that are
  no longer used (as we no longer have a linux compat module).  We
  remove sv_mask and sv_prepsyscall.  Saves 1ns (woo woo!).

* Do some minor rearrangement of code to remove additional unnecessary
  conditionals.

5 years agokernel - Adjust pv caching a little
Matthew Dillon [Fri, 4 May 2018 04:58:40 +0000 (21:58 -0700)]
kernel - Adjust pv caching a little

* Rearrange pv_cache() usage to remove a conditional.

* Use atomic_fcmpset_*() to improve performance a little.

5 years agokernel - Flesh out Spectre mitigation support
Matthew Dillon [Tue, 1 May 2018 03:50:13 +0000 (20:50 -0700)]
kernel - Flesh out Spectre mitigation support

* Add handling for all modes for AMD CPUs, including support for
  IBRS_AUTO and STIBP_AUTO (always-on) bits which will be added
  to future cpus.

* Add STIBP handling to Intel CPUs.  I can't find definitions for
  AUTO (always-on) modes for Intel, so those are still not supported
  (no current CPU has AUTO support yet anyway).

* Current DragonFlyBSD defaults: Will enable IBRS_AUTO and STIBP_AUTO
  (always on) support by default if the cpu has it.  Will NOT enable IBRS
  or STIBP (non-auto) toggling by default.  Will not enable IBPB by default.

  IBPB is currently not enabled by default.  The overhead is an enormous
  ~2uS.  We will follow Linux in this regard.

* Change the machdep.spectre_mitigation sysctl to take a string of
  features to enable.  Change machdep.spectre_support to display a
  string of features supported.  Possible features are:

  IBRS          Indirect Branch Restricted Speculation (U->K and K->U)
  STIBP         Single Thread Indirect Branch Prediction (U->K and K->U)
  IBPB          Branch Prediction Barrier (U->K)
  IBRS_AUTO     IBRS always-on (set once and forget)
  STIBP_AUTO    STIBP always-on (set once and forget)

  The machdep.spectre_support sysctl tells you whats available.

* Refactor tr_pcb_gflags into tr_pcb_spec_ctrl[2] to make it easier
  for the assembly code to program the SPEC_CTRL MSR.

* Note that some of the above bits will never be supported by current
  hardware and exist to allow future hardware to support these features
  in a less expensive manner.

* Also note that for Meltdown, AMD is immune and the meltdown mitigation
  will not be enabled.  Intel is vulnerable and the mitigation will be
  enabled by default.  See sysctl machdep.meltdown_mitigation.

5 years agokernel - Fix CVE-2018-8897, debug register issue
Matthew Dillon [Tue, 1 May 2018 03:47:20 +0000 (20:47 -0700)]
kernel - Fix CVE-2018-8897, debug register issue

* #DB can be delayed in a way that causes it to occur on the first
  instruction of the int $3 or syscall handlers.  These handlers must
  be able to detect and handle the condition.  This is a historical
  artifact of cpu operation that has existed for a very long time on
  both AMD and Intel CPUs.

* Fix by giving #DB its own trampoline stack and a way to load a
  deterministic %gs and %cr3 independent of the normal CS check.
  This is CVE-2018-8897.

* Also fix the NMI trampoline while I'm here.

* Also fix an old issue with debug register trace traps which can
  occur when the kernel is accessing the user's address space.
  This fix was lost years ago, now recovered.

Credits: Nick Peterson of Everdox Tech, LLC (original reporter)
Credits: Thanks to Microsoft for coordinating the OS vendor response

5 years agoRaise WARNS to 1 in gnu/usr.bin/cvs.
Sascha Wildner [Tue, 8 May 2018 09:22:50 +0000 (11:22 +0200)]
Raise WARNS to 1 in gnu/usr.bin/cvs.

5 years agoconfig.8: Mention NO_KERNEL_OLD_STRIP.
Sascha Wildner [Tue, 8 May 2018 08:48:38 +0000 (10:48 +0200)]
config.8: Mention NO_KERNEL_OLD_STRIP.

5 years agokernel/nfs: Use the correct prototype for sys_nfssvc().
Sascha Wildner [Mon, 7 May 2018 16:13:41 +0000 (18:13 +0200)]
kernel/nfs: Use the correct prototype for sys_nfssvc().

The code handles loading of nfs.ko (nfssvc() is the only {,un}loadable
syscall). sys_nfssvc()'s prototype is automatically generated, so just
use that.

The sy_narg setting is not strictly needed because it is already
initialized correctly. Just the sy_call pointer is either sys_nosys
or sys_nfssvc, depending on the module load.

Reported-by: zrj
5 years agoigb: Dump registers.
Sepherosa Ziehau [Mon, 7 May 2018 14:55:46 +0000 (22:55 +0800)]
igb: Dump registers.

This helps debugging.

Obtained-from: dillon

5 years agomrsas(4): Remove wrong extra arg from MR_LdBlockSizeGet().
Sascha Wildner [Mon, 7 May 2018 12:43:02 +0000 (14:43 +0200)]
mrsas(4): Remove wrong extra arg from MR_LdBlockSizeGet().

Reported-by: zrj
5 years agodrm/i915: Start building i915_gpu_error.c
François Tigeot [Mon, 7 May 2018 07:42:24 +0000 (09:42 +0200)]
drm/i915: Start building i915_gpu_error.c

5 years agodrm/linux: Add scnprintf()
François Tigeot [Mon, 7 May 2018 07:02:10 +0000 (09:02 +0200)]
drm/linux: Add scnprintf()

Obtained-from: FreeBSD

5 years agodrm/linux: Add or improve various *printf functions
François Tigeot [Mon, 7 May 2018 05:45:28 +0000 (07:45 +0200)]
drm/linux: Add or improve various *printf functions

5 years agodrm/linux: Start using stop_machine.h
François Tigeot [Mon, 7 May 2018 05:28:35 +0000 (07:28 +0200)]
drm/linux: Start using stop_machine.h

5 years agoSync zoneinfo database with tzdata2018e from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Sun, 6 May 2018 20:20:20 +0000 (22:20 +0200)]
Sync zoneinfo database with tzdata2018e from ftp://ftp.iana.org/tz/releases

* North Korea switched back from +0830 to +09 on May, 5.

* Miscellaneous changes, see NEWS.

For a detailed list of changes, see share/zoneinfo/NEWS.

5 years agoppp(8): Don't go via <sys/tty.h> for bringing in <termios.h>.
Sascha Wildner [Sun, 6 May 2018 17:05:15 +0000 (19:05 +0200)]
ppp(8): Don't go via <sys/tty.h> for bringing in <termios.h>.

Include it directly.

5 years ago<unistd.h>: Remove 'restrict' from symlink().
Sascha Wildner [Sun, 6 May 2018 16:25:14 +0000 (18:25 +0200)]
<unistd.h>: Remove 'restrict' from symlink().

Neither NetBSD, OpenBSD, glibc, nor any standard I checked has them.

Discussed-with: zrj

5 years ago<libgen.h>: Add comments about POSIX diffs for {base,dir}name().
Sascha Wildner [Sun, 6 May 2018 15:18:12 +0000 (17:18 +0200)]
<libgen.h>: Add comments about POSIX diffs for {base,dir}name().

5 years agodrm/linux: Add do_gettimeofday()
François Tigeot [Sun, 6 May 2018 14:42:05 +0000 (16:42 +0200)]
drm/linux: Add do_gettimeofday()

5 years agodrm: Sync include directives with Linux
François Tigeot [Sun, 6 May 2018 14:33:01 +0000 (16:33 +0200)]
drm: Sync include directives with Linux

* Add a few key include/asm or include/linux headers

* Move some code from .h to .c files in order to avoid clashes
  between the DragonFly and Linux variants of kmalloc() and kfree()

5 years agoAdd NetBSD's orders(7) manual page.
Sascha Wildner [Sat, 5 May 2018 21:10:01 +0000 (23:10 +0200)]
Add NetBSD's orders(7) manual page.

5 years agolibc/termios: Sync a bit with FreeBSD.
Sascha Wildner [Sat, 5 May 2018 20:12:02 +0000 (22:12 +0200)]
libc/termios: Sync a bit with FreeBSD.

Add tcsetsid() to libc.

Taken-from:     FreeBSD
Dports-testing: zrj

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