dragonfly.git
7 years agoi386 removal, part 54/x: Remove perfmon(4) remains.
Sascha Wildner [Sun, 7 Aug 2016 15:26:26 +0000 (17:26 +0200)]
i386 removal, part 54/x: Remove perfmon(4) remains.

It only ever was compilable into i386 kernels. I forgot to remove it
too in f4c88b0b86f1810db0482795bc097597d1197c54.

7 years agoi386 removal, part 53/x: Remove the code of the fe(4) driver too.
Sascha Wildner [Sun, 7 Aug 2016 14:22:04 +0000 (16:22 +0200)]
i386 removal, part 53/x: Remove the code of the fe(4) driver too.

It only ever was compilable into i386 kernels. I forgot to remove it
too in f4c88b0b86f1810db0482795bc097597d1197c54.

7 years agokernel: Remove the old ep(4) and ex(4) network drivers.
Sascha Wildner [Sun, 7 Aug 2016 14:08:27 +0000 (16:08 +0200)]
kernel: Remove the old ep(4) and ex(4) network drivers.

Aside from being quite obsolete, their documentation always was in the
i386 so i have my doubts that they still work.

If anyone needs them back for some reason I can't imagine currently,
we can take another look then.

7 years agoi386 removal, part 52/x: Remove the old cs(4) network driver.
Sascha Wildner [Sun, 7 Aug 2016 13:09:47 +0000 (15:09 +0200)]
i386 removal, part 52/x: Remove the old cs(4) network driver.

Looks like it was i386 specific and ended up in our x86_64 configs by
mistake. At least its manpage was in the i386 section and FreeBSD does
not have it in amd64's NOTES either.

7 years agoClean up some more after the sys/emulation/linux removal.
Sascha Wildner [Sun, 7 Aug 2016 12:49:22 +0000 (14:49 +0200)]
Clean up some more after the sys/emulation/linux removal.

7 years agosbin/hammer: Abort if failed to creat recover target dir
Tomohiro Kusumi [Sun, 7 Aug 2016 11:28:44 +0000 (20:28 +0900)]
sbin/hammer: Abort if failed to creat recover target dir

7 years agosbin/hammer: Add verbose volume message while recovering
Tomohiro Kusumi [Sun, 7 Aug 2016 08:59:07 +0000 (17:59 +0900)]
sbin/hammer: Add verbose volume message while recovering

sizetostr() is brought from newfs_hammer code.

newfs_hammer should use sizetostr() by linking sbin/hammer/misc.o,
as it already has dependencies on other sbin/hammer/*.o.
(Also note that hammer2 also has sizetostr() in both directories)

7 years ago<time.h>: Adjust the visibility of CLOCK_REALTIME and TIMER_ABSTIME.
Sascha Wildner [Sun, 7 Aug 2016 09:29:13 +0000 (11:29 +0200)]
<time.h>: Adjust the visibility of CLOCK_REALTIME and TIMER_ABSTIME.

Looks like they came in with IEEE Std 1003.1b-1993.

Helps building math/clblas with GCC.

Reported-by: zrj
7 years agoboot - Force -O
Matthew Dillon [Sun, 7 Aug 2016 08:34:54 +0000 (01:34 -0700)]
boot - Force -O

* Always force -O for the boot code.  -O2 will implode it.  This is a bit
  weird but -O will override any prior -O2.  We still want other CFLAGS
  that mk scripts supply so we can't just set CFLAGS=

7 years agotcsh - Work around gcc-5 bug
Matthew Dillon [Sun, 7 Aug 2016 08:04:48 +0000 (01:04 -0700)]
tcsh - Work around gcc-5 bug

* GCC-5 improperly tries to optimize tcsh's calloc() replacement into a
  tail-jmp to tcsh's calloc.  It tries to optimize the malloc+memset
  sequence into calloc, inside calloc itself.

  This is really a bug in GCC-5 but work around it for now by hacking
  tcsh's calloc().

7 years agobuild - prepare for higher optimization levels (2)
Matthew Dillon [Sun, 7 Aug 2016 07:21:55 +0000 (00:21 -0700)]
build - prepare for higher optimization levels (2)

* A couple more programs need Makefile mods.

7 years agobuild - Add support for new NO_* make variables
Matthew Dillon [Sun, 7 Aug 2016 07:07:29 +0000 (00:07 -0700)]
build - Add support for new NO_* make variables

* Add support for NO_STRICT_ALIASING, NO_STRICT_OVERFLOW,
  and NO_WARRAY_BOUNDS.

7 years agobuild - prepare for higher optimization levels
Matthew Dillon [Sun, 7 Aug 2016 07:04:51 +0000 (00:04 -0700)]
build - prepare for higher optimization levels

* Add NO_STRICT_ALIASING, NO_STRICT_OVERFLOW, and NO_WARRAY_BOUNDS
  make variables as-needed.

7 years agokernel - Fix minor bug in powermng
Matthew Dillon [Sun, 7 Aug 2016 07:00:30 +0000 (00:00 -0700)]
kernel - Fix minor bug in powermng

* Fix a minor array overflow (incorrect index used) bug in powermng.

7 years agokernel - Cleanup gcc warnings
Matthew Dillon [Sun, 7 Aug 2016 04:02:46 +0000 (21:02 -0700)]
kernel - Cleanup gcc warnings

* Cleanup gcc warnings at higher optimization levels.  This will allow
  us to build kernels -O2 or -O3.

7 years agolibc/strptime: Handle ISO 8601 time zone formats in %z.
zrj [Wed, 27 Jul 2016 16:17:54 +0000 (19:17 +0300)]
libc/strptime: Handle ISO 8601 time zone formats in %z.

Formats of +hh:mm +hh Z are now also accepted to previous +hhmm.

7 years agolibc/strptime: Fix "%Y %W %w %H:%M:%S".
zrj [Tue, 26 Jul 2016 12:29:59 +0000 (15:29 +0300)]
libc/strptime: Fix "%Y %W %w %H:%M:%S".

Also throw in the fix for "12:34:56 2016 30 0", "%H:%M:%S %Y %W %w".
Correct partial format reads are still not supported.

7 years agostrptime.3: Sync with FreeBSD.
zrj [Tue, 26 Jul 2016 13:48:35 +0000 (16:48 +0300)]
strptime.3: Sync with FreeBSD.

7 years agolibc/strptime: Attempt to fix up %U and %W.
zrj [Tue, 26 Jul 2016 12:14:49 +0000 (15:14 +0300)]
libc/strptime: Attempt to fix up %U and %W.

Thera are still few issues left.

Taken-from: FreeBSD

7 years agolibc/strptime: Add support for %t and %n per POSIX.
zrj [Tue, 26 Jul 2016 10:05:36 +0000 (13:05 +0300)]
libc/strptime: Add support for %t and %n per POSIX.

Only skip space for %e and fail on unknown specifiers.
Also remove magic year 1900 constants.

Taken-from: FreeBSD

7 years agolibc/strptime: Check for NULL, not 0.
zrj [Tue, 26 Jul 2016 06:59:42 +0000 (09:59 +0300)]
libc/strptime: Check for NULL, not 0.

Also add check for gmtime_r() result.

While there, perform license change as per FreeBSD r267544

7 years agokernel - Fix memcpy assembly ABI
Matthew Dillon [Sun, 7 Aug 2016 04:25:26 +0000 (21:25 -0700)]
kernel - Fix memcpy assembly ABI

* memcpy must return the original (dst) argument, and wasn't for the kernel.
  Nothing used it explicitly, but gcc sometimes decides to call memcpy and
  assumes the correct return value.  It was just luck that it hasn't up until
  now.

7 years agolibc - Include information on the 'e' flag in the popen() manual page.
Matthew Dillon [Sat, 6 Aug 2016 18:05:10 +0000 (11:05 -0700)]
libc - Include information on the 'e' flag in the popen() manual page.

* Include information on the 'e' flag in the popen() manual page.

7 years agokernel, world - Remove the remaining vestiges of linux emul
Matthew Dillon [Sat, 6 Aug 2016 17:53:59 +0000 (10:53 -0700)]
kernel, world - Remove the remaining vestiges of linux emul

* Remove the remaining bits of the 32-bit linux emulation code.  This
  code hasn't been used in ages and we have no plans to implement a
  64-bit linux emulation.

7 years agosbin/hammer: Directly access volume in volume list
Tomohiro Kusumi [Sat, 6 Aug 2016 12:08:15 +0000 (21:08 +0900)]
sbin/hammer: Directly access volume in volume list

This is what ondisk code does.
No reference/etc to acquire via get_volume().

7 years agosys/vfs/hammer: Add HAMMER_VOL_BUF_SIZE()
Tomohiro Kusumi [Sat, 6 Aug 2016 09:58:58 +0000 (18:58 +0900)]
sys/vfs/hammer: Add HAMMER_VOL_BUF_SIZE()

7 years agosbin/hammer: Remove rel_volume()
Tomohiro Kusumi [Sat, 6 Aug 2016 08:54:29 +0000 (17:54 +0900)]
sbin/hammer: Remove rel_volume()

It does nothing after da519351 which got rid of unnecessary
volume-modified flag.

volume_info list never gets cleaned up once it's added, so
release isn't necessary, unlike buffers (incl volume buffer)
that need to be managed.

7 years agokernel - Fix kern.proc.pathname sysctl
Matthew Dillon [Fri, 5 Aug 2016 20:12:08 +0000 (13:12 -0700)]
kernel - Fix kern.proc.pathname sysctl

* kern.proc.pathname is a sysctl used by programs to find the path
  of the running program.  This sysctl was created before we stored
  sufficient information in the proc structure to construct the
  correct path when multiple aliases are present (due to e.g. null-mounts)
  to the same file.

* We do have this information, in p->p_textnch, so change the sysctl to
  use it.  The sysctl will now return the actual full path in the context
  of whomever ran the program, so it should properly take into account
  chroots and such.

7 years agoUse ; instead of , where appropriate.
Sascha Wildner [Fri, 5 Aug 2016 08:33:54 +0000 (10:33 +0200)]
Use ; instead of , where appropriate.

Also add the coccinelle patch which found this to test/cocci (taken from
https://github.com/coccinelle/coccinellery/blob/master/comma/comma.cocci).

7 years agodma - Fix security hole
Matthew Dillon [Fri, 5 Aug 2016 07:18:07 +0000 (00:18 -0700)]
dma - Fix security hole

* dma makes an age-old mistake of not properly checking whether a file
  owned by a user is a symlink or not, a bug which the original mail.local
  also had.

* Add O_NOFOLLOW to disallow symlinks.

Thanks-to: BSDNow Episode 152, made me dive dma to check when they talked
   about the mail.local bug.

7 years agobsd-family-tree: Sync with FreeBSD (DragonFly 4.6.0).
Sascha Wildner [Fri, 5 Aug 2016 07:07:57 +0000 (09:07 +0200)]
bsd-family-tree: Sync with FreeBSD (DragonFly 4.6.0).

7 years agoMerge branch 'vendor/OPENSSH'
Peter Avalos [Thu, 4 Aug 2016 10:29:55 +0000 (03:29 -0700)]
Merge branch 'vendor/OPENSSH'

7 years agoAdd a openbsd-compat file for latest import.
Peter Avalos [Thu, 4 Aug 2016 10:28:43 +0000 (03:28 -0700)]
Add a openbsd-compat file for latest import.

7 years agoUpdate files for OpenSSH-7.3p1 import.
Peter Avalos [Thu, 4 Aug 2016 10:27:08 +0000 (03:27 -0700)]
Update files for OpenSSH-7.3p1 import.

7 years agoMerge branch 'vendor/OPENSSH'
Peter Avalos [Thu, 4 Aug 2016 08:15:20 +0000 (01:15 -0700)]
Merge branch 'vendor/OPENSSH'

7 years agoImport OpenSSH-7.3p1.
Peter Avalos [Thu, 4 Aug 2016 06:09:16 +0000 (23:09 -0700)]
Import OpenSSH-7.3p1.

7 years agoRemove most local modifications from OpenSSH.
Peter Avalos [Thu, 4 Aug 2016 01:25:04 +0000 (18:25 -0700)]
Remove most local modifications from OpenSSH.

This primarily removes the HPN patches. It's become too cumbersome to
maintain these patches as demonstrated by the fact that we haven't
updated OpenSSH in quite some time. If people want additional
functionality in their OpenSSH, it's available in dports
(security/openssh).

Instead of just silently ignoring removed options in people's
configurations, I decided to treat these as errors so that the admin
will need to decide to remove it from their configuration or install the
dport to get the functionality back.

7 years agomake upgrade: Remove no longer existing manpages after the OpenSSL upgrade.
Sascha Wildner [Thu, 4 Aug 2016 06:53:34 +0000 (08:53 +0200)]
make upgrade: Remove no longer existing manpages after the OpenSSL upgrade.

7 years agostrftime.3: Remove extra whitespace.
Sascha Wildner [Thu, 4 Aug 2016 06:53:21 +0000 (08:53 +0200)]
strftime.3: Remove extra whitespace.

7 years agokernel - Fix lwp_fork/exit race (2) (vkernel)
Matthew Dillon [Thu, 4 Aug 2016 02:38:11 +0000 (19:38 -0700)]
kernel - Fix lwp_fork/exit race (2) (vkernel)

* Fix same race as before, in vkernel also.

7 years agolibcrypto(3): Set CC variable for Perl scripts.
Peter Avalos [Wed, 3 Aug 2016 20:22:16 +0000 (13:22 -0700)]
libcrypto(3): Set CC variable for Perl scripts.

This detects assembler/compiler capabilities.

Obtained-from:   FreeBSD

7 years agodrm/linux: kernel_ulong_t is defined in linux/mod_devicetable.h
François Tigeot [Wed, 3 Aug 2016 19:35:34 +0000 (21:35 +0200)]
drm/linux: kernel_ulong_t is defined in linux/mod_devicetable.h

7 years agoFix typo.
Peter Avalos [Wed, 3 Aug 2016 19:16:05 +0000 (12:16 -0700)]
Fix typo.

7 years agolibcrypto(3): Remove some cruft from when we supported 32-bit.
Peter Avalos [Wed, 3 Aug 2016 19:11:29 +0000 (12:11 -0700)]
libcrypto(3): Remove some cruft from when we supported 32-bit.

7 years agoAdd IDEA support for libcrypto(3).
Peter Avalos [Wed, 3 Aug 2016 19:05:00 +0000 (12:05 -0700)]
Add IDEA support for libcrypto(3).

The patent expired years ago.

7 years agovkernel: Add a simple pagezero() macro (unbreaks build).
Sascha Wildner [Wed, 3 Aug 2016 18:09:42 +0000 (20:09 +0200)]
vkernel: Add a simple pagezero() macro (unbreaks build).

7 years agoUpdate files for OpenSSL-1.0.2h import.
Peter Avalos [Wed, 3 Aug 2016 09:52:16 +0000 (02:52 -0700)]
Update files for OpenSSL-1.0.2h import.

Make the jump to 1.0.2, because support for 1.0.1 ends at the end of
this year.

7 years agoMerge branch 'vendor/OPENSSL'
Peter Avalos [Wed, 3 Aug 2016 08:18:34 +0000 (01:18 -0700)]
Merge branch 'vendor/OPENSSL'

7 years agoImport OpenSSL-1.0.2h. vendor/OPENSSL
Peter Avalos [Wed, 3 Aug 2016 08:02:32 +0000 (01:02 -0700)]
Import OpenSSL-1.0.2h.

7 years agokernel - Fix lwp_fork/exit race
Matthew Dillon [Wed, 3 Aug 2016 05:28:54 +0000 (22:28 -0700)]
kernel - Fix lwp_fork/exit race

* In a multi-threaded program it is possible for the exit sequence to
  deadlock if one thread is trying to exit (exit the entire process)
  while another thread is simultaniously creating a new thread.

* Fix the issue by having the new thread checking for the exit condition and
  sending a SIGKILL to itself.  And kprintf() a message when it happens.

7 years agolibrt/aio: #ifndef notyet -> #if 0 /* not yet */
Sascha Wildner [Wed, 3 Aug 2016 03:39:50 +0000 (05:39 +0200)]
librt/aio: #ifndef notyet -> #if 0 /* not yet */

7 years agoAdjust a couple of manual pages to the recent header changes.
Sascha Wildner [Wed, 3 Aug 2016 02:59:16 +0000 (04:59 +0200)]
Adjust a couple of manual pages to the recent header changes.

7 years ago<sys/types.h>: Use __BSD_VISIBLE instead of !_POSIX_SOURCE.
Sascha Wildner [Wed, 3 Aug 2016 02:48:08 +0000 (04:48 +0200)]
<sys/types.h>: Use __BSD_VISIBLE instead of !_POSIX_SOURCE.

7 years ago<sys/stat.h>: Clean up the POSIX namespace.
Sascha Wildner [Wed, 3 Aug 2016 02:47:13 +0000 (04:47 +0200)]
<sys/stat.h>: Clean up the POSIX namespace.

* Use __BSD_VISIBLE instead of !_POSIX_SOURCE.

* Reduce visibility of some BSD specific stuff.

* Expand visibility of fchmod() and lstat().

7 years ago<sys/aio.h>: Remove unneeded includes (cleans up namespace).
Sascha Wildner [Wed, 3 Aug 2016 02:46:23 +0000 (04:46 +0200)]
<sys/aio.h>: Remove unneeded includes (cleans up namespace).

7 years ago<sys/ipc.h>: Some POSIX adjustments.
Sascha Wildner [Wed, 3 Aug 2016 02:45:14 +0000 (04:45 +0200)]
<sys/ipc.h>: Some POSIX adjustments.

* Use standard types.

* Reduce visibility of some BSD specific stuff.

* While here, add missing parentheses around a macro argument.

7 years ago<sys/shm.h>: Some POSIX adjustments.
Sascha Wildner [Wed, 3 Aug 2016 02:43:40 +0000 (04:43 +0200)]
<sys/shm.h>: Some POSIX adjustments.

* Define pid_t, size_t and time_t as required.

* Put BSD specific stuff under __BSD_VISIBLE.

7 years ago<sys/sem.h>: Some POSIX adjustments.
Sascha Wildner [Wed, 3 Aug 2016 02:42:14 +0000 (04:42 +0200)]
<sys/sem.h>: Some POSIX adjustments.

* Define pid_t, size_t and time_t as required.

* Put BSD specific stuff under __BSD_VISIBLE.

* Use standard types.

7 years ago<sys/msg.h>: Some POSIX adjustments.
Sascha Wildner [Wed, 3 Aug 2016 02:41:14 +0000 (04:41 +0200)]
<sys/msg.h>: Some POSIX adjustments.

* Define msglen_t and msgqnum_t and use them (no size change).

* Define pid_t, size_t, ssize_t and time_t as required.

* Put BSD specific stuff under __BSD_VISIBLE.

7 years ago<netinet/tcp.h>: Clean up the POSIX namespace a bit.
Sascha Wildner [Wed, 3 Aug 2016 02:39:47 +0000 (04:39 +0200)]
<netinet/tcp.h>: Clean up the POSIX namespace a bit.

7 years agoClean up whitespace in a few headers (no functional change).
Sascha Wildner [Wed, 3 Aug 2016 02:36:12 +0000 (04:36 +0200)]
Clean up whitespace in a few headers (no functional change).

<netinet/tcp.h>
<sys/aio.h>
<sys/ipc.h>
<sys/msg.h>
<sys/sem.h>
<sys/shm.h>
<sys/stat.h>
<sys/types.h>

In preparation for namespace cleanup.

7 years agokernel - Remove PG_ZERO and zeroidle (page-zeroing) entirely
Matthew Dillon [Wed, 3 Aug 2016 00:41:08 +0000 (17:41 -0700)]
kernel - Remove PG_ZERO and zeroidle (page-zeroing) entirely

* Remove the PG_ZERO flag and remove all page-zeroing optimizations,
  entirely.  Aftering doing a substantial amount of testing, these
  optimizations, which existed all the way back to CSRG BSD, no longer
  provide any benefit on a modern system.

  - Pre-zeroing a page only takes 80ns on a modern cpu.  vm_fault overhead
    in general is ~at least 1 microscond.

  - Pre-zeroing a page leads to a cold-cache case on-use, forcing the fault
    source (e.g. a userland program) to actually get the data from main
    memory in its likely immediate use of the faulted page, reducing
    performance.

  - Zeroing the page at fault-time is actually more optimal because it does
    not require any reading of dynamic ram and leaves the cache hot.

  - Multiple synth and build tests show that active idle-time zeroing of
    pages actually reduces performance somewhat and incidental allocations
    of already-zerod pages (from page-table tear-downs) do not affect
    performance in any meaningful way.

* Remove bcopyi() and obbcopy() -> collapse into bcopy().  These other
  versions existed because bcopy() used to be specially-optimized and
  could not be used in all situations.  That is no longer true.

* Remove bcopy function pointer argument to m_devget().  It is no longer
  used.  This function existed to help support ancient drivers which might
  have needed a special memory copy to read and write mapped data.  It has
  long been supplanted by BUSDMA.

7 years agokernel - Cleanup vm_page_pcpu_cache()
Matthew Dillon [Mon, 1 Aug 2016 20:03:52 +0000 (13:03 -0700)]
kernel - Cleanup vm_page_pcpu_cache()

* Remove the empty vm_page_pcpu_cache() function and related call.  Page
  affinity is handled by the vm_page_queues[] array now.

7 years agodrm/linux: Add linux/kobject.h
François Tigeot [Sun, 31 Jul 2016 15:45:29 +0000 (17:45 +0200)]
drm/linux: Add linux/kobject.h

7 years agokernel - Refactor cpu localization for VM page allocations (3)
Matthew Dillon [Sun, 31 Jul 2016 03:40:06 +0000 (20:40 -0700)]
kernel - Refactor cpu localization for VM page allocations (3)

* Instead of iterating the cpus in the mask starting at cpu #0, iterate
  starting at mycpu to the end, then from 0 to mycpu - 1.

  This fixes random masked wakeups from favoring lower-numbered cpus.

* The user process scheduler (usched_dfly) was favoring lower-numbered
  cpus due to a bug in the simple selection algorithm, causing forked
  processes to initially weight improperly.  A high fork or fork/exec
  rate skewed the way the cpus were loaded.

  Fix this by correctly scanning cpus from the (scancpu) rover.

* For now, use a random 'previous' affinity for initially scheduling a
  fork.

7 years agodrm/linux: Add vmap()
François Tigeot [Sun, 31 Jul 2016 06:06:36 +0000 (08:06 +0200)]
drm/linux: Add vmap()

7 years agoSync ACPICA with Intel's version 20160729.
Sascha Wildner [Sat, 30 Jul 2016 20:19:24 +0000 (22:19 +0200)]
Sync ACPICA with Intel's version 20160729.

* Restructured and standardized the C library configuration for
  ACPICA.

* AML interpreter: Allows for execution of so-called "executable"
  AML code outside of control methods, not just at the module level
  (top level) but also within any scope declared outside of a
  control method - Scope{}, Device{}, Processor{}, PowerResource{},
  and ThermalZone{}. Lv Zheng.

* iASL: Add full support for the RASF ACPI table (RAS Features Table).

* iASL: Allows for compilation/disassembly of so-called "executable"
  AML code (see above).

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

7 years agokernel - Refactor cpu localization for VM page allocations (2)
Matthew Dillon [Sat, 30 Jul 2016 19:30:24 +0000 (12:30 -0700)]
kernel - Refactor cpu localization for VM page allocations (2)

* Finish up the refactoring.  Localize backoffs for search failures
  by doing a masked domain search.  This avoids bleeding into non-local
  page queues until we've completely exhausted our local queues,
  regardess of the starting pg_color index.

* We try to maintain 16-way set associativity for VM page allocations
  even if the topology does not allow us to do it perfect.  So, for
  example, a 4-socket x 12-core (48-core) opteron can break the 256
  queues into 4 x 64 queues, then split the 12-cores per socket into
  sets of 3 giving 16 queues (the minimum) to each set of 3 cores.

* Refactor the page-zeroing code to only check the localized area.
  This fixes a number of issues related to the zerod pages in the
  queues winding up severely unbalanced.  Other cpus in the local
  group can help replentish a particular cpu's pre-zerod pages but
  we intentionally allow a heavy user to exhaust the pages.

* Adjust the cpu topology code to normalize the physical package id.
  Some machines start at 1, some machines start at 0.  Normalize
  everything to start at 0.

7 years agokernel - cleanup vfs_cache debugging
Matthew Dillon [Sat, 30 Jul 2016 19:27:09 +0000 (12:27 -0700)]
kernel - cleanup vfs_cache debugging

* Remove the deep namecache recursion warning, we've taken care of it
  properly for a while now so we don't need to know when it happens any
  more.

* Augment the cache_inval_internal warnings with more information.

7 years agoif_iwm - Fix iwm_poll_bit() usage in iwm_stop_device().
Imre Vadász [Sat, 30 Jul 2016 10:32:26 +0000 (12:32 +0200)]
if_iwm - Fix iwm_poll_bit() usage in iwm_stop_device().

* The iwm(4) iwm_poll_bit() returns 1 on success and 0 on failure,
  whereas iwl_poll_bit() in Linux iwlwifi returns >= 0 on success and
  < 0 on failure.

7 years agokernel - Refactor cpu localization for VM page allocations
Matthew Dillon [Sat, 30 Jul 2016 00:03:22 +0000 (17:03 -0700)]
kernel - Refactor cpu localization for VM page allocations

* Change how cpu localization works.  The old scheme was extremely unbalanced
  in terms of vm_page_queue[] load.

  The new scheme uses cpu topology information to break the vm_page_queue[]
  down into major blocks based on the physical package id, minor blocks
  based on the core id in each physical package, and then by 1's based on
  (pindex + object->pg_color).

  If PQ_L2_SIZE is not big enough such that 16-way operation is attainable
  by physical and core id, we break the queue down only by physical id.

  Note that the core id is a real core count, not a cpu thread count, so
  an 8-core/16-thread x 2 socket xeon system will just fit in the 16-way
  requirement (there are 256 PQ_FREE queues).

* When a particular queue does not have a free page, iterate nearby queues
  start at +/- 1 (before we started at +/- PQ_L2_SIZE/2), in an attempt to
  retain as much locality as possible.  This won't be perfect but it should
  be good enough.

* Also fix an issue with the idlezero counters.

7 years agosystat - Adjust extended vmstats display
Matthew Dillon [Fri, 29 Jul 2016 21:59:15 +0000 (14:59 -0700)]
systat - Adjust extended vmstats display

* When the number of devices are few enough (or you explicitly specify
  just a few disk devices, or one), there is enough room for the
  extended vmstats display.  Make some adjustments to this display.

* Display values in bytes (K, M, G, etc) instead of pages like the other
  fields.

* Rename zfod to nzfod and subtract-away ozfod when displaying nzfod
  (only in the extended display), so the viewer doesn't have to do the
  subtraction in his head.

7 years agokernel - Reduce memory testing and early-boot zeroing.
Matthew Dillon [Fri, 29 Jul 2016 20:29:03 +0000 (13:29 -0700)]
kernel - Reduce memory testing and early-boot zeroing.

* Reduce the amount of memory testing and early-boot zeroing that
  we do, improving boot times on systems with large amounts of memory.

* Fix race in the page zeroing count.

* Refactor the VM zeroidle code.  Instead of having just one kernel thread,
  have one on each cpu.

  This significantly increases the rate at which the machine can eat up
  idle cycles to pre-zero pages in the cold path, improving performance
  in the hot-path (normal) page allocations which request zerod pages.

* On systems with a lot of cpus there is usually a little idle time (e.g.
  0.1%) on a few of the cpus, even under extreme loads.  At the same time,
  such loads might also imply a lot of zfod faults requiring zero'd pages.

  On our 48-core opteron we see a zfod rate of 1.0 to 1.5 GBytes/sec and
  a page-freeing rate of 1.3 - 2.5 GBytes/sec.  Distributing the page
  zeroing code and eating up these miniscule bits of idle improves the
  kernel's ability to provide a pre-zerod page (vs having to zero-it in
  the hot path) significantly.

  Under the synth test load the kernel was still able to provide 400-700
  MBytes/sec worth of pre-zerod pages whereas before this change the kernel
  was only able to provide 20 MBytes/sec worth of pre-zerod pages.

7 years agokernel - Cleanup namecache stall messages on console
Matthew Dillon [Fri, 29 Jul 2016 17:22:53 +0000 (10:22 -0700)]
kernel - Cleanup namecache stall messages on console

* Report the proper elapsed time and also include td->td_comm
  in the printed output on the console.

7 years agokernel - Fix rare tsleep/callout race
Matthew Dillon [Fri, 29 Jul 2016 17:02:50 +0000 (10:02 -0700)]
kernel - Fix rare tsleep/callout race

* Fix a rare tsleep/callout race.  The callout timer can trigger before
  the tsleep() releases its lwp_token (or if someone else holds the
  calling thread's lwp_token).

  This case is detected, but failed to adjust lwp_stat before
  descheduling and switching away.  This resulted in an endless sleep.

7 years agomktemp.3: Improve the manpage, add mklinks.
zrj [Fri, 29 Jul 2016 07:12:39 +0000 (10:12 +0300)]
mktemp.3: Improve the manpage, add mklinks.

Fix SYNOPSIS, remove outdated information and clarify availability.

Taken-from: FreeBSD

7 years agomdoc.local: Add DragonFly 4.6 for future reference.
zrj [Fri, 29 Jul 2016 07:27:22 +0000 (10:27 +0300)]
mdoc.local: Add DragonFly 4.6 for future reference.

7 years agohyperv/vmbus: Passthrough interrupt resource allocation to nexus
Sepherosa Ziehau [Fri, 29 Jul 2016 08:56:10 +0000 (16:56 +0800)]
hyperv/vmbus: Passthrough interrupt resource allocation to nexus

This greatly simplies interrupt allocation.  And reenable the interrupt
resource not found warning in acpi.

7 years agolibthread_xu - Don't override vfork()
Matthew Dillon [Fri, 29 Jul 2016 01:05:42 +0000 (18:05 -0700)]
libthread_xu - Don't override vfork()

* Allow vfork() to operate normally in a threaded environment.  The kernel
  can handle multiple concurrent vfork()s by different threads (only the
  calling thread blocks, same as how Linux deals with it).

7 years agomktemp.3: Fix a typo and bump .Dd
Sascha Wildner [Thu, 28 Jul 2016 20:16:33 +0000 (22:16 +0200)]
mktemp.3: Fix a typo and bump .Dd

7 years agokernel - Be nicer to pthreads in vfork()
Matthew Dillon [Thu, 28 Jul 2016 17:12:39 +0000 (10:12 -0700)]
kernel - Be nicer to pthreads in vfork()

* When vfork()ing, give the new sub-process's lwp the same TID as the one
  that called vfork().  Even though user processes are not supposed to do
  anything sophisticated inside a vfork() prior to exec()ing, some things
  such as fileno() having to lock in a threaded environment might not be
  apparent to the programmer.

* By giving the sub-process the same TID, operations done inside the
  vfork() prior to exec that interact with pthreads will not confuse
  pthreads and cause corruption due to e.g. TID 0 clashing with TID 0
  running in the parent that is running concurrently.

7 years agoed(1): Sync with FreeBSD.
Sascha Wildner [Thu, 28 Jul 2016 17:10:40 +0000 (19:10 +0200)]
ed(1): Sync with FreeBSD.

7 years agoed(1): Remove handling of non-POSIX environment.
Sascha Wildner [Thu, 28 Jul 2016 17:18:46 +0000 (19:18 +0200)]
ed(1): Remove handling of non-POSIX environment.

7 years agolibc - Fix more popen() issues
Matthew Dillon [Thu, 28 Jul 2016 17:03:08 +0000 (10:03 -0700)]
libc - Fix more popen() issues

* Fix a file descriptor leak between popen() and pclose() in a threaded
  environment.  The control structure is removed from the list, then the
  list is unlocked, then the file is closed.  This can race a popen
  inbetween the unlock and the closure.

* Do not use fileno() inside vfork, it is a complex function in a threaded
  environment which could lead to corruption since the vfork()'s lwp id may
  clash with one from the parent process.

7 years agokernel - Fix getpid() issue in vfork() when threaded
Matthew Dillon [Thu, 28 Jul 2016 16:39:57 +0000 (09:39 -0700)]
kernel - Fix getpid() issue in vfork() when threaded

* upmap->invfork was a 0 or 1, but in a threaded program it is possible
  for multiple threads to be in vfork() at the same time.  Change invfork
  to a count.

* Fixes improper getpid() return when concurrent vfork()s are occuring in
  a threaded program.

7 years agodrm/linux: Clean-up pci_resource_start()
François Tigeot [Thu, 28 Jul 2016 06:56:12 +0000 (08:56 +0200)]
drm/linux: Clean-up pci_resource_start()

Making it less verbose

7 years agosystat - Restrict %rip sampling to root
Matthew Dillon [Wed, 27 Jul 2016 23:22:11 +0000 (16:22 -0700)]
systat - Restrict %rip sampling to root

* Only allow root to sample the %rip and %rsp on all cpus.  The sysctl will
  not sample and return 0 for these fields if the uid is not root.

  This is for security, as %rip sampling can be used to break cryptographic
  keys.

* systat -pv 1 will not display the sampling columns if the sample value
  is 0.

7 years agotest - Add umtx1 code
Matthew Dillon [Wed, 27 Jul 2016 18:22:56 +0000 (11:22 -0700)]
test - Add umtx1 code

* Add umtx1 code - fast context switch tests

* Make blib.c thread-safe.

7 years agolibc - Fix numerous fork/exec*() leaks, also add mkostemp() and mkostemps().
Matthew Dillon [Wed, 27 Jul 2016 18:13:44 +0000 (11:13 -0700)]
libc - Fix numerous fork/exec*() leaks, also add mkostemp() and mkostemps().

* Use O_CLOEXEC in many places to prevent temporary descriptors from leaking
  into fork/exec'd code (e.g. in multi-threaded situations).

* Note that the popen code will close any other popen()'d descriptors in
  the child process that it forks just prior to exec.  However, there was
  a descriptor leak where another thread issuing popen() at the same time
  could leak the descriptors into their exec.

  Use O_CLOEXEC to close this hole.

* popen() now accepts the 'e' flag (i.e. "re") to retain O_CLOEXEC in the
  returned descriptor.  Normal "r" (etc) will clear O_CLOEXEC in the returned
  descriptor.

  Note that normal "r" modes are still fine for most use cases since popen
  properly closes other popen()d descriptors in the fork().  BUT!! If the
  threaded program calls exec*() in other ways, such descriptors may
  unintentionally be passed onto sub-processes.  So consider using "re".

* Add mkostemp() and mkostemps() to allow O_CLOEXEC to be passed in,
  closing a thread race that would otherwise leak the temporary descriptor
  into other fork/exec()s.

Taken-from: Mostly taken from FreeBSD

7 years agokernel - Disable lwp->lwp optimization in thread switcher
Matthew Dillon [Tue, 26 Jul 2016 23:24:14 +0000 (16:24 -0700)]
kernel - Disable lwp->lwp optimization in thread switcher

* Put #ifdef around the existing lwp->lwp switch optimization and then
  disable it.  This optimizations tries to avoid reloading %cr3 and avoid
  pmap->pm_active atomic ops when switching to a lwp that shares the same
  process.

  This optimization is no longer applicable on multi-core systems as such
  switches are very rare.  LWPs are usually distributed across multiple cores
  so rarely does one switch to another on the same core (and in cpu-bound
  situations, the scheduler will already be in batch mode).  The conditionals
  in the optimization, on the other hand, did measurably (just slightly)
  reduce performance for normal switches.  So turn it off.

* Implement an optimization for interrupt preemptions, but disable it for
  now.  I want to keep the code handy but so far my tests show no improvement
  in performance with huge interrupt rates (from nvme devices), so it is
  #undef'd for now.

7 years agokernel - Minor cleanup swtch.s
Matthew Dillon [Tue, 26 Jul 2016 20:12:51 +0000 (13:12 -0700)]
kernel - Minor cleanup swtch.s

* Minor cleanup

7 years agokernel - Fix namecache race & panic
Matthew Dillon [Tue, 26 Jul 2016 20:01:27 +0000 (13:01 -0700)]
kernel - Fix namecache race & panic

* Properly lock and re-check the parent association when iterating its
  children, fixing a bug in a code path associated with unmounting
  filesystems.

  The code improperly assumed that there could be no races because there
  are were no accessors left.  In fact, under heavy loads, the namecache
  scan in this routine can race against the negative-name-cache management
  code.

* Generally speaking can only happen when lots of mounts and unmounts are
  done under heavy loads (for example, tmpfs mounts during a poudriere or
  synth run).

7 years agokernel - Reduce atomic ops in switch code
Matthew Dillon [Tue, 26 Jul 2016 19:56:31 +0000 (12:56 -0700)]
kernel - Reduce atomic ops in switch code

* Instead of using four atomic 'and' ops and four atomic 'or' ops, use
  one atomic 'and' and one atomic 'or' when adjusting the pmap->pm_active.

* Store the array index and simplified cpu mask in the globaldata structure
  for the above operation.

7 years agokernel - refactor CPUMASK_ADDR()
Matthew Dillon [Tue, 26 Jul 2016 19:53:39 +0000 (12:53 -0700)]
kernel - refactor CPUMASK_ADDR()

* Refactor CPUMASK_ADDR(), removing the conditionals and just indexing the
  array as appropriate.

7 years agokernel - Fix VM bug introduced earlier this month
Matthew Dillon [Tue, 26 Jul 2016 00:06:52 +0000 (17:06 -0700)]
kernel - Fix VM bug introduced earlier this month

* Adding the yields to the VM page teardown and related code was a great
  idea (~Jul 10th commits), but it also introduced a bug where the page
  could get torn-out from under the scan due to the vm_object's token being
  temporarily lost.

* Re-check page object ownership and (when applicable) its pindex before
  acting on the page.

7 years agosystat - Refactor memory displays for systat -vm
Matthew Dillon [Mon, 25 Jul 2016 23:05:40 +0000 (16:05 -0700)]
systat - Refactor memory displays for systat -vm

* Report paging and swap activity in bytes and I/Os instead of pages and
  I/Os (I/Os usually matched pages).

* Report zfod and cow in bytes instead of pages.

* Replace the REAL and VIRTUAL section with something that makes a bit
  more sense.

  Report active memory (this is just active pages), kernel memory
  (currently just wired but we can add more stuff later), Free
  (inactive + cache + free is considered free/freeable memory), and
  total system memory as reported at boot time.

  Report total RSS - basically how many pages the system is mapping to
  user processes.  Due to sharing this can be a large value.

  Do not try to report aggregate VSZ as there's no point in doing so
  any more.

  Reported swap usage on the main -vm display as well as total swap
  allocated.

* Fix display bug in systat -sw display.

* Add "nvme" device type match for the disk display.

7 years agoif_iwm - Fix inverted logic in iwm_tx().
Imre Vadász [Sun, 24 Jul 2016 19:11:29 +0000 (21:11 +0200)]
if_iwm - Fix inverted logic in iwm_tx().

The PROT_REQUIRE flag in should be set for data frames above a certain
length, but we were setting it for !data frames above a certain length,
which makes no sense at all.

Taken-From: OpenBSD, Linux iwlwifi

7 years agokernel - Fix mountctl() / unmount race
Matthew Dillon [Mon, 25 Jul 2016 18:31:04 +0000 (11:31 -0700)]
kernel - Fix mountctl() / unmount race

* kern_mountctl() now properly checks to see if an unmount is in-progress
  and returns an error, fixing a later panic.

7 years agosysconf.3: Fix typo.
Sascha Wildner [Mon, 25 Jul 2016 19:46:01 +0000 (21:46 +0200)]
sysconf.3: Fix typo.

7 years agolibc/strptime: Return NULL, not 0, since the function returns char *.
Sascha Wildner [Mon, 25 Jul 2016 18:43:03 +0000 (20:43 +0200)]
libc/strptime: Return NULL, not 0, since the function returns char *.

While here, accept 'UTC' for %Z as well.

Taken-from: FreeBSD