dragonfly.git
18 years agoFix a process exit/wait race. The wait*() code was making a faulty test
Matthew Dillon [Fri, 2 Dec 2005 22:02:20 +0000 (22:02 +0000)]
Fix a process exit/wait race.  The wait*() code was making a faulty test
to determine that the exiting process had completely exited and was no
longer running.  Testing the TDF_RUNNING flag is insufficient because an
exiting process may block at various points after becoming a Zombie, but
before it deschedules itself for the last time.

Add a new flag, TDF_EXITING, which is set just prior to a thread descheduling
itself for the last time.  The reaper then checks that TDF_EXITING is set
and TDF_RUNNING is clear.

Fix a second faulty test in both the exit and the thread cpu migration
code.  If a thread gets preempted, TDF_RUNNING will be temporarily cleared,
so testing TDF_RUNNING is not sufficient by itself.  We must also test
the TDF_PREEMPT_LOCK flag to be sure that it is also clear.

So the grand result is that to really be sure the zombie process has been
completely descheduled and is no longer running or will ever run again,
the TDF_EXITING, TDF_RUNNING, *and* TDF_PREEMPT_LOCK flags must be tested
and all must be clear except for TDF_EXITING.

It should be noted that TDF_RUNNING on the previously scheduled process
is always cleared AFTER we have context-switched into the next scheduled
thread or the idle thread, so seeing a cleared TDF_RUNNING along with the
appropriate state for the other flags does in fact guarentee that the thread
in question is no longer using its stack in any way.

Reported-by: Stefan Krueger <skrueger@meinberlikomm.de>
18 years agoFix a bug in the big tsleep/wakeup cleanup commit. When stopping a
Matthew Dillon [Fri, 2 Dec 2005 19:31:49 +0000 (19:31 +0000)]
Fix a bug in the big tsleep/wakeup cleanup commit.  When stopping a
sleeping process in psignal, we must wakeup() the parent process that
might be waiting in a wait4().

Reported-by: YONETANI Tomokazu <qhwt+dfly@les.ath.cx>
18 years agocred may be NULL due to a prior error code. crhold() handles NULL creds,
Matthew Dillon [Fri, 2 Dec 2005 17:29:45 +0000 (17:29 +0000)]
cred may be NULL due to a prior error code.  crhold() handles NULL creds,
but crfree() does not.  Check for NULL.

Reported-by: Stefan Krueger <skrueger@meinberlikomm.de>
18 years agoChange the initial path from /bin:/usr/bin to /bin:/usr/bin:/sbin:/usr/sbin
Matthew Dillon [Fri, 2 Dec 2005 17:16:10 +0000 (17:16 +0000)]
Change the initial path from /bin:/usr/bin to /bin:/usr/bin:/sbin:/usr/sbin
when no PATH environment variable is present.  This only really effects
boot -s, and not having [/usr]/sbin has always been an annoyance.

Requested-by: many
18 years agoDo not hold the ifnet serializer when entering tsleep() in the PPP TUN
Matthew Dillon [Thu, 1 Dec 2005 21:15:54 +0000 (21:15 +0000)]
Do not hold the ifnet serializer when entering tsleep() in the PPP TUN
interface code.  This can deadlock the network protocol threads.

Reported-by: Stefan Krueger
18 years agoFor MPSAFE syscall operation, CURSIG->__cursig->issignal() may be called
Matthew Dillon [Thu, 1 Dec 2005 18:54:20 +0000 (18:54 +0000)]
For MPSAFE syscall operation, CURSIG->__cursig->issignal() may be called
without the MP lock held.  At the moment issignal() needs to be MP locked
so wrap the function in the lock.  Note that issignal() is only called if
there is a signal pending so this will not disrupt kern.syscall_mpsafe
operation.

18 years agoThe primary mbuf cluster management code needs to be made MPSAFE since
Matthew Dillon [Thu, 1 Dec 2005 18:40:56 +0000 (18:40 +0000)]
The primary mbuf cluster management code needs to be made MPSAFE since
m_free() is now MPSAFE.  This involves using atomic_*() increment and
decrement for the mbuf cluster ref count and using a serializer if there
is a potential for a double-free (if the ref count is 2 or greater).  The
common code path will tend not to need the serializer unless the interface
is being tapped.

Reported-by: Peter Avalos <pavalos@theshell.com>
18 years agotsleep_interlock() must be called prior to testing the serializer lock
Matthew Dillon [Thu, 1 Dec 2005 18:34:09 +0000 (18:34 +0000)]
tsleep_interlock() must be called prior to testing the serializer lock
state, otherwise a serializer wakeup on another cpu may race our tsleep().

Reported-by: Emiel Kollof <coolvibe@hackerheaven.org>
18 years agoGet rid of the p_stat SZOMB state. p_stat can now only be SIDL, SSLEEP, or
Matthew Dillon [Thu, 1 Dec 2005 18:30:13 +0000 (18:30 +0000)]
Get rid of the p_stat SZOMB state.  p_stat can now only be SIDL, SSLEEP, or
SRUN.  Instead mark zombie processes with a new flag, P_ZOMBIE.  The eproc
code will convert P_ZOMBIE into SZOMB for /bin/ps.

This further isolates the tsleep code from the process status and fixes
a panic when a process in SZOMB tried to tsleep().

Reported-by: Stefan Krueger <skrueger@meinberlikomm.de>
18 years agoFix comment.
Sascha Wildner [Wed, 30 Nov 2005 14:48:54 +0000 (14:48 +0000)]
Fix comment.

18 years agounbreak LINT building
Sepherosa Ziehau [Wed, 30 Nov 2005 13:35:24 +0000 (13:35 +0000)]
unbreak LINT building

18 years ago- Fix wrong table size (which resulted in the descriptions being off by
Sascha Wildner [Wed, 30 Nov 2005 08:25:07 +0000 (08:25 +0000)]
- Fix wrong table size (which resulted in the descriptions being off by
  one in the menu).

- Change description of sysid #165 from 'FreeBSD' to 'DF/FBSD' since we
  share it with FreeBSD.

18 years agoupgrade_etc: remove altqd and network scripts too, which have been around
YONETANI Tomokazu [Wed, 30 Nov 2005 06:23:52 +0000 (06:23 +0000)]
upgrade_etc: remove altqd and network scripts too, which have been around
for a while but removed in CVS HEAD.

18 years agoJumbo mbuf mangement's extbuf callbacks must be MPSAFE. Use a serializer
Matthew Dillon [Tue, 29 Nov 2005 19:56:56 +0000 (19:56 +0000)]
Jumbo mbuf mangement's extbuf callbacks must be MPSAFE.  Use a serializer
to accomplish the task.  This is a workaround until we create a generic
mbuf management API for jumbo frames.

18 years agoipw (is the only driver that) needs a working interrupt to perform
Matthew Dillon [Tue, 29 Nov 2005 19:55:02 +0000 (19:55 +0000)]
ipw (is the only driver that) needs a working interrupt to perform
initialization.  This means we have to release the serializer across
the tsleep.  The code must additionally be MP Safe.

Reported-by: Johannes Hofmann <Johannes.Hofmann@gmx.de>
18 years agoProperly serialize IPW.
Matthew Dillon [Tue, 29 Nov 2005 17:15:56 +0000 (17:15 +0000)]
Properly serialize IPW.

Reported-by: Johannes Hofmann <Johannes.Hofmann@gmx.de>
With-help-from: Hiten Pandya <hmp@backplane.com>

18 years agoSync zoneinfo database with tzdata2005o from elsie.
Sascha Wildner [Tue, 29 Nov 2005 08:54:32 +0000 (08:54 +0000)]
Sync zoneinfo database with tzdata2005o from elsie.

asia:           7.86 -> 7.88
northamerica:   7.80 -> 7.82
southamerica:   7.62 -> 7.63

From the announcement:

"These incorporate the Georgia, Cuba, Nicaragua, and Jordan changes
 circulated over the past two weeks by Paul Eggert on the time zone
 mailing list."

18 years agoFix mdoc errors exising at least since the beginning of time (1991 import).
Simon Schubert [Mon, 28 Nov 2005 17:43:46 +0000 (17:43 +0000)]
Fix mdoc errors exising at least since the beginning of time (1991 import).

Spotted-by: corecode
mdoc-clue: swildner

18 years agoMake all network interrupt service routines MPSAFE part 1/3.
Matthew Dillon [Mon, 28 Nov 2005 17:13:47 +0000 (17:13 +0000)]
Make all network interrupt service routines MPSAFE part 1/3.

Replace the critical section that was previously used to serialize access
with the LWKT serializer.  Integrate the serializer into the IFNET structure.
Note that kern.intr_mpsafe must be set to 1 for network interrupts to actually
run MPSAFE.  Also note that any interrupts shared with othre non-MP drivers
will cause all drivers on that interrupt to run with the Big Giant Lock.

Network interrupt - Each network driver then simply passes that serializer
to bus_setup_intr() so only a single serializer is required to process the
entire interrupt path.  LWKT serialization support is already 100% integrated
into the interrupt subsystem so it will already be held as of when the
registered interrupt procedure is called.

Ioctl and if_* functions - All callers of if_* functions (such as if_start,
if_ioctl, etc) now obtain the IFNET serializer before making the call.  Thus
all of these entry points into the driver will now be serialized.

if_input - All code that calls if_input now ensures that the serializer
is held.  It will either already be held (when called from a driver), or
the serializer will be wrapped around the call.  When packets are forwarded
or bridged between interfaces, the target interface serializer will be
dropped temporarily to avoid a deadlock.

Device Driver access - dev_* entry points into certain pseudo-network
devices now obtain and release the serializer.  This had to be done on
a device-by-device basis (but there are only a few such devices).

Thanks to several people for helping test the patch, in particular
Sepherosa Ziehau.

18 years agotcp_syncache.cache_limit is a per-cpu limit, reserve enough space for all
Matthew Dillon [Sat, 26 Nov 2005 20:54:34 +0000 (20:54 +0000)]
tcp_syncache.cache_limit is a per-cpu limit, reserve enough space for all
cpus using it to hit the limit.

Reported-by: Peter Avalos <pavalos@theshell.com>
18 years agoIn unregister_int():
Sepherosa Ziehau [Sat, 26 Nov 2005 14:36:21 +0000 (14:36 +0000)]
In unregister_int():
- Don't update i_mplock_required, if the unregistering intr record is not found
- Use a local variable `rec0' to test whether after the unregistering there
  are still intr records which require MP lock.  `rec' can't be reused here,
  since `rec' is the intr record to free, if it is reused in this test, *wrong*
  intr record will be freed

18 years agoFix a mbuf statistics bug.
Matthew Dillon [Fri, 25 Nov 2005 17:52:53 +0000 (17:52 +0000)]
Fix a mbuf statistics bug.

Reported-by: Tomaz Borstnar and numerous others
18 years agoAssert that he mbuf type is correct rather then blinding setting m_type.
Matthew Dillon [Fri, 25 Nov 2005 17:16:23 +0000 (17:16 +0000)]
Assert that he mbuf type is correct rather then blinding setting m_type.

18 years ago- Ansify function definitions.
Sascha Wildner [Fri, 25 Nov 2005 00:58:52 +0000 (00:58 +0000)]
- Ansify function definitions.

- Move function type on a separate line.

18 years ago- Ansify function definitions.
Sascha Wildner [Fri, 25 Nov 2005 00:32:49 +0000 (00:32 +0000)]
- Ansify function definitions.

- Move function type on a separate line.

18 years ago- Ansify function definitions.
Sascha Wildner [Thu, 24 Nov 2005 23:42:54 +0000 (23:42 +0000)]
- Ansify function definitions.

- Move function type on a separate line.

- Minor style(9) cleanup.

18 years agoAdd the ips driver to GENERIC.
Matthew Dillon [Thu, 24 Nov 2005 23:01:58 +0000 (23:01 +0000)]
Add the ips driver to GENERIC.

Requested-by: Tomaz Borstnar <tomaz.borstnar@over.net>
18 years ago- Ansify function definitions.
Sascha Wildner [Thu, 24 Nov 2005 22:23:03 +0000 (22:23 +0000)]
- Ansify function definitions.

- Move function type on a separate line.

18 years agoMove individual parameter comments into the general comment.
Sascha Wildner [Thu, 24 Nov 2005 17:18:30 +0000 (17:18 +0000)]
Move individual parameter comments into the general comment.

Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years ago- Note that 'make upgrade' not only upgrades /etc but the whole system.
Sascha Wildner [Thu, 24 Nov 2005 16:33:03 +0000 (16:33 +0000)]
- Note that 'make upgrade' not only upgrades /etc but the whole system.

- Add some words of warning about running 'make upgrade' before
  'make installworld'.

18 years agoFix LINT kernel; spin_lock function definitions have been split into
YONETANI Tomokazu [Thu, 24 Nov 2005 02:16:17 +0000 (02:16 +0000)]
Fix LINT kernel; spin_lock function definitions have been split into
<sys/spinlock2.h>, so one has to explicitly #include it to use these
functions now.

18 years agoFix some minor bugs in lwkt_serialize_handler*() which upcoming code will
Matthew Dillon [Wed, 23 Nov 2005 22:54:22 +0000 (22:54 +0000)]
Fix some minor bugs in lwkt_serialize_handler*() which upcoming code will
depend on.

18 years agoRemove forgotten K&R parameter declaration.
Sascha Wildner [Wed, 23 Nov 2005 08:55:59 +0000 (08:55 +0000)]
Remove forgotten K&R parameter declaration.

Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years agoAdd an XXX comment to document that the initializations are for silencing
Sascha Wildner [Wed, 23 Nov 2005 08:51:56 +0000 (08:51 +0000)]
Add an XXX comment to document that the initializations are for silencing
GCC warnings.

Requested-by: joerg
Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years agoRemove prototypes for hidden functions. We'll deal with that later
Sascha Wildner [Wed, 23 Nov 2005 08:50:34 +0000 (08:50 +0000)]
Remove prototypes for hidden functions. We'll deal with that later
appropriately.

Requested-by: joerg
Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years agoAdd a lwkt_serialize_try() API function.
Matthew Dillon [Wed, 23 Nov 2005 01:27:55 +0000 (01:27 +0000)]
Add a lwkt_serialize_try() API function.

18 years agoMove ef.4 from sys/net/ef to share/man/man4.
Sascha Wildner [Tue, 22 Nov 2005 09:36:58 +0000 (09:36 +0000)]
Move ef.4 from sys/net/ef to share/man/man4.

18 years agoConsolidate the initialization of td_mpcount into lwkt_init_thread().
Matthew Dillon [Tue, 22 Nov 2005 08:41:06 +0000 (08:41 +0000)]
Consolidate the initialization of td_mpcount into lwkt_init_thread().

Fix a bug in kern.trap_mpsafe, the mplock was not being properly released
when operating in vm86 mode (when kern.trap_mpsafe was set to 1).

18 years agoDo not try to set up hardware vectors for software interrupts.
Matthew Dillon [Tue, 22 Nov 2005 06:13:42 +0000 (06:13 +0000)]
Do not try to set up hardware vectors for software interrupts.

18 years agoDocument the fact that the vm86 instruction emulator is MPSAFE.
Matthew Dillon [Tue, 22 Nov 2005 04:09:38 +0000 (04:09 +0000)]
Document the fact that the vm86 instruction emulator is MPSAFE.

18 years agoRemove unused label.
Matthew Dillon [Tue, 22 Nov 2005 03:58:34 +0000 (03:58 +0000)]
Remove unused label.

18 years agoAdd a sysctl and tunable kern.trap_mpsafe which allows some traps to run
Matthew Dillon [Tue, 22 Nov 2005 01:52:25 +0000 (01:52 +0000)]
Add a sysctl and tunable kern.trap_mpsafe which allows some traps to run
without having to hold the MP lock.  The more sophisticated traps, such as
a VM fault, will still obtain the MP lock.  The sysctl is disabled (0)
by default.

The main thing effected by turning this on is T_ASTFLT, which is used to
switch away from a user process to either a kernel thread (non preemptively)
or another user process.  When enabled, switching from a user process to
a kernel thread and back again will not require the MP lock.  However, the
real benefit will not be realized until more kernel threads run without the
MP lock.

18 years agoWrap psignal() and a few other places that require the MP lock when
Matthew Dillon [Tue, 22 Nov 2005 00:49:18 +0000 (00:49 +0000)]
Wrap psignal() and a few other places that require the MP lock when
events occur while returning from a system call.

18 years agoFix the design of ifq_dequeue/altq_dequeue by adding an mbuf pointer and
Matthew Dillon [Tue, 22 Nov 2005 00:24:35 +0000 (00:24 +0000)]
Fix the design of ifq_dequeue/altq_dequeue by adding an mbuf pointer and
requiring that a polled mbuf be passed as an argument to the dequeue
function.  Assert that the passed argument matches the mbuf that is actually
dequeued.  Also remove assignments of the return value from ifq_dequeue()
in such cases which implied that the mbuf might be different when, in fact,
it had better not be.

18 years agoFollowup to last commit, cleanup some SMP/UP conditionals.
Matthew Dillon [Mon, 21 Nov 2005 22:54:16 +0000 (22:54 +0000)]
Followup to last commit, cleanup some SMP/UP conditionals.

18 years agoAdd a sysctl and tunable kern.syscall_mpsafe which allows system calls
Matthew Dillon [Mon, 21 Nov 2005 21:59:52 +0000 (21:59 +0000)]
Add a sysctl and tunable kern.syscall_mpsafe which allows system calls
marked MPSAFE in syscalls.master to run without the MP lock.  This sysctl
is disabled (0) by default.

To make this work the userland scheduler's passive release / acquire code
had to be made MPSAFE.  The release code accomplishes this by using
atomic_*() ops to manipulate curprocmask and rdyprocmask.  The acquisition
code currently obtains the MP lock unconditionally.  The userland scheduler
really need to be rewritten to be cpu-localized.

Only a few system calls, such as getuid(), are currently marked MPSAFE.
No matter how a system call is marked, the MP lock is obtained
unconditionally when ktracing or signaling.

18 years agoStart working on making the printf() path MPSAFE, because it isn't at the
Matthew Dillon [Mon, 21 Nov 2005 21:56:14 +0000 (21:56 +0000)]
Start working on making the printf() path MPSAFE, because it isn't at the
moment.  Ensure that index computations on the message buffer cannot cause
a crash if multiple cpus are writing to the message buffer at the same time.

18 years agoAdd a sysctl and tunable kern.intr_mpsafe which allows threaded interrupts
Matthew Dillon [Mon, 21 Nov 2005 21:50:26 +0000 (21:50 +0000)]
Add a sysctl and tunable kern.intr_mpsafe which allows threaded interrupts
marked INTR_MPSAFE to run without the MP lock.  This sysctl is disabled (0)
by default.

18 years agoAdd a thread flag, TDF_MPSAFE, which is used during thread creation to
Matthew Dillon [Mon, 21 Nov 2005 18:49:27 +0000 (18:49 +0000)]
Add a thread flag, TDF_MPSAFE, which is used during thread creation to
determine whether the thread should initially be holding the MP lock or not.

18 years agoRemove inthand_add() and inthand_remove(). Instead, register_int() and
Matthew Dillon [Mon, 21 Nov 2005 18:02:46 +0000 (18:02 +0000)]
Remove inthand_add() and inthand_remove().  Instead, register_int() and
unregister_int() are called directly and the machine level vector setup and
teardown ABI calls are made from register_int() and unregister_int().

18 years agoThere are two possible causes which will make vr(4) stall:
Sepherosa Ziehau [Mon, 21 Nov 2005 13:20:29 +0000 (13:20 +0000)]
There are two possible causes which will make vr(4) stall:
in vr_start(), if vr_encap() fails:
1) vr_start() will set IFF_OACTIVE.  If the packet causing vr_encap() to fail
   is the only packet pending to be downloaded to device, vr(4) will stall,
   since:
   * No more packets can be transfered, because IFF_OACTIVE is turned on
   * Except for vr_{init, stop}(), vr_txeoc() is the only function that can
     turn off IFF_OACTIVE.  It is triggered by "frame download completing"
     interrupt.  But this kind of interrupt will not be generated here, since
     there are no other packets pending to be downloaded.
2) vr_start() will skip TX head and tail pointer updating, which leaks all
   previous successfully encapsulated TX chains.

Following fixes are applied:
- Allocate chunk of memory in vr_attch() to reduce the failure chance of
  vr_encap().  This will also reduce the load of mbuf allocation system
- Use indexes instead of pointers for TX chain processing.  This can save us
  some spaces in every vr_chain
- Update Tx head and tail indexes when there are successfully encapsultaed
  packets pending to be downloaded to device, even if vr_encap() fails for
  some packets
- Cache TX buffer and next TX descriptor's physical address in vr_chain, since
  these addresses are fixed during the life time of vr(4)

Other stuffs:
- Use M_ZERO flag in memory allocation instead of calling bzero() later
- Remove (char *) cast in bzero()
- Minor style changes

Reported-by: corecode
With-helps-form: joerg
Reviewed-by: joerg, submit@
18 years agoAdd XXX comments to document dubious random number acquisition technique.
Sascha Wildner [Sun, 20 Nov 2005 14:58:40 +0000 (14:58 +0000)]
Add XXX comments to document dubious random number acquisition technique.

18 years ago- Ansify function definitions.
Sascha Wildner [Sun, 20 Nov 2005 13:24:36 +0000 (13:24 +0000)]
- Ansify function definitions.

- Add prototypes.

- Fix some warnings.

In-collaboration-with: Alexey Slynko <slynko@tronet.ru>

18 years agoPrefer m_getcl() to EPIC_MGETCLUSTER() which uses MGETHDR()+MCLGET()
Sepherosa Ziehau [Sun, 20 Nov 2005 13:08:35 +0000 (13:08 +0000)]
Prefer m_getcl() to EPIC_MGETCLUSTER() which uses MGETHDR()+MCLGET()

18 years ago- Ansify function definitions.
Sascha Wildner [Sun, 20 Nov 2005 12:37:49 +0000 (12:37 +0000)]
- Ansify function definitions.

- Fix some warnings.

- In function definitions, move the type on a line of its own.

- Perform some style(9) cleanup.

- Remove (void) casts for discarded return values.

- Remove parameter names from function prototypes.

In-collaboration-with: Alexey Slynko <slynko@tronet.ru>

18 years ago- Remove unnecessary ETHER_* macros
Sepherosa Ziehau [Sun, 20 Nov 2005 11:59:54 +0000 (11:59 +0000)]
- Remove unnecessary ETHER_* macros
- Utilize pcidevs.h for PCI device id and vendor id
- Prefer PCIR_BAR() macro to PCIR_MAPS
- Use common device probing style, epic_devtype() is merged
- Nuke epic_softc_t.cardvend, since it is only used in epic_common_attach().
  Move epic_softc_t.cardid to the end of the struct
- Minor style changes

18 years ago- Ansify function definitions.
Sascha Wildner [Sun, 20 Nov 2005 11:07:30 +0000 (11:07 +0000)]
- Ansify function definitions.

- Fix some warnings.

- In function definitions, move the type on a line of its own.

- Remove (void) casts for discarded return values.

- Use va_copy() where appropriate.

In-collaboration-with: Alexey Slynko <slynko@tronet.ru>

18 years agoSync with FreeBSD's rev. 1.15. This brings in documentation for va_copy().
Sascha Wildner [Sun, 20 Nov 2005 11:05:44 +0000 (11:05 +0000)]
Sync with FreeBSD's rev. 1.15. This brings in documentation for va_copy().

18 years agoSync with FreeBSD dev/xe
Sepherosa Ziehau [Sun, 20 Nov 2005 10:16:56 +0000 (10:16 +0000)]
Sync with FreeBSD dev/xe

if_xe.c 1.39
if_xe_pccard 1.11
if_xereg.h 1.6
if_xevar.h 1.4
Major update to xe driver: (*)
- Make multicast work
- Fix (some of) the watchdog timeouts after card reset
- Add support for CE2, CEM28 and CEM33 cards
- General code cleanup

if_xe.c 1.42
if_xe_pccard.c 1.14
- Add hw.xe.debug sysctl node, set it to 1 by default
- Turn XE_DEBUG on by default

(*) This update was submitted to FreeBSD by
    Scott Mitchell <scott+freebsd at fishballoon.org>

18 years agoANSIfy
Sepherosa Ziehau [Sun, 20 Nov 2005 09:46:31 +0000 (09:46 +0000)]
ANSIfy

Submitted-by: Matthias Schmidt <schmidtm at mathematik.uni-marburg.de>
18 years ago- Fix some warnings.
Sascha Wildner [Sun, 20 Nov 2005 09:18:37 +0000 (09:18 +0000)]
- Fix some warnings.

- Include missing header files.

- Add prototypes.

- Put individual function parameter comments into a general comment
  to make the definition look better.

- Perform some style(9) cleanup.

Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years agoFix a bug in the last commit. The proc pointer can be NULL at the
Matthew Dillon [Sun, 20 Nov 2005 02:23:59 +0000 (02:23 +0000)]
Fix a bug in the last commit.  The proc pointer can be NULL at the
point where we PHOLD it, conditionalize the hold/rele.

Reported-by: Sascha Wildner <saw@online.de>
18 years ago- Document ttyname_r().
Sascha Wildner [Sat, 19 Nov 2005 22:32:53 +0000 (22:32 +0000)]
- Document ttyname_r().

- Fix several compilation warnings.

- Perform some style(9) cleanup.

Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years agoAdd missing prototypes.
Sascha Wildner [Sat, 19 Nov 2005 22:26:54 +0000 (22:26 +0000)]
Add missing prototypes.

Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years agoHonor NOFSCHG.
Joerg Sonnenberger [Sat, 19 Nov 2005 22:00:20 +0000 (22:00 +0000)]
Honor NOFSCHG.

18 years agoAdd removal of etc/rc.d/network[123] to 'make upgrade'.
Sascha Wildner [Sat, 19 Nov 2005 21:55:46 +0000 (21:55 +0000)]
Add removal of etc/rc.d/network[123] to 'make upgrade'.

18 years agoRemove unused network[123] scripts.
Sascha Wildner [Sat, 19 Nov 2005 21:52:09 +0000 (21:52 +0000)]
Remove unused network[123] scripts.

18 years ago- Remove unused "network" and "network[123]" scripts.
Sascha Wildner [Sat, 19 Nov 2005 21:47:32 +0000 (21:47 +0000)]
- Remove unused "network" and "network[123]" scripts.

- Remove obsolete "DragonFly" keyword.

18 years ago- Fix several compilation warnings.
Sascha Wildner [Sat, 19 Nov 2005 20:46:32 +0000 (20:46 +0000)]
- Fix several compilation warnings.

- Put individual function parameter comments into a general comment
  to make the definition look better.

Submitted-by: Alexey Slynko <slynko@tronet.ru>
18 years agoDon't depend on DragonFly keyword for shutdown scripts as well.
Joerg Sonnenberger [Sat, 19 Nov 2005 19:59:47 +0000 (19:59 +0000)]
Don't depend on DragonFly keyword for shutdown scripts as well.

Reminded-by: swildner
18 years agoDon't depend on the DragonFly keyword anymore, all unsupported scripts
Joerg Sonnenberger [Sat, 19 Nov 2005 18:34:02 +0000 (18:34 +0000)]
Don't depend on the DragonFly keyword anymore, all unsupported scripts
have been removed a while ago.

This has the additional advantage that pkgsrc rc scripts can be linked
directly under /etc/rc.d and be used as part of normal dependency
tracking.

18 years agoProtect allproc scans with PHOLD/PRELE, in particular to support the
Matthew Dillon [Sat, 19 Nov 2005 17:58:33 +0000 (17:58 +0000)]
Protect allproc scans with PHOLD/PRELE, in particular to support the
sysctl that fstat uses.

Add an additional wait state in exit1() when p_lock is non-zero.  Do not
remove the process from the allproc list until p_lock is zero in order to
protect allproc scans.

Remove a spurious PHOLD in the NFS code.  Generally clean up uses of PHOLD
that no longer apply.

Fstat problems reported by: Stefan Krueger <skrueger@meinberlikomm.de>

18 years agoConvert the lockmgr interlock from a token to a spinlock. This fixes a
Matthew Dillon [Sat, 19 Nov 2005 17:19:52 +0000 (17:19 +0000)]
Convert the lockmgr interlock from a token to a spinlock.  This fixes a
problem on SMP boxes where the MP lock would unexpectedly lose atomicy for
a short period of time due to token acquisition.

Add a tsleep_interlock() call which takes advantage of tsleep()'s cpu
locality of reference to provide a helper function which allows us to
atomically spin_unlock() and tsleep() in an MP safe manner with only
a critical section.  Basically all it does is set a cpumask bit for the
ident hash index to cause other cpu's issuing a wakeup to notify our cpu.
Any actual wakeup occuring during the race period after the spin_unlock
but before the tsleep() call will be delayed by the critical section
until after the tsleep has queued the thread.

Cleanup some unused junk in vm_map.h.

18 years agoMake the syslog message string static const, saves the copy.
Joerg Sonnenberger [Sat, 19 Nov 2005 15:19:03 +0000 (15:19 +0000)]
Make the syslog message string static const, saves the copy.
Noticed by Valeriy E. Ushakov.
Include some more headers, use __unused in the function declaration,
not in the protorype. This fixes most warnings.

18 years ago- Constify betting instructions.
Sascha Wildner [Sat, 19 Nov 2005 09:50:30 +0000 (09:50 +0000)]
- Constify betting instructions.
- Rename some local variables.
- Add __unused for unused parameters.
- Raise WARNS to 6.

Submitted-by: Peter Avalos <pavalos@theshell.com>
18 years agoDo a better job formatting vmstat -i output. Output entries that look like
Matthew Dillon [Thu, 17 Nov 2005 21:43:10 +0000 (21:43 +0000)]
Do a better job formatting vmstat -i output.  Output entries that look like
installed interrupt handlers even if no interrupts have occured.

18 years agoRemove ancient interrupt handler hacks that are no longer needed.
Matthew Dillon [Thu, 17 Nov 2005 21:29:45 +0000 (21:29 +0000)]
Remove ancient interrupt handler hacks that are no longer needed.

18 years agoIf a /dev/<disk> device node is fsynced at the same time the related
Matthew Dillon [Wed, 16 Nov 2005 17:55:22 +0000 (17:55 +0000)]
If a /dev/<disk> device node is fsynced at the same time the related
softupdates filesystem is fscyned, a self-referential D_BMSAFEMAP dependancy
can wind up being created from the /dev/<disk> vnode to the device vnode.
Catch and ignore the case.

Reported-by: Xin LI <delphij@frontfree.net>, David Beck <dbeck@beckground.hu>
Original-FreeBSD-bugreport: PR/66781 by John-Mark Gurney

18 years agoContinue work on our pluggable scheduler abstraction. Implement a system
Matthew Dillon [Wed, 16 Nov 2005 02:24:33 +0000 (02:24 +0000)]
Continue work on our pluggable scheduler abstraction.  Implement a system
call to set the scheduler for the current process (and future children),
and add an abstraction for scheduler registration.

Submitted-by: Sergey Glushchenko <deen@smz.com.ua>
18 years agoTemporarily check for and correct a race in getnewbuf() that exists due
Matthew Dillon [Mon, 14 Nov 2005 19:14:05 +0000 (19:14 +0000)]
Temporarily check for and correct a race in getnewbuf() that exists due
to the fact that lockmgr locks use tokens for their interlock.  The use
of a token can cause the atomicy of the big giant lock to be temporarily
lost and wind up breaking the assumed atomicy of higher level operations that
believed themselves to be safe making lockmgr calls with the LK_NOWAIT flag.

The general problem will soon be fixed by changing the lockmgr interlock
from a token to one of Jeffrey Hsu's spin locks.  Fortunately there are
only a few places left in DragonFly where LK_INTERLOCK is used.

18 years agoMake tsleep/wakeup() MP SAFE for kernel threads and get us closer to
Matthew Dillon [Mon, 14 Nov 2005 18:50:18 +0000 (18:50 +0000)]
Make tsleep/wakeup() MP SAFE for kernel threads and get us closer to
making it MP SAFE for user processes.  Currently the code is operating
under the rule that access to a thread structure requires cpu locality of
reference, and access to a proc structure requires the Big Giant Lock.  The
two are not mutually exclusive so, for example, tsleep/wakeup on a proc
needs both cpu locality of reference *AND* the BGL.  This was true with the
old tsleep/wakeup and has now been documented.

The new tsleep/wakeup algorithm is quite simple in concept.  Each cpu has its
own ident based hash table and each hash slot has a cpu mask which tells
wakeup() which cpu's might have the ident.  A wakeup iterates through all
candidate cpus simply by chaining the IPI message through them until either
all candidate cpus have been serviced, or (with wakeup_one()) the requested
number of threads have been woken up.

Other changes made in this patch set:

* The sense of P_INMEM has been reversed.  It is now P_SWAPPEDOUT.  Also,
  P_SWAPPING, P_SWAPINREQ are not longer relevant and have been removed.

* The swapping code has been cleaned up and seriously revamped.  The new
  swapin code staggers swapins to give the VM system a chance to respond
  to new conditions.  Also some lwp-related fixes were made (more
  p_rtprio vs lwp_rtprio confusion).

* As mentioned above, tsleep/wakeup have been rewritten.  The process
  p_stat no longer does crazy transitions from SSLEEP to SSTOP.  There is
  now only SSLEEP and SSTOP is synthesized from P_SWAPPEDOUT for userland
  consumpion.  Additionally, tsleep() with PCATCH will NO LONGER STOP THE
  PROCESS IN THE TSLEEP CALL.  Instead, the actual stop is deferred until
  the process tries to return to userland.  This removes all remaining cases
  where a stopped process can hold a locked kernel resource.

* A P_BREAKTSLEEP flag has been added.  This flag indicates when an event
  occurs that is allowed to break a tsleep with PCATCH.  All the weird
  undocumented setrunnable() rules have been removed and replaced with a
  very simple algorithm based on this flag.

* Since the UAREA is no longer swapped, we no longer faultin() on PHOLD().
  This also incidently fixes the 'ps' command's tendancy to try to swap
  all processes back into memory.

* speedup_syncer() no longer does hackish checks on proc0's tsleep channel
  (td_wchan).

* Userland scheduler acquisition and release has now been tightened up and
  KKASSERT's have been added (one of the bugs Stefan found was related
  to an improper lwkt_schedule() that was found by one of the new assertions).
  We also have added other assertions related to expected conditions.

* A serious race in pmap_release_free_page() has been corrected.  We
  no longer couple the object generation check with a failed
  pmap_release_free_page() call.  Instead the two conditions are checked
  independantly.  We no longer loop when pmap_release_free_page() succeeds
  (it is unclear how that could ever have worked properly).

Major testing by: Stefan Krueger <skrueger@meinberlikomm.de>

18 years agoFix a broken array lookup in the old 4.3 BSD mmap compatibility code
Matthew Dillon [Mon, 14 Nov 2005 18:07:13 +0000 (18:07 +0000)]
Fix a broken array lookup in the old 4.3 BSD mmap compatibility code
that could crash the kernel.

Reported-by: Stefan Krueger <skrueger@meinberlikomm.de>
18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 12:27:04 +0000 (12:27 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Change pmap_set()'s 'port' parameter from int to u_short.
- In function definitions, move the type on a line of its own.
- Remove (void) casts for discarded return values.
- Remove 'register' storage class specifiers.

18 years agoSwitch to NetBSD's ftp client.
Simon Schubert [Sun, 13 Nov 2005 11:59:03 +0000 (11:59 +0000)]
Switch to NetBSD's ftp client.

18 years agoUpdate libedit from NetBSD.
Simon Schubert [Sun, 13 Nov 2005 11:58:31 +0000 (11:58 +0000)]
Update libedit from NetBSD.

libedit update by: Ben Woolley <tautolog@gmail.com>
consumers update by: corecode

18 years agoMerge from vendor branch LUKEMFTP:
Simon Schubert [Sun, 13 Nov 2005 11:28:53 +0000 (11:28 +0000)]
Merge from vendor branch LUKEMFTP:
Import NetBSD's ftp client as of 2005-11-12.

18 years agoImport NetBSD's ftp client as of 2005-11-12. vendor/LUKEMFTP
Simon Schubert [Sun, 13 Nov 2005 11:28:53 +0000 (11:28 +0000)]
Import NetBSD's ftp client as of 2005-11-12.

18 years agoDon't close the toplevel makefile.
Simon Schubert [Sun, 13 Nov 2005 10:55:36 +0000 (10:55 +0000)]
Don't close the toplevel makefile.

Submitted-by: Eric Jacobs <eric@theeric.com>
18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 02:17:18 +0000 (02:17 +0000)]
Cleanup:

- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 02:13:52 +0000 (02:13 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 02:04:47 +0000 (02:04 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- In function definitions, move the type on a line of its own.
- Move function's open brace on a line of its own.
- Remove (void) casts for discarded return values.
- Remove unused variables.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 01:20:49 +0000 (01:20 +0000)]
Cleanup:

- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 01:19:15 +0000 (01:19 +0000)]
Cleanup:

- Ansify function definitions.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 00:07:42 +0000 (00:07 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Remove (void) casts for discarded return values.
- In function definitions, move the type on a line of its own.
- Remove __P.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 23:01:55 +0000 (23:01 +0000)]
Cleanup:

- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 22:35:01 +0000 (22:35 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 22:21:13 +0000 (22:21 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 21:56:11 +0000 (21:56 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.
- Ansify function definitions.

18 years agoUSB mouse fix for certain mice, such as the Logitech LX700. Do not assume
Matthew Dillon [Fri, 11 Nov 2005 19:34:38 +0000 (19:34 +0000)]
USB mouse fix for certain mice, such as the Logitech LX700.  Do not assume
that the last matching item is the one we want.  Save state for the first
item that matched.

Submitted-by: Jonathan Fosburgh
18 years agoAdd missing CPU options and reorder a little bit.
Sascha Wildner [Fri, 11 Nov 2005 16:35:49 +0000 (16:35 +0000)]
Add missing CPU options and reorder a little bit.