Commit Graph

3434 Commits

Author SHA1 Message Date
Poul-Henning Kamp
1fd7b93f3f Convert a Debugger(3) to a panic(9) and a EINVAL.
Reminded by:	bde
2001-01-21 21:19:49 +00:00
Jake Burkholder
a448b62ac9 Make intr_nesting_level per-process, rather than per-cpu. Setup
interrupt threads to run with it always >= 1, so that malloc can
detect M_WAITOK from "interrupt" context.  This is also necessary
in order to context switch from sched_ithd() directly.

Reviewed By:	peter
2001-01-21 19:25:07 +00:00
Jason Evans
527c2fd277 Make the order of the static initializer for all_mtx match the order of
fields in struct mtx.

Found by:	jake
2001-01-21 11:05:02 +00:00
Peter Wemm
654c30a008 Remove APIC_INTR_DIAGNOSTIC - this has been disabled for some time now.
Remove some leftovers of removed SMP options.
2001-01-21 07:54:10 +00:00
Jason Evans
d1c1b8413e Remove MUTEX_DECLARE() and MTX_COLD. Instead, postpone full mutex
initialization until after malloc() is safe to call, then iterate through
all mutexes and complete their initialization.

This change is necessary in order to avoid some circular bootstrapping
dependencies.
2001-01-21 07:52:20 +00:00
Jake Burkholder
3e899e1063 Remove the per-cpu pages used for copy and zero-ing pages of memory
for SMP; just use the same ones as UP.  These weren't used without
holding Giant anyway, and the routines that use them would have to
be protected from pre-emption to avoid migrating cpus.
2001-01-21 06:50:03 +00:00
John Baldwin
27e864e300 - All of proc_compare needs sched_lock, so hold it for the for loop that
calls it rather than obtaining and releasing it a lot in proc_compare.
- Collect all of the data gathering and stick it just after the
  proc_compare loop.  This way, we only have to grab sched_lock once now
  when handling SIGINFO.  All the printf's are done after the values are
  calculated.

Submitted mostly by:	bde
2001-01-20 23:03:20 +00:00
Bosko Milekic
56acb799b2 When short of mbufs or mbuf clusters, we sleep on appropriate "counters."
The counters are incremented when a thread goes to sleep and decremented
either when a thread is woken up by another thread or when the sleep
times out. There existed a race where the sleep count could be decremented
twice resulting in an eventual underflow.
Move the decrementing of the "counters" to the thread initiating the sleep
and thus remedy the problem.
2001-01-20 21:29:10 +00:00
John Baldwin
049ebc15a1 Temporarily disable the printf() for micruptime() going backwards, the
SIGXCPU signal, and killing of processes that exceed their allowed run
time until they can play nice with sched_lock.  Right now they are just
potentital panics waiting to happen.  The printf() has bitten several
people.
2001-01-20 02:57:59 +00:00
Jake Burkholder
c1ef8aac9e - Make npx_intr INTR_MPSAFE and move acquiring Giant into the
function itself.
- Remove a hack to allow acquiring Giant from the npx asm trap
  vector.
2001-01-20 02:30:58 +00:00
John Baldwin
4848fbae35 Be more careful with sched_lock in the SIGINFO handler. Specifically, do
not hold sched_lock while calling ttyprintf().  If we are on a serial
console, then ttyprintf() will end up getting the sio lock, resulting in
a lock order violation.

Noticed by:	des
2001-01-20 02:04:44 +00:00
Peter Wemm
558226eae7 Use #ifdef DEV_NPX from opt_npx.h instead of #if NNPX > 0 from npx.h 2001-01-19 13:19:02 +00:00
Peter Wemm
f7b6e45d5b apic_itrace_splz[] is unused 2001-01-19 10:48:35 +00:00
Peter Wemm
198c5b0891 Remove the static splXXX functions and replace them by static __inline
stubs.  Remove the xxx_imask variables which have been all but gone for
a while.
2001-01-19 09:57:29 +00:00
John Baldwin
568ae39fd5 Revert revision 1.102. I don't think p_nice needs to be protected with
sched_lock, and I'm fairly certain P_TRACED will be protected with the
proc lock instead.

Pointed out indirectly by:	bde
2001-01-19 08:23:22 +00:00
Matthew Dillon
bcc740c453 Do not cluster with B_LOCKED buffers.
This is an odd one.  This patch appears to fix a panic related to background
bitmap writes (for FFS), though neither Kirk, Ian, or I can figure out how
B_CLUSTEROK could possibly be set on a bitmap block to cause the clustering
code to improperly cluster with a buffer undergoing a background write.

In anycase, the clustering code is very fragile and this patch helps with
that, as well as possibly fixing a bug Andre was having.

Suggested by: Ian Dowse <iedowse@maths.tcd.ie>
Testing by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
2001-01-19 05:31:07 +00:00
Bosko Milekic
08812b3925 Implement MTX_RECURSE flag for mtx_init().
All calls to mtx_init() for mutexes that recurse must now include
the MTX_RECURSE bit in the flag argument variable. This change is in
preparation for an upcoming (further) mutex API cleanup.
The witness code will call panic() if a lock is found to recurse but
the MTX_RECURSE bit was not set during the lock's initialization.

The old MTX_RECURSE "state" bit (in mtx_lock) has been renamed to
MTX_RECURSED, which is more appropriate given its meaning.

The following locks have been made "recursive," thus far:
eventhandler, Giant, callout, sched_lock, possibly some others declared
in the architecture-specific code, all of the network card driver locks
in pci/, as well as some other locks in dev/ stuff that I've found to
be recursive.

Reviewed by: jhb
2001-01-19 01:59:14 +00:00
John Baldwin
dcfc09d931 Protect p_stat and p_oncpu with sched_lock in forward_signal(). 2001-01-18 08:19:25 +00:00
Bosko Milekic
35c05ac61b Add some KASSERTs valid if WITNESS is defined to verify that the mbuf
allocation routines are being called safely. Since we drop our relevant
mbuf mutex and acquire Giant before we call kmem_malloc(), we have
to make sure that this does not pave the way for a fatal lock order
reversal. Check that either Giant is already held (in which case it's safe
to grab it again and recurse on it) or, if Giant is not held, that no
other locks are held before we try to acquire Giant.

Similarily, add a KASSERT valid in the WITNESS case in m_reclaim() to
nail callers who end up in m_reclaim() and hold a lock.

Pointed out by: jhb
2001-01-16 01:53:13 +00:00
Jason Evans
238510fc46 Implement condition variables. 2001-01-16 01:00:43 +00:00
Poul-Henning Kamp
9039f19fa0 A bit of sanity-checking in bioqdisksort(): panic if we recurse. 2001-01-14 18:48:42 +00:00
Dag-Erling Smørgrav
faa784b70c Use predictable internal names for the sysvipc modules, so we have a
chance of getting dependencies working.
2001-01-14 18:04:30 +00:00
John Baldwin
b947e93403 - Use sched_lock to prevent the mutex name from changing out from under us
while we are copying it to the kinfo_proc structure.
- Test against p_stat to see if we are blocked on a mutex.
- Terminate ki_mtxname with a null char rather than ki_wmesg.
2001-01-13 23:08:34 +00:00
Ben Smithurst
4c061a9da1 Fix getsid() to use "=" instead of "==".
Not objected to by:	audit
2001-01-13 22:49:59 +00:00
Jake Burkholder
063415120b Change return ??? to return -1 in some #if 0'ed code. 2001-01-12 08:24:25 +00:00
David Malone
3b54736e19 Style improvements for last fix. Should be functionally the same.
Submitted by:	bde
2001-01-11 00:13:54 +00:00
Jake Burkholder
ef73ae4b0c Use PCPU_GET, PCPU_PTR and PCPU_SET to access all per-cpu variables
other then curproc.
2001-01-10 04:43:51 +00:00
Bosko Milekic
d113d3857e In m_mballoc_wait(), drop the mmbfree mutex lock prior to calling
m_reclaim() and re-acquire it when m_reclaim() returns. This means that
we now call the drain routines without holding the mutex lock and
recursing into it. This was done for mainly two reasons:

(i) Avoid the long recursion; long recursions are typically bad and this
    is the case here because we block all other code from freeing mbufs
    if they need to. Doing that is kind of counter-productive, since we're
    really hoping that someone will free.

(ii) More importantly, avoid a potential lock order reversal. Right now,
     not all the locks have been added to our networking code; but
     without this change, we're introducing the possibility for deadlock.
     Consider for example ip_drain(). We will likely eventually introduce
     a lock for ipq there, and so ip_freef() will be called with ipq lock
     held. But, ip_freef() calls m_freem() which in turn acquires the
     mmbfree lock. Since we were previously calling ip_drain() with mmbfree
     held, our lock order would be: mmbfree->ipq->mmbfree. Some other code
     may very well lock ipq first and then call ip_freef(). This would
     result in the regular lock order, ipq->mmbfree. Clearly, we have
     deadlock if one thread acquires the ipq lock and sits waiting for
     mmbfree while another thread calling m_reclaim() acquires mmbfree
     and sits waiting for the ipq lock.

Also, make sure to add a comment above m_reclaim()'s definition briefly
explaining this. Also document this above the call to m_reclaim() in
m_mballoc_wait().

Suggested and reviewed by: alfred
2001-01-09 23:58:56 +00:00
Garrett Wollman
0a2c3d48c6 select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
Nick Hibma
11a8d6c202 Unset the devclass if the attach fails and the devclass was not set to
begin with.

Reviewed by:	dfr
2001-01-08 22:16:26 +00:00
David Malone
2ebaaccd47 If we failed to allocate the file discriptor for the write end of
the pipe, then we were corrupting the pipe_zone free list by calling
pipeclose on rpipe twice. NULL out rpipe to avoid this.

Reviewed by:	dillon
Reviewed by:	iedowse
2001-01-08 22:14:48 +00:00
Jake Burkholder
bb5c0622b7 Fix a warning. The type of globaldata.gd_prvspace has changed. 2001-01-08 15:25:45 +00:00
Alfred Perlstein
bdfa4f04d9 Don't use SCARG.
Pointed out by: bde
2001-01-08 07:22:06 +00:00
Alfred Perlstein
0bad156a91 Limit size of passed in data for utrace function.
Requested by: rwatson
Obtained from: NetBSD
2001-01-06 09:34:20 +00:00
John Baldwin
a0a7328bb0 - Move all of the KTR sysctl's under a new debug.ktr mib.
- Provide TUNABLE_INT() hooks for ktr_cpumask, ktr_mask, and ktr_verbose
  so that they can be set from the loader by their respective sysctl names.
  For example, to turn on KTR_INTR and KTR_PROC in ktr_mask, one could
  stick 'debug.ktr.mask="0x1200"' in /boot/loader.conf.
2001-01-06 06:51:43 +00:00
John Baldwin
5192404af2 Protect p_nice and P_TRACED in psignal() above the switch statement with
sched_lock.
2001-01-06 00:08:39 +00:00
Warner Losh
38c490a10f Make this file conform mostly to style(9):
o Use 8 space hard tabs
o Eliminate trailing white space (while I'm here, just in a couple of places)
o wrap mostly at 80 columns (printf literal strings being the notable
  exception)
o use return (foo) consistantly
o use 0 vs NULL more consistantly
o use queue(3) xxx_FOREACH macros where appropriate (some places used it
  before, others didn't).
o use BSD line continuation parameters

Pendants will likely notice minor style(9) violations, but for the
most part the file now looks much much closer to style(9) and is
mostly self-consistant.

Approved in principle by: dfr
Reviewed by: md5 (no changes to the .o)
2001-01-05 07:29:54 +00:00
John Baldwin
c5f9b6d075 - For dynamic sysctl's added at runtime, don't assume that the name passed
to the SYSCTL_ADD_FOO() macros is a constant that should be turned into
  a string via the pre-processor.  Instead, require it to be an explicit
  string so that names can be generated on the fly.
- Make some of the char * arguments to sysctl_add_oid() const to quiet
  warnings.
2001-01-05 07:00:45 +00:00
Nick Hibma
f0b8108f1d Fix a bug in both scripts: HEADER sections were not emitted to the header
file.

While there fix the layout of function headers (noticable in long headers)

Fix up some style nits. It's Perl and should be written in that style.
2001-01-04 13:41:24 +00:00
John Baldwin
3e6831f510 The previous commit wasn't entirely correct. At least one goto to the
out: label in psignal() did not grab sched_lock before trying to release
it.  Also, the previous version had several cases where it grabbed
sched_lock before jumping to out: unneccessarily, so rework this a bit.
The runfast: and out: labels must be called with sched_lock released, and
the run: label must be called with it held.  Appropriate mtx_assert()'s
have been added that should catch any bugs that may still be in this
code.

Noticed by:	bde
2001-01-02 18:54:09 +00:00
Poul-Henning Kamp
1550c317bf Fix the <sys/queue.h> abuse.
Submitted by:	Dima Dorfman <dima@unixfreak.org>
Reviewed by:	/sbin/md5
2001-01-02 11:51:55 +00:00
Poul-Henning Kamp
7f9cb01893 Add an XXX about a <sys/queue.h> transgression which needs cleaned up. 2001-01-02 10:34:09 +00:00
Poul-Henning Kamp
8eb6e436e8 Remove a bogus #ifdef KTR stanza.
Noticed by:	Alexander Langer <alex@big.endian.de>
2001-01-01 23:09:53 +00:00
John Baldwin
4bfba0cf19 Push down sched_lock in psignal(). sched_lock was being held across
recursive calls into psignal() as well as calls to signotify(),
forward_signal(), etc.
2001-01-01 02:31:08 +00:00
John Baldwin
ef8294075b Add in a missing release of the proctree lock.
Submitted by:	Sja <sakari.jalovaara@eqonline.fi>
2001-01-01 02:19:51 +00:00
Matt Jacob
56f29ddd1e there is no more miscfs/devfs 2000-12-31 23:12:20 +00:00
Seigo Tanimura
338c0bc664 Ignore a net interrupt if the corresponding handler is not
registered.

This fixes panic on my laptop where a spurious arp packet
is received when arp is not ready to run.
2000-12-31 01:31:55 +00:00
Paul Saab
e9df486f0a Backout rev 1.57 & 1.58. While the previous revisions fixed
attaching to running processes, it completely breaks normal debugging.
A better fix is in the works, but cannot be properly tested until
the problem with gdb hanging the system in -current is solved.
2000-12-31 01:30:27 +00:00
Paul Saab
894653d6fa Pass me the pointy hat. Do not hold sched_lock over psignal.
Submitted by:	alfred
2000-12-30 00:44:44 +00:00
Greg Lehey
7fcd0cb31a Partially revert revision 1.7: Only use getnanotime instead of
nanotime if we would run into trouble with nanotime (i.e. if we are
tracing KTR_LOCK).

Reviewed by: 	jhb
2000-12-29 06:27:39 +00:00