dragonfly.git
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.

4 years agokernel - Implement support for SMAP and SMEP security (3)
Matthew Dillon [Fri, 17 May 2019 01:44:28 +0000 (18:44 -0700)]
kernel - Implement support for SMAP and SMEP security (3)

* Issue clac after the push on all traps, interrupts, and
  exceptions.

* Improve code documentation.

4 years agokernel - Clean up direction flag on syscall entry
Matthew Dillon [Fri, 17 May 2019 01:43:20 +0000 (18:43 -0700)]
kernel - Clean up direction flag on syscall entry

* Make sure the direction flag is clear on syscall entry.  Don't
  trust userland.

4 years agokernel - Implement support for SMAP and SMEP security (2)
Matthew Dillon [Fri, 17 May 2019 00:37:48 +0000 (17:37 -0700)]
kernel - Implement support for SMAP and SMEP security (2)

* Oops.  Do the CR4 initialization in the correct place, so it is
  applied to all CPUs.

4 years agokernel - Implement support for SMAP and SMEP security
Matthew Dillon [Fri, 17 May 2019 00:14:58 +0000 (17:14 -0700)]
kernel - Implement support for SMAP and SMEP security

* Implement support for SMAP security.  This prevents accidental
  accesses to user address space from the kernel.  When available,
  we wrap intentional user-space accesses from the kernel with
  the 'stac' and 'clac' instructions.

  We use a NOP replacement policy to implement the feature.  The wrapper
  is initially a 'nop %eax' (3-byte NOP), and is replaced by 'stac' and
  'clac' via a .section iteration when the feature is supported.

* Implement support for SMEP security.  This prevents accidental
  execution of user code from the kernel and simply requires
  turning the bit on in CR4.

* Reports support in dmesg via the 'CPU Special Features Installed:'
  line.

4 years agokernel - Implement retpoline for kernel
Matthew Dillon [Thu, 16 May 2019 18:11:35 +0000 (11:11 -0700)]
kernel - Implement retpoline for kernel

* Now that we have gcc-8 operational, we can turn on retpoline (software
  spectre protection against the return stack buffer).  Turn it on via
  -mindirect-branch=thunk-inline

* No discernable performance loss with a generic buildkernel test:

Xeon e5-2620v4 x 2
                        time make -j 32 nativekernel (all tmpfs)
BEFORE 1717.427u 323.662s 2:28.49 1374.5%      9582+721k 200842+0io 4870pf+0w
BEFORE 1720.130u 338.635s 2:30.21 1370.5%      9555+720k 199720+0io 4804pf+0w
BEFORE 1722.395u 341.508s 2:30.71 1369.4%      9559+720k 199720+0io 4804pf+0w

AFTER  1720.271u 329.492s 2:28.27 1382.4%      9578+721k 200842+0io 4870pf+0w
AFTER  1736.268u 344.874s 2:30.90 1379.1%      9555+720k 199720+0io 4804pf+0w
AFTER  1726.056u 348.324s 2:31.14 1372.4%      9543+719k 199720+0io 4804pf+0w

4 years agoDon't include "internal" headers outside of regular headers.
Sascha Wildner [Wed, 15 May 2019 20:34:17 +0000 (22:34 +0200)]
Don't include "internal" headers outside of regular headers.

Include files like <sys/_timespec.h> and so on contain small parts
such as struct timespec that are supposed to be provided by multiple
regular headers. They should only be included by other headers, not
by *.c files.

None of these was actually needed except for the libtelnet one
(replaced with <stddef.h>).

4 years agoUpdate the pciconf(8) database.
Sascha Wildner [Wed, 15 May 2019 18:27:38 +0000 (20:27 +0200)]
Update the pciconf(8) database.

May 14, 2019 snapshot from https://pci-ids.ucw.cz

4 years agokernel - Add MDS mitigation support for Intel side-channel attack
Matthew Dillon [Wed, 15 May 2019 00:33:39 +0000 (17:33 -0700)]
kernel - Add MDS mitigation support for Intel side-channel attack

* Add MDS (Microarchitectural Data Sampling) attack mitigation to
  the kernel.  This is an attack against Intel CPUs made from 2011
  to date.  The attack is not currently known to work against AMD CPUs.

  With an intel microcode update the mitigation can be enabled with

  sysctl machdep.mds_mitigation=MD_CLEAR

* Without the intel microcode update, only disabling hyper-threading
  gives you any protection.  Older architectures might not get
  support.  If sysctl machdep.mds_support does not show support,
  then the currently loaded microcode does not have support for the
  feature.

* DragonFlyBSD only supports the MD_CLEAR mode, and it will only
  be available with a microcode update from Intel.

  Updating the microcode alone does not protect against the attack.
  The microcode must be updated AND the mode must be turned on in
  DragonFlyBSD to protect against the attack.

  This mitigation burns around 250nS of additional latency on kernel->user
  transitions (system calls and interrupts primarily).  The additional
  latency will not be present if the microcode has support but it is disabled
  in the kernel, so you should be able to safely update your microcode
  even if you do not intend to use the mitigation.

* It is unclear whether the microcode + mitigation completely protects
  the machine.  The attack is supposedly a sibling hyper-thread
  attack and it may be that the only way to completely protect your
  machine is to disable hyper-threading entirely.  Or buy AMD.

Templated-from: NetBSD

4 years agokernel - VM rework part 8 - Precursor work for terminal pv_entry removal
Matthew Dillon [Tue, 14 May 2019 03:35:51 +0000 (20:35 -0700)]
kernel - VM rework part 8 - Precursor work for terminal pv_entry removal

* Adjust structures so the pmap code can iterate backing_ba's with
  just the vm_object spinlock.

  Add a ba.pmap back-pointer.

  Move entry->start and entry->end into the ba (ba.start, ba.end).
  This is replicative of the base entry->ba.start and entry->ba.end,
  but local modifications are locked by individual objects to allow
  pmap ops to just look at backing ba's iterated via the object.

  Remove the entry->map back-pointer.

  Remove the ba.entry_base back-pointer.

* ba.offset is now an absolute offset and not additive.  Adjust all code
  that calculates and uses ba.offset (fortunately it is all concentrated
  in vm_map.c and vm_fault.c).

* Refactor ba.start/offset/end modificatons to be atomic with
  the necessary spin-locks to allow the pmap code to safely iterate
  the vm_map_backing list for a vm_object.

* Test VM system with full synth run.

4 years agokernel/evdev: Synchronize event codes with Linux 4.16
Peeter Must [Mon, 13 May 2019 09:31:47 +0000 (12:31 +0300)]
kernel/evdev: Synchronize event codes with Linux 4.16

Taken-from: FreeBSD, Linux

4 years agortld-elf - Notify thread state to optimize relocations (2)
Matthew Dillon [Sun, 12 May 2019 16:26:54 +0000 (09:26 -0700)]
rtld-elf - Notify thread state to optimize relocations (2)

* Remove write() prototype in dlfcn.c that was only used for
  debugging.

Reminded-by: swildner
4 years agopathconf.2/sysconf.3: Add some related references to SEE ALSO.
Sascha Wildner [Sun, 12 May 2019 16:19:52 +0000 (18:19 +0200)]
pathconf.2/sysconf.3: Add some related references to SEE ALSO.

4 years agortld-elf - Notify thread state to optimize relocations
Matthew Dillon [Sun, 12 May 2019 04:01:55 +0000 (21:01 -0700)]
rtld-elf - Notify thread state to optimize relocations

* Add shims to allow libthread_xu to notify rtld when threading
  is being used.

* Requires weak symbols in libc which are overriden by rtld-elf.

* Implement the feature in rtld-elf and use it to avoid making calls
  to lwp_gettid().  When threaded, use tls_get_tcb() (which does not
  require a system call) instead of lwp_gettid().  When not threaded,
  just use a constant.

  NOTE: We cannot use tls_get_tcb() unconditionally because the tcb
is not setup during early relocations.  So do this whack-a-mole
to make it work.

* This leaves just the sigprocmask wrappers around rtld-elf (which
  are needed to prevent stacked relocations from signal handlers).

Poked-by: mjg
4 years agokernel - VM rework part 7 - Initial vm_map_backing index
Matthew Dillon [Sat, 11 May 2019 05:39:53 +0000 (22:39 -0700)]
kernel - VM rework part 7 - Initial vm_map_backing index

* Implement a TAILQ and hang vm_map_backing structures off
  of the related object.  This feature is still in progress
  and will eventually be used to allow pmaps to manipulate
  vm_page's without pv_entry's.

  At the same time, remove all sharing of vm_map_backing.
  For example, clips no longer share the vm_map_backing.  We
  can't share the structures if they are being used to
  itemize areas for pmap management.

  TODO - reoptimize this at some point.

  TODO - not yet quite deterministic enough for pmap
 searches (due to clips).

* Refactor vm_object_reference_quick() to again allow
  operation on any vm_object whos ref_count is already
  at least 1, or which belongs to a vnode.  The ref_count
  is no longer being used for complex vm_object collapse,
  shadowing, or migration code.

  This allows us to avoid a number of unnecessary token
  grabs on objects during clips, shadowing, and forks.

* Cleanup a few fields in vm_object.  Name TAILQ_ENTRY()
  elements blahblah_entry instead of blahblah_list.

* Fix an issue with a.out binaries (that are still supported but
  nobody uses) where the object refs on the binaries were not
  being properly accounted for.

4 years agokernel - VM rework part 6 - Stabilize
Matthew Dillon [Sat, 11 May 2019 01:41:08 +0000 (18:41 -0700)]
kernel - VM rework part 6 - Stabilize

* Fix a case and situations where VPAGETABLE won't work.

4 years agokernel - VM rework part 5 - Cleanup
Matthew Dillon [Fri, 10 May 2019 18:37:00 +0000 (11:37 -0700)]
kernel - VM rework part 5 - Cleanup

* Cleanup vm_map_entry_shadow()

* Remove (unused) vmspace_president_count()
  Remove (barely used) struct lwkt_token typedef.

* Cleanup the vm_map_aux, vm_map_entry, vm_map, and vm_object
  structures

* Adjfustments to in-code documentation

4 years agoClean up some Makefiles.
Sascha Wildner [Sat, 11 May 2019 22:08:34 +0000 (00:08 +0200)]
Clean up some Makefiles.

* WARNS?=6 is usually not needed because upper-level Makefile.inc's
  already have it (such as usr.bin/Makefile.inc).

* Remove an unneded SRCS in ndis_events(8).

4 years agolibutil: Raise WARNS to 6.
Sascha Wildner [Sat, 11 May 2019 21:56:20 +0000 (23:56 +0200)]
libutil: Raise WARNS to 6.

4 years agokcollect - Adjust Mops right hand on graph
Matthew Dillon [Sat, 11 May 2019 18:39:22 +0000 (11:39 -0700)]
kcollect - Adjust Mops right hand on graph

* Adjust the Mops cap based on ncpus.

4 years agokernel - Restore kern.cam.da.X.trim_enabled sysctl
Matthew Dillon [Sat, 11 May 2019 16:06:43 +0000 (09:06 -0700)]
kernel - Restore kern.cam.da.X.trim_enabled sysctl

* This sysctl was not always being properly installed due to an
  ordering and timing issue.

* The code was not setting the trim flag in the correct structure.

4 years agokernel - VM rework (fix introduced bug)
Matthew Dillon [Sat, 11 May 2019 16:04:25 +0000 (09:04 -0700)]
kernel - VM rework (fix introduced bug)

* Fix a null-pointer dereferencing bug in vm_object_madvise() introduced
  in recent commits.

4 years agokernel - VM rework part 4 - Implement vm_fault_collapse()
Matthew Dillon [Fri, 10 May 2019 01:37:10 +0000 (18:37 -0700)]
kernel - VM rework part 4 - Implement vm_fault_collapse()

* Add the function vm_fault_collapse().  This function simulates
  faults to copy all pages from backing objects into the front
  object, allowing the backing objects to be disconnected
  from the map entry.

  This function is called under certain conditions from the
  vmspace_fork*() code prior to a fork to potentially collapse
  the entry's backing objects into the front object.  The
  caller then disconnects the backing objects, truncating the
  list to a single object (the front object).

  This optimization is necessary to prevent the backing_ba list
  from growing in an unbounded fashion.  In addition, being able
  to disconnect the graph allows redundant backing store to
  be freed more quickly, reducing memory use.

* Add sysctl vm.map_backing_shadow_test (default enabled).
  The vmspace_fork*() code now does a quick all-shadowed test on
  the first backing object and calls vm_fault_collapse()
  if it comes back true, regardless of the chain length.

* Add sysctl vm.map_backing_limit (default 5).
  The vmspace_fork*() code calls vm_fault_collapse() when the
  ba.backing_ba list exceeds the specified number of entries.

* Performance is a tad faster than the original collapse
  code.

4 years agokernel - VM rework part 3 - Cleanup pass
Matthew Dillon [Thu, 9 May 2019 06:31:25 +0000 (23:31 -0700)]
kernel - VM rework part 3 - Cleanup pass

* Cleanup various structures and code

4 years agokernel - VM rework part 2 - Replace backing_object with backing_ba
Matthew Dillon [Thu, 9 May 2019 02:39:44 +0000 (19:39 -0700)]
kernel - VM rework part 2 - Replace backing_object with backing_ba

* Remove the vm_object based backing_object chains and all related
  chaining code.

  This removes an enormous number of locks from the VM system and
  also removes object-to-object dependencies which requires careful
  traversal code.  A great deal of complex code has been removed
  and replaced with far simpler code.

  Ultimately the intention will be to support removal of pv_entry
  tracking from vm_pages to gain lockless shared faults, but that
  is far in the future.  It will require hanging vm_map_backing
  structures off of a list based in the object.

* Implement the vm_map_backing structure which is embedded in the
  vm_map_entry and then links to additional dynamically allocated
  vm_map_backing structures via entry->ba.backing_ba.  This structure
  contains the object and offset and essentially takes over the
  functionality that object->backing_object used to have.

  backing objects are now handled via vm_map_backing.  In this
  commit, fork operations create a fan-in tree to shared subsets
  of backings via vm_map_backing.  In this particular commit,
  these subsets are not collapsed in any way.

* Remove all the vm_map_split and collapse code.  Every last line
  is gone.  It will be reimplemented using vm_map_backing in a
  later commit.

  This means that as-of this commit both recursive forks and
  parent-to-multiple-children forks cause an accumulation of
  inefficient lists of backing objects to occur in the parent
  and children.  This will begin to get addressed in part 3.

* The code no longer releases the vm_map lock (typically shared)
  across (get_pages) I/O.  There are no longer any chaining locks to
  get in the way (hopefully).  This means that the code does not
  have to re-check as carefully as it did before.  However, some
  complexity will have to be added back in once we begin to address
  the accumulation of vm_map_backing structures.

* Paging performance improved by 30-40%

4 years agokernel - VM rework part 1 - Remove shadow_list
Matthew Dillon [Tue, 7 May 2019 06:14:02 +0000 (23:14 -0700)]
kernel - VM rework part 1 - Remove shadow_list

* Remove shadow_head, shadow_list, shadow_count.

* This leaves the kernel operational but without collapse optimizations
  on 'other' processes when a prorgam exits.

4 years agoSync ACPICA with Intel's version 20190509.
Sascha Wildner [Fri, 10 May 2019 09:46:14 +0000 (11:46 +0200)]
Sync ACPICA with Intel's version 20190509.

* Revert some changes that were causing issues in the kernel subsystem
  and in iasl(8).

* Additional improvements in iasl(8).

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

4 years agokernel - __read_mostly pass on vm_fault
Matthew Dillon [Fri, 10 May 2019 01:00:25 +0000 (18:00 -0700)]
kernel - __read_mostly pass on vm_fault

* Qualify a number of variables with __read_mostly

4 years agokernel - __read_mostly pass on vfs_subr
Matthew Dillon [Fri, 10 May 2019 00:57:44 +0000 (17:57 -0700)]
kernel - __read_mostly pass on vfs_subr

* Qualify a number of variables with __read_mostly

4 years agokernel - __read_mostly pass on vfs_cache
Matthew Dillon [Fri, 10 May 2019 00:48:44 +0000 (17:48 -0700)]
kernel - __read_mostly pass on vfs_cache

* Qualify a number of variables with __read_mostly

* Move the numdefered global to the pcpu structure and adjust the
  heuristic for it.

4 years agokernel - __read_mostly pass on lwkt_thread
Matthew Dillon [Fri, 10 May 2019 00:47:21 +0000 (17:47 -0700)]
kernel - __read_mostly pass on lwkt_thread

* Qualify a number of globals as __read_mostly

* Conditionalize-out (effectively remove) a number of other
  globals that were being used for debugging.

4 years agokernel - Quick pass add __read_frequently
Matthew Dillon [Thu, 9 May 2019 23:52:12 +0000 (16:52 -0700)]
kernel - Quick pass add __read_frequently

* Do a quick pass to add __read_frequently to certain specific
  globals.

4 years agokernel - Bring in __read_mostly etc
Matthew Dillon [Thu, 9 May 2019 23:45:05 +0000 (16:45 -0700)]
kernel - Bring in __read_mostly etc

* Bring __read_mostly, __read_frequently, and __exclusive_cache_line
  in from FreeBSD.

* Remove linux compat __read_mostly now that we have a real one.

Taken-From: FreeBSD/mjg_

4 years agoRemove any remaining traces of varargs.h.
Sascha Wildner [Wed, 8 May 2019 19:48:05 +0000 (21:48 +0200)]
Remove any remaining traces of varargs.h.

This is a follow-up of b3a17fb68c15a4c57da6867f1b2119587b7a68a8.

4 years agokernel: Stop including userland-only includes in kernel code (1/x).
Sascha Wildner [Wed, 8 May 2019 08:19:59 +0000 (10:19 +0200)]
kernel: Stop including userland-only includes in kernel code (1/x).

Specifically <stdbool.h>, <arpa/inet.h>, <dlfcn.h>, <limits.h>, and
<unistd.h>.

Only in hammer2's zlib it needed to be exchanged with a more suitable
header. The rest could be removed.

4 years agoAdd fuse kernel part to LINT64.
Sascha Wildner [Wed, 8 May 2019 08:13:49 +0000 (10:13 +0200)]
Add fuse kernel part to LINT64.

4 years agodup3.3: Adjust HISTORY section.
Sascha Wildner [Tue, 7 May 2019 06:51:30 +0000 (08:51 +0200)]
dup3.3: Adjust HISTORY section.

4 years agolibc: Add dup3() from FreeBSD.
Sascha Wildner [Mon, 6 May 2019 16:53:26 +0000 (18:53 +0200)]
libc: Add dup3() from FreeBSD.

As proposed in http://austingroupbugs.net/view.php?id=411

It seems to help with various ports.

Pointed-out-by: zrj
4 years ago<unistd.h>: Move eaccess() prototype to a better place.
Sascha Wildner [Mon, 6 May 2019 15:24:26 +0000 (17:24 +0200)]
<unistd.h>: Move eaccess() prototype to a better place.

4 years agolibc/net: Document more functions.
Sascha Wildner [Mon, 6 May 2019 07:45:03 +0000 (09:45 +0200)]
libc/net: Document more functions.

gethostbyaddr_r()
gethostbyname_r()
gethostbyname2_r()
gethostent_r()
getnetbyaddr_r()
getnetbyname_r()
getnetent_r()

4 years agolibc/net: Adjust h_errorp arg name to herrno_p like everywhere else.
Sascha Wildner [Mon, 6 May 2019 07:01:57 +0000 (09:01 +0200)]
libc/net: Adjust h_errorp arg name to herrno_p like everywhere else.

4 years ago<netdb.h>: Add whitespace in a prototype.
Sascha Wildner [Mon, 6 May 2019 05:54:15 +0000 (07:54 +0200)]
<netdb.h>: Add whitespace in a prototype.

4 years agogetservent.3: Fix function name.
Sascha Wildner [Mon, 6 May 2019 05:40:47 +0000 (07:40 +0200)]
getservent.3: Fix function name.

4 years agolibc: Change a few DIAGNOSTICS sections into RETURN VALUES and/or ERRORS.
Sascha Wildner [Sun, 5 May 2019 00:10:38 +0000 (02:10 +0200)]
libc: Change a few DIAGNOSTICS sections into RETURN VALUES and/or ERRORS.

DIAGNOSTICS is for stderr type messages only.

4 years agolibc: Add forgotten MLINK.
Sascha Wildner [Sat, 4 May 2019 23:37:05 +0000 (01:37 +0200)]
libc: Add forgotten MLINK.

4 years agolibc: Document yp_maplist().
Sascha Wildner [Sat, 4 May 2019 23:33:57 +0000 (01:33 +0200)]
libc: Document yp_maplist().

While here, correct a wrong type.

Taken-from: OpenBSD

4 years ago<sys/fcntl.h>: Restrict POSIX_FADV_* visibility to userland.
Sascha Wildner [Sat, 4 May 2019 21:28:38 +0000 (23:28 +0200)]
<sys/fcntl.h>: Restrict POSIX_FADV_* visibility to userland.

While here, add a clarifying comment that the information isn't used.

Pointed-out-by: zrj
4 years agolibc/locale: Document mbrtoc{16,32}_l() and c{16,32}rtomb_l().
Sascha Wildner [Sat, 4 May 2019 21:24:53 +0000 (23:24 +0200)]
libc/locale: Document mbrtoc{16,32}_l() and c{16,32}rtomb_l().

4 years agodrm/radeon - Attempt to fix data structure corruption on exit
Matthew Dillon [Sat, 4 May 2019 21:18:34 +0000 (14:18 -0700)]
drm/radeon - Attempt to fix data structure corruption on exit

* Attempt to fix data structure corruption in the radeon driver
  when X exits.  This was causing X to lockup due to an attempt
  to double-remove vm->va from its interval tree.

* Validation operations based on field state.  In particular,
  do not try to issue the interval tree removal unless
  it.start or it.last are non-zero.

  Also, in radeon_vm_fini() do not issue the interval tree removal
  unless the bo can be successfully reserved.  Otherwise the
  structure might be placed in a bad state while it is still in use.

4 years agodrm - Move startup delay to VERSION ioctl
Matthew Dillon [Sat, 4 May 2019 21:15:30 +0000 (14:15 -0700)]
drm - Move startup delay to VERSION ioctl

* We had a startup delay in the i915 attach path, which is
  synchronous with the kldload that X does.  Unfortunately, this
  doesn't appear to work well, probably because it just stalls
  everything and leaves the race intact after the sleep returns.
  Also, the kld lock is held across the sleep.

* Move the startup delay to the first call of the DRM_IOCTL_VERSION
  ioctl.  This is outside the kld path allows drm to free-run while
  simply imposing a short delay on the X startup to give the drm
  system time to stabilize.

* Should fix several intel i915 startup issues that can leave the
  screen corrupt, and perhaps other startup issues.

4 years agolibc: Add posix_fadvise(), for now empty except for some error checking.
Sascha Wildner [Sat, 4 May 2019 20:20:02 +0000 (22:20 +0200)]
libc: Add posix_fadvise(), for now empty except for some error checking.

This should help some dports.

From POSIX' point of view this is sufficient because it is not
required that the implementation does anything with the passed
information.

The manual page was taken from FreeBSD.

4 years agolibc: Document getservent_r(), getservbyport_r(), and getservbyname_r().
Sascha Wildner [Sat, 4 May 2019 17:44:03 +0000 (19:44 +0200)]
libc: Document getservent_r(), getservbyport_r(), and getservbyname_r().

Partially-taken-from: OpenBSD

4 years agolibc: Document getprotoent_r(), getprotobynumber_r(), and getprotobyname_r().
Sascha Wildner [Sat, 4 May 2019 10:20:06 +0000 (12:20 +0200)]
libc: Document getprotoent_r(), getprotobynumber_r(), and getprotobyname_r().

Partially-taken-from: OpenBSD

4 years agolibc: Document offtime(), timelocal(), and timeoff().
Sascha Wildner [Sat, 4 May 2019 09:50:10 +0000 (11:50 +0200)]
libc: Document offtime(), timelocal(), and timeoff().

Taken-from: NetBSD

4 years agobuild - Make sure /usr/local/bin is NOT in the $PATH for kernel
Matthew Dillon [Sat, 4 May 2019 04:46:16 +0000 (21:46 -0700)]
build - Make sure /usr/local/bin is NOT in the $PATH for kernel

* Make sure /usr/local/bin is NOT in the $PATH when building the
  kernel.  If it is, a dports-installed binutils can cause an
  incompatible linker (e.g. one that doesn't recognize LDVER, for
  example) to be used, blowing up incremental builds between
  buildkernel, nativekernel, and manual builds from the object
  directory ( /usr/obj/usr/src/sys/<KERNEL_CONFIG> ).

4 years agodrm/ttm: Fix a deadlock involving fictitious VM pages
Matthew Dillon [Fri, 3 May 2019 20:36:22 +0000 (22:36 +0200)]
drm/ttm: Fix a deadlock involving fictitious VM pages

This prevents processes getting hung in "ttm_unm" state.

4 years agodrm: Sync ttm and radeon drivers with Linux 3.18
François Tigeot [Fri, 3 May 2019 19:56:27 +0000 (21:56 +0200)]
drm: Sync ttm and radeon drivers with Linux 3.18

4 years agodrm: Import dma-buf reservation code from Linux 4.7.10
François Tigeot [Fri, 3 May 2019 19:53:58 +0000 (21:53 +0200)]
drm: Import dma-buf reservation code from Linux 4.7.10

4 years agodrm: More linux/seqlock.h functions
François Tigeot [Fri, 3 May 2019 19:45:23 +0000 (21:45 +0200)]
drm: More linux/seqlock.h functions

4 years agokernel - Permanently fix FP bug - completely remove lazy heuristic
Matthew Dillon [Fri, 3 May 2019 20:24:13 +0000 (13:24 -0700)]
kernel - Permanently fix FP bug - completely remove lazy heuristic

* Remove the FP lazy heuristic.  When the FP unit is being used by a
  thread, it will now *always* be actively saved and restored on
  context switch.

  This means that if a process uses the FP unit at all, its context
  switches (to another thread) will active save/restore the state forever
  more.

* This fixes a known hardware bug on Intel CPUs that we thought was fixed
  before (by not saving The FP context from thread A from the DNA interrupt
  on thread B)...  but it turns out it wasn't.

  We could tickle the bug on Intel CPUs by forcing synth to regenerate
  its flavor index over and over again.  This regeneration fork/exec's
  about 60,000 make's, sequencing concurrently on all cores, and usually
  hits the bug in less than 5 minutes.

* We no longer support lazy FP restores, period.  This is like the fourth
  time I've tried to deal with this, so now its time to give up and not
  use lazy restoration at all, ever again.

4 years agokernel - Backout procfs map change
Matthew Dillon [Fri, 3 May 2019 20:04:39 +0000 (13:04 -0700)]
kernel - Backout procfs map change

* Backout the addition of MAP_STACK 'STK' flagging in the map
  output.  It blows up gcore's /proc/pid/map scan (not procfs's
  fault)... but lets not rock the boat for now.  The flag isn't
  important.

4 years agokernel - Implement debug function w/kern.logsigexit > 1
Matthew Dillon [Fri, 3 May 2019 17:15:13 +0000 (10:15 -0700)]
kernel - Implement debug function w/kern.logsigexit > 1

* kern.logsigexit defaults to 1, which logs signal exits that might
  core dump.

* This change allows setting this sysctl to 2 for debugging purposes.
  The kernel will log the error and then stall uninterruptibly until
  you set the sysctl back to 1 (to resume logging normally).

  This is more kernel debugging only.

4 years agolibrecrypto: Rename unused header.
zrj [Fri, 3 May 2019 10:59:15 +0000 (13:59 +0300)]
librecrypto: Rename unused header.

It is not used during the buildworld.

4 years agodrm/linux: Add an interval_tree implementation
Matthew Dillon [Fri, 3 May 2019 08:58:10 +0000 (10:58 +0200)]
drm/linux: Add an interval_tree implementation

Contrary to the official Linux one, it does not use RB trees.

4 years agodrm: Do not directly define __OS_HAS_AGP
François Tigeot [Fri, 3 May 2019 08:46:33 +0000 (10:46 +0200)]
drm: Do not directly define __OS_HAS_AGP

Use CONFIG_AGP instead

4 years agodrm: Do not use PHOLD/PRELE() in flush_taskqueue()
François Tigeot [Fri, 3 May 2019 08:28:26 +0000 (10:28 +0200)]
drm: Do not use PHOLD/PRELE() in flush_taskqueue()

4 years agodrm/linux: Expand mm_types.h and mmu_notifier.h coverage
François Tigeot [Fri, 3 May 2019 07:37:41 +0000 (09:37 +0200)]
drm/linux: Expand mm_types.h and mmu_notifier.h coverage

4 years agoindent.1: Add some missing whitespace.
Sascha Wildner [Fri, 3 May 2019 07:29:12 +0000 (09:29 +0200)]
indent.1: Add some missing whitespace.

4 years agoworld - update manual page for mmap()
Matthew Dillon [Fri, 3 May 2019 06:21:52 +0000 (23:21 -0700)]
world - update manual page for mmap()

* Update the manual page for mmap().

4 years agokernel - Fix serious bug in MAP_STACK, deprecate auto-grow semantics
Matthew Dillon [Fri, 3 May 2019 06:03:32 +0000 (23:03 -0700)]
kernel - Fix serious bug in MAP_STACK, deprecate auto-grow semantics

* When MAP_STACK is used without MAP_TRYFIXED, the address the kernel
  determines for the stack was *NOT* being returned to userland.  Instead,
  userland always got only the hint address.

* This fixes ruby MAP_STACK use cases and possibly more.

* Deprecate MAP_STACK auto-grow semantics.  All user mmap() calls with
  MAP_STACK are now converted to normal MAP_ANON mmaps.  The kernel will
  continue to create an auto-grow stack segment for the primary user stack
  in exec(), allowing older pthread libraries to continue working, but this
  feature is deprecated and will be removed in a future release.

4 years agopthreads and kernel - change MAP_STACK operation
Matthew Dillon [Fri, 3 May 2019 02:48:53 +0000 (19:48 -0700)]
pthreads and kernel - change MAP_STACK operation

* Only allow new mmap()'s to intrude on ungrown MAP_STACK areas when
  MAP_TRYFIXED is specified.  This was not working as intended before.
  Adjust the manual page to be more clear.

* Make kern.maxssiz (the maximum user stack size) visible via sysctl.

* Add kern.maxthrssiz, indicating the approximate space for placement
  of pthread stacks.  This defaults to 128GB.

* The old libthread_xu stack code did use TRYFIXED and will work
  with the kernel changes, but change how it works to not assume
  that the user stack should suddenly be limited to the pthread stack
  size (~2MB).

  Just use a normal mmap() now without TRYFIXED and a hint based on
  kern.maxthrssiz (defaults to 512GB), calculating a starting address
  hint that is (_usrstack - maxssiz - maxthrssiz).

* Adjust procfs to report MAP_STACK segments as 'STK'.

4 years agopthread_set_name_np.3: Add some articles.
Sascha Wildner [Thu, 2 May 2019 08:28:42 +0000 (10:28 +0200)]
pthread_set_name_np.3: Add some articles.

4 years agokernel - Add kern.ipc.soaccept_reuse and set default to 1
Matthew Dillon [Wed, 1 May 2019 18:31:50 +0000 (11:31 -0700)]
kernel - Add kern.ipc.soaccept_reuse and set default to 1

* This feature, enabled by default, allows a service listening on
  a socket to be killed and restarted without causing
  "bind: Address already in use" errors due to accepted connections still
  being present.

* The accepted connections may still be present either because they
  are still in active use (though typically this is not the case when
  a service is killed... its children also get killed).  But also, more
  importantly, if the sockets are still present due to lingering on a
  TCP timeout.

  In both of these situations we allow bind() to ignore matches against
  accepted connections.  This allows a service to be restared without
  having to set SO_REUSEADDR (for example named/bind generally does not
  set SO_REUSEADDR and restarting can be a pain).

4 years agoPRIV: Handle histedit.h in unpriv_base.sh
zrj [Wed, 1 May 2019 07:50:24 +0000 (10:50 +0300)]
PRIV: Handle histedit.h in unpriv_base.sh

4 years agoComplete upgrade of libedit from 2017-03-29 to 2019-03-24
zrj [Tue, 30 Apr 2019 20:00:20 +0000 (23:00 +0300)]
Complete upgrade of libedit from 2017-03-29 to 2019-03-24