dragonfly.git
12 years agokernel: Fix two cases of sizeof(sizeof(x)).
Sascha Wildner [Sun, 4 Dec 2011 17:08:16 +0000 (18:08 +0100)]
kernel: Fix two cases of sizeof(sizeof(x)).

12 years agoAdd a simple coccinelle patch for finding NELEM() candidates.
Sascha Wildner [Sun, 4 Dec 2011 16:06:44 +0000 (17:06 +0100)]
Add a simple coccinelle patch for finding NELEM() candidates.

From a similar NetBSD patch from the web.

12 years agokernel: Use NELEM() in some more places.
Sascha Wildner [Sun, 4 Dec 2011 13:32:47 +0000 (14:32 +0100)]
kernel: Use NELEM() in some more places.

12 years agopru_send: Allow non-NULL address parameter to be passed
Sepherosa Ziehau [Sun, 4 Dec 2011 13:21:51 +0000 (21:21 +0800)]
pru_send: Allow non-NULL address parameter to be passed

Currently the passed in address is copied into a newly allocated
memory (grr, additional blocking kmalloc), and the PRUS_FREEADDR
will be set so that protocol thread could know when to free the
address.

Before this change netperf UDP_STREAM (unconnected socket) could
only do ~200Kpps (w/ -m 18), now it could do ~990Kpps (w/ -m 18).
This gives ~500% performance improvement for tiny UDP packet TX.
The improvement is not as good as the connected socket, which is
~600%, mainly because of the additional memory allocation for
the address.  We _may_ further optimize out the address allocation.

12 years agoudp: Support asynchronized pru_send for connected socket
Sepherosa Ziehau [Sun, 4 Dec 2011 10:43:40 +0000 (18:43 +0800)]
udp: Support asynchronized pru_send for connected socket

The result:

192.168.3.1 PhenomII 970 (runs netperf, hw 82571EB)
192.168.3.2 Phenom 9550 (runs netserver, hw 82574L)

netperf -H 192.168.3.2 -t UDP_STREAM -P0 -l 30 -- -n -m 18
(10 second `netstat -nI emx0 -w 1`, unit: pps)

  old      new
204736   1225536
203712   1224960
203520   1224640
202880   1228416
203392   1225408
203648   1224960
203456   1219968
203648   1224064
203712   1218880
204224   1222464

This gives ~600% tiny UDP packet TX performance improvement.

The the current tiny UDP packet TX rate (1.22Mpps) is quite near
the 1.48Mpps 1000baseT limitation.

12 years agoudp: Prepare for the asynchronized pru_send 2
Sepherosa Ziehau [Sat, 3 Dec 2011 14:07:10 +0000 (22:07 +0800)]
udp: Prepare for the asynchronized pru_send 2

Save the MSG_DONTROUTE in the netmsg instead of messing w/ socket.so_options

12 years agoudp: Prepare for the asynchronized pru_send
Sepherosa Ziehau [Sat, 3 Dec 2011 13:41:17 +0000 (21:41 +0800)]
udp: Prepare for the asynchronized pru_send

Save necessary netmsg information into stack variables

12 years agoudp: Simplify udp_output interface
Sepherosa Ziehau [Sat, 3 Dec 2011 13:26:47 +0000 (21:26 +0800)]
udp: Simplify udp_output interface

12 years agodhclient - Use -q option instead of redirection.
Antonio Huete Jimenez [Sat, 3 Dec 2011 21:08:40 +0000 (22:08 +0100)]
dhclient - Use -q option instead of redirection.

Obtained-from: OpenBSD

12 years agodhclient - Do not add/remove route 127.0.0.1 for our newly assigned IP/aliases.
Antonio Huete Jimenez [Sat, 3 Dec 2011 18:18:21 +0000 (19:18 +0100)]
dhclient - Do not add/remove route 127.0.0.1 for our newly assigned IP/aliases.

Taken-from: FreeBSD 149479

12 years agoVFS accounting: implement an initialization framework
Francois Tigeot [Sat, 6 Aug 2011 21:02:32 +0000 (23:02 +0200)]
VFS accounting: implement an initialization framework

Only enable accounting for a short list of whitelisted filesystem types

12 years agonrelease: In the mk.conf we add, don't quote PKG_DEFAULT_OPTIONS.
Sascha Wildner [Sat, 3 Dec 2011 11:52:40 +0000 (12:52 +0100)]
nrelease: In the mk.conf we add, don't quote PKG_DEFAULT_OPTIONS.

It will not work with quotes.

Reported-by: Matthias Rampke <matthias@rampke.de>
12 years agodu(1): Move the fts_close() behind fts_read()'s errno check.
Sascha Wildner [Sat, 3 Dec 2011 09:39:06 +0000 (10:39 +0100)]
du(1): Move the fts_close() behind fts_read()'s errno check.

12 years agoAdd missing fts_close() calls
François Tigeot [Sat, 3 Dec 2011 08:40:15 +0000 (09:40 +0100)]
Add missing fts_close() calls

12 years agovquota.8: Add a missing .El and use . instead of empty lines.
Sascha Wildner [Sat, 3 Dec 2011 08:37:46 +0000 (09:37 +0100)]
vquota.8: Add a missing .El and use . instead of empty lines.

12 years agovquota(8): style(9)/whitespace fixes.
Sascha Wildner [Sat, 3 Dec 2011 07:44:40 +0000 (08:44 +0100)]
vquota(8): style(9)/whitespace fixes.

12 years agoUnbreak buildworld on i386
François Tigeot [Fri, 2 Dec 2011 23:51:16 +0000 (00:51 +0100)]
Unbreak buildworld on i386

12 years agopf: fix another double lock release
Jan Lentfer [Fri, 2 Dec 2011 22:39:16 +0000 (23:39 +0100)]
pf: fix another double lock release

    On module unload pf_consistency_lock was
    already released by pf_purge_expired_states().

12 years agoAdd a skeleton vquota(8) manpage
Francois Tigeot [Sun, 4 Sep 2011 12:33:09 +0000 (14:33 +0200)]
Add a skeleton vquota(8) manpage

12 years agoAdd a vquota(8) utility
Francois Tigeot [Sat, 6 Aug 2011 20:57:36 +0000 (22:57 +0200)]
Add a vquota(8) utility

12 years agopf -- Remove unused pf_mod_lck.
Venkatesh Srinivas [Fri, 2 Dec 2011 18:02:27 +0000 (10:02 -0800)]
pf -- Remove unused pf_mod_lck.

pf_mod_lck was not used, except in a lksleep on module unload.

Reported-by: tuxillo
12 years agoaccept: Call pru_accept in protocol thread
Sepherosa Ziehau [Fri, 2 Dec 2011 11:54:17 +0000 (19:54 +0800)]
accept: Call pru_accept in protocol thread

This avoids socket.so_pcb use-after-check race against protocol thread.

There is no performance impact on the mostly used sockets:
- IPv4/IPv6 TCP implemented pru_savefaddr, so their pru_accept will not
  be called at all
- UNIX domain socket uses sync msgport, so no protocol thread dispatching

12 years agoFix some whitespace issues.
Sascha Wildner [Fri, 2 Dec 2011 10:11:48 +0000 (11:11 +0100)]
Fix some whitespace issues.

12 years agokernel - Use atomic allocate-hold in vnode_pager_alloc().
Matthew Dillon [Fri, 2 Dec 2011 04:17:10 +0000 (20:17 -0800)]
kernel - Use atomic allocate-hold in vnode_pager_alloc().

* Use vm_object_allocate_hold() in vnode_pager_alloc() to atomically
  initialize the additional fields with the object lock held throughout.

Reported-by: Venkatesh Srinivas <vsrinivas@crater.dragonflybsd.org>
12 years agoHAMMER VFS - Attempt to fix a low-memory deadlock
Matthew Dillon [Fri, 2 Dec 2011 01:13:40 +0000 (17:13 -0800)]
HAMMER VFS - Attempt to fix a low-memory deadlock

* (add missing header file change for last commit)

12 years agoHAMMER VFS - Attempt to fix a low-memory deadlock
Matthew Dillon [Fri, 2 Dec 2011 01:12:12 +0000 (17:12 -0800)]
HAMMER VFS - Attempt to fix a low-memory deadlock

* Avoid trying to allocate a new buffer cache buffer when memory is
  low from inside the blockmap allocation path (where the global
  blockmap lock is held).

Reported-by: tuxillo
12 years agokernel - Refactor the vmspace locking code and several use cases
Matthew Dillon [Fri, 2 Dec 2011 00:54:19 +0000 (16:54 -0800)]
kernel - Refactor the vmspace locking code and several use cases

* Reorder the vnode ref/rele sequence in the exec path so p_textvp is
  left in a more valid state while being initialized.

* Removing the vm_exitingcnt test in exec_new_vmspace().  Release
  various resources unconditionally on the last exiting thread regardless
  of the state of exitingcnt.  This just moves some of the resource
  releases out of the wait*() system call path and back into the exit*()
  path.

* Implement a hold/drop mechanic for vmspaces and use them in procfs_rwmem(),
  vmspace_anonymous_count(), and vmspace_swap_count(), and various other
  places.

  This does a better job protecting the vmspace from deletion while various
  unrelated third parties might be trying to access it.

* Implement vmspace_free() for other code to call instead of them trying
  to call sysref_put() directly.  Interlock with a vmspace_hold() so
  final termination processing always keys off the vm_holdcount.

* Implement vm_object_allocate_hold() and use it in a few places in order
  to allow OBJT_SWAP objects to be allocated atomically, so other third
  parties (like the swapcache cleaning code) can't wiggle their way in
  and access a partially initialized object.

* Reorder the vmspace_terminate() code and introduce some flags to ensure
  that resources are terminated at the proper time and in the proper order.

12 years agokernel - Remove unnecessary MP lock in vgone_vxlocked()
Matthew Dillon [Fri, 2 Dec 2011 00:51:32 +0000 (16:51 -0800)]
kernel - Remove unnecessary MP lock in vgone_vxlocked()

* Remove an unnecessary MP lock from the vnode destruction path.

12 years agolibkvm - Fix seg-fault in ps output when loading a process's argv
Matthew Dillon [Thu, 1 Dec 2011 23:53:24 +0000 (15:53 -0800)]
libkvm - Fix seg-fault in ps output when loading a process's argv

* An offset calculation used when the string space is relocated by realloc
  was being stored in an 'int' instead of a 'size_t', causing the
  recalculated pointer to go wild.

12 years agokernel - Enhanced lockmgr debugging, panic in double unlock
Matthew Dillon [Thu, 1 Dec 2011 23:24:01 +0000 (15:24 -0800)]
kernel - Enhanced lockmgr debugging, panic in double unlock

* Panic if an attempt is made to unlock a lock which is not locked.

* Add some additinal debugging (disabled)

12 years agokernel - Fix lost lock in devfs
Matthew Dillon [Thu, 1 Dec 2011 23:22:44 +0000 (15:22 -0800)]
kernel - Fix lost lock in devfs

* vn_lock() will always fail if a vnode is undergoing reclamation, do
  not try to unlock/relock in the spec_close code in that case.

* Refactor the error test in devfs_allocv() in case vget() returns
  an error other than ENOENT in the future.

12 years agokernel - Remove double unlock in elf core dumping code
Matthew Dillon [Thu, 1 Dec 2011 23:19:09 +0000 (15:19 -0800)]
kernel - Remove double unlock in elf core dumping code

* Remove a double vnode unlock in the elf core dumping code.  vn_unlock()
  ignored double unlocks before but soon won't.

12 years agoMerge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
Matthew Dillon [Thu, 1 Dec 2011 23:18:53 +0000 (15:18 -0800)]
Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly

12 years agoFix a bug in nullfs_mount() and nullfs_statfs()
François Tigeot [Sun, 14 Aug 2011 13:13:30 +0000 (15:13 +0200)]
Fix a bug in nullfs_mount() and nullfs_statfs()

Most filesystems register the name of their mount point at mount time and
are able to return it later with a VFS_STATFS call. nullfs did not.

12 years agoAdjust some comment indentation.
Sascha Wildner [Thu, 1 Dec 2011 19:36:28 +0000 (20:36 +0100)]
Adjust some comment indentation.

12 years agoMerge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
Matthew Dillon [Thu, 1 Dec 2011 19:14:24 +0000 (11:14 -0800)]
Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly

12 years agoMerge branch 'master' of /repository/git/dragonfly
Venkatesh Srinivas [Thu, 1 Dec 2011 19:12:30 +0000 (11:12 -0800)]
Merge branch 'master' of /repository/git/dragonfly

12 years agokernel - ddb: Print raw instruction pointers in ddb backtrace.
Venkatesh Srinivas [Thu, 1 Dec 2011 19:11:58 +0000 (11:11 -0800)]
kernel - ddb: Print raw instruction pointers in ddb backtrace.

12 years agogold linker 2.22: Unbreak it
John Marino [Thu, 1 Dec 2011 17:32:06 +0000 (18:32 +0100)]
gold linker 2.22: Unbreak it

The trick to avoid rebuilding 6 object files unnecessarily ended up making
the gold linker of binutils 2.22 stop working.  This commit takes them
off of the gold library and back to the gold program, and again to the
incremental-dump program.  Until somebody shows me the way the latter
program can use object files from the former one, we're just going to
build them twice.

12 years agorcrun(8): Teach rcstart, rcstop and friends to handle other rc dirs.
Sascha Wildner [Thu, 1 Dec 2011 17:15:49 +0000 (18:15 +0100)]
rcrun(8): Teach rcstart, rcstop and friends to handle other rc dirs.

This commit makes rcrun(8) and its various incarnations work also with
rc scripts that are in either /usr/pkg/etc/rc.d or /usr/local/etc/rc.d
(the paths in rc.conf's local_startup, actually).

While here, do some cleanup:

* Remove some unneeded 'cd' commands (rcorder as we call it will already
  give the full path to the script)

* Remove extra whitespace at the end of the file

* Add a copyright.

12 years agokernel - sysctl - use a larger buffer to ensure that a ksnprintf() fits
Matthew Dillon [Thu, 1 Dec 2011 04:39:02 +0000 (20:39 -0800)]
kernel - sysctl - use a larger buffer to ensure that a ksnprintf() fits

* Use a larger buffer to ensure that a ksnprintf() fits.  This doesn't
  fix any bugs per-say but it does ensure that any normal integer OID
  will be properly displayed.

* No current sysctls have OIDs large enough to have triggered the problem.

12 years agokernel - Fix race between procfs / proc sysctls and exec, refactor PHOLD/etc
Matthew Dillon [Thu, 1 Dec 2011 04:29:15 +0000 (20:29 -0800)]
kernel - Fix race between procfs / proc sysctls and exec, refactor PHOLD/etc

* During a [v]fork/exec sequence the exec will replace the VM space of the
  target process.  A concurrent 'ps' operation could access the target
  process's vmspace as it was being ripped out, resulting in memory
  corruption.

* The P_INEXEC test in procfs was insufficient, the exec code itself must
  also wait for procfs's PHOLD() on the process to go away before it can
  proceed.  This should properly interlock the entire operation.

* Can occur with procfs or non-procfs ps's (via proc sysctls).

* Possibly related to the seg-fault issue we have where the user stack gets
  corrupted.

* Also revamp PHOLD()/PRELE() and add PSTALL(), changing all manual while()
  loops waiting on p->p_lock to use PSTALL().

  These functions now integrate a wakeup request flag into p->p_lock
  using atomic ops and no longer tsleep() for 1 tick (or hz ticks, or
  whatever).  Wakeups are issued proactively.

12 years agokernel - Minor cleanups
Matthew Dillon [Thu, 1 Dec 2011 01:34:39 +0000 (17:34 -0800)]
kernel - Minor cleanups

* lwkt_wait_free() no longer exists, remove the prototype.

* Reformat a kprintf() in vm/swap_pager.c to not overflow 80 columns.

12 years agokernel - Fix pmap->pm_active race in switch code
Matthew Dillon [Thu, 1 Dec 2011 01:29:35 +0000 (17:29 -0800)]
kernel - Fix pmap->pm_active race in switch code

* Use an atomic cmpxchg to set the cpu bit in the pmap->pm_active bitmap
  AND test the pmap interlock bit at the same time, instead of testing
  the interlock bit afterwords.

* In addition, if we find the lock bit set and must spin-wait for it to
  clear, we skip the %cr3 comparison check and unconditionally load %cr3.

* It is unclear if the race could be realized in any way.  It was probably
  not responsible for the seg-fault issue as prior tests with an unconditional
  load of %cr3 did not fix the problem.  Plus in the same-%cr3-as-last-thread
  case the cpu bit is already set so there should be no possibility of
  losing a TLB interlock IPI (and %cr3 is loaded unconditionally when it
  doesn't match, so....).

  But fix the race anyway.

12 years agokernel - Add requires p->p_token locking and holds around fork()'s child proc
Matthew Dillon [Thu, 1 Dec 2011 01:24:11 +0000 (17:24 -0800)]
kernel - Add requires p->p_token locking and holds around fork()'s child proc

* fork() and vfork() allocate a new process, p2, initialize, and add it to
  the allproc list as well as other lists.

* These functions failed to acquire p2's token, p2 becomes visible to the
  rest of the system when it's added to the allproc list.  Even though p2's
  state is set to SIDL, this is insufficient protection.

  Acquire the token prior to adding p2 to allproc and keep holding the token
  until after we have finished initializing p2.

* We must also PHOLD()/PRELE() p2 around the start_forked_proc() call
  to prevent it from getting ripped out from under us (if it exits
  quickly and/or detaches itself from its parent).

* Possibly fixes the random seg-faulting issue we've seen under very heavy
  fork/exec (parallel compile) loads on the 48-core monster.

12 years agokernel - Fix minor bug in last swapcache commit
Matthew Dillon [Wed, 30 Nov 2011 22:28:25 +0000 (14:28 -0800)]
kernel - Fix minor bug in last swapcache commit

* Fix an issue where the marker could get stuck at the end of the
  vm_object_list and stop the cleaning process.

12 years agokernel - Add missing lwkt_switch_return() call to pcb_ext path
Matthew Dillon [Wed, 30 Nov 2011 20:04:10 +0000 (12:04 -0800)]
kernel - Add missing lwkt_switch_return() call to pcb_ext path

* Add missing lwkt_switch_return() call to pcb_ext path

* This path is only used when a program accesses /dev/io (basically
  none in normal system operation).

12 years agokernel - swtch.s cleanup
Matthew Dillon [Wed, 30 Nov 2011 20:03:27 +0000 (12:03 -0800)]
kernel - swtch.s cleanup

* Cleanup the code a bit, no functional changes.

12 years agomkdir - Fix MP race in mkdir -p
Matthew Dillon [Wed, 30 Nov 2011 17:52:08 +0000 (09:52 -0800)]
mkdir - Fix MP race in mkdir -p

* mkdir -p can race other mkdir -p commands

* Do the same fix that we did for xinstall... if the mkdir() fails after
  the stat() check, stat() again to see if the directory creation raced.

12 years agoxinstall - Fix bug in last commit
Matthew Dillon [Wed, 30 Nov 2011 17:51:38 +0000 (09:51 -0800)]
xinstall - Fix bug in last commit

* Fix bug in last commit, the mode to create with is nmode, not mode.

12 years agotcp6: Implement pru_savefaddr
Sepherosa Ziehau [Wed, 30 Nov 2011 13:52:12 +0000 (21:52 +0800)]
tcp6: Implement pru_savefaddr

12 years agokernel - Fix fragmentation and object list scan bug in swapcache
Matthew Dillon [Wed, 30 Nov 2011 04:46:03 +0000 (20:46 -0800)]
kernel - Fix fragmentation and object list scan bug in swapcache

* When swapcache reaches maxswappct (typically 75% of swap) it reduces
  swap use before allowing it to continue to build again, with some
  hysteresis.

* The cleanup phase which reduces swap use was seriously fragmenting swap
  space by cleaning up too small a portion of each VM object.

* Increase the amount cleaned up before moving onto the next VM object.

* Fix bugs in the vm_object_list traversal which could result in a bad
  object being accessed followed by a panic.

12 years agokernel - Fix a few edge cases in subr_blist.c
Matthew Dillon [Wed, 30 Nov 2011 04:41:20 +0000 (20:41 -0800)]
kernel - Fix a few edge cases in subr_blist.c

* In the all-allocated special case set bm_bighint to 0 instead of to
  count.  This fixes an edge case where failed allocations wind up
  traversing too much of the radix tree.

* In the all-free special case be sure to set bm_bighint to the radix,
  higher layers check bm_bighint when recursing.  (This bug could not occur
  unless you had 4 swap devices configured).

* Improve code documentation and minor cleanups.

12 years agolibkvm - Enhance swapinfo dump
Matthew Dillon [Wed, 30 Nov 2011 02:20:05 +0000 (18:20 -0800)]
libkvm - Enhance swapinfo dump

* pstat -ss dumps the swap space radix tree, do additional checks and
  dump more information.

12 years agodmesg - Don't fail when the kernel is adding to the dmesg quickly
Matthew Dillon [Tue, 29 Nov 2011 21:41:54 +0000 (13:41 -0800)]
dmesg - Don't fail when the kernel is adding to the dmesg quickly

* If the kernel is quickly adding to the dmesg buffer and has not started
  recycling the FIFO the increasing size of the buffer will exceed the
  probed size.

* Add another 4K to the probed size to try to deal with this case.

12 years agobuild - Significantly improve parallel buildworld times
Matthew Dillon [Tue, 29 Nov 2011 21:38:34 +0000 (13:38 -0800)]
build - Significantly improve parallel buildworld times

* Change the serialized command sequence used for bootstrap tools,
  btools, and ctools into dependencies so buildworld can build them
  concurrently.

* Utilize the new SUBDIR concurrent build feature by specifying
  a SUBDIR_ORDERED make variable (usually empty) in various high-level
  Makefile's.

12 years agobuild - Support concurrent SUBDIR traversal, fix make depend bug
Matthew Dillon [Tue, 29 Nov 2011 21:34:03 +0000 (13:34 -0800)]
build - Support concurrent SUBDIR traversal, fix make depend bug

* Support concurrent SUBDIR traversals during a make -j N.

  Create individual targets for each target/directory combination so Make
  will run them in parallel when possible.

* SUBDIR_ORDERED, if it exists, indicates the subset of SUBDIR which must
  be ordered.  Any directories not mentioned can run concurrently.

* If SUBDIR_ORDERED does not exist at all then all directories default
  to being strongly ordered and will NOT run concurrently.

* Try to make sure that all include files and generated source files
  are generated before running the depend core.

12 years agobuild - install should not complain if the mkdir() races
Matthew Dillon [Tue, 29 Nov 2011 21:32:27 +0000 (13:32 -0800)]
build - install should not complain if the mkdir() races

* install should not complain if the mkdir() races

* A make -j N can cause concurrent install's to race their mkdir() calls.

12 years agobuildworld - Fix parallel build race in ncurses
Matthew Dillon [Tue, 29 Nov 2011 20:40:49 +0000 (12:40 -0800)]
buildworld - Fix parallel build race in ncurses

* Generated files must depend on headers during make depend step
  (at the very least), because make has no idea about the dependencies
  during that step.

12 years agobuildworld: Be more relaxed with which binutils are on the host.
Sascha Wildner [Tue, 29 Nov 2011 17:50:26 +0000 (18:50 +0100)]
buildworld: Be more relaxed with which binutils are on the host.

If the building world has a new binutils version (which at this
point isn't yet on the host), don't make assumptions about what
binutils version is on the host.

Instead, just take from /usr/libexec/binutils* the one with the
highest version number.

12 years agoaccept: Save foreign address earlier, if protocol supports it
Sepherosa Ziehau [Tue, 29 Nov 2011 13:38:34 +0000 (21:38 +0800)]
accept: Save foreign address earlier, if protocol supports it

- Add so_faddr into socket, which records the accepted socket's foreign
  address.  If it is set, kern_accept() will use it directly instead of
  calling protocol specific method to extract the foreign address.
- Add protocol specific method, pru_safefaddr, which will save the
  foreign address into socket.so_faddr if the necessary information is
  supplied.  This protocol method will only be called in protocol
  thread.
- Pass the foreign address to sonewconn() if possible, so the foreign
  address could be saved before the accepted socket is put onto the
  complete list.

Currently only IPv4/TCP implemented pru_savefaddr

This intends to address the following problems:
- Calling pru_accept directly from user context is not MPSAFE, we
  always races the socket.so_pcb check->use against protocol thread
  clear/free socket.so_pcb, though the race window is too tiny to
  be hit.  To make it mpsafe, we should dispatch pru_accept to
  protocol thread.
  If socket.so_faddr is set here, we are race against nothing and
  nothing expensive like put the current user thread into sleep will
  happen.  However, if the socket is dropped when it still sits
  on the complete list, the error will not be timely delivered, i.e.
  accept(2) will not return error, but the later on read(2)/write(2)
  on the socket will deliver the error.
- Calling pru_accept directly races against the inpcb.inp_f{addr,port}
  setting up in the protocol thread, since inpcb.inp_f{addr,port} is
  setup _after_ the accepted socket was put onto the complete list.

     user thread                  proto thread
          :                             :
          :                  accepted socket -> comp
          :             (inpcb.inp_f{addr,port} are 0 here)
    comp -> socket                      :
     pru_accept                         :
          :                setup inpcb.inp_f{addr,port}

  Returning of 0.0.0.0:0 from accept(2) was observed on heavily loaded
  web servers.

12 years agokernel - Fix race in multi-LWP exit
Matthew Dillon [Tue, 29 Nov 2011 06:13:38 +0000 (22:13 -0800)]
kernel - Fix race in multi-LWP exit

* Fix a very small race condition after TDF_EXITING could get set where a
  LWPs thread could get destroyed by another cpu (reaping it) before
  the thread actually finished exiting.

* Clean up a case where we were improperly testing TDF_RUNQ which could
  result in unnecessary 1-tick delays in exit reaping.

* Beef up the assertion when TDF_EXITING is found to be set that
  both TDF_RUNQ and TDF_TSLEEPQ are not set (before it was just checking
  TDF_TSLEEPQ).

* Clean up reaplwp().

* Remove lwkt_wait_free()

* lwkt_free_thread() now waits for td_refs to drop to 0 before freeing
  the thread.

12 years agokernel - Add required vm_token back in to swaponvp()
Matthew Dillon [Tue, 29 Nov 2011 06:10:29 +0000 (22:10 -0800)]
kernel - Add required vm_token back in to swaponvp()

* This case is not normally hit unless you try to add new swap space
  while the machine is already heavily paging to or from swap.

* The blist operations and vm_swap_size variable manipulation needs
  the token.

* Clean-up the exit code by creating a common exit code section.

12 years agokernel - Check PG_MARKER in pmap_object_init_pt_callback()
Matthew Dillon [Tue, 29 Nov 2011 06:08:40 +0000 (22:08 -0800)]
kernel - Check PG_MARKER in pmap_object_init_pt_callback()

* All PG_MARKER pages are also PG_BUSY so the code was already handling
  the case, but checking for PG_MARKER is the official way to check for
  a marker so do that too.

12 years agokernel - RB_SCAN() requires a short-term spinlock
Matthew Dillon [Tue, 29 Nov 2011 06:03:23 +0000 (22:03 -0800)]
kernel - RB_SCAN() requires a short-term spinlock

* RB_SCAN() links and unlinks an info structure.  If called with a shared
  lock the linking and unlinking operations requires a very short-term spin
  lock to avoid clobbering each other.

* Note that RB_REMOVE() scans the inprog list but this function can only
  be safely called with the RB tree held exclusively anyway, so there's
  no need to spinlock the info list.

* Add kern/subr_rbtree.c glue functions for acquiring and releasing the
  spinlock, so sys/tree.h only needs to include sys/spinlock.h and not
  also sys/spinlock2.h

Reported-by: sephe
12 years agokernel - Attempt to fix early release panic w/USB's sim.
Matthew Dillon [Tue, 29 Nov 2011 05:14:45 +0000 (21:14 -0800)]
kernel - Attempt to fix early release panic w/USB's sim.

* Acquire the CAM_SIM lock when called via the callout, and don't
  acquire the lock when we already hold it via the xpt_dev_async() path.

Reported-by: JustinS
12 years ago<sys/rman.h>: rman_get_rid() macro takes one parameter only.
Sascha Wildner [Mon, 28 Nov 2011 19:06:41 +0000 (20:06 +0100)]
<sys/rman.h>: rman_get_rid() macro takes one parameter only.

12 years agox86_64/pmap: Remove an unused function.
Sascha Wildner [Mon, 28 Nov 2011 19:06:02 +0000 (20:06 +0100)]
x86_64/pmap: Remove an unused function.

12 years agoldns: Update local files for update to 1.6.11
Jan Lentfer [Mon, 28 Nov 2011 15:58:25 +0000 (16:58 +0100)]
ldns: Update local files for update to 1.6.11

12 years agoMerge branch 'vendor/LDNS'
Jan Lentfer [Mon, 28 Nov 2011 12:52:48 +0000 (13:52 +0100)]
Merge branch 'vendor/LDNS'

12 years agoldns: Removed empty file common.h
Jan Lentfer [Mon, 28 Nov 2011 12:48:06 +0000 (13:48 +0100)]
ldns: Removed empty file common.h

12 years agoldns: Update vendor branch to 1.6.11
Jan Lentfer [Mon, 28 Nov 2011 09:57:30 +0000 (10:57 +0100)]
ldns: Update vendor branch to 1.6.11

This fixes a severe bug (CVE-2011-3581)

12 years agolibc -- Remove assembler i386 strlen() routine.
Venkatesh Srinivas [Sun, 27 Nov 2011 17:57:36 +0000 (09:57 -0800)]
libc -- Remove assembler i386 strlen() routine.

On a number of processors, it is slower than the obvious C version.
(400,000,000 loops, times in sec)

On a 2.66 GHz Core 2:
                asm     C
10-by string    22.9    9.5
68-by string    77.2    19.8
175-by string   173.7   40.6

On a 2.0 GHz Athlon64 3000+:
                asm     C
10-by string    11.3    9.9
68-by string    34.7    34.7
175-by string   78.7    77.6

On a 2.2 GHz Core i7 (nehalem):
                asm     C
10-by string    13.4    5.2
68-by string    33.8    29.5
175-by string   71.6    67.4

12 years agokernel -- ktrace: Fix possible one-word stack leak to userspace.
Venkatesh Srinivas [Sun, 27 Nov 2011 17:16:45 +0000 (09:16 -0800)]
kernel -- ktrace: Fix possible one-word stack leak to userspace.

From OpenBSD kern_ktrace.c 1.55, via Loganaden Velvindron.

12 years agox86_64/ioapic_abi: Implement MachIntrABI.rman_setup
Sepherosa Ziehau [Sun, 27 Nov 2011 13:49:16 +0000 (21:49 +0800)]
x86_64/ioapic_abi: Implement MachIntrABI.rman_setup

12 years agotest: from lancer
Sepherosa Ziehau [Sun, 27 Nov 2011 11:16:41 +0000 (19:16 +0800)]
test: from lancer

12 years agotest: from xanadu64
Sepherosa Ziehau [Sun, 27 Nov 2011 11:13:03 +0000 (19:13 +0800)]
test: from xanadu64

12 years agotest: from enigma
Sepherosa Ziehau [Sun, 27 Nov 2011 11:09:54 +0000 (19:09 +0800)]
test: from enigma

12 years agoUnbreak buildworld
Thomas Nikolajsen [Sun, 27 Nov 2011 08:20:38 +0000 (09:20 +0100)]
Unbreak buildworld

12 years agobinutils 2.20: remove source files
John Marino [Sat, 26 Nov 2011 09:23:14 +0000 (10:23 +0100)]
binutils 2.20: remove source files

Binutils 2.20 has not been building for a month, but the source files
were still present in case we wanted to switch it back on.

Per IRC discussion, the general consensus is that DragonFly wants to
continue to maintain two sets of binutils in addition to two compilers.
A new vendor branch has been created, vendor/BINUTILS-ALL, and
binutils 2.20 is the first version to go into this branch.  All future
versions of binutils will also go into this branch rather than create
a new vendor branch each time.  Everything else including objformat
and the naming scheme will remain as it was.  The idea is that the
newest version of binutils is always "prime" and the older version is
the backup which does not require updating.  When a new version of
binutils is brought in, the previous backup version will be deleted.
That's what is happening with binutils version 2.20 today.

12 years agobinutils 2.22: Promote to primary binutils
John Marino [Fri, 25 Nov 2011 23:14:58 +0000 (00:14 +0100)]
binutils 2.22: Promote to primary binutils

12 years agobinutils 2.22: Activate building in world
John Marino [Fri, 25 Nov 2011 23:05:34 +0000 (00:05 +0100)]
binutils 2.22: Activate building in world

The next commit will change the default to make binutils 2.22 prime
and demote binutils 2.21 to be the backup.

12 years agobinutils 2.22: Add makefiles, new incremental-dump binary
John Marino [Fri, 25 Nov 2011 22:42:29 +0000 (23:42 +0100)]
binutils 2.22: Add makefiles, new incremental-dump binary

The makefiles and headers for binutils 2.22 are similar to those of
binutils 2.21 with the exception of the restructuring of the gold
build.  A dedicated include file was created, and several files were
moved to libgold.  This was done to avoid redundant compiling of
object files in common between ld.gold and incremental-dump.  The
latter was never built before although the source was previously
available.

12 years agobinutils 2.22: Add READMEs and local modifications
John Marino [Fri, 25 Nov 2011 22:30:41 +0000 (23:30 +0100)]
binutils 2.22: Add READMEs and local modifications

12 years agoMerge branch 'vendor/BINUTILS_ALL'
John Marino [Sat, 26 Nov 2011 11:44:16 +0000 (12:44 +0100)]
Merge branch 'vendor/BINUTILS_ALL'

12 years agoInitial import of binutils 2.22 on the new vendor branch avalon/vendor/BINUTILS_ALL
John Marino [Sat, 26 Nov 2011 11:42:21 +0000 (12:42 +0100)]
Initial import of binutils 2.22 on the new vendor branch

Future version of binutils will also reside on this branch rather
than continuing to create new binutils branches for each version.

12 years agoRevert "Merge branch 'vendor/BINUTILS-ALL'"
John Marino [Sat, 26 Nov 2011 11:05:52 +0000 (12:05 +0100)]
Revert "Merge branch 'vendor/BINUTILS-ALL'"

This reverts commit 92a1e2d9549ce76d785444d000d358126cf7762f, reversing
changes made to 2b195d6a566cb8441f5d6d66363235683bbd92af.

12 years agoRevert "binutils 2.22: Add READMEs and local modifications"
John Marino [Sat, 26 Nov 2011 11:04:00 +0000 (12:04 +0100)]
Revert "binutils 2.22: Add READMEs and local modifications"

This reverts commit ca679fdaaa1df38750514ba8786c627ce15864d0.

12 years agoRevert "binutils 2.22: Add makefiles, new incremental-dump binary"
John Marino [Sat, 26 Nov 2011 11:03:59 +0000 (12:03 +0100)]
Revert "binutils 2.22: Add makefiles, new incremental-dump binary"

This reverts commit d83cfc8d85b905d12358d755882d57f95b2a0f48.

12 years agoRevert "binutils 2.22: Activate building in world"
John Marino [Sat, 26 Nov 2011 11:03:57 +0000 (12:03 +0100)]
Revert "binutils 2.22: Activate building in world"

This reverts commit e8402471895f5f3b9bc77fde77d732db0feea249.

12 years agoRevert "binutils 2.22: Promote to primary binutils"
John Marino [Sat, 26 Nov 2011 11:03:54 +0000 (12:03 +0100)]
Revert "binutils 2.22: Promote to primary binutils"

This reverts commit c2e570e14a87f984d27b71ec02365064555dee87.

12 years agobinutils 2.22: Promote to primary binutils
John Marino [Fri, 25 Nov 2011 23:14:58 +0000 (00:14 +0100)]
binutils 2.22: Promote to primary binutils

12 years agobinutils 2.22: Activate building in world
John Marino [Fri, 25 Nov 2011 23:05:34 +0000 (00:05 +0100)]
binutils 2.22: Activate building in world

The next commit will change the default to make binutils 2.22 prime
and demote binutils 2.21 to be the backup.

12 years agobinutils 2.22: Add makefiles, new incremental-dump binary
John Marino [Fri, 25 Nov 2011 22:42:29 +0000 (23:42 +0100)]
binutils 2.22: Add makefiles, new incremental-dump binary

The makefiles and headers for binutils 2.22 are similar to those of
binutils 2.21 with the exception of the restructuring of the gold
build.  A dedicated include file was created, and several files were
moved to libgold.  This was done to avoid redundant compiling of
object files in common between ld.gold and incremental-dump.  The
latter was never built before although the source was previously
available.

12 years agobinutils 2.22: Add READMEs and local modifications
John Marino [Fri, 25 Nov 2011 22:30:41 +0000 (23:30 +0100)]
binutils 2.22: Add READMEs and local modifications

12 years agoMerge branch 'vendor/BINUTILS-ALL'
John Marino [Sat, 26 Nov 2011 08:32:25 +0000 (09:32 +0100)]
Merge branch 'vendor/BINUTILS-ALL'

12 years agoInitial import of binutils 2.22 on the new vendor branch avalon/vendor/BINUTILS-ALL
John Marino [Sat, 26 Nov 2011 08:27:44 +0000 (09:27 +0100)]
Initial import of binutils 2.22 on the new vendor branch

Future versions of binutils will also reside on this branch rather
than continuing to create new binutils branches for each new version.

12 years agox86_64/ioapic_abi: Disable interrupt load balance by default
Sepherosa Ziehau [Fri, 25 Nov 2011 06:17:43 +0000 (14:17 +0800)]
x86_64/ioapic_abi: Disable interrupt load balance by default

Add hw.ioapic.gsi.balance tunable to enable/disable interrupt
load balance.  It is disabled by default.

12 years agoaccept: Implement fast soaccept predication
Sepherosa Ziehau [Thu, 24 Nov 2011 05:53:54 +0000 (13:53 +0800)]
accept: Implement fast soaccept predication

Fast soaccept predication tries to run soaccept_predicate before
domsg to the proto-thread, i.e. put the current thread into sleep.

We could do this because listen socket's completion list is always
protected by the listen socket's pool-token.  Domsg to proto-thread
to extract socket from completion list for non-block listen socket
does not make any sense.  Even for blocking listen socket if there
are sockets on the completion list, domsg to the proto-thread to
extract socket from completion list also wastes time.

The result:

192.168.249.42 (Xeon E3-1230 HT enabled, 16G) runs httperf
192.168.249.29 (i7-2600 HT enabled, 16G) runs nginx (web server)

The server runs nginx-1.0.4 (from pkgsrc-2011Q2), using the default
configure w/ following changes:
events {
    worker_connections  10240;
    use kqueue;
}

The client runs httperf-0.9.0 manually compiled w/ FD_SETSIZE to 16424
The client machine runs following commands before starting benching:
net.inet.ip.portrange.last=60000
route change -net 192.168.249.0/24 -msl 500

16 parallel httperf --server=192.168.249.29 --wsess=5000,1,1 --max-conn=4
4 runs (Request rate, unit: req/s)

old  23554.0  23542.0  23557.0  23526.2
new  24793.7  24809.9  24792.7  24794.4

This gives 5.3% performance improvement

12 years agobce: Use MPSAFE callout
Sepherosa Ziehau [Mon, 21 Nov 2011 05:46:13 +0000 (13:46 +0800)]
bce: Use MPSAFE callout