dragonfly.git
4 years agoUse NULL instead of 0 for the third argument in fts_open()
Aaron LI [Sat, 15 Jun 2019 10:55:11 +0000 (18:55 +0800)]
Use NULL instead of 0 for the third argument in fts_open()

Bug-report: #3138

4 years agoMakefile: Require explicit target
Aaron LI [Sat, 15 Jun 2019 08:29:40 +0000 (16:29 +0800)]
Makefile: Require explicit target

Explicit target (e.g., buildworld, buildkernel) is required, otherwise
fail with an error.

Obtained-from: FreeBSD
Bug-report: #3158

4 years agolibstand/hammer1: Fix vol_name to be vol_label
Aaron LI [Sat, 15 Jun 2019 05:49:38 +0000 (13:49 +0800)]
libstand/hammer1: Fix vol_name to be vol_label

The 'vol_name' field in 'struct hammer_volume_ondisk' was changed to
'vol_label' in commit 6c39d27aedd299180e0b77179a8690d90d1e6e6d .

This fix enables libstand/hammer1.c to be build with -DTESTING.

Reported-by: daftaupe
Bug-report: #3185

4 years agou4b/audio: Fix panic by kfree(NULL)
Aaron LI [Sat, 15 Jun 2019 05:18:36 +0000 (13:18 +0800)]
u4b/audio: Fix panic by kfree(NULL)

DragonFly's kfree(9) doesn't allow a NULL pointer, while FreeBSD's
free(9) allows.

Reported-by: tse
Bug-report: #3192

4 years agoiostat - Fix column count bug
Matthew Dillon [Fri, 14 Jun 2019 05:24:46 +0000 (22:24 -0700)]
iostat - Fix column count bug

* The maxshowdevs parameter was improperly conditionalized in the
  list iteration, causing the list to be truncated early in some cases.

* Remove md*, pass*, and sg* by default, they are not usually
  interesting.

* Display more columns by default if stdout is a terminal and is wide
  enough.

4 years agolibdevstat - Fix a bug in DS_SELECT_REMOVE
Matthew Dillon [Fri, 14 Jun 2019 02:59:08 +0000 (19:59 -0700)]
libdevstat - Fix a bug in DS_SELECT_REMOVE

* An improper decrement cut the list scan short, causing wildcard
  removals to not select all matching devices.

* This only really effects e.g. systat -vm and similar utilities.

4 years agokernel - Fix gdb / tracing
Matthew Dillon [Thu, 13 Jun 2019 17:38:28 +0000 (10:38 -0700)]
kernel - Fix gdb / tracing

* The tstop fix broke gdb / tracing.  Get gdb / tracing working
  again.

4 years agoUse some standard type names better.
Sascha Wildner [Wed, 12 Jun 2019 21:09:07 +0000 (23:09 +0200)]
Use some standard type names better.

struct sigaltstack -> stack_t
struct __siginfo   -> siginfo_t
struct __sigset    -> sigset_t

No functional change.

4 years ago<sys/signal.h>: Adjust the type of stack_t's ss_sp from char * to void *.
Sascha Wildner [Wed, 12 Jun 2019 20:34:10 +0000 (22:34 +0200)]
<sys/signal.h>: Adjust the type of stack_t's ss_sp from char * to void *.

4 years agodrm/linux: Fix schedule_timeout()
François Tigeot [Wed, 12 Jun 2019 19:48:53 +0000 (21:48 +0200)]
drm/linux: Fix schedule_timeout()

Interruptible sleeps were returning wrong values.

4 years agomtree: Indent with spaces.
Sascha Wildner [Tue, 11 Jun 2019 20:51:46 +0000 (22:51 +0200)]
mtree: Indent with spaces.

4 years agolibc: Add missing #include "un-namespace.h" in a few files.
Sascha Wildner [Wed, 12 Jun 2019 07:47:41 +0000 (09:47 +0200)]
libc: Add missing #include "un-namespace.h" in a few files.

4 years agolibc/pwcache: Remove some old RCS related stuff.
Sascha Wildner [Wed, 12 Jun 2019 07:46:09 +0000 (09:46 +0200)]
libc/pwcache: Remove some old RCS related stuff.

4 years ago<sys/param.h>: Fix _DragonFly_version.
Sascha Wildner [Wed, 12 Jun 2019 06:27:21 +0000 (08:27 +0200)]
<sys/param.h>: Fix _DragonFly_version.

4 years agoChanges for DragonFly 5.7. v5.7.0
Justin C. Sherrill [Wed, 12 Jun 2019 01:26:44 +0000 (21:26 -0400)]
Changes for DragonFly 5.7.

4 years agolibc: Use quotation marks around {un-,}namespace.h (private header).
Sascha Wildner [Tue, 11 Jun 2019 19:12:21 +0000 (21:12 +0200)]
libc: Use quotation marks around {un-,}namespace.h (private header).

4 years agoworld - Makme shm_open() more compatible with expectations
Matthew Dillon [Tue, 11 Jun 2019 19:04:49 +0000 (12:04 -0700)]
world - Makme shm_open() more compatible with expectations

* Create a tmpfs mount in /var/run/shm and also create /var/run/shm/tmp
  under it, both modes 1777, to support shm_open().  No longer base
  shm_open() at the root directory.

* shm_open() and shm_unlink() now access files relative to /var/run/shm.

  This fixes numerous ports and removes the need for numerous
  port patches.

* Rejigger libraries using namespace.h/un-namespace.h to add _unlink() and
  _unlinkat() into the mix.

4 years agoinstaller - Default to HAMMER2 (2)
Matthew Dillon [Tue, 11 Jun 2019 04:20:11 +0000 (21:20 -0700)]
installer - Default to HAMMER2 (2)

* Fix comments.

Reported-by: noob237
4 years agoinstaller - Default to HAMMER2
Matthew Dillon [Tue, 11 Jun 2019 00:53:46 +0000 (17:53 -0700)]
installer - Default to HAMMER2

* Change the installer default from HAMMER1 to HAMMER2.

* Adjust the nrelease build to print the location of the image files
  when it finishes.

4 years agodrm/linux: Add task_struct, rework sleep and wake up functions
François Tigeot [Mon, 10 Jun 2019 19:34:39 +0000 (21:34 +0200)]
drm/linux: Add task_struct, rework sleep and wake up functions

Really implement wake_up_process(), signal_pending(),
signal_pending_state() and schedule_timeout()

Some fixes contributed by Matthew Dillon.

4 years ago/etc/group: Add 'input', so it is available right away on new systems.
Sascha Wildner [Mon, 10 Jun 2019 12:30:26 +0000 (14:30 +0200)]
/etc/group: Add 'input', so it is available right away on new systems.

Pointed-out-by: zrj
4 years agoevdev: Create device entries with the "input" group
Peeter Must [Mon, 3 Jun 2019 07:57:11 +0000 (10:57 +0300)]
evdev: Create device entries with the "input" group

* Add a new group "input" with an id 43.

* Make the devfs subsystem override the /dev/input/event*
  devices with perm 0660 and root:input.

* This approach is standard in many Linux systems.

4 years agoRemove lint checks in system headers.
Sascha Wildner [Sun, 2 Jun 2019 17:23:22 +0000 (19:23 +0200)]
Remove lint checks in system headers.

Modern checkers do not (need to) pass this anymore to the build.

4 years agosys/vfs/hammer: Rename hammer_flush_inode_done() -> hammer_sync_inode_done()
Tomohiro Kusumi [Sun, 2 Jun 2019 05:54:18 +0000 (14:54 +0900)]
sys/vfs/hammer: Rename hammer_flush_inode_done() -> hammer_sync_inode_done()

It's a counterpart for hammer_sync_inode().

4 years agodrm: Sync drm_gem_object_lookup() with Linux 4.7.10
François Tigeot [Sun, 2 Jun 2019 05:16:11 +0000 (07:16 +0200)]
drm: Sync drm_gem_object_lookup() with Linux 4.7.10

4 years agolibm: Fix some -Wredundant-decls. signgam is in <math.h> already.
Sascha Wildner [Sat, 1 Jun 2019 15:03:30 +0000 (17:03 +0200)]
libm: Fix some -Wredundant-decls. signgam is in <math.h> already.

4 years agoCorrect some casts in printf arguments in various utilities.
Sascha Wildner [Sat, 1 Jun 2019 08:23:09 +0000 (10:23 +0200)]
Correct some casts in printf arguments in various utilities.

4 years agokernel/evdev: create input devices with UID_ROOT and GID_WHEEL
Peeter Must [Sat, 1 Jun 2019 06:56:05 +0000 (09:56 +0300)]
kernel/evdev: create input devices with UID_ROOT and GID_WHEEL

* In preparation to follow the same scheme as in drm devices:
  access rights will be set using the devfs system, see commit
  82aec1d31805500239e50c9b6ed8d25802b0a17c.

4 years agoem/emx/igb: Merge Intel em-7.7.4 and igb-2.5.6
Sepherosa Ziehau [Sun, 3 Mar 2019 12:51:53 +0000 (20:51 +0800)]
em/emx/igb: Merge Intel em-7.7.4 and igb-2.5.6

Most noticeably added I219 V6/V7 support for em/emx.

4 years agoresident(8): Remove a.out support.
Sascha Wildner [Fri, 31 May 2019 15:36:37 +0000 (17:36 +0200)]
resident(8): Remove a.out support.

4 years agoldd(1): Remove unneeded inclusion of <a.out.h>.
Sascha Wildner [Fri, 31 May 2019 15:36:08 +0000 (17:36 +0200)]
ldd(1): Remove unneeded inclusion of <a.out.h>.

4 years agogcore(1): Stop depending on <a.out.h>.
Sascha Wildner [Fri, 31 May 2019 15:36:03 +0000 (17:36 +0200)]
gcore(1): Stop depending on <a.out.h>.

4 years agoRemove symorder(1). It's no longer useful.
Sascha Wildner [Fri, 31 May 2019 15:32:08 +0000 (17:32 +0200)]
Remove symorder(1). It's no longer useful.

4 years agocrunchide(1): Remove a.out, elf32 and ECOFF traces.
Sascha Wildner [Fri, 31 May 2019 13:58:40 +0000 (15:58 +0200)]
crunchide(1): Remove a.out, elf32 and ECOFF traces.

4 years agodrm/radeon: Stop naming the kernel module "radeonkms"
François Tigeot [Fri, 31 May 2019 05:23:05 +0000 (07:23 +0200)]
drm/radeon: Stop naming the kernel module "radeonkms"

It is named "radeon" in Linux.

4 years agovkernel - Adjust use of GDF_VIRTUSER
Matthew Dillon [Fri, 31 May 2019 04:38:29 +0000 (23:38 -0500)]
vkernel - Adjust use of GDF_VIRTUSER

* Don't clear GDF_VIRTUSER until after exiting the critical section,
  otherwise hardclock() will tick sys instead of user.

  A user bound program should now show more reasonable values for
  user%.

* Scrap some debug counters that are no longer applicable, cleaning
  up a few cache line bounces.

4 years agodummynet - Poll only if operational, change default freq for vkernel
Matthew Dillon [Fri, 31 May 2019 03:41:32 +0000 (22:41 -0500)]
dummynet - Poll only if operational, change default freq for vkernel

* Default frequency for vkernel is now 100 hz instead of 1000 hz.
  The frequency can be changed at any time with a sysctl.

* The systimer is only configured when there are pipes or flows
  present, and will be deconfigured when there aren't.  This
  saves us from doing any unnecessary polling.

* dummynet still has some considerable holes related to SMP
  operation.  It really needs a rewrite to some degree.

4 years agodrm/linux: Implement i2c_bit_add_bus()
François Tigeot [Thu, 30 May 2019 15:42:44 +0000 (17:42 +0200)]
drm/linux: Implement i2c_bit_add_bus()

4 years agosysctl.8: Revert 39d69daecef529eb49d36fefa429c8ac08e7cbc1.
Sascha Wildner [Thu, 30 May 2019 13:03:40 +0000 (15:03 +0200)]
sysctl.8: Revert 39d69daecef529eb49d36fefa429c8ac08e7cbc1.

The manpage just says whether it's a number, a string or something
else, not the exact type.

4 years ago<sys/sysctl.h>: Remove the unused CTL_HW_NAMES define.
Sascha Wildner [Thu, 30 May 2019 11:25:44 +0000 (13:25 +0200)]
<sys/sysctl.h>: Remove the unused CTL_HW_NAMES define.

Reported-by: zrj
4 years agokernel/sysctl: Switch kern.osrevision to showing __DragonFly_version.
Sascha Wildner [Thu, 30 May 2019 10:56:52 +0000 (12:56 +0200)]
kernel/sysctl: Switch kern.osrevision to showing __DragonFly_version.

It was tied to a historic define (BSD) that started as 199506 and was
sporadically bumped in the past until 200708. Revert the define back
to 199506, as it is not supposed to be bumped, and add a comment about
this (taken from NetBSD). We cannot remove these defines completely
because at least some are used by ports.

4 years agodrm/linux: Add wait_event_interruptible_locked()
François Tigeot [Thu, 30 May 2019 08:06:06 +0000 (10:06 +0200)]
drm/linux: Add wait_event_interruptible_locked()

4 years agodrm/linux: Add vmalloc() and vzalloc()
François Tigeot [Thu, 30 May 2019 07:51:56 +0000 (09:51 +0200)]
drm/linux: Add vmalloc() and vzalloc()

4 years agodrm/linux: Add set_memory_uc()
François Tigeot [Thu, 30 May 2019 07:49:40 +0000 (09:49 +0200)]
drm/linux: Add set_memory_uc()

4 years agodrm/linux: Add gcd()
François Tigeot [Thu, 30 May 2019 07:48:47 +0000 (09:48 +0200)]
drm/linux: Add gcd()

4 years agodrm/linux: Add list_prev_entry()
François Tigeot [Thu, 30 May 2019 07:47:17 +0000 (09:47 +0200)]
drm/linux: Add list_prev_entry()

Obtained-from: FreeBSD

4 years agodrm/linux: Fix pci_map_page() arguments
François Tigeot [Thu, 30 May 2019 07:40:22 +0000 (09:40 +0200)]
drm/linux: Fix pci_map_page() arguments

4 years agovkernel - Restore vkernel build
Matthew Dillon [Wed, 29 May 2019 21:38:21 +0000 (14:38 -0700)]
vkernel - Restore vkernel build

* Finish cleaning up the vkernel pmap code so the build works again.

Tested-by: dillon, tested with a NFS boot.
4 years agokernel - Don't block in tstop() with locks held
Matthew Dillon [Wed, 29 May 2019 21:33:07 +0000 (14:33 -0700)]
kernel - Don't block in tstop() with locks held

* There are several places where the kernel improperly blocks on a
  STOP signal while locks might be held.  This is a particular problem
  when PCATCH is specified e.g. in the middle of the NFS code.  It is
  meant to catch INTR but it also improperly allowed STOP to function
  and left the vnode lock held.

  Several other places in the kernel also use PCATCH and don't expect
  the kernel to actually block indefinitely on a STOP.

* Don't block in STOP in these situations.  Simply mark the thread as
  stopped and wait until it tries to return to userland before actually
  stopping.

  Any kernel subsystems which desire to act on the STOP in-line instead
  of upon return to userland can do so manually, as long as they release
  all locks for the duration.

4 years ago<sys/syslimits.h>: Clean up inclusion check and warning.
Sascha Wildner [Wed, 29 May 2019 12:41:04 +0000 (14:41 +0200)]
<sys/syslimits.h>: Clean up inclusion check and warning.

4 years agoClean up a few math related manualpages.
Sascha Wildner [Tue, 28 May 2019 19:17:34 +0000 (21:17 +0200)]
Clean up a few math related manualpages.

* In frexp.3, change the library to libc, because it is part of libc,
  not libm (anymore).

* In fpclassify.3 and signbit.3, remove the LIBRARY section, because
  all these are macros from <math.h>.

4 years agokernel - Build 'evdev' into the kernel
Matthew Dillon [Tue, 28 May 2019 18:57:59 +0000 (11:57 -0700)]
kernel - Build 'evdev' into the kernel

* Build evdev into the kernel along with its EVDEV_SUPPORT option.

Requested-by: peeter
4 years agokernel - Refactor scheduler weightings part 2/2.
Matthew Dillon [Mon, 27 May 2019 00:20:48 +0000 (17:20 -0700)]
kernel - Refactor scheduler weightings part 2/2.

* Change the default fork()ing mechanic from 0x80 (random cpu) to
  0x20 (best cpu).  We no longer need to mix it up on fork because
  weight4 now works.

* The best cpu algorithm has a number of desirable characteristics
  for fork() and fork()/exec().

  - Will generally start the child topologically 'close' to the parent,
    reducing fork/exec/exit/wait overheads, but still spread the children
    out while machine load is light.  If the child sticks around for
    long enough, it will get spread out even more optimally.  If not,
    closer is better.

  - Will not stack children up on the same cpu unnecessarily (e.g. parent
    fork()s a bunch of times at once).

  - Will optimize heavy and very-heavy load situations.  If the child
    have nowhere else reasonable to go, this will schedule it on a
    hyper-thread sibling or even on the same cpu as the parent.  Depending
    on the load.

* Gives us around a 15% improvement in fork/exec/exit/wait performance.

* Once a second we clear the td_wakefromcpu hint on the currently
  running thread.  This allows a thread which has become cpu-bound
  to start to 'wander' afield (though the scheduler will still try to
  avoid moving it too far away, topologically).

4 years agokernel/pmap: Clean up no longer used MALLOC_DEFINE.
Sascha Wildner [Mon, 27 May 2019 16:09:05 +0000 (18:09 +0200)]
kernel/pmap: Clean up no longer used MALLOC_DEFINE.

4 years ago<sys/cdefs.h>: Remove the old unused __DF_VISIBLE.
Sascha Wildner [Sun, 26 May 2019 17:43:17 +0000 (19:43 +0200)]
<sys/cdefs.h>: Remove the old unused __DF_VISIBLE.

Nothing depends on it anymore and nothing sets _DRAGONFLY_SOURCE or
_NETBSD_SOURCE. We handle all non-POSIX visibility with __BSD_VISIBLE
quite well.

Pointed-out-by: zrj
4 years agoRemove expand(1) from the bootstrap tools.
Sascha Wildner [Sun, 26 May 2019 13:30:40 +0000 (15:30 +0200)]
Remove expand(1) from the bootstrap tools.

4 years agoroute(8): Simplify the keywords handling.
Sascha Wildner [Sun, 26 May 2019 12:54:53 +0000 (14:54 +0200)]
route(8): Simplify the keywords handling.

Adapted from FreeBSD. This eliminates paste(1) as a bootstrap tool.

4 years agodump(8): Remove some unneeded defines.
Sascha Wildner [Sun, 26 May 2019 12:02:07 +0000 (14:02 +0200)]
dump(8): Remove some unneeded defines.

4 years agokernel - VM rework part 21 - Start resynchronizing the vkernel
Matthew Dillon [Sun, 26 May 2019 16:49:02 +0000 (09:49 -0700)]
kernel - VM rework part 21 - Start resynchronizing the vkernel

* Fix some minor syntax errors.

* The vkernel is still not operational in master.  It will be a little
  while.  Even though the vkernel retains the old pmap mechanism, there
  are some i's to dot and t's to cross in the expectations the mainline
  kernel has of the APIs.

Reported-by: swildner
4 years agokernel - Backout 'Reduce token backoff'
Matthew Dillon [Sun, 26 May 2019 16:47:29 +0000 (09:47 -0700)]
kernel - Backout 'Reduce token backoff'

* Return the backoff to 4096.  Basically there are multiple situations
  here where a smaller backoff works better, and multiple situations
  where a larger backoff works better.  For now, return the setting to
  its former glory and don't mess with it.

4 years agokernel - Refactor scheduler weightings part 1/2.
Matthew Dillon [Sun, 26 May 2019 16:37:51 +0000 (09:37 -0700)]
kernel - Refactor scheduler weightings part 1/2.

* Refactor the scheduler's weightings and fix a few issues that
  have cropped up due to breaking previous tunings.  This gets
  our pgbench results back to normal.

* There will probably be a follow-up commit with a bit more
  tuning work, particular with regards to resetting the
  td_wakefromcpu field which we currently do not do at all.

* Increase weight1 (keep thread on current CPU) slightly,
  implement weight4, and re-tune the algorithm.

* Break-out the IPC pairing control fields into two new
  sysctls, kern.usched_dfly.ipc_smt and kern.usched_dfly.ipc_same,
  with the default set to -1 (auto).

  ipc_smt Tries to schedule IPC pairings onto sibling
hyperthreads to avoid cache mastership changes
when the load is greater than (ncpus / 2).

  ipc_same Tries to schedule IPC pairings onto the same
logical cpu to avoid both cache mastership changes
AND IPIs when the load is greater than (ncpus).

* Keep in mind that the scheduler cannot perfectly predict program
  behavior.  In particular, these IPC pairings can work better or worse
  depending on the mix between local cpu use within each process,
  verses the amount of data being transfered between them.  By default
  we try to localize IPC pairings to nearby cores but we do not try
  to schedule them to sibling hyperthreads unless the load is high
  enough for it to make sense.

* The main IPC weighting is weight2, whereas the fairness metric is
  weight4.  Generally speaking, weight4 should be somewhat smaller
  than weight2 but still high enough to ensure that available CPUs
  in the system are reasonably well utilized.  Also note that the
  fairness metric (weight4) is based on priority-weighted load.

4 years agokernel - pipe locks are not needed in the kqueue event code
Matthew Dillon [Sat, 25 May 2019 18:49:46 +0000 (11:49 -0700)]
kernel - pipe locks are not needed in the kqueue event code

* The kqueue event code locks the knote itself, and this should be
  sufficient to interlock any race between the filter and the
  other side.

  Remove the token locks from the event filters and add a little code
  to handle any invalid kn_data values (due to not being locked).

Testing-with: sysutils/pv (via zrj)

4 years agokernel - Reduce token backoff
Matthew Dillon [Sat, 25 May 2019 18:45:35 +0000 (11:45 -0700)]
kernel - Reduce token backoff

* Reduce lwkt.token_backoff_max from 4096 to 128.  4096 was just too
  long and results in poor performance when heavy token contention is
  present.

Testing-with: sysutils/pv (via zrj)

4 years agokernel/netmap: Move headers into <net/netmap/...>.
Sascha Wildner [Sat, 25 May 2019 07:31:30 +0000 (09:31 +0200)]
kernel/netmap: Move headers into <net/netmap/...>.

Note that netmap isn't hooked into the build right now, and because of
that, this commit results in removing them from their current location.

Some dports like net/libpcap started breaking after 2c68437386f4be2ed45a4
because configure found a building netmap_user.h and decided that we have
a current and usable netmap.

Reported-by: zrj
4 years agokernel - Enhance indefinite wait buffer console message
Matthew Dillon [Thu, 23 May 2019 16:24:41 +0000 (09:24 -0700)]
kernel - Enhance indefinite wait buffer console message

* Enhance debug info for indefinite wait buffers.

4 years agokernel: Remove two more unneeded .PATHs.
Sascha Wildner [Thu, 23 May 2019 07:43:14 +0000 (09:43 +0200)]
kernel: Remove two more unneeded .PATHs.

4 years agokernel/smbus: Remove an unneeded .PATH in a Makefile.
Sascha Wildner [Thu, 23 May 2019 07:17:09 +0000 (09:17 +0200)]
kernel/smbus: Remove an unneeded .PATH in a Makefile.

4 years agoMove <sys/fd_set.h> to <sys/_fd_set.h>.
Sascha Wildner [Thu, 23 May 2019 06:49:31 +0000 (08:49 +0200)]
Move <sys/fd_set.h> to <sys/_fd_set.h>.

It is only supposed to be included by other headers. Normal code
should use <sys/select.h>.

4 years agoDon't include the full <sys/signal.h> in headers that just need sigset_t.
Sascha Wildner [Thu, 23 May 2019 06:41:49 +0000 (08:41 +0200)]
Don't include the full <sys/signal.h> in headers that just need sigset_t.

Namely, <select.h> and <spawn.h>.

Split it out into a separate header, <sys/_sigset_t.h> and include that
in <spawn.h> and <sys/select.h>.

This cleans up these two headers' name space considerably.

Thanks to zrj for testing with a dports bulk build.

4 years agokernel - Reduce acpi_ec timeout after failure, silence errors
Matthew Dillon [Thu, 23 May 2019 06:27:57 +0000 (23:27 -0700)]
kernel - Reduce acpi_ec timeout after failure, silence errors

* Reduce the acpi_ec timeout from 750ms to 100ms after a
  failure.

* Automatically silence... well, all acpi error messages,
  after 10 acpi_ec errors.

* This allows the dell xps-13 to boot in a more reasonable
  period of time and not spew EC errors to the console all
  the time, as a default, without us having to disable EC manually..

4 years agodhclient - Allow 'start' keyword
Matthew Dillon [Thu, 23 May 2019 00:43:47 +0000 (17:43 -0700)]
dhclient - Allow 'start' keyword

* There's something weird in our rc scripts that is causing dhclient
  to be called with 'start <interface>' on the wlan, so temporarily
  hack allowing the 'start' keyword.

4 years agodrm: Reduce differences with Linux in ioctl code
François Tigeot [Wed, 22 May 2019 21:40:59 +0000 (23:40 +0200)]
drm: Reduce differences with Linux in ioctl code

4 years agokernel - VM rework part 20 - Fix vmmeter_neg_slop_cnt
Matthew Dillon [Wed, 22 May 2019 07:16:17 +0000 (00:16 -0700)]
kernel - VM rework part 20 - Fix vmmeter_neg_slop_cnt

* Fix some serious issues with the vmmeter_neg_slop_cnt calculation.
  The main problem is that this calculation was then causing
  vmstats.v_free_min to be recalculated to a much higher value
  than it should beeen calculated to, resulting in systems starting
  to page far earlier than they should.

  For example, the 128G TR started paging tmpfs data with 25GB of
  free memory, which was not intended.  The correct target for that
  amount of memory is more around 3GB.

* Remove vmmeter_neg_slop_cnt entirely and refactor the synchronization
  code to be smarter.  It will now synchronize vmstats fields whos
  adjustments exceed -1024, but only if paging would actually be
  needed in the worst-case scenario.

* This algorithm needs low-memory testing and might require more
  tuning.

4 years agokernel - Reduce/refactor nbuf and maxvnodes calculations.
Matthew Dillon [Wed, 22 May 2019 03:12:34 +0000 (20:12 -0700)]
kernel - Reduce/refactor nbuf and maxvnodes calculations.

* The prime motivation for this commit is to target about 1/20
  (5%) of physical memory for use by the kernel.  These changes
  significantly reduce kernel memory usage on systems with less
  than 4GB of ram (and more specific for systems with less
  than 1TB of ram), and also emplace more reasonable caps on
  systems with 128GB+ of ram.

  These changes return 100-200MB of ram to userland on systems
  with 1GB of ram, and return around 6.5GB of ram on systems
  with 128G of ram.

* The nbuf calculation and related code documentation was a bit
  crufty, still somewhat designed for an earlier era and was
  calculating about twice the stated 5% target.  For systems with
  128GB of ram or less the calculation was simply creating too many
  filesystem buffers, allowing as much as 10% of physical memory to
  be locked up by the buffer cache.

  Particularly on small systems, this 10% plus other kernel overheads
  left a lot less memory available for user programs than we would
  have liked.  This work gets us closer to the 5% target.

* Change the base calculation from 1/10 of physical memory to 1/20
  of physical memory, cutting the number of buffers in half on
  most systems.  The code documentation stated 1/20 but was actually
  calculating 1/10.

* On large memory systems > 100GB the number of buffers is now capped
  at around 400000 or so (allowing the buffer cache to use around
  6.5 GBytes).  This cap was previously based on a relatively
  disconnected parameter relating to available memory in early boot,
  and when triggered it actually miscalculating nbufs to be double
  the intended number.

  The new cap is based on a fixed maximum of 500MB worth of
  struct bufs, roughly similar to the original intention.  This
  change reduces the number of buffers reserved on system with
  more than around 100GB of ram from around 12GB worth of data
  down to 6.5GB.

* With the BKVABIO work eliminating most SMP invltlbs on buffer
  recyclement, there is no real reason to need a huge buffer
  cache.  Just make sure its big enough on large-memory machines
  to fully cache the likely live datasets for things like bulk
  compiles and such.

* For kern.maxvnodes (which can be changed at run-time if you
  desire), the base calcualtion on systems with less than 1GB
  of ram has been cut in half (~60K vnodes to ~30K vnodes).  It
  will ramp up more slowly until it roughly matches the prior
  calculation at 4GB of system memory.  On systems with enough
  memory, maxvnodes is now explicitly capped at 4M.

  There generally is no need to allow an excessive number of vnodes
  to be cached.

  For HAMMER1 you can set vfs.hammer.double_buffer=1 to cause it
  to cache data from the underlying device, allowing it to utilize
  all available free(ish) memory regardless of the maxvnodes setting.

  HAMMER2 caches disk blocks in the underlying device by default.
  The vnode-based vm_object caches decompressed data, so we want
  to have enough vnodes for nominal heavily parallel bulk operations
  to avoid unnecessary re-lookups of the vnode as well as avoid having
  to decompress the same thing over and over again.

  In both cases an excessively high kern.maxvnodes actually wastes
  memory on both HAMMER1 and HAMMER2... or at least makes the pageout
  daemon's job more difficult.

* Remove vfs.maxmallocbufspace.  It is no longer connected to
  anything.

4 years agokernel - VM rework part 19 - Cleanup
Matthew Dillon [Wed, 22 May 2019 02:24:20 +0000 (19:24 -0700)]
kernel - VM rework part 19 - Cleanup

* vmpageinfo breaks down the kernel load size, vm_page_array
  size, and buffer headers for the buffer cache, all of which
  are major boot-time wired kernel memory.

  Note that the vm_page_array[] uses 3.1% of physical memory.
  Its a lot, but there is no convenient way to make it less.

4 years agokernel - VM rework part 18 - Cleanup
Matthew Dillon [Tue, 21 May 2019 20:55:43 +0000 (13:55 -0700)]
kernel - VM rework part 18 - Cleanup

* Significantly reduce the zone limit for pvzone (for pmap
  pv_entry structures).  pv_entry's are no longer allocated
  on a per-page basis so the limit can be made much smaller.

  This also has the effect of reducing the per-cpu cache limit
  which ultimately stabilizes wired memory use for the zone.

* Also reduce the generic pre-cpu cache limit for zones.
  This only really effects the pvzone.

* Make pvzone, mapentzone, and swap_zone __read_mostly.

* Enhance vmstat -z, report current structural use and actual
  total memory use.

* Also cleanup the copyright statement for vm/vm_zone.c.  John Dyson's
  original copyright was slightly different than the BSD copyright and
  stipulated no changes, so separate out the DragonFly addendum.

4 years ago<net/netmap_user.h>: s/<malloc.h>/<stdlib.h>/.
Sascha Wildner [Tue, 21 May 2019 18:43:42 +0000 (20:43 +0200)]
<net/netmap_user.h>: s/<malloc.h>/<stdlib.h>/.

It is not used in base and in fact the netmap we have in the tree is
not hooked in, but it seems at least one port stumbles over this.

Reported-by: zrj
4 years agokernel - VM rework part 17 - Cleanup
Matthew Dillon [Tue, 21 May 2019 00:35:57 +0000 (17:35 -0700)]
kernel - VM rework part 17 - Cleanup

* Adjust kmapinfo and vmpageinfo in /usr/src/test/debug.
  Enhance the code to display more useful information.

* Get pmap_page_stats_*() working again.

* Change systat -vm's 'VM' reporting.  Replace VM-rss with PMAP and
  VMRSS.  Relabel VM-swp to SWAP and SWTOT.

  PMAP - Amount of real memory faulted into user pmaps.

  VMRSS - Sum of all process RSS's in thet system.  This is
  the 'virtual' memory faulted into user pmaps and
  includes shared pages.

  SWAP - Amount of swap space currently in use.

  SWTOT - Total amount of swap installed.

* Redocument vm_page.h.

* Remove dead code from pmap.c (some left over cruft from the
  days when pv_entry's were used for PTEs).

4 years agokernel - VM rework part 16 - Optimization & cleanup pass
Matthew Dillon [Mon, 20 May 2019 16:37:12 +0000 (09:37 -0700)]
kernel - VM rework part 16 - Optimization & cleanup pass

* Adjust __exclusive_cache_line to use 128-byte alignment as
  per suggestion by mjg.  Use this for the global vmstats.

* Add the vmmeter_neg_slop_cnt global, which is a more generous
  dynamic calculation verses -VMMETER_SLOP_COUNT.  The idea is to
  return how often vm_page_alloc() synchronizes its per-cpu statistics
  with the global vmstats.

4 years agokernel - VM rework part 15 - Core pmap work, refactor PG_*
Matthew Dillon [Mon, 20 May 2019 16:29:43 +0000 (09:29 -0700)]
kernel - VM rework part 15 - Core pmap work, refactor PG_*

* Augment PG_FICTITIOUS.  This takes over some of PG_UNMANAGED's previous
  capabilities.  In addition, the pmap_*() API will work with fictitious
  pages, making mmap() operation (aka of the GPU) more consistent.

* Add PG_UNQUEUED.  This prevents a vm_page from being manipulated in
  the vm_page_queues[] in any way.  This takes over another feature
  of the old PG_UNMANAGED flag.

* Remove PG_UNMANAGED

* Remove PG_DEVICE_IDX.  This is no longer relevant.  We use PG_FICTITIOUS
  for all device pages.

* Refactor vm_contig_pg_alloc(), vm_contig_pg_free(),
  vm_page_alloc_contig(), and vm_page_free_contig().

  These functions now set PG_FICTITIOUS | PG_UNQUEUED on the returned
  pages, and properly clear the bits upon free or if/when a regular
  (but special contig-managed) page is handed over to the normal paging
  system.

  This is combined with making the pmap*() functions work better with
  PG_FICTITIOUS is the primary 'fix' for some of DRMs hacks.

4 years agokernel - VM rework part 14 - Core pmap work, stabilize for X/drm
Matthew Dillon [Mon, 20 May 2019 01:48:30 +0000 (18:48 -0700)]
kernel - VM rework part 14 - Core pmap work, stabilize for X/drm

* Don't gratuitously change the vm_page flags in the drm code.

  The vm_phys_fictitious_reg_range() code in drm_vm.c was clearing
  PG_UNMANAGED.  It was only luck that this worked before, but
  because these are faked pages, PG_UNMANAGED must be set or the
  system will implode trying to convert the physical address back
  to a vm_page in certain routines.

  The ttm code was setting PG_FICTITIOUS in order to prevent the
  page from getting into the active or inactive queues (they had
  a conditional test for PG_FICTITIOUS).  But ttm never cleared
  the bit before freeing the page.  Remove the hack and instead
  fix it in vm_page.c

* in vm_object_terminate(), allow the case where there are still
  wired pages in a OBJT_MGTDEVICE object that has wound up on a
  queue (don't complain about it).  This situation arises because the
  ttm code uses the contig malloc API which returns wired pages.

  NOTE: vm_page_activate()/vm_page_deactivate() are allowed to mess
with wired pages.  Wired pages are not anything 'special' to
the queues, which allows us to avoid messing with the queues
when pages are assigned to the buffer cache.

4 years agokernel - VM rework part 13 - Core pmap work, stabilize & optimize
Matthew Dillon [Sun, 19 May 2019 19:59:49 +0000 (12:59 -0700)]
kernel - VM rework part 13 - Core pmap work, stabilize & optimize

* Refactor the vm_page_hash hash again to get a better distribution.

* I tried to only hash shared objects but this resulted in a number of
  edge cases where program re-use could miss the optimization.

* Add a sysctl vm.page_hash_vnode_only (default off).  If turned on,
  only vm_page's associated with vnodes will be hashed.  This should
  generally not be necessary.

* Refactor vm_page_list_find2() again to avoid all duplicate queue
  checks.  This time I mocked the algorithm up in userland and twisted
  it until it did what I wanted.

* VM_FAULT_QUICK_DEBUG was accidently left on, turn it off.

* Do not remove the original page from the pmap when vm_fault_object()
  must do a COW.  And just in case this is ever added back in later,
  don't do it using pmap_remove_specific() !!!  Use pmap_remove_pages()
  to avoid the backing scan lock.

  vm_fault_page() will now do this removal (for procfs rwmem), the normal
  vm_fault will of course replace the page anyway, and the umtx code
  uses different recovery mechanisms now and should be ok.

* Optimize vm_map_entry_shadow() for the situation where the old
  object is no longer shared.  Get rid of an unnecessary transient
  kmalloc() and vm_object_hold_shared().

4 years agokernel - VM rework part 12 - Core pmap work, stabilize & optimize
Matthew Dillon [Sun, 19 May 2019 16:53:12 +0000 (09:53 -0700)]
kernel - VM rework part 12 - Core pmap work, stabilize & optimize

* Add tracking for the number of PTEs mapped writeable in md_page.
  Change how PG_WRITEABLE and PG_MAPPED is cleared in the vm_page
  to avoid clear/set races.  This problem occurs because we would
  have otherwise tried to clear the bits without hard-busying the
  page. This allows the bits to be set with only an atomic op.

  Procedures which test these bits universally do so while holding
  the page hard-busied, and now call pmap_mapped_sfync() prior to
  properly synchronize the bits.

* Fix bugs related to various counterse.  pm_stats.resident_count,
  wiring counts, vm_page->md.writeable_count, and
  vm_page->md.pmap_count.

* Fix bugs related to synchronizing removed pte's with the vm_page.
  Fix one case where we were improperly updating (m)'s state based
  on a lost race against a pte swap-to-0 (pulling the pte).

* Fix a bug related to the page soft-busying code when the
  m->object/m->pindex race is lost.

* Implement a heuristical version of vm_page_active() which just
  updates act_count unlocked if the page is already in the
  PQ_ACTIVE queue, or if it is fictitious.

* Allow races against the backing scan for pmap_remove_all() and
  pmap_page_protect(VM_PROT_READ).  Callers of these routines for
  these cases expect full synchronization of the page dirty state.
  We can identify when a page has not been fully cleaned out by
  checking vm_page->md.pmap_count and vm_page->md.writeable_count.
  In the rare situation where this happens, simply retry.

* Assert that the PTE pindex is properly interlocked in pmap_enter().
  We still allows PTEs to be pulled by other routines without the
  interlock, but multiple pmap_enter()s of the same page will be
  interlocked.

* Assert additional wiring count failure cases.

* (UNTESTED) Flag DEVICE pages (dev_pager_getfake()) as being
  PG_UNMANAGED.  This essentially prevents all the various
  reference counters (e.g. vm_page->md.pmap_count and
  vm_page->md.writeable_count), PG_M, PG_A, etc from being
  updated.

  The vm_page's aren't tracked in the pmap at all because there
  is no way to find them.. they are 'fake', so without a pv_entry,
  we can't track them.  Instead we simply rely on the vm_map_backing
  scan to manipulate the PTEs.

* Optimize the new vm_map_entry_shadow() to use a shared object
  token instead of an exclusive one.  OBJ_ONEMAPPING will be cleared
  with the shared token.

* Optimize single-threaded access to pmaps to avoid pmap_inval_*()
  complexities.

* Optimize __read_mostly for more globals.

* Optimize pmap_testbit(), pmap_clearbit(), pmap_page_protect().
  Pre-check vm_page->md.writeable_count and vm_page->md.pmap_count
  for an easy degenerate return; before real work.

* Optimize pmap_inval_smp() and pmap_inval_smp_cmpset() for the
  single-threaded pmap case, when called on the same CPU the pmap
  is associated with.  This allows us to use simple atomics and
  cpu_*() instructions and avoid the complexities of the
  pmap_inval_*() infrastructure.

* Randomize the page queue used in bio_page_alloc().  This does not
  appear to hurt performance (e.g. heavy tmpfs use) on large many-core
  NUMA machines and it makes the vm_page_alloc()'s job easier.

  This change might have a downside for temporary files, but for more
  long-lasting files there's no point allocating pages localized to a
  particular cpu.

* Optimize vm_page_alloc().

  (1) Refactor the _vm_page_list_find*() routines to avoid re-scanning
      the same array indices over and over again when trying to find
      a page.

  (2) Add a heuristic, vpq.lastq, for each queue, which we set if a
      _vm_page_list_find*() operation had to go far-afield to find its
      page.  Subsequent finds will skip to the far-afield position until
      the current CPUs queues have pages again.

  (3) Reduce PQ_L2_SIZE From an extravagant 2048 entries per queue down
      to 1024.  The original 2048 was meant to provide 8-way
      set-associativity for 256 cores but wound up reducing performance
      due to longer index iterations.

* Refactor the vm_page_hash[] array.  This array is used to shortcut
  vm_object locks and locate VM pages more quickly, without locks.
  The new code limits the size of the array to something more reasonable,
  implements a 4-way set-associative replacement policy using 'ticks',
  and rewrites the hashing math.

* Effectively remove pmap_object_init_pt() for now.  In current tests
  it does not actually improve performance, probably because it may
  map pages that are not actually used by the program.

* Remove vm_map_backing->refs.  This field is no longer used.

* Remove more of the old now-stale code related to use of pv_entry's
  for terminal PTEs.

* Remove more of the old shared page-table-page code.  This worked but
  could never be fully validated and was prone to bugs.  So remove it.
  In the future we will likely use larger 2MB and 1GB pages anyway.

* Remove pmap_softwait()/pmap_softhold()/pmap_softdone().

* Remove more #if 0'd code.

4 years agokernel - VM rework part 11 - Core pmap work to remove terminal PVs
Matthew Dillon [Sat, 18 May 2019 06:18:11 +0000 (23:18 -0700)]
kernel - VM rework part 11 - Core pmap work to remove terminal PVs

* Remove pv_entry_t belonging to terminal PTEs.  The pv_entry's for
  PT, PD, PDP, and PML4 remain.  This reduces kernel memory use for
  pv_entry's by 99%.

  The pmap code now iterates vm_object->backing_list (of vm_map_backing
  structures) to run-down pages for various operations.

* Remove vm_page->pv_list.  This was one of the biggest sources of
  contention for shared faults.  However, in this first attempt I
  am leaving all sorts of ref-counting intact so the contention has
  not been entirely removed yet.

* Current hacks:

  - Dynamic page table page removal currently disabled because the
    vm_map_backing scan needs to be able to deterministically
    run-down PTE pointers.  Removal only occurs at program exit.

  - PG_DEVICE_IDX probably isn't being handled properly yet.

  - Shared page faults not yet optimized.

* So far minor improvements in performance across the board.
  This is realtively unoptimized.  The buildkernel test improves
  by 2% and the zero-fill fault test improves by around 10%.

  Kernel memory use is improved (reduced) enormously.

4 years agokernel - VM rework part 10 - Precursor work for terminal pv_entry removal
Matthew Dillon [Fri, 17 May 2019 18:55:14 +0000 (11:55 -0700)]
kernel - VM rework part 10 - Precursor work for terminal pv_entry removal

* Effectively remove pmap_track_modified().  Turn it into an assertion.
  The normal pmap code should NEVER EVER be called with any range inside
  the clean map.

  This assertion, and the routine in its entirety, will be removed in a
  later commit.

* The purpose of the original code was to prevent buffer cache kvm mappings
  from being misinterpreted as contributing to the underlying vm_page's
  modified state.  Normal paging operation synchronizes the modified bit and
  then transfers responsibility to the buffer cache.  We didn't want
  manipulation of the buffer cache to further affect the modified bit for
  the page.

  In modern times, the buffer cache does NOT use a kernel_object based
  mapping for anything and there should be no chance of any kernel related
  pmap_enter() (entering a managed page into the kernel_pmap) from messing
  with the space.

4 years agokernel - VM rework part 9 - Precursor work for terminal pv_entry removal
Matthew Dillon [Fri, 17 May 2019 17:03:35 +0000 (10:03 -0700)]
kernel - VM rework part 9 - Precursor work for terminal pv_entry removal

* Cleanup the API a bit

* Get rid of pmap_enter_quick()

* Remove unused procedures.

* Document that vm_page_protect() (and thus the related
  pmap_page_protect()) must be called with a hard-busied page.  This
  ensures that the operation does not race a new pmap_enter() of the page.

4 years ago<assert.h>: Sync comments a bit with FreeBSD.
Sascha Wildner [Mon, 20 May 2019 19:16:55 +0000 (21:16 +0200)]
<assert.h>: Sync comments a bit with FreeBSD.

4 years ago<assert.h>: add missing __dead2 to __assert().
Ed Schouten [Sun, 9 Jan 2011 21:39:46 +0000 (21:39 +0000)]
<assert.h>: add missing __dead2 to __assert().

__assert() is called when an assertion fails. After printing an error
message, it will call abort(). abort() never returns, hence it has the
__dead2 attribute. Also add this attribute to __assert().

Taken-from: FreeBSD (r217207)
Submitted-by: Jan Beich
4 years agopam_ftpusers.8: Remove reference to ftpusers.5.
Sascha Wildner [Mon, 20 May 2019 06:46:31 +0000 (08:46 +0200)]
pam_ftpusers.8: Remove reference to ftpusers.5.

4 years agosys/boot: Clean up btxld's manual page.
Sascha Wildner [Mon, 20 May 2019 06:36:48 +0000 (08:36 +0200)]
sys/boot: Clean up btxld's manual page.

It is a host tool only and not installed to base.

4 years agoi386 removal, part 72/x: Remove i386 specific ed.4 manpage references.
Sascha Wildner [Mon, 20 May 2019 06:26:53 +0000 (08:26 +0200)]
i386 removal, part 72/x: Remove i386 specific ed.4 manpage references.

This was missing from 09ab7e4ea7d3a5476ab60148ed6fa1b8a0e61b0c.

4 years agobsd-family-tree: Sync with FreeBSD (add OpenBSD 6.5).
Sascha Wildner [Mon, 20 May 2019 06:03:06 +0000 (08:03 +0200)]
bsd-family-tree: Sync with FreeBSD (add OpenBSD 6.5).

4 years agodrm: Do not report PRIME as supported
François Tigeot [Sun, 19 May 2019 16:48:03 +0000 (18:48 +0200)]
drm: Do not report PRIME as supported

This fixes kernel panics with the Ravenports graphics stack

4 years agokernel - Remove improper direct user-space access
Matthew Dillon [Sat, 18 May 2019 16:31:26 +0000 (09:31 -0700)]
kernel - Remove improper direct user-space access

* chroot_kernel() (a privileged system call) was improperly
  callin kprintf() with a direct user address.  Just remove
  the kprintf().

Reported-by: tdfbsd
4 years agokernel: Don't include <sys/user.h> in kernel code.
Sascha Wildner [Sat, 18 May 2019 15:11:58 +0000 (17:11 +0200)]
kernel: Don't include <sys/user.h> in kernel code.

There is really no point in doing that because its main purpose is to
expose kernel structures to userland. The majority of cases wasn't
needed at all and the rest required only a couple of other includes.

4 years agomandoc(1): Use base recallocarray().
Sascha Wildner [Sat, 18 May 2019 12:53:17 +0000 (14:53 +0200)]
mandoc(1): Use base recallocarray().

4 years agoMerge branch 'vendor/MDOCML'
Sascha Wildner [Sat, 18 May 2019 12:57:28 +0000 (14:57 +0200)]
Merge branch 'vendor/MDOCML'

4 years agoRemove the compat recallocarray() on the vendor branch.
Sascha Wildner [Sat, 18 May 2019 12:55:15 +0000 (14:55 +0200)]
Remove the compat recallocarray() on the vendor branch.

4 years agomakedb: Fix apropos database generation better across release/master.
Sascha Wildner [Fri, 17 May 2019 14:20:45 +0000 (16:20 +0200)]
makedb: Fix apropos database generation better across release/

The apropos database format used by our new man(1) is different and
incompatible to that used by our old man(1). The files are also named
differently, mandoc.db (new) and whatis (old).

So it makes no sense to use the old makewhatis on new systems or the
new makewhatis on old systems. If the desired makewhatis does not
exist, then we just don't generate the db, because the building system
doesn't have the makewhatis needed to generate it.

Once installed, the database will be updated regularly as per weekly
periodic.

4 years agoRevert "kernel - Clean up direction flag on syscall entry"
Matthew Dillon [Fri, 17 May 2019 01:55:32 +0000 (18:55 -0700)]
Revert "kernel - Clean up direction flag on syscall entry"

Actually not needed, the D flag is cleared via the mask
set in MSR_SF_MASK.  Revert.

This reverts commit cea0e49dc0b2e5aea1b929d02f12d00df66528e2.