dragonfly.git
12 years agoioapic/x86_64: Add missing imen_lock/unlock
Sepherosa Ziehau [Thu, 3 Nov 2011 14:58:32 +0000 (22:58 +0800)]
ioapic/x86_64: Add missing imen_lock/unlock

12 years agotcp: Allow pure asynchronized pru_send
Sepherosa Ziehau [Thu, 3 Nov 2011 13:38:49 +0000 (21:38 +0800)]
tcp: Allow pure asynchronized pru_send

- net.inet.tcp.sosnd_async is added to allow pure asynchronized pru_send.
  It is default to off currently.
- To prevent soclose() and soshutdown() from interfering TCP processing on
  the loopback interface, so_pru_sync() is added, which will make sure
  that so_pru_disconnect() and so_pru_shutdown() run only after all of the
  previous sent packets had been requeued to netisr (the semantics of the
  original half asynchronized pru_send).

12 years agogcc41: Add a missing file to CLEANFILES.
Sascha Wildner [Thu, 3 Nov 2011 10:19:20 +0000 (11:19 +0100)]
gcc41: Add a missing file to CLEANFILES.

12 years agoloader.8: Fix typo.
Sascha Wildner [Wed, 2 Nov 2011 23:53:59 +0000 (00:53 +0100)]
loader.8: Fix typo.

12 years agokernel - reformulate the maxusers auto-sizing calculation
Matthew Dillon [Wed, 2 Nov 2011 06:44:37 +0000 (23:44 -0700)]
kernel - reformulate the maxusers auto-sizing calculation

* Reformulate the maxusers auto-sizing calculation, which is used as a
  basis for mbufs and mbuf cluster calculations.  Base the values on
  limsize (basically the lower of KVM vs physical memory).

* Remove artificial limits.

* This basically effects x86-64 systems with > 4G of ram, greatly
  increasing the default maxusers value and related mbuf limits.

12 years agokernel - Fix spin-based msgports
Matthew Dillon [Wed, 2 Nov 2011 06:43:11 +0000 (23:43 -0700)]
kernel - Fix spin-based msgports

* LWKT threads can use thread/IPI or spin-based message ports.  The
  default is thread-based.  Spin-based ports had numerous problems which
  would result in panics.  This commit fixes those panics and makes the
  spinlock version viable.

* However, currently there is no performance improvement so the default
  is staying as it was.

12 years agokernel - Fix x86-64 pmap race
Matthew Dillon [Wed, 2 Nov 2011 06:42:06 +0000 (23:42 -0700)]
kernel - Fix x86-64 pmap race

* Fix a x86-64 pmap race where a pte can get ripped out from under
  the pmap_remove*() code.  Recheck the pte after locking pt_pv.

12 years agokernel - Major MP work on kq and signal processing
Matthew Dillon [Wed, 2 Nov 2011 06:38:42 +0000 (23:38 -0700)]
kernel - Major MP work on kq and signal processing

* Remove the global kq_token and move to a per-kq and per-kqlist
  pool token.  This greatly improves postgresql and mysql performance
  on MP systems.

* Adjust signal processing tokens to be per-LWP instead of per-PROC.
  Signal delivery still utilizes a per-proc token but signal distribution
  now uses a per-LWP token, which allows the trap code to only lock the
  LWP when checking for pending signals.

  This also significantly improves database performance.

* The socket code also now uses only its per-socket pool token instead
  of kq_token for its kq operations.  kq handles its own tokens.

12 years agokernel - add MAP_SIZEALIGN
Matthew Dillon [Wed, 2 Nov 2011 06:33:40 +0000 (23:33 -0700)]
kernel - add MAP_SIZEALIGN

* Add a mmap() MAP_SIZEALIGN flag which requests alignment the same
  as the size argument (different from Solaris's MAP_ALIGN which uses
  the address hint).

* Will be used in upcoming libc/stdlib/dmalloc.c work.  The dmalloc code
  will work without it just fine, too..

12 years agobuildkernel - remove COMPAT_43 and COMPAT_DF12
Matthew Dillon [Wed, 2 Nov 2011 06:31:50 +0000 (23:31 -0700)]
buildkernel - remove COMPAT_43 and COMPAT_DF12

* Remove old compats that we really should not be compiling into kernels
  any more.

  In particular, the old getpid() did some weird things which created
  unnecessary slowdowns on MP systems.

12 years agokernel - Add bsflong() asm functions
Matthew Dillon [Wed, 2 Nov 2011 06:21:59 +0000 (23:21 -0700)]
kernel - Add bsflong() asm functions

* Add bsflong() inline asm functions which operate on the 'long' data type.

12 years agoBump __DragonFly_version for the removal of <crypt.h> (to be safe).
Sascha Wildner [Tue, 1 Nov 2011 21:29:17 +0000 (22:29 +0100)]
Bump __DragonFly_version for the removal of <crypt.h> (to be safe).

12 years agopf/pf_ioctl.c: Fix whitespace error
Jan Lentfer [Tue, 1 Nov 2011 21:02:29 +0000 (22:02 +0100)]
pf/pf_ioctl.c: Fix whitespace error

12 years agoUnbreak LINT.
Sascha Wildner [Tue, 1 Nov 2011 10:34:17 +0000 (11:34 +0100)]
Unbreak LINT.

12 years agopf: convert to use kmalloc instead of zalloc
Jan Lentfer [Thu, 6 Jan 2011 10:03:55 +0000 (11:03 +0100)]
pf: convert to use kmalloc instead of zalloc

12 years agokernel - Fix mbuf cluster statistics, fix type change bug
Matthew Dillon [Mon, 31 Oct 2011 21:18:52 +0000 (14:18 -0700)]
kernel - Fix mbuf cluster statistics, fix type change bug

* The mbuf cluster statistics were not properly handling a sharecount race case,
  causing the cluster count to continuously increase under heavy loads.

* atomic_set_short() was being improperly used to set m->m_type, causing the type field
  to collect a logical OR of changeouts.  Just set it normally.

* We don't need to use atomic ops for per-cpu stats updates.

Reported-by: Peter Avalos <peter@theshell.com>, "Samuel J. Greear" <sjg@evilcode.net>
12 years agoRemove various unneeded definitions of abs() in userland.
Sascha Wildner [Mon, 31 Oct 2011 20:00:42 +0000 (21:00 +0100)]
Remove various unneeded definitions of abs() in userland.

12 years agokernel - Expand panic message for invalid pte case
Matthew Dillon [Mon, 31 Oct 2011 19:55:46 +0000 (12:55 -0700)]
kernel - Expand panic message for invalid pte case

* Expand a panic assertion to provide more information.

12 years agokernel - Fix missing token release in msync() error path
Matthew Dillon [Mon, 31 Oct 2011 18:16:59 +0000 (11:16 -0700)]
kernel - Fix missing token release in msync() error path

* Fix a missing token release in the msync() error path that would lead
  to a panic in the syscall return code.

Reported-by: swildner
12 years agoFix a macro argument expansion bug
Maurizio Lombardi [Mon, 31 Oct 2011 11:01:49 +0000 (12:01 +0100)]
Fix a macro argument expansion bug

12 years agoadduser(8): Sync with FreeBSD.
Sascha Wildner [Mon, 31 Oct 2011 15:43:37 +0000 (16:43 +0100)]
adduser(8): Sync with FreeBSD.

Submitted-by: Juan Francisco Cantero Hurtado <iam@juanfra.info>
Dragonfly-bug: <http://bugs.dragonflybsd.org/issue2159>
               <http://bugs.dragonflybsd.org/issue2160>

12 years agoFix x86_64 buildkernel with 'options DIAGNOSTIC'.
Sascha Wildner [Mon, 31 Oct 2011 12:00:24 +0000 (13:00 +0100)]
Fix x86_64 buildkernel with 'options DIAGNOSTIC'.

12 years agoFix buildkernel without 'options INVARIANTS'.
Sascha Wildner [Mon, 31 Oct 2011 00:02:04 +0000 (01:02 +0100)]
Fix buildkernel without 'options INVARIANTS'.

Submitted-by: Joel K. Pettersson <joelkpettersson@gmail.com>
Dragonfly-bug: <http://bugs.dragonflybsd.org/issue2172>

12 years agoRemove /usr/include/crypt.h via 'make upgrade'.
Sascha Wildner [Sun, 30 Oct 2011 20:20:32 +0000 (21:20 +0100)]
Remove /usr/include/crypt.h via 'make upgrade'.

12 years agoRevert "libcrypt - install crypt.h header"
Sascha Wildner [Sun, 30 Oct 2011 20:16:07 +0000 (21:16 +0100)]
Revert "libcrypt - install crypt.h header"

This reverts commit b4ed82ece2b69f4a6711d35c5e42938dfc1d804c.

BSDs have libcrypt and the prototypes for its functions are in
<unistd.h>. The reason we had crypt.h installed for a while was
to make KDE link against libcrypt, due to a wrong check in KDE.

Unfortunately, at least one other package (chat/dircproxy)
assumed that if <crypt.h> exists, it would also find prototypes
for crypt() and friends there, which is not the case. So it
would crash on x86_64 due to defaulting to int as crypt()'s
return type (which is a pointer).

The check in KDE has been fixed since and it properly checks
for the presence of libcrypt:

https://bugs.kde.org/show_bug.cgi?id=247627

Hence this revert.

In-discussion-with: alexh

12 years agoioapic_abi/x86_64: Optimize the GSI search a little bit
Sepherosa Ziehau [Sun, 30 Oct 2011 13:50:45 +0000 (21:50 +0800)]
ioapic_abi/x86_64: Optimize the GSI search a little bit

Use the recorded max line based IRQ instead of scanning the whole
IRQ map array

12 years agoioapic_abi/x86_64: Record the max line based IRQ
Sepherosa Ziehau [Sun, 30 Oct 2011 12:27:39 +0000 (20:27 +0800)]
ioapic_abi/x86_64: Record the max line based IRQ

12 years agox86_64/ioapic_abi: Rework debug messages
Sepherosa Ziehau [Sun, 30 Oct 2011 11:18:57 +0000 (19:18 +0800)]
x86_64/ioapic_abi: Rework debug messages

12 years agogrep: Upgrade to version 2.9
John Marino [Sat, 29 Oct 2011 22:59:01 +0000 (00:59 +0200)]
grep: Upgrade to version 2.9

Release 2.9 (2011-06-21) [stable]
Release 2.8 (2011-05-13) [stable]

Bug Fixes
===================
1. echo c|grep '[c]' would fail for any c in 0x80..0xff,
   and in many locales.
   E.g., printf '\xff\n'|grep "$(printf '[\xff]')" || echo FAIL
   would print FAIL rather than the required matching line.
   [bug introduced in grep-2.6]

2. grep's interpretation of range expression is now more consistent with
   that of other tools.  [bug present since multi-byte character set
   support was introduced in 2.5.2, though the steps needed to reproduce
   it changed in grep-2.6]

3. grep erroneously returned with exit status 1 on some memory allocation
   failure. [bug present since "the beginning"]

4. grep no longer clobbers heap for an ERE like '(^| )*( |$)'
   [bug introduced in grep-2.6]

5. grep is faster on regular expressions that match multibyte characters
   in brackets (such as '[áéíóú]').

6. echo c|grep '[c]' would fail for any c in 0x80..0xff, with a uni-byte
   encoding for which the byte-to-wide-char mapping is nontrivial.  For
   example, the ISO-88591 locales are not affected, but ru_RU.KOI8-R is.
   [bug introduced in grep-2.6]

7. grep -P no longer aborts when PCRE's backtracking limit is exceeded
   Before, echo aaaaaaaaaaaaaab |grep -P '((a+)*)+$' would abort.  Now,
   it diagnoses the problem and exits with status 2.

12 years agoMerge branch 'vendor/GREP'
John Marino [Sat, 29 Oct 2011 23:57:46 +0000 (01:57 +0200)]
Merge branch 'vendor/GREP'

12 years agoUpgrade grep version 2.7 to 2.9 on the vendor branch
John Marino [Sat, 29 Oct 2011 22:00:25 +0000 (00:00 +0200)]
Upgrade grep version 2.7 to 2.9 on the vendor branch

12 years agodiff: Remove location modification from 2004
John Marino [Sat, 29 Oct 2011 20:02:12 +0000 (22:02 +0200)]
diff: Remove location modification from 2004

diffutils has been carrying this modification since version 2.8.1.  That
version was changed to support libgnuregex which has since been removed.

It appears that likely libgnuregex didn't support the
RE_NO_POSIX_BACKTRACKING option, and thus required the modification.

12 years agodiffutils: Upgrade to version 3.2
John Marino [Sat, 29 Oct 2011 17:47:23 +0000 (19:47 +0200)]
diffutils: Upgrade to version 3.2

The majority of the changes were inherited from gnulib.  There were only
a few observable differences from version 3.0:

Release 3.2 (2011-09-02) [stable]
Release 3.1 (2011-08-10) [stable]

Bug fixes
===================
diff no longer reports spurious differences merely because two entries
in the same directory have names that compare equal in the current
locale, or compare equal because --ignore-file-name-case was given.

Changes in behavior
===================
--ignore-file-name-case now applies at the top level too.
For example, "diff dir inIt" might compare "dir/Init" to "inIt".

New features
===================
diff and sdiff have a new option --ignore-trailing-space (-Z).

12 years agoMerge branch 'vendor/DIFFUTILS'
John Marino [Sat, 29 Oct 2011 19:02:07 +0000 (21:02 +0200)]
Merge branch 'vendor/DIFFUTILS'

12 years agoUpgrade diffutils from 3.0 to 3.2 on the vendor branch
John Marino [Sat, 29 Oct 2011 15:39:48 +0000 (17:39 +0200)]
Upgrade diffutils from 3.0 to 3.2 on the vendor branch

12 years agokernel - Fix LINT compilation on 32-bit
Matthew Dillon [Sat, 29 Oct 2011 18:37:03 +0000 (11:37 -0700)]
kernel - Fix LINT compilation on 32-bit

* Fix conditional debug compilation that was breaking 32-bit LINT builds

Reported-by: swildner
12 years agokernel - Fix deadlock in vm_prefault
Matthew Dillon [Sat, 29 Oct 2011 18:23:24 +0000 (11:23 -0700)]
kernel - Fix deadlock in vm_prefault

* vm_prefault*() was being called while the primary vm_fault page was
  still being held busy, which could result in a deadlock.

* Reorder the case to unbusy the primary fault page before calling
  vm_prefault().

Reported-by: tuxillo
12 years agoipcs - Make it compile w/WARNS=6
Matthew Dillon [Sat, 29 Oct 2011 18:20:34 +0000 (11:20 -0700)]
ipcs - Make it compile w/WARNS=6

* Correct misc types, verify compilation on 32 and 64 bit

12 years agoipcs: Adjust ipcs display to take into account new shared memory sizes
Jan Lentfer [Sat, 30 Apr 2011 16:51:23 +0000 (18:51 +0200)]
ipcs: Adjust ipcs display to take into account new shared memory sizes

12 years agolibhammer - Include overlooked field freebigblocks.
Antonio Huete Jimenez [Sat, 29 Oct 2011 17:27:59 +0000 (19:27 +0200)]
libhammer - Include overlooked field freebigblocks.

12 years agox86_64/nexus: Per-cpu IRQ rman
Sepherosa Ziehau [Sat, 29 Oct 2011 14:35:23 +0000 (22:35 +0800)]
x86_64/nexus: Per-cpu IRQ rman

Now interrupt thread will be pin to the same CPU as where its GSI
will go.

12 years agox86_64/ioapic: Allow GSI's target CPU to be configured
Sepherosa Ziehau [Sat, 29 Oct 2011 13:13:43 +0000 (21:13 +0800)]
x86_64/ioapic: Allow GSI's target CPU to be configured

- Tuneable hw.ioapic.gsi.X.cpu is added, which could be used to specify
  the GSI X's target CPU id
- If hw.ioapic.gsi.X is not set, then GSI X will be target to CPU Y,
  Y = X % ncpus

12 years agokernel: Add missing MODULE_VERSION()s for file systems.
Sascha Wildner [Sat, 29 Oct 2011 09:57:42 +0000 (11:57 +0200)]
kernel: Add missing MODULE_VERSION()s for file systems.

The loader will figure out by itself whether to load a module or not,
depending on whether it's already in the kernel config or not, iif
MODULE_VERSION() is present.

I.e., if MSDOSFS (that has MODULE_VERSION()) is in the config and
msdos_load="YES" is in /boot/loader.conf, msdos.ko will not be loaded
by the loader at all.

Without MODULE_VERSION() it will lead (in the best case) to whining in
dmesg like for ahci or (in the worst case) to weird behavior, such as
for nullfs:

# mount -a
null: vfsload(null): No such file or directory

Therefore, we definitely want MODULE_VERSION() for all new modules.

This commit is the first in a series to add the missing MODULE_VERSION()s.

I know that ufs is not a module, just included it for completeness' sake.

Reported-by: marino, tuxillo
12 years agoFurther shared memory adjustments to be in line with POSIX.
Sascha Wildner [Sat, 29 Oct 2011 06:12:38 +0000 (08:12 +0200)]
Further shared memory adjustments to be in line with POSIX.

* shmat()'s and shmdt()'s addr argument shall be const.

* Make struct shmid_ds's shm_nattch unsigned and define the shmatt_t
  type for it.

* More manual page adjustments.

12 years agokernel - Autosize maximum shm pages
Matthew Dillon [Sat, 29 Oct 2011 02:09:27 +0000 (19:09 -0700)]
kernel - Autosize maximum shm pages

* If not overridden with a tunable autosize sysv shm to 2/3 of available
  ram.

12 years agokernel - Fix bug in shmget()
Matthew Dillon [Sat, 29 Oct 2011 01:54:01 +0000 (18:54 -0700)]
kernel - Fix bug in shmget()

* Fix bug in shmget() which was truncating requests >= 4G.

12 years agokernel - Remove libc shm shims
Matthew Dillon [Sat, 29 Oct 2011 01:53:26 +0000 (18:53 -0700)]
kernel - Remove libc shm shims

* Remove the shims so the new system calls are used instead of shmsys().

12 years agokernel - shmget() adjustments
Matthew Dillon [Sat, 29 Oct 2011 00:37:07 +0000 (17:37 -0700)]
kernel - shmget() adjustments

* Fix prototype and manual page

12 years agokernel - regenerate system calls
Matthew Dillon [Sat, 29 Oct 2011 00:19:58 +0000 (17:19 -0700)]
kernel - regenerate system calls

* Regenerate system calls (shm_ds).

12 years agokernel - shmid_ds structure needs to change on 64-bit :-(
Matthew Dillon [Sat, 29 Oct 2011 00:17:30 +0000 (17:17 -0700)]
kernel - shmid_ds structure needs to change on 64-bit :-(

* shmid_ds had very old parameters and used 'int' for the shm segment
  size.  It has to be adjusted to use size_t to accomodate shm segments
  greater than 2GB.

  This will break binary package compatibility on 64-bit systems until
  the related packages are recompiled.

* shmget() system call now takes a size_t instead of an int.

12 years agokillall - Add support for pts specifications
Matthew Dillon [Fri, 28 Oct 2011 23:51:58 +0000 (16:51 -0700)]
killall - Add support for pts specifications

* killall -t <number> now uses /dev/pts/<number> instead of
  /dev/tty<number>.

  killall -t <alpha>* continues to use /dev/tty<alpha>*.

12 years agogcc44: Update version from 4.4.6-RELEASE to 4.4.7-20111025
John Marino [Thu, 27 Oct 2011 22:33:06 +0000 (00:33 +0200)]
gcc44: Update version from 4.4.6-RELEASE to 4.4.7-20111025

12 years agoMerge branch 'vendor/GCC44'
John Marino [Fri, 28 Oct 2011 20:08:30 +0000 (22:08 +0200)]
Merge branch 'vendor/GCC44'

12 years agoUpgrade GCC from 4.4.6-RELEASE to 4.4.7 snapshot 2011-10-25
John Marino [Thu, 27 Oct 2011 22:03:08 +0000 (00:03 +0200)]
Upgrade GCC from 4.4.6-RELEASE to 4.4.7 snapshot 2011-10-25

12 years agokernel - Fix vm_object->rb_memq race in pageout daemon
Matthew Dillon [Fri, 28 Oct 2011 17:20:26 +0000 (10:20 -0700)]
kernel - Fix vm_object->rb_memq race in pageout daemon

* We were not properly holding a VM object's token while scanning its
  rb_memq.  Hold the token properly and also assert that it is held.

12 years agokernel - Another huge HUGE VM performance improvement for many-cores
Matthew Dillon [Fri, 28 Oct 2011 16:32:51 +0000 (09:32 -0700)]
kernel - Another huge HUGE VM performance improvement for many-cores

This requires a bit of explanation.  The last single-point spinlocks in the
VM system were the spinlocks for the inactive and active queue.  Even though
these two spinlocks are only held for a very short period of time they can
create a major point of contention when one has (e.g.) 48 cores all trying
to run a VM fault at the same time.  This is an issue with multi-socket/
many-cores systems and not so much an issue with single-socket systems.

On many cores systems the global VM fault rate was limited to around
~200-250K zfod faults per second prior to this commit on our 48-core
opteron test box.  Since any single compiler process can run ~35K zfod
faults per second the maximum concurrency topped out at around ~7 concurrent
processes.

With this commit the global VM fault rate was tested to almost 900K zfod
faults per second.  That's 900,000 page faults per second (about 3.5 GBytes
per second).  Typical operation was consistently above 750K zfod faults per
second.  Maximum concurrency at a 35K fault rate per process is thus
increased from 7 processes to over 25 processes, and is probably approaching
the physical memory bus limit considering that one also has to take into
account generic page-fault overhead above and beyond the memory impact on the
page itself.

I can't stress enough how important it is to avoid contention entirely when
possible on a many-cores system.  In this case even though the VM page queue
spinlocks are only held for a very short period of time, the convulsing of
the cache coherency management between physical cpu sockets when all the
cores need to use the spinlock still created an enormous bottleneck.  Fixing
this one spinlock easily doubled concurrent compiler performance on our
48-core opteron.

* Fan-out the PQ_INACTIVE and PQ_ACTIVE page queues from 1 queue to
  256 queues, each with its own spin lock.

* This removes the last major contention point in the VM system.

* -j48 buildkernel test on monster (48-core opteron) now runs in 55 seconds.
  It was originally 167 seconds, and 101 seconds just prior to this commit.

  Concurrent compiles are now three times faster (a +200% improvement) on
  a many-cores box, with virtually no contention at all.

12 years agokernel - Clean up spinlock code, add more lwkt_yield()s
Matthew Dillon [Fri, 28 Oct 2011 16:29:28 +0000 (09:29 -0700)]
kernel - Clean up spinlock code, add more lwkt_yield()s

* Clean up some of the critical path in the spin_unlock() API

* Add a few more lwkt_yield()s in the buffer cache and vm_object cleaning
  code.

12 years agokernel - add lwkt_set_interrupt_support_thread() API
Matthew Dillon [Fri, 28 Oct 2011 16:27:20 +0000 (09:27 -0700)]
kernel - add lwkt_set_interrupt_support_thread() API

* Add a new API that may be used by a device driver's support thread
  to run the thread at a higher (near interrupt) priority and allow
  it to preempt normal threads.

* Adjust the AHCI driver's helper threads to use the new API.

12 years agoswi: Pass cpuid to swi register and unregister
Sepherosa Ziehau [Fri, 28 Oct 2011 15:47:31 +0000 (23:47 +0800)]
swi: Pass cpuid to swi register and unregister

Pass -1 as cpuid then these functions will try pin the ithread to
different CPU based on the 'intr' to be registered/unregistered.

Device and taskqueue swi ithreads' cpuid is not explicitly specified,
i.e. -1 is used, swi_vm still runs on CPU0.

12 years agointr: Pass cpuid to register_int and unregister_int
Sepherosa Ziehau [Fri, 28 Oct 2011 15:33:11 +0000 (23:33 +0800)]
intr: Pass cpuid to register_int and unregister_int

12 years agoFix i386 buildkernel.
Sascha Wildner [Fri, 28 Oct 2011 12:30:41 +0000 (14:30 +0200)]
Fix i386 buildkernel.

12 years agokernel - More many-cores SMP work
Matthew Dillon [Fri, 28 Oct 2011 06:50:51 +0000 (23:50 -0700)]
kernel - More many-cores SMP work

* Add lwkt_yield() calls in a few critical places which can hog the cpu
  on large many-cores boxes during periods of very heavy contention.  This
  allows other kernel threads on the same cpu to run and reduces symptoms
  of e.g. high ping times under certain load conditions.

* Run the callout kernel threads at the same priority as other kernel
  threads so cpu-hogging operations run from callouts can yield to
  other kernel threads (e.g. yield to the netisr threads).

* Change the vm_page_alloc() API to catch situations where the allocation
  races an insertion due to potentially blocking when dealing with
  PQ_CACHE pages.  VM_ALLOC_NULL_OK allows vm_page_alloc() to return NULL
  in this case (otherwise it will panic).

* Change vm_page_insert() to return TRUE if the insertion succeeded and
  FALSE if it didn't due to a race against another thread.

* Change the meaning of the cpuid argument to lwkt_alloc_thread() and
  lwkt_create().  A cpuid of -1 will cause the kernel to choose a cpu
  to run the thread on (instead of choosing the current cpu).

  Eventually this specification will allow dynamic migration (but not at
  the moment).

  Adjust lwp_fork() to specify the current cpu, required for initial
  LWKT calls when setting the forked thread up.

  Numerous kernel threads will now be spread around available cpus for
  now.  devfs core threads, NFS socket threads, etc.

  Interrupt threads are still fixed on cpu 0 awaiting additional work from
  Sephe.

  Put the emergency interrupt thread on the last cpu.

* Change the vm_page_grab() API.  When VM_ALLOC_ZERO is specified the
  vm_page_grab() code will automatically set an invalid page valid and
  zero it (using the PG_ZERO optimization if possible).  Pages which are
  already valid are not zero'd.

  This simplies several use cases.

* Change vm_fault_page() to enter the page into the pmap while the vm_map
  is still locked, instead of after unlocking it.  For now anyhow.

* Minor change to ensure that a deterministic value is stored in *freebuf
  in vn_fullpath().

* Minor debugging features added to help track down a x86-64 sge-fault
  issue.

12 years agozone.tab: Fix tzsetup(8) breakage.
Sascha Wildner [Fri, 28 Oct 2011 03:23:19 +0000 (05:23 +0200)]
zone.tab: Fix tzsetup(8) breakage.

If a country has >1 zones, each one needs a description.

tzdata2011m accidentally violated this rule (when Moldova was split),
which caused tzsetup(8) to exit early and whine about it:

tzsetup: /usr/share/zoneinfo/zone.tab:261: conflicting zone definition

To fix this, add the standard "most locations" for the Europe/Chisinau
zone until the next tzdata2011n arrives.

12 years agokernel - Fix deep recursion in vm_object_collapse() (2)
Matthew Dillon [Thu, 27 Oct 2011 03:14:26 +0000 (20:14 -0700)]
kernel - Fix deep recursion in vm_object_collapse() (2)

* Fix bug in previous deep recursion commit.  A chainlock was being
  released too late.

12 years agokernel - Fix memory leak when execv()ing certain paths.
Matthew Dillon [Thu, 27 Oct 2011 02:03:42 +0000 (19:03 -0700)]
kernel - Fix memory leak when execv()ing certain paths.

* Fix a memory leak when execv()ing paths prefixed with a "./"

12 years agokernel - Fix deep recursion in vm_object_collapse()
Matthew Dillon [Thu, 27 Oct 2011 01:56:39 +0000 (18:56 -0700)]
kernel - Fix deep recursion in vm_object_collapse()

* vm_object_collapse() will loop but its backing_object sometimes needs
  to be deallocated as well and this can trigger another collapse against
  a different parent object.

* Introduce vm_object_dealloc_list and friends to collect a list of objects
  requiring deallocation so the caller can run the list in a way that avoids
  a deep recursion.

Reported-by: juanfra
12 years agotest - Add code to test recent bus error issue
Matthew Dillon [Wed, 26 Oct 2011 22:48:10 +0000 (15:48 -0700)]
test - Add code to test recent bus error issue

Submitted-by: "Samuel J. Greear" <sjg@evilcode.net>
12 years agokernel - Fix recently introduced bus error w/postgres scoreboard
Matthew Dillon [Wed, 26 Oct 2011 22:44:13 +0000 (15:44 -0700)]
kernel - Fix recently introduced bus error w/postgres scoreboard

* The OBJ_ONEMAPPING flag has to be cleared when forking a shared
  mapping.

* Fixed an issue with the postgres scoreboard.

Reported-by: Studbolt, thesjg
12 years agokernel - pmap (64bit) add missing wiring to fix panic
Matthew Dillon [Wed, 26 Oct 2011 22:43:09 +0000 (15:43 -0700)]
kernel - pmap (64bit) add missing wiring to fix panic

* When entering an unmanaged pte into a user pmap we have to bump the
  wiring count of the parent page table page.

Reported-by: thesjg
12 years agokernel - Adjust pagezero/pagecopy assembly and re-enable VM_ALLOC_ZERO
Matthew Dillon [Wed, 26 Oct 2011 21:48:10 +0000 (14:48 -0700)]
kernel - Adjust pagezero/pagecopy assembly and re-enable VM_ALLOC_ZERO

* Remove the movnti, sfence, and prefetch instructions from the pagezero(0
  and pagecopy() assembly.  They don't help and will eve hurt on some of
  the less powerful cpus.

* Re-enable the use of VM_ALLOC_ZERO.  There was no difference in test
  compile times w/ the concurrent buildkernel -j 48 NO_MODULES=TRUE test.
  It might help w/lower-load edge cases so keep it around.

12 years agokernel - Handle pmap_protect() race in pmap code
Matthew Dillon [Wed, 26 Oct 2011 21:46:52 +0000 (14:46 -0700)]
kernel - Handle pmap_protect() race in pmap code

* If we find an unexpectedly non-NULL pte_pv from a pv_find(), which only
  holds the pv, we have to resolve a locked pte_pv to rectify the race.
  Add debug code to catch and rectify the situation.

12 years agokernel - Rewrite the x86-64 pmap code
Matthew Dillon [Wed, 26 Oct 2011 18:42:18 +0000 (11:42 -0700)]
kernel - Rewrite the x86-64 pmap code

* Use unassociated VM pages (without a VM object) for all page table pages.

* Remove kptobj and pmap->pm_pteobj.

* For the moment implement a Red-Black tree for pv_entry_t manipulation.
  Revamp the pindex to include all page table page levels, from terminal
  pages to the PML4 page.  The hierarchy is now arranged via the PV system.

* As before, the kernel page tables only use PV entries for terminal pages.

* Refactor the locking to allow blocking operations during deep scans.
  Individual PV entries are now locked and critical PMAP operations do not
  require the pmap->pm_token.  This should greatly improve threaded
  program performance.

* Fix kgdb on the live kernel (pmap_extract() was not handling short-cutted
  page directory pages).

12 years agokernel - remove MP lock from uipc socket functions, route table, and mld6
Matthew Dillon [Wed, 26 Oct 2011 18:39:40 +0000 (11:39 -0700)]
kernel - remove MP lock from uipc socket functions, route table, and mld6

* Remove the MP lock from the uipc_socket.c kqueue filterops.

* Remove the MP lock from the route table threads.

* Remoev the MP lock from the IPV6 MLD6 implementation.

12 years agokernel - Major vm_page, lwkt thread, and other changes
Matthew Dillon [Wed, 26 Oct 2011 18:26:48 +0000 (11:26 -0700)]
kernel - Major vm_page, lwkt thread, and other changes

* Remove the rest of the LWKT fairq code, it may be added back in a different
  form later.  Go back to the strict priority model with round-robining
  of same-priority LWKT threads.

  Currently the model scans gd_tdrunq for sort insertion, which is probably
  a bit too inefficient.

* Refactor the LWKT scheduler clock.  The round-robining is now based on
  the head of gd->gd_tdrunq and the lwkt_schedulerclock() function will
  move it.  When a thread not on the head is selected to run (because
  the head is contending on a token), the round-robin tick will force a
  resched on the next tick.  As before, we never reschedule-ahead the
  kernel scheduler helper thread or threads that have already dropped
  to a user priority.

* The token code now tries a little harder to acquire the token before
  giving up, controllable with lwkt.token_spin and lwkt.token_delay
  (token_spin is the number of times to try and token_delay is the delay
  between tries, in nanoseconds).

* Fix a serious bug in usched_bsd4.c which improperly reassigned the 'dd'
  variable and caused the scheduler helper to monitor the wrong dd
  structure.

* Refactor the vm_page coloring code.  On SMP systems we now use the
  coloring code to implement cpu localization when allocating pages.
  The pages are still 'twisted' based on their physical address so both
  functions are served, but cpu localization is now the more important
  function.

* Implement NON-OBJECT vm_page allocations.  NULL may now be passed, which
  allocates a VM page unassociated with any VM object.  This will be
  used by the pmap code.

* Implement cpu localization for zalloc() and friends.  This removes a major
  contention point when handling concurrent VM faults.  The only major
  contention point left is the PQ_INACTIVE vm_page_queues[] queue.

* Temporarily remove the VM_ALLOC_ZERO request.  This will probably be
  reenabled in a later commit.

* Remove MSGF_NORESCHED (it is not being used) and simplify related
  lwkt scheduler functions.

* schedcpu_stats() and schedcpu_resource() no longer stall the callout
  kernel threads when scanning allproc, if they are unable to acquire
  proc->p_token.

* Move the need_lwkt_resched() from hardclock() to lwkt_schedulerclock()
  (which hardclock() calls).

12 years agokernel - Make the itimers MPSAFE
Matthew Dillon [Wed, 26 Oct 2011 18:23:03 +0000 (11:23 -0700)]
kernel - Make the itimers MPSAFE

* Use the per-process p_token instead of the MP lock for per-process
  itimers.

12 years agokernel - Optimize spinlocks for 48-core contention
Matthew Dillon [Wed, 26 Oct 2011 18:18:54 +0000 (11:18 -0700)]
kernel - Optimize spinlocks for 48-core contention

* Change the spinlock algorithm to do a read-test before atomic_swap_int().
  This has no effect on single-chip cpus (tested on phenom II quad-core),
  but has a HUGE HUGE HUGE effect on multi-chip/many-core systems.  On
  monster (48-core opteron / 4 x 12-core chips) concurrent kernel compile
  time is reduced from 170 seconds to 75 seconds with this one change.
  That's well over 100%.

  The reason the change is important is because it unloads the hardware
  cache coherency bus and communication by creating a closed-loop with
  the pre-read, which essentially passively waits for the cache update
  instead of actively issuing a locked bus cycle memory op.  This prevents
  total armagheddon on the memory busses when a substantial number of
  cores are doing real work.

* Increase the number of pool spinlocks from 1024 to 8192.  We need them
  now that vm_page's use pool spinlocks.

12 years agokernel - limit allproc_scan() to snapshot
Matthew Dillon [Wed, 26 Oct 2011 18:15:47 +0000 (11:15 -0700)]
kernel - limit allproc_scan() to snapshot

* Limit the allproc_scan() to (roughly) a snapshot of nprocs processes.
  If we don't do this it is possible for the scan to race fork/exec'ing
  programs and essentially run forever.

12 years agokernel - Fix cumulative nprocs bug
Matthew Dillon [Wed, 26 Oct 2011 18:13:56 +0000 (11:13 -0700)]
kernel - Fix cumulative nprocs bug

* nprocs requires atomic ops now that the related code is MPSAFE.

* Fixes issue reported w/pkgbox64 of the machine running out of processes
  unexpectedly.

* Also move a wakeup() to outside p->p_token to improve concurrency and
  other minor adjustments.

12 years agokernel - callout_init() -> callout_init_mp() in selected cases
Matthew Dillon [Wed, 26 Oct 2011 18:12:17 +0000 (11:12 -0700)]
kernel - callout_init() -> callout_init_mp() in selected cases

* Use callout_init_mp() in numerous cases where the BGL is not
  needed.  There are still a lot more left.

12 years agolibc -- string: strspn should return 0 for empty match strings, not string len.
Venkatesh Srinivas [Wed, 26 Oct 2011 14:37:39 +0000 (07:37 -0700)]
libc -- string: strspn should return 0 for empty match strings, not string len.

Reported-by: lentferj
12 years agopf.conf.5/swapcache.8: Fix some typos (verses -> versus).
Sascha Wildner [Wed, 26 Oct 2011 13:11:56 +0000 (15:11 +0200)]
pf.conf.5/swapcache.8: Fix some typos (verses -> versus).

12 years agolibrt -- aio: lio_listio: Do not dereference NULL sigevp.
Venkatesh Srinivas [Wed, 26 Oct 2011 12:35:59 +0000 (05:35 -0700)]
librt -- aio: lio_listio: Do not dereference NULL sigevp.

Reported-by: Z`
12 years agolibhammer - HAMMER filesystem library.
Antonio Huete Jimenez [Tue, 25 Oct 2011 22:34:24 +0000 (00:34 +0200)]
libhammer - HAMMER filesystem library.

Initial work to bring a library to help operating
HAMMER filesystems from userland.

It's barebones as of now, only "info" directive is
adapted, progressively the rest of the directives
will be migrated

Help-from: @swildner, @sjg

12 years agokernel -- lwbuf: Convert cmpxchg loop to LOCK OR; we are just setting a bit.
Venkatesh Srinivas [Tue, 25 Oct 2011 17:48:20 +0000 (10:48 -0700)]
kernel -- lwbuf: Convert cmpxchg loop to LOCK OR; we are just setting a bit.

12 years agoSync zoneinfo database with tzdata2011m from munnari.oz.au
Sascha Wildner [Tue, 25 Oct 2011 13:26:02 +0000 (15:26 +0200)]
Sync zoneinfo database with tzdata2011m from munnari.oz.au

asia:           8.68 -> 8.69
australasia:    8.27 -> 8.28
backward:       8.9  -> 8.10
europe:         8.38 -> 8.39
northamerica:   8.49 -> 8.50
southamerica:   8.50 -> 8.52
zone.tab:       8.49 -> 8.50

* asia, australasia, northamerica: Bump version for tzdata2011l.

* europe, backward: Pridnestrovian Moldavian Republic (Europe/Tiraspol)
    has followed much of Russia, and will retain "summer time" year round
    (that is no time transition is due Oct 30). This reintroduces a zone
    that had earlier been removed, and so removes the "backward" link.

    On the other hand, Ukraine have decided not to follow, so the change
    which had been made in preparation for that in tzdata2011k is now
    reverted, and there will be a transition on Oct 30.

* southamerica: The change to Bahia, Brazil, that introduced summer time
    (following the regular Brazil rules, so commencing this year on
    Oct 16 - last SUnday) that was mooted before tzdata2011l was released,
    but withdrawn because the change was not yet official, has now been
    ratified.

12 years agoperiodic/daily: Fix the check for denied zone transfers (AXFR and IXFR).
Sascha Wildner [Tue, 25 Oct 2011 12:08:22 +0000 (14:08 +0200)]
periodic/daily: Fix the check for denied zone transfers (AXFR and IXFR).

Just use grep -E here (fgrep -E seems to have stopped working at some
point anyway).

12 years agotmpfs: Implement vptofh, so programs open files in tmpfs could coredump
Sepherosa Ziehau [Tue, 25 Oct 2011 11:57:33 +0000 (19:57 +0800)]
tmpfs: Implement vptofh, so programs open files in tmpfs could coredump

Submitted-by: Tim Bissont <bissont@mac.com>
12 years agokernel - Increase VM page free minimums for allocations
Matthew Dillon [Tue, 25 Oct 2011 04:53:43 +0000 (21:53 -0700)]
kernel - Increase VM page free minimums for allocations

* Recent work removed the global vm_token and moved to per-vm_page_queue
  spin locks, which allows cpus to allocate VM pages concurrently.  This
  could result in a situation where remaining free pages got blown out
  without giving the system a chance to replentish them.

* Symptoms included the BUF/BIO system complaining of memory exhaustion
  and the pageout daemon deadlocking on low memory (which would deadlock
  the whole machine in a memory-exhausted state).

* Increase minimums to prevent this.  In particular, the interrupt_free_min
  was previously hardwired to a value of 2.. as in 2 pages (8192 bytes),
  which is an excessively low value.  The new calculations place this value
  (typically) around a few-hundred pages.

12 years agoMerge branch 'devel'
Sepherosa Ziehau [Mon, 24 Oct 2011 12:10:07 +0000 (20:10 +0800)]
Merge branch 'devel'

12 years agotcp: Aggregate the mbuf in sosendtcp() a little bit
Sepherosa Ziehau [Mon, 24 Oct 2011 11:21:37 +0000 (19:21 +0800)]
tcp: Aggregate the mbuf in sosendtcp() a little bit

This greatly reducse the ipi interrupts caused by ipi sending (both
domsg and sendmsg), thus improves overall performance a bit.

net.inet.tcp.sosnd_agglim is added to tune how much mbuf should be
aggregated; it is default to 2.  Setting this sysctl to 1 restores
the old behaviour: one full mbuf at a time.

On Phenom 9550 (4 core, 2.2GHz):
8 parallel netperf -H 127.0.0.1 -P0 (4 runs, unit; Mbps)

                                              IPIs/s (sum of 4 core)
 1 mbuf  6735.98  6903.13  6971.89  7056.66   ~400K
 2 mbuf  7675.47  7757.28  7815.45  7514.50   ~240K
 4 mbuf  7895.33  7584.22  7704.12  7723.33   ~180K
 8 mbuf  8006.94  8077.87  7701.23  8061.12   ~120K
16 mbuf  8151.68  8023.03  7972.42  8046.13   ~100K

The default value (2) for the sosnd_agglim improve the whole
performance by ~10%.  IPI rate is also reduce greatly.

It has no obvious impact on 1000BaseT or 100baseTX network performace.

12 years agotcp: Let sosendtcp() call tcp_usrreq.pru_send asynchronous
Sepherosa Ziehau [Sun, 23 Oct 2011 12:55:16 +0000 (20:55 +0800)]
tcp: Let sosendtcp() call tcp_usrreq.pru_send asynchronous

- Embed netmsg_pru_send into mbuf.m_hdr, which shares the space with
  netmsg_pru_packet.
- Use the newly added netmsg_pru_send in mbuf to perform asynchronous
  pru_send.  For asynchronous pru_send, PRUS_NOREPLY is added, which
  prevents pru_send to reply the message.
- In sosendtcp(), if we have more data to call pru_send, we call it
  asynchronously.  The last piece of data or OOB data will still be
  passed to pru_send synchronously.

On Phenom 9550 (4 core, 2.2GHz):
8 parallel netperf -H 127.0.0.1 (4 runs, unit: Mbps)

old  5863.85  5773.13  5534.14  5506.72
new  6735.98  6903.13  6971.89  7056.66

This give ~20% performance improvement.

It has no obvious impact on 1000BaseT or 100baseTX network performace.

12 years agotcp: Add sosendtcp for further optimization
Sepherosa Ziehau [Sun, 23 Oct 2011 10:30:39 +0000 (18:30 +0800)]
tcp: Add sosendtcp for further optimization

Currently:
- Cleanup the 'atomic' logic
- Free the 'control' earlier
- Remove the "implied connection" related bits

12 years agoRemove some EISA remains in a couple of manual pages.
Sascha Wildner [Sun, 23 Oct 2011 06:13:51 +0000 (08:13 +0200)]
Remove some EISA remains in a couple of manual pages.

12 years agotest - Little program to list processes from coredumps or kmem.
Antonio Huete Jimenez [Sat, 22 Oct 2011 21:21:49 +0000 (23:21 +0200)]
test - Little program to list processes from coredumps or kmem.

12 years agokern - Do not allow calls to vmspace_president_count() from userland.
Antonio Huete Jimenez [Sat, 22 Oct 2011 10:20:29 +0000 (12:20 +0200)]
kern - Do not allow calls to vmspace_president_count() from userland.

- Processes' vm_map is not read in by kvm_proclist() thus we cannot
  call vmspace_president_count() which entirely relies on that.
- This fixes segfaults in ps(1), w(1) and fstat(1) when using -M
  and -N parameters.

Help-from: @corecode

12 years agokernel - Fix null-pointer crash in i386/pmap.c
Matthew Dillon [Sat, 22 Oct 2011 21:07:29 +0000 (14:07 -0700)]
kernel - Fix null-pointer crash in i386/pmap.c

* Related to recent work, check that m->object is not NULL

12 years agoaccept_filter.9: Add missing include.
Sascha Wildner [Sat, 22 Oct 2011 18:13:02 +0000 (20:13 +0200)]
accept_filter.9: Add missing include.

12 years agotcp: We have dropped T/TCP for a long time; remove the implied connection
Sepherosa Ziehau [Sat, 22 Oct 2011 11:49:01 +0000 (19:49 +0800)]
tcp: We have dropped T/TCP for a long time; remove the implied connection

The hack padding at the end of the struct netmsg_pru_send is also removed,
since connect will not happen on the sending path at all.

12 years agotcp: We have dropped T/TCP for a long time; remove the implied connection
Sepherosa Ziehau [Sat, 22 Oct 2011 11:49:01 +0000 (19:49 +0800)]
tcp: We have dropped T/TCP for a long time; remove the implied connection

The hack padding at the end of the struct netmsg_pru_send is also removed,
since connect will not happen on the sending path at all.

12 years agoRemove some duplicate includes in sys/kern.
Sascha Wildner [Sat, 22 Oct 2011 09:27:10 +0000 (11:27 +0200)]
Remove some duplicate includes in sys/kern.