Commit Graph

6464 Commits

Author SHA1 Message Date
tsutsui 33dfc34006 Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t. 2008-06-17 16:05:23 +00:00
reinoud f6a70673ba Mark a buffer `busy` in getnewbuf() when it came from the pool_cache since
its not on a free list.

Also change buf_init() to not automatically mark buffers `busy' since this
only makes sense for bufcache buffers.

Mark all buf_init'd buffers 'busy' on the places where they ought to be
flagged as such to not confuse the buffer cache.

Fixes PR 38923.
2008-06-17 14:53:10 +00:00
ad 4810cbe2bf sleepq_block: add a comment. 2008-06-17 09:11:25 +00:00
ad cad3a145a3 PR kern/38761: new (?) race in buffer cache code
Back out the workaround from cv_has_waiters(), which is not longer needed.
Removal was missed earlier.
2008-06-16 12:03:01 +00:00
ad a9c4cefebd PR kern/38927: processes getting stuck in uvm_map (cv_timedwait), hanging
machine

Assume that a vnode (and associated data structures) costs 2kB in the
worst imaginable case. Don't allow sysctl to set desiredvnodes to a
value that would use more than 75% of KVA or 75% of physical memory.
2008-06-16 11:26:28 +00:00
ad 45850c3df9 PPWAIT need only be locked by proc_lock, so move it to proc::p_lflag. 2008-06-16 10:15:57 +00:00
ad 672f91757e PR kern/38761: new (?) race in buffer cache code
- Back out the previous workaround now that the sleep queue code has
  been changed to never let the queue become empty if there are valid
  waiters.
- Use sleepq_hashlock() to improve clarity.
- Sprinkle some assertions.
2008-06-16 10:03:47 +00:00
ad 461a5fb24b PR kern/38761: new (?) race in buffer cache code
sleepq_changepri, sleepq_lendpri: don't let an active sleep queue head become
empty. The condvar code inspects the queue head without holding the sleep
queue lock and needs to see a non-empty queue if there are waiters.
2008-06-16 10:02:15 +00:00
ad 5adf7333fd - PPWAIT is need only be locked by proc_lock, so move it to proc::p_lflag.
- Remove a few needless lock acquires from exec/fork/exit.
- Sprinkle branch hints.

No functional change.
2008-06-16 09:51:14 +00:00
ad b0ac1133c6 Sprinkle some assertions. 2008-06-16 09:48:13 +00:00
ad 5bfa865311 Sprinkle more assertions. 2008-06-16 09:47:55 +00:00
ad b7f5063255 lwp_lock_retry: return a pointer to the lock acquired. No functional change. 2008-06-16 09:45:20 +00:00
rmind 481ae1556f - Add general cpuset macros.
- Use kcpuset name for kernel-only functions.
- Use cpuid_t to specify CPU ID.
- Unify all cpuset users.

API is expected to be stable now.
2008-06-16 01:41:20 +00:00
christos 09e715922e regen 2008-06-16 01:00:21 +00:00
uebayasi 9d4479f7e9 Typo. 2008-06-16 00:54:53 +00:00
christos 20d8fbfbe4 typo 2008-06-16 00:54:10 +00:00
christos 88c08e3b98 regen 2008-06-16 00:32:23 +00:00
christos 5c45905c42 adjust prototypes for the affinity calls. 2008-06-16 00:31:17 +00:00
rmind a6092d3c4a gencpuset: avoid returning of unitialized error.
sched_setaffinity: instead of E2BIG, return EINVAL in a case of invalid
CPU, which is more consistent.
2008-06-15 23:29:09 +00:00
christos f30b5785d5 Don't expose struct cpuset, share the l_affinity flag and only allocate it
if we need to. This is not a compatible change, but the syscalls are new
enough and they don't need to be versioned. Approved by rmind.
2008-06-15 20:32:57 +00:00
chris 44d939d150 Fix for biowait hangs, and possibly other condvar hangs. Also should fix
PR kern/38761.

The condvar must access the sleepq with the sleepq lock held, doing so
is causing inconsistent sleepq state to be read.

This is because some accesses to the sleepq don't come via the cv code,
but are call directly into sleepq_changepri and sleepq_lendpri, which take
the sleepq lock, and removes then re-inserts lwps into the sleepq.

Running a build.sh with -j8 now completes on my quad-core, also tested by
Simon@ on a 8-core server and matt@ on a quad-core.

I believe there is room to be more efficient with this, as we now take the
sleepq lock for all cv_broadcast and cv_signal calls. I'll look into this
and post a diff to tech-kern.
2008-06-15 09:56:18 +00:00
drochner a748803de9 tighten type checking: use device_t instead of void* at some places 2008-06-11 15:56:11 +00:00
ad 62c877a460 Don't call uvm_pageidlezero() if the CPU is marked offline. 2008-06-11 13:42:02 +00:00
drochner 520a61068b remove the hacks around fakemdrootdev[] which should be unnecessary now
that "md" devices show up in the "alldevs" list
2008-06-11 10:40:21 +00:00
dyoung 1e479b72f8 In device_pmf_driver_deregister, postpone deleting a device_t's
reference to the PMF private data until the private data has no
more waiters.  This protects against a NULL dereference.

In device_pmf_lock1(), test a device_t for PMF registration before
dereferencing its PMF private data.
2008-06-11 06:26:32 +00:00
simonb a0f8ee25d3 In mount_domount() there is no need to initialise "mp" if the first time
we use it we set it.
2008-06-10 14:14:01 +00:00
ad 06da5288fa There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.
2008-06-10 11:49:11 +00:00
ad f77c704577 Fix error in previous. 2008-06-09 11:49:40 +00:00
ad c862aeca6f ras_purgeall: avoid taking p_auxlock. 2008-06-09 11:46:34 +00:00
ad 5ab3329550 Correct previous. 2008-06-08 12:23:18 +00:00
ad 7304342b50 cdev_tty: don't acquire kernel lock, as we may need to call this with
tty_lock already held (and it would reverse the usual lock order).
2008-06-08 12:22:39 +00:00
ad d78b3bf8f2 PR kern/38881 execve(2) panic: lock error, with path argument > PATH_MAX 2008-06-06 22:21:11 +00:00
drochner 598d615d27 add a KASSERT to catch missing locators 2008-06-06 17:52:40 +00:00
ad 6a33531fe1 - Make getiobuf() return buffers marked BUSY.
- Sprinkle more assertions.
2008-06-06 12:49:15 +00:00
cegger 6e390579fc make this build 2008-06-05 21:55:51 +00:00
ad b91062326d Avoid "free vnode isn't" assertion. 2008-06-05 12:32:57 +00:00
ad 13c7f6ff40 Move lib/libkern/rb.h to sys/rb.h, so it can be used by kernel header
files.
2008-06-04 14:31:15 +00:00
rmind af4e8e9ea7 Check the result of allocation in the cases where size is passed by user. 2008-06-04 13:02:41 +00:00
ad cbbf514e2c - vm_page: put listq, pageq into a union alongside a LIST_ENTRY, so we can
use both types of list.

- Make page coloring and idle zero state per-CPU.

- Maintain per-CPU page freelists. When freeing, put pages onto the local
  CPU's lists and the global lists. When allocating, prefer to take pages
  from the local CPU. If none are available take from the global list as
  done now. Proposed on tech-kern@.
2008-06-04 12:45:28 +00:00
ad 621389e8b2 Fix broken enable test; fixes random coredumps. 2008-06-04 12:26:20 +00:00
ad 65b594ff61 Make sure the PAX flags are copied/zeroed correctly. 2008-06-04 12:16:06 +00:00
ad 8dd7771d61 Disable the wakeup assertion for the time being because the tty code
triggers it.
2008-06-04 11:22:55 +00:00
ad cee82bbafa Don't use proc specificdata for the PAX stuff. Speeds up mmap() and others. 2008-06-03 22:15:14 +00:00
ad d191ae6b1b Don't use proc specificdata. Speeds up mmap() and others. 2008-06-03 22:14:24 +00:00
ad 1b23b70818 vfs_cache:
- Don't use goto in critical paths, it can confuse the compiler.
- Sprinkle some branch hints.
- Make namecache stats per-CPU and collate once per second.
- Use vtryget().
2008-06-03 15:50:22 +00:00
ad 457a3f8942 vtryget: try to get an initial reference to a vnode without taking its
interlock. Only works if v_usecount is already non-zero, which is nearly
always true for busy files like libc.so or ld_elf.so.
2008-06-03 14:54:12 +00:00
dyoung b5bf86befb Before freeing a ktr_desc, destroy its condition variables. 2008-06-03 05:53:09 +00:00
ad a51fec9810 Avoid assertion failures. From drochner@. 2008-06-02 22:56:09 +00:00
drochner 99cb76cad6 adjust a KASSERT to reality after atomic vnode usecount changes 2008-06-02 19:20:22 +00:00
ad 3a8db3158e Use atomics to maintain v_usecount. 2008-06-02 16:25:34 +00:00
ad 30115e937a Most contention on proc_lock is from getppid(), so cache the parent's PID. 2008-06-02 16:18:09 +00:00
ad fb8c6fcc83 Don't needlessly acquire v_interlock. 2008-06-02 16:16:27 +00:00
ad 0d151db6c9 Don't needlessly acquire v_interlock. 2008-06-02 16:00:33 +00:00
ad 8ad974fae5 vn_marktext, vn_lock: don't needlessly acquire v_interlock. 2008-06-02 15:29:18 +00:00
ad ea8a92578d If vfork(), we want the LWP to run fast and on the same CPU
as its parent, so that it can reuse the VM context and cache
footprint on the local CPU.
2008-06-02 13:58:07 +00:00
ad c3e93e738f Make trap counters per-cpu, like syscalls. 2008-06-01 21:24:15 +00:00
ad 736a4d9b78 Kill devsw_lock and just use specfs_lock. The two would need merging
in order to prevent unload of modules when a device that they provide
is still open.
2008-05-31 21:34:42 +00:00
ad 2feabc3836 PR kern/38812 race between lwp_exit_switchaway and exit1/coredump
Move the LWP RUNNING and TIMEINTR flags into the thread-private flag word.
2008-05-31 21:26:01 +00:00
dyoung 8f34c216d0 Add printf_tolog(), which writes to the kernel message buffer,
only.  I believe this is the safest way to log serious conditions
indicated by NMI.
2008-05-31 20:27:24 +00:00
ad 4c57df4a3c - Put in place module compatibility check against __NetBSD_Version__,
as discussed on tech-kern.

- Remove unused module_jettison().
2008-05-31 20:14:38 +00:00
ad bda19becba Fix wmesg for !LOCKDEBUG. 2008-05-31 16:25:23 +00:00
ad 506130b087 biodone2: if the buffer is async or has a callback method, assert that
there are no waiters on b_done (threads in biowait()).
2008-05-31 13:41:44 +00:00
ad 7442154bd9 - Give each condition variable its own sleep queue head. Helps the system
to scale more gracefully when there are thousands of active threads.
  Proposed on tech-kern@.

- Use LOCKDEBUG to catch some errors in the use of condition variables:

  freeing an active CV
  re-initializing an active CV
  using multiple distinct mutexes during concurrent waits
  not holding the interlocking mutex when calling cv_broadcast/cv_signal
  waking waiters and destroying the CV before they run and exit it
2008-05-31 13:36:25 +00:00
ad e10320350c Use __noinline. 2008-05-31 13:31:25 +00:00
ad a6f1414cd1 tsleep -> kpause 2008-05-31 13:26:29 +00:00
ad 7b8f512433 LOCKDEBUG:
- Tweak it so it can also catch common errors with condition variables.
  The change to kern_condvar.c is not included in this commit and will
  come later.

- Don't call kmem_alloc() if operating in interrupt context, just fail
  the allocation and disable debugging for the object. Makes it safe
  to do mutex_init/rw_init/cv_init in interrupt context, when running
  a LOCKDEBUG kernel.
2008-05-31 13:15:21 +00:00
ad 10d96b47b0 shmrealloc: destroy condition variables before freeing them. 2008-05-31 13:11:14 +00:00
ad deda5b9d55 Hold proc_lock when sleeping on p_waitcv, not proc::p_lock. 2008-05-31 13:04:14 +00:00
ad 5b4d14b9f1 Add a comment to turnstile_block:
* NOTE: if you get a panic in this code block, it is likely that
        * a lock has been destroyed or corrupted while still in use.  Try
        * compiling a kernel with LOCKDEBUG to pinpoint the problem.
2008-05-31 12:03:15 +00:00
freza 1531f6d32e Any time we remove event from the queue make sure we 1. release the
event plist and 2. free the drvctl_event struct.

Discussed with jmcneill@.
2008-05-30 15:30:37 +00:00
ad 13cf4bcc55 PR kern/38663 Kernel preemption can't be enabled on x86 because of amd64
FPU handling

Remove ifdef(i386), kernel preemption works on amd64 now.
2008-05-30 12:18:14 +00:00
rmind 1be38c90d8 do_sys_accept: release the reference to sock in few error paths.
Should fix PR/38790, report and test-case by Nicolas Joly.
2008-05-30 09:49:01 +00:00
rmind a68758f8bd sched_idle: initialise 'tci' to NULL, avoids compiler warning. 2008-05-30 08:31:42 +00:00
ad e98d2c1016 lwp_exit_switchaway: set l_lwpctl->lc_curcpu = EXITED, not NONE. 2008-05-29 23:29:59 +00:00
rmind 29170d3854 Simplifcation for running LWP migration. Removes double-locking in
mi_switch(), migration for LSONPROC is now performed via idle loop.
Handles/fixes on-CPU case in lwp_migrate(), misc.

Closes PR/38169, idea of migration via idle loop by Andrew Doran.
2008-05-29 22:33:27 +00:00
rmind 15e36ef766 sys_shmget: use the correct size variable for uobj_wirepages().
Adjust shm_memlock() for consistency too.

Fixes PR/38782, reported by Adam Hoka.
2008-05-29 21:38:18 +00:00
joerg 157262cae8 Explicitly compute the next interval using 64bit arithmetic, if the time
was either stepped backwards or the timer has overflown. This fixes
PR 26470.
2008-05-29 15:27:51 +00:00
pooka de98844194 Mark pread/pwrite rump syscalls.
from Arnaud Ysmal
2008-05-29 12:01:37 +00:00
ad 79d0501e52 Disable zero copy if MULTIPROCESSOR, until it is fixed:
- The TLB coherency overhead on MP systems is really expensive.
- It triggers a race in the VM system (grep kpause uvm/*).
2008-05-28 21:01:42 +00:00
dyoung 801c395b47 Run shutdown hooks whether or not the kernel has panicked. Restores
NetBSD's shutdown behavior of more than 6 years before rev 1.176.
Ok joerg@.

It is essential that we restore some hardware to initial conditions
before rebooting, in order to avoid interfering with the BIOS
bootstrap.  For example, if NetBSD gives control back to the Soekris
comBIOS while the kernel text is write-protected, the BIOS bootstrap
hangs during the power-on self-test, "POST: 0123456789bcefghip".
In principle, bus masters can also interfere with BIOS boot.
2008-05-28 15:40:58 +00:00
ad b5d8351e8e PR kern/38355 lockf deadlock detection is broken after vmlocking
- Fix it; tested with Sun's libMicro.
- Use pool_cache.
- Use a global lock, so the deadlock detection code is safer.
2008-05-28 13:35:32 +00:00
ad 5831c8ac63 Pull in sys/evcnt.h. 2008-05-27 22:05:50 +00:00
ad f79b59f700 #ifdef strikes again 2008-05-27 21:36:03 +00:00
ad 4c634c7155 Sigh. The previous change did bad things to MySQL sysbench. Continue stealing
jobs from sched_nextlwp, but also do it in the idle loop. In sched_nextlwp
use trylock, in the idle LWP try harder.
2008-05-27 19:05:52 +00:00
ad 208df81d99 Move lwp_exit_switchaway() into kern_synch.c. Instead of always switching
to the idle loop, pick a new LWP from the run queue.
2008-05-27 17:51:17 +00:00
ad aa7e99c693 Replace a couple of tsleep calls with cv_wait. 2008-05-27 17:50:03 +00:00
ad 234470c22e tsleep -> kpause 2008-05-27 17:49:07 +00:00
ad ec32985f61 Use pool_cache. 2008-05-27 17:48:27 +00:00
ad f90f3a01ea Use kmem_alloc/free. 2008-05-27 17:42:14 +00:00
ad 81fa379a0b PR kern/38707 scheduler related deadlock during build.sh
- Fix performance regression inroduced by the workaround by making job
  stealing a lot simpler: if the local run queue is empty, let the CPU enter
  the idle loop. In the idle loop, try to steal a job from another CPU's run
  queue if we are idle. If we succeed, re-enter mi_switch() immediatley to
  dispatch the job.

- When stealing jobs, consider a remote CPU to have one less job in its
  queue if it's currently in the idle loop. It will dispatch the job soon,
  so there's no point sloshing it about.

- Introduce a few event counters to monitor what's happening with the run
  queues.

- Revert the idle CPU bitmap change. It's pointless considering NUMA.
2008-05-27 14:48:52 +00:00
ad f985e88f2b Start profiling clock on new process before setting it running, in case
there is a preemption.
2008-05-27 14:18:51 +00:00
christos b51f45d9e6 More fixes needed in the error paths for the chroot code to work. 2008-05-26 18:20:36 +00:00
rmind 06171502fc Adjust and thus unify my license. 2008-05-26 17:45:51 +00:00
ad c9ac92b592 Use pool_cache for sockets. 2008-05-26 17:21:18 +00:00
ad 46540aaf0e brelse: always wakeup on b_busy, in case BC_WANTED is not set. 2008-05-26 14:56:55 +00:00
ad 95488a6b7b Broken assertion. 2008-05-26 12:58:24 +00:00
ad 93e0e98369 Take the mutex pointer and waiters count out of sleepq_t: the values can
be or are maintained elsewhere. Now a sleepq_t is just a TAILQ_HEAD.
2008-05-26 12:08:38 +00:00
christos 0d264cffef PR/38745: Kouichirou Hiratsuka: chroot(8) can leak information of outside of
chrooted directory
2008-05-26 02:29:13 +00:00
christos 0e41ecf58b use PNBUF_* instead of malloc 2008-05-26 02:27:36 +00:00
ad c7615c48c8 PR kern/38707 scheduler related deadlock during build.sh
Fail sched_catchlwp() if mutex_tryenter() on the remote CPU's state fails.
Seems to work around the issue described in this PR.

XXX Stealing jobs from remote CPUs could probably be moved into the idle
loop, making the locking quite a bit simpler.
2008-05-25 23:46:55 +00:00
ad 1cc9a3ae7e If converting a process/thread from SCHED_OTHER to a realtime thread,
ignore the existing priority. If no priority is specified, give threads
the minimum user RT priority.
2008-05-25 23:34:24 +00:00
ad 90035a10c9 sched_tick:
- Do timeslicing for SCHED_RR threads. At ~16Hz it's too slow but better
  than nothing. XXX

- If a SCHED_OTHER thread has hogged the CPU for 1/8s without taking a
  trip through mi_switch(), try to force a kernel preemption to give other
  threads a chance.
2008-05-25 22:04:50 +00:00
christos 6e0baf783e don't forget to fill in the emulation. 2008-05-25 20:18:33 +00:00
ad 5e4b324300 Properly fix the "hanging in tty" bug that was worked around with cv_wakeup()
some time again.
2008-05-25 19:22:21 +00:00
jmcneill 1e2888bbbd Export device-driver and device-unit properties via drvctl 2008-05-25 15:03:01 +00:00
jmcneill 3a8a32076d Add DRVGETEVENT support for /dev/drvctl, based on devmon support by
Jachym Holecek for Google Summer of Code. DRVGETEVENT plist is currently
limited to event type, device name, and device parent name.
2008-05-25 12:30:40 +00:00
christos 934b677fde Coverity CID 5015: Remove unnecessary test; if l was null we would have
crashed before when p = l->l_proc.
2008-05-24 18:43:02 +00:00
christos 2847938186 Coverity CID 5019: Check before deref. 2008-05-24 16:49:30 +00:00
christos a2c63c0004 Coverity CID 5025: sbreserve is never called with a null socket. 2008-05-24 16:35:28 +00:00
ad 25866fbff7 Set cpu_onproc on entry to the idle loop. 2008-05-24 12:59:06 +00:00
njoly 12da67c77e Make msgsnd return EINVAL instead of 0, when the value of mtype is
less than 1.
2008-05-22 11:25:54 +00:00
ad 697d5e2cd4 PR kern/38663 Kernel preemption can't be enabled on x86 because of amd64
FPU handling

Ugly hack until the amd64 fpu handling is working (which should be soon):
enable kernel preemption on i386.
2008-05-21 15:41:03 +00:00
ad d88444761b Ignore return from module_load() and just try vfsop lookup again. 2008-05-20 19:30:03 +00:00
ad ce7cbbfb63 Back out unintentional change. 2008-05-20 19:21:23 +00:00
ad 61270d54f1 If autoloading a module, don't consider the current working directory. 2008-05-20 19:20:38 +00:00
ad 88435c0e48 Remove stale comment. 2008-05-20 19:16:07 +00:00
ad a72f5a57fb Don't try to load a module while holding a vnode lock. 2008-05-20 17:28:59 +00:00
ad 7bf8432671 If mount fails because the needed file system code isn't in kernel, try
to autoload with the needed vfsops.
2008-05-20 17:25:49 +00:00
ad 67280de1f2 Allow module class to be passed to module_load(), as a basic sanity check
that we are loading the right kind of module.
2008-05-20 17:24:56 +00:00
martin bd3d112a87 fix !MODULAR compiles 2008-05-20 16:18:51 +00:00
ad e69aa3297c Take $MACHINE into account when looking for modules. 2008-05-20 16:04:08 +00:00
ad ef621e3353 Remove pointless COMPAT ifdef. 2008-05-20 16:03:31 +00:00
ad 7a3561a8dc PR kern/38694 module dependencies do not work as expected
Autoload modules from the correct path based on kernel version.
2008-05-20 14:11:55 +00:00
ad d0bd9aa452 - Do local relocs before loading requisite modules, and all others only
after requisite modules have been loaded. For PR kern/38697.
- Simplify kobj interface slightly to make error handling easier.
2008-05-20 13:34:44 +00:00
jmcneill 3ea8229871 If we see a non-loadable BSS section in a pre-loaded module, make sure we
don't return success from kobj_load or nasty things will happen.
2008-05-19 17:33:42 +00:00
ad b0f6f924e3 Give devsw_detach() a dummy error return. 2008-05-19 17:15:00 +00:00
ad 245f0726ac Reduce ifdefs due to MULTIPROCESSOR slightly. 2008-05-19 17:06:02 +00:00
rmind 5f701aa0a3 - Make periodical balancing mandatory.
- Fix priority raising in M2 (broken after making runqueues mandatory).
2008-05-19 12:48:54 +00:00
hannken 940992e2c0 Remove a bad assertion from last commit.
Non bufcache buffers may have BC_BUSY unset.
2008-05-16 14:08:56 +00:00
hannken 5d2bff060a Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write.  Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn().  If set the caller
  intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
  may clear the buffer and runs copy-on-write.  Process possible errors
  from getblk() or fscow_run().  Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
2008-05-16 09:21:59 +00:00
hannken 961a5d4bcb Fscow_run() may recurse into itself.
Take care by adding a per-lwp recursion counter.
2008-05-16 09:01:56 +00:00
ad cefdd6012a In panic, we busy wait if another CPU is already panicking. Don't spl0(),
because we could recurse and run off the end of the stack. Pointed out by
chs@.
2008-05-13 11:54:45 +00:00
yamt c27d8958e0 sys_ptrace: fix a locking botch. PR/38649 from Martin Husemann. 2008-05-13 09:16:11 +00:00
ad a9ee17c54d Use cpu_index(), not ci_cpuid. 2008-05-12 14:28:22 +00:00
rmind 76db3ec4cd sys_shmget: fix an object leak in case of error. 2008-05-11 18:48:00 +00:00
ad 32c5d76875 Fix locking botch. Pointed out by kardel@. 2008-05-11 14:42:18 +00:00
wrstuden 97003b024b Oops. These are supposed to come alive on the branch, not the head. 2008-05-11 00:18:09 +00:00
wrstuden dbbab92bc9 Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
2008-05-10 23:48:44 +00:00
rumble a1221b6d4a Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

As a consequence, most of the file systems can now be loaded as new style
modules.

Quick sanity check by ad@.
2008-05-10 02:26:09 +00:00
ad 541e4662f9 - Add tc_gonebad(): allows timecounter to be flagged as bad and removed at
the next clock tick.
- Remove time_lock, which is no longer required.
2008-05-08 18:56:58 +00:00
njoly 24cbc2830b - Make semctl SETVAL/SETALL commands validate the semaphore value to
be set, which needs to be in the range [0,SEMVMX].
- Adjust the man page.
2008-05-06 20:25:09 +00:00
ad 82f138617e sys_unmount: drop ref to root dir before dounmount(), otherwise we'll
always get EBUSY.
2008-05-06 19:14:32 +00:00
ad 42d0626726 PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
  sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
  and is only ever write locked in dounmount(). A write hold can't be taken
  on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
  example when going r/o -> r/w, and is only present to serialize updates.
  In order to take this lock, a read hold must first be taken on
  mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 18:43:44 +00:00
ad a4e0004be3 LOCKDEBUG: try to speed it up a bit by not using so much global state.
This will break the build briefly but will be followed by another commit
to fix that..
2008-05-06 18:40:57 +00:00
ad 81194e34f1 Allow rw_tryenter(&lock, RW_READER) to recurse, for vfs_busy(). 2008-05-06 17:11:45 +00:00
ad d63f54a366 lookup: Do a vfs_trybusy(). If the file system is being unmounted, then
just fail the operation.
2008-05-06 15:04:00 +00:00
xtraeme f5b5967c0e Make this build again. 2008-05-06 13:31:02 +00:00
ad 39d40db63f PR kern/38141 lookup/vfs_busy acquire rwlock recursively
- sys_sync: acquire a write lock on the mount since the operation modifies
  the mount structure.
- sys_fchdir: use vfs_trybusy(). If an unmount is in progress, just fail it.
2008-05-06 12:54:25 +00:00
ad 8384d709ae Fix a couple of problems with checkdirs():
- vnode and cwd locks were being taken with proc_lock held, which is bad
  because proc_lock can only be held for a short period of time.

- Processes could have continually forked and escaped notice, keeping
  a reference to the old directory on top of which a new mount exists.
2008-05-06 12:51:22 +00:00
ad bdaf7ef5fc PR kern/38141 lookup/vfs_busy acquire rwlock recursively
vfs_busy: don't deadlock if curlwp is unmounting.
2008-05-06 12:39:32 +00:00