dragonfly.git
12 years agodfregress(8): Add some missing braces.
Sascha Wildner [Fri, 9 Dec 2011 18:05:33 +0000 (19:05 +0100)]
dfregress(8): Add some missing braces.

12 years agolib: Fix various whitespace and indent issues (no functional change).
Sascha Wildner [Fri, 9 Dec 2011 16:55:19 +0000 (17:55 +0100)]
lib: Fix various whitespace and indent issues (no functional change).

12 years agoSome cosmetics: #if(0) -> #if 0
Sascha Wildner [Fri, 9 Dec 2011 12:21:31 +0000 (13:21 +0100)]
Some cosmetics: #if(0) -> #if 0

12 years agokernel/nfs: Fix a bug due to missing braces.
Sascha Wildner [Fri, 9 Dec 2011 11:38:39 +0000 (12:38 +0100)]
kernel/nfs: Fix a bug due to missing braces.

The lwkt_reltoken() was added in c6b43e93a6cf0a70bde32cd141057a0df9860e13
but it was forgotten to put braces around the if's body (now having
lwkt_reltoken() and the return()).

12 years agokernel: Fix various whitespace and indent issues (no functional change).
Sascha Wildner [Fri, 9 Dec 2011 10:47:25 +0000 (11:47 +0100)]
kernel: Fix various whitespace and indent issues (no functional change).

12 years agosf(4): Remove a duplicated flag in a header.
Sascha Wildner [Thu, 8 Dec 2011 19:01:48 +0000 (20:01 +0100)]
sf(4): Remove a duplicated flag in a header.

12 years agorc.conf.5: Start a sentence in upper case.
Sascha Wildner [Thu, 8 Dec 2011 09:33:39 +0000 (10:33 +0100)]
rc.conf.5: Start a sentence in upper case.

12 years agotcpdump(1): Fix some sizeof(sizeof(x)) issues.
Sascha Wildner [Thu, 8 Dec 2011 08:26:24 +0000 (09:26 +0100)]
tcpdump(1): Fix some sizeof(sizeof(x)) issues.

Has been committed upstream too:

http://sourceforge.net/tracker/?func=detail&aid=3453360&group_id=53066&atid=469573

12 years agoacpi: Include acdragonfly.h from acenv.h.
Sascha Wildner [Thu, 8 Dec 2011 08:16:15 +0000 (09:16 +0100)]
acpi: Include acdragonfly.h from acenv.h.

12 years agokernel - Support bdwrite() on tmpfs buffer cache buffers
Matthew Dillon [Thu, 8 Dec 2011 06:32:33 +0000 (22:32 -0800)]
kernel - Support bdwrite() on tmpfs buffer cache buffers

* tmpfs itself does not call bdwrite() when no swap space has been
  allocated but certain system side effects such as nvtruncbuf()
  when a file is truncated CAN cause bdwrite() to be called.

  This eventually causes the buffer to run through tmpfs's strategy
  function.

* Adjust the strategy function to handle the no-swap case by marking
  the underlying pages dirty and valid and completing the I/O.

* Also handle the case when swap exists but fills up.  If the
  swap_strategy() function fails with ENOMEM fall-back to again
  marking the pages dirty andvalid and completing the I/O.

  This allows tmpfs to fill up to the system's total memory+swap instead
  of just the system's swap.

12 years agotcp: Don't check PRUS_OOB again in tcp_usr_send
Sepherosa Ziehau [Thu, 8 Dec 2011 05:38:37 +0000 (13:38 +0800)]
tcp: Don't check PRUS_OOB again in tcp_usr_send

- It is not necessary; it was checked in sosendtcp
- It does not work w/ asynchronized pru_send

Reminded-by: dillon@
12 years agokernel - Fix missing token release on I/O error during exec
Matthew Dillon [Thu, 8 Dec 2011 05:36:57 +0000 (21:36 -0800)]
kernel - Fix missing token release on I/O error during exec

* If an EIO occurs while exec is mapping pages from the binary we need
  to drop the vm_object we are holding before returning.

* Fixes panic when the system runs out of memory and no swap is present.

12 years agokernel - Remove partially commit debug code
Matthew Dillon [Thu, 8 Dec 2011 04:22:45 +0000 (20:22 -0800)]
kernel - Remove partially commit debug code

* Remove partially committed debug code that will cause the compile
  to fail.

12 years agokernel - Remove unneeded initialization
Matthew Dillon [Thu, 8 Dec 2011 04:19:40 +0000 (20:19 -0800)]
kernel - Remove unneeded initialization

* vm_object->flags is set to 0 by _vm_object_allocate() and does not
  need to be set to 0 again.

12 years agokernel - Clear the quick-return flag when changing PSL_IOPL.
Matthew Dillon [Thu, 8 Dec 2011 04:18:07 +0000 (20:18 -0800)]
kernel - Clear the quick-return flag when changing PSL_IOPL.

* Make sure we do a full syscall return when changing PSL_IOPL.

12 years agokernel - Add additional safety assertions in the pmap path
Matthew Dillon [Thu, 8 Dec 2011 04:16:36 +0000 (20:16 -0800)]
kernel - Add additional safety assertions in the pmap path

* Assert additional state is correct in pmap_pinit()

* Assert that the critical section count makes preemption impossible
  in pmap_interlock_wait(), which is called from the depths of swtch.s
  during a thread switch.

12 years agokernel - Adjust stack by an addition 128 in sendupcall()
Matthew Dillon [Thu, 8 Dec 2011 04:14:56 +0000 (20:14 -0800)]
kernel - Adjust stack by an addition 128 in sendupcall()

* Adjust stack by an addition 128 in sendupcall() for red-zone
  Note however that this code is currently unused, so it has no effect.

* If getmemsize() finds an overlapping region we break out of the inner
  loop so we can continue the outer loop.

Reported-by: swildner
12 years agokernel - Add -fno-stack-protector for kernel build
Matthew Dillon [Thu, 8 Dec 2011 04:14:04 +0000 (20:14 -0800)]
kernel - Add -fno-stack-protector for kernel build

* Add -fno-stack-protector for kernel build in order to be consistent
  with the other platform kernel builds

* Has no effect with the current version of gcc but may prevent bad vibes
  in the future.

12 years agokernel - Do not use LK_NOWAIT for vfs_busy() after initialization
Matthew Dillon [Thu, 8 Dec 2011 04:13:09 +0000 (20:13 -0800)]
kernel - Do not use LK_NOWAIT for vfs_busy() after initialization

* Minor adjustment, this is more appropriate then what we had but it
  will not effect the code since nobody references the mp yet at this
  point (thus the lock always succeeds even w/ LK_NOWAIT).

12 years agokernel - Fix panic during diskless mount
Matthew Dillon [Thu, 8 Dec 2011 04:10:13 +0000 (20:10 -0800)]
kernel - Fix panic during diskless mount

* Remove improper vfs_unbusy()'s from the nfs_mountroot path.  The mount
  is unbusied by the caller instead.  This fixes a lockmgr panic.

12 years agokernel - Fix endless nfs error 70 during shutdown
Matthew Dillon [Thu, 8 Dec 2011 04:08:03 +0000 (20:08 -0800)]
kernel - Fix endless nfs error 70 during shutdown

* When shutting down NFS rw mounts left over buffers may not be able to
  flush during a forced unmount.

* When unable to flush during a forced unmount mark the bp EIO instead
  of ESTALE and also mark it B_INVAL to remove the buffer from the the
  vnode.

12 years agokernel - Add TDF_RUNNING assertions
Matthew Dillon [Thu, 8 Dec 2011 02:51:52 +0000 (18:51 -0800)]
kernel - Add TDF_RUNNING assertions

* Assert that the target lwkt thread being switched to is not flagged as
  running.

* Assert that the originating lwkt thread being switched from is flagged as
  running.

* Fix the running flag initial condition for the idle thread.

12 years agokernel - Fix alarm() timer race against exit
Matthew Dillon [Thu, 8 Dec 2011 02:44:15 +0000 (18:44 -0800)]
kernel - Fix alarm() timer race against exit

* Stop the callout synchronously to ensure that any pending alarm timeout
  is completely removed before we allow a process to exit.

* Add a required PHOLD() to the relaitexpire() function.

12 years agokernel - add DEBUG_LOCKS_LATENCY option
Matthew Dillon [Thu, 8 Dec 2011 02:42:01 +0000 (18:42 -0800)]
kernel - add DEBUG_LOCKS_LATENCY option

* This is for debugging only, default disabled.  If optioned this adds
  a sysctl to add a forced latency loop (count to N) in front of any
  spinlock or gettoken.

12 years agobuildworld - Add uuid for HAMMER2
Matthew Dillon [Thu, 8 Dec 2011 02:40:06 +0000 (18:40 -0800)]
buildworld - Add uuid for HAMMER2

* Add the uuid for a HAMMER2 filesystem

12 years agobuildworld - Fix -j n collisions
Matthew Dillon [Thu, 8 Dec 2011 02:38:07 +0000 (18:38 -0800)]
buildworld - Fix -j n collisions

* Each of _gcc41_tools and _gcc44_tools needs to be ordered

* Currently installation of the objc include files can collide in a way
  that interferes with a parallel build, when gcc41 and gcc44 are built
  concurrently.  For now don't build them concurrently :-(.

12 years agokernel - Fix panic in vm_page_try_to_free()
Matthew Dillon [Thu, 8 Dec 2011 02:36:10 +0000 (18:36 -0800)]
kernel - Fix panic in vm_page_try_to_free()

* This function is supposed to work with the VM page in any state, including
  a potentially free state.

* Add additional checks to ignore the page if it is already in PQ_FREE or
  PQ_HOLD

Reported-by: sephe
12 years agokernel - Fix kqueue race with NOTE_EXIT
Matthew Dillon [Thu, 8 Dec 2011 02:34:01 +0000 (18:34 -0800)]
kernel - Fix kqueue race with NOTE_EXIT

* Fix a kqueue race where the process receiving a NOTE_EXIT can go
  away while the NOTE_EXIT is being delivered.

* Add a required PHOLD/PRELE since knote_remove() can block.

* Properly return on-zero if KN_DETACHED is set at the end of knote_release()
  so the caller knows to restart the list scan.

Reported-by: sephe
12 years agokernel/netgraph: Set resp to NULL if it is kfree()'d in the switch case.
Sascha Wildner [Wed, 7 Dec 2011 21:11:09 +0000 (22:11 +0100)]
kernel/netgraph: Set resp to NULL if it is kfree()'d in the switch case.

This will prevent a later kfree() in the function from freeing it again.

12 years agokfree.cocci: Add a few more memory freeing functions to take into account.
Sascha Wildner [Wed, 7 Dec 2011 18:03:13 +0000 (19:03 +0100)]
kfree.cocci: Add a few more memory freeing functions to take into account.

12 years agox86_64/ioapic: Always allow user to specify GSI's target CPU
Sepherosa Ziehau [Wed, 7 Dec 2011 13:07:19 +0000 (21:07 +0800)]
x86_64/ioapic: Always allow user to specify GSI's target CPU

Even if interrupt automatic load balance is disable we still should
obey the explicit GSI target CPU configuration.

12 years agox86_64/icu: Implement rman_setup MachIntrABI method
Sepherosa Ziehau [Wed, 7 Dec 2011 12:05:16 +0000 (20:05 +0800)]
x86_64/icu: Implement rman_setup MachIntrABI method

- Add per-cpu IRQ mapping support
- Use MachIntrABI.rman_setup to set the interrupt rman's managing
  regions properly

12 years agokernel: Save another bzero() by using M_ZERO.
Sascha Wildner [Tue, 6 Dec 2011 19:01:43 +0000 (20:01 +0100)]
kernel: Save another bzero() by using M_ZERO.

12 years agokernel: Remove another NULL check after kmalloc() with M_WAITOK.
Sascha Wildner [Tue, 6 Dec 2011 19:01:11 +0000 (20:01 +0100)]
kernel: Remove another NULL check after kmalloc() with M_WAITOK.

12 years agovknetd - Document recently added rc.d script.
Antonio Huete Jimenez [Tue, 6 Dec 2011 18:47:53 +0000 (19:47 +0100)]
vknetd - Document recently added rc.d script.

12 years ago<sys/malloc.h>: Remove the MALLOC() and FREE() macros.
Sascha Wildner [Tue, 6 Dec 2011 17:09:15 +0000 (18:09 +0100)]
<sys/malloc.h>: Remove the MALLOC() and FREE() macros.

12 years agokernel: Replace all usage of MALLOC()/FREE() with kmalloc()/kfree().
Sascha Wildner [Tue, 6 Dec 2011 17:58:34 +0000 (18:58 +0100)]
kernel: Replace all usage of MALLOC()/FREE() with kmalloc()/kfree().

12 years agorc.d - Add a basic vknetd script.
Antonio Huete Jimenez [Tue, 6 Dec 2011 17:59:30 +0000 (18:59 +0100)]
rc.d - Add a basic vknetd script.

12 years agokernel - Remove unnecessary < 0 checks for sopt_valsize unsigned field + fixup
Matthew Dillon [Tue, 6 Dec 2011 17:21:35 +0000 (09:21 -0800)]
kernel - Remove unnecessary < 0 checks for sopt_valsize unsigned field + fixup

* Remove unnecessary < 0 checks for sopt_valsize, which is an unsigned field

* Add an upper-bound test in one place which did not have it.

Reported-by: Edward O'callaghan, logan1
12 years agovknetd.8: Use the full month name in .Dd.
Sascha Wildner [Tue, 6 Dec 2011 13:41:20 +0000 (14:41 +0100)]
vknetd.8: Use the full month name in .Dd.

12 years agokfree.cocci: We neither have BUG() nor BUG_ON().
Sascha Wildner [Tue, 6 Dec 2011 13:41:12 +0000 (14:41 +0100)]
kfree.cocci: We neither have BUG() nor BUG_ON().

12 years agoAdd a coccinelle patch that searches for use-after-kfree.
Sascha Wildner [Tue, 6 Dec 2011 11:14:13 +0000 (12:14 +0100)]
Add a coccinelle patch that searches for use-after-kfree.

Taken-from: Linux

12 years agomlx(4): Don't free 'meo' until we're finished using it.
Sascha Wildner [Tue, 6 Dec 2011 10:35:01 +0000 (11:35 +0100)]
mlx(4): Don't free 'meo' until we're finished using it.

12 years agokernel/nfs: Don't free 'info' until we're finished using it.
Sascha Wildner [Tue, 6 Dec 2011 10:34:35 +0000 (11:34 +0100)]
kernel/nfs: Don't free 'info' until we're finished using it.

12 years agocryptodev(4): Fix a bug where the wrong key was bzero()'d before kfree().
Sascha Wildner [Tue, 6 Dec 2011 09:33:29 +0000 (10:33 +0100)]
cryptodev(4): Fix a bug where the wrong key was bzero()'d before kfree().

12 years agodpt(4): Remove duplicate bit in an | operation.
Sascha Wildner [Tue, 6 Dec 2011 07:46:32 +0000 (08:46 +0100)]
dpt(4): Remove duplicate bit in an | operation.

12 years agopthread_condattr_setclock(3): Fix the check for a known clock.
Sascha Wildner [Mon, 5 Dec 2011 21:46:06 +0000 (22:46 +0100)]
pthread_condattr_setclock(3): Fix the check for a known clock.

The way it was before, this function would always return EINVAL.

12 years agovknetd - Fix a bug in previous commit.
Antonio Huete Jimenez [Mon, 5 Dec 2011 15:45:45 +0000 (16:45 +0100)]
vknetd - Fix a bug in previous commit.

We have to create pidfile and install signal handlers for the child.

12 years agokernel: Use M_ZERO for kmalloc() instead of bzero()ing.
Sascha Wildner [Mon, 5 Dec 2011 13:53:56 +0000 (14:53 +0100)]
kernel: Use M_ZERO for kmalloc() instead of bzero()ing.

12 years agokernel: Remove some unneeded NULL checks after kmalloc() with M_WAITOK.
Sascha Wildner [Mon, 5 Dec 2011 10:39:06 +0000 (11:39 +0100)]
kernel: Remove some unneeded NULL checks after kmalloc() with M_WAITOK.

12 years agovknetd - Add pidfile and signal handlers.
Antonio Huete Jimenez [Sun, 4 Dec 2011 23:47:17 +0000 (00:47 +0100)]
vknetd - Add pidfile and signal handlers.

When started up, vknetd will create a pidfile in
/var/run/vknetd.pid by default or where specified
by option -i.

Add signal handlers to cleanup pid file.

12 years agokernel/netinet6: Add back a ':' I accidentally removed.
Sascha Wildner [Sun, 4 Dec 2011 22:09:31 +0000 (23:09 +0100)]
kernel/netinet6: Add back a ':' I accidentally removed.

12 years agokernel/netinet6: Fix stupid NULL pointer derefs.
Sascha Wildner [Sun, 4 Dec 2011 22:00:42 +0000 (23:00 +0100)]
kernel/netinet6: Fix stupid NULL pointer derefs.

12 years agokernel: Move some dereferences below the NULL checks.
Sascha Wildner [Sun, 4 Dec 2011 19:15:43 +0000 (20:15 +0100)]
kernel: Move some dereferences below the NULL checks.

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.