Commit Graph

50 Commits

Author SHA1 Message Date
pooka 840bf0206b If we are "unsleepable" due to a dying proc, yield() instead of
returning directly.  This allows other threads to run possible
setting a condition we are waiting on.

Fixes a busyloop condition which could be entered from vfs_unmountall()
where we were waiting for vrele_pending and the vrele thread could
not run since we were hogging the CPU.
2011-01-28 17:04:39 +00:00
pooka 96de0bb9fe Some lwp-walkers expect the correct value for l_stat, so use a flag
in l_flag instead of l_stat for the purpose of flagging lwps in a
dying proc.
2011-01-28 16:58:27 +00:00
haad 61583090b2 Add support for compiling ZFS and Solaris modules as RUMP libraries. Add
some locking and rumpcopy primitives and refactor module building Makefiles
to work with both RUMP and kernel modules. This is first part of adding
support for regular test of zfs on NetBSD to hunt some bugs and make it
stable.

Ok by pooka@.
2011-01-18 22:21:22 +00:00
pooka b0bfbf33ac When the client and the rump kernel are the same host process, all
threads blocking in the kernel automatically exit when the process
exists.  However, for the sysproxy case this does not hold.
Typically it's ~harmless, but e.g. in the case of socket binding
following by poll it gets annoying.

Introduce sysproxy procexit, which wakes up all threads blocking
on a condition when a process's communication socket is closed.
The code is a little different from the regular kernel simply
because in a rump kernel l_mutex is not available at all times
(this is because scheduling happens on every kernel entry and exit,
and that path must be kept lockless for any reasonable performance).
Instead, use gating which makes sure all threads are either out of
the cv code or suspended in a well-known state.  Then, wake up the
threads and tell them to get the hell out of our galaxy.
2011-01-12 12:51:21 +00:00
pooka 97936d4ea0 antipasto 2011-01-06 13:36:48 +00:00
pooka cd73d116db Support LOCKDEBUG. To use it, compile sys/rump with RUMP_LOCKDEBUG=yes.
requested by martin (sparc64 gdb cannot reliably produce a stack trace)
2011-01-06 11:22:54 +00:00
pooka 48ac8b3849 implement mutex_owner() 2010-12-01 17:22:51 +00:00
pooka 5e1b7bf36d Track lwp as the rumpuser mutex owner instead of pthread_t (this
is done in rumpuser for simplicity, since on the kernel side things
we assume we have only one pointer of space).  As a side-effect,
we can no longer know if the current thread is holding on to a
mutex locked without curlwp context (basically all mutexes inited
outside of mutex_init()).  The only thing that called rumpuser_mutex_held()
for a non-kmutex was the giant lock.  So, instead implement recursive
locking for the giant lock in the rump kernel and get rid of the
now-unused recursive pthread mutex in the hypercall interface.
2010-12-01 14:59:37 +00:00
pooka 4b8e90305c Similarly to cv_wait, fail if trying to cv_wait_sig() without threads. 2010-06-09 07:54:13 +00:00
pooka fdeac1d7df Move routines related to kernel locking and scheduling from
locks.c to klock.c.

No functional change.
2010-05-18 15:12:19 +00:00
pooka b1b7862792 Make it possible to use the scheduler lock as the rumpuser condvar
interlock.  This is applicable in cases where the actual interlock
is the CPU the currently running thread is scheduled on.  Borrowing
the scheduler lock as the mutex mandated by pthread_cond_wait()
does away with need to have an additional mutex.  This both optimizes
runtime execution and simplifies code, as the extra lock typically
lead to quite some trickeries to avoid the dungeon collapsing due
to zaps from the wand of deadlock.
2010-05-18 14:58:41 +00:00
pooka c741c01282 Add comment about clock mismatch. 2010-04-14 10:34:54 +00:00
snj 58e4422c47 Some might argue that it is benefi_c_ial to spell words correctly. 2010-01-31 00:54:22 +00:00
pooka 2ce80d0210 Remove last remnants of the long-ago-properly-fixed RUMP_LMUTEX_MAGIC hack. 2009-12-03 13:12:16 +00:00
pooka 62e84772b7 Almost there for virtual CPU MP support:
* support bound kernel threads
* bind softint threads to specific virtual cpus
  + remove now-unnecessary locks from softint code

Now, if we only had MI CPU_INFO_FOREACH() .... (hi rmind ;)
2009-12-01 09:50:51 +00:00
pooka 9c1300e7ee Provide some sort of cv_is_valid(). What a silly routine. 2009-11-26 17:29:34 +00:00
pooka ee4c8e1012 Make rumpuser_cv_timedwait take two int64's instead timespec to
uncouple it from the timespec layout.  Also, change return value
to zero for "timeout didn't expire" and non-zero for "timeout
expired".  This decouples the interface from errno assignments.
2009-11-11 16:46:50 +00:00
pooka 510038040b Use kern_mutex_obj.c directly instead of copypasting code. 2009-11-04 13:32:39 +00:00
pooka 254ffabc38 Include sys_select.c for proper select()/poll() support. 2009-10-16 00:14:53 +00:00
pooka 2f6e67dfd6 When allocating the temporary lwp we must have an lwp context. So
take turns using lwp0 for this purpose, nothing else uses it.
2009-10-15 23:15:55 +00:00
pooka 8559951571 Give lwp usage some much-needed love: stop treating lwp0 as the
all-sink and make sure each separate thread in rump has its own
lwp.  Happy-go-lucky callers will get scheduled a temporary lwp
on entry, while true lwp connoisseurs may request a stable lwp
for their purposes.  Some more love may be required later down the
road, but for now different threads will stepping on each others
toes.
2009-10-15 16:39:22 +00:00
pooka 9454f185c4 Add initial work on a rump virtual cpu scheduler. This is necessary
for kernel code which has been written to avoid MP contention by
using cpu-local storage (most prominently, select and pool_cache).

Instead of always assuming rump_cpu, the scheduler must now be run
(and unrun) on all entry points into rump.  Likewise, rumpuser
unruns and re-runs the scheduler around each potentially blocking
operation.  As an optimization, I modified some locking primitives
to try to get the lock without blocking before releasing the cpu.

Also, ltsleep was modified to assume that it is never called without
the biglock held and made to use the biglock as the sleep interlock.
Otherwise there is just too much drama with deadlocks.  If some
kernel code wants to call ltsleep without the biglock, then, *snif*,
it's no longer supported and rump and should be modified to support
newstyle locks anyway.
2009-10-15 00:28:46 +00:00
pooka fb39ec98d5 panic if cv_wait() is called in non-threaded mode 2009-10-02 09:56:08 +00:00
pooka 9188159bb1 Make the clock interrupt tick based on absolute time instead of
relative time.  This prevents drifting.  Also, keep track of time
within userspace, so we do not have to make a syscall to get the
clock value.  This is approximately 7 times cheaper, but on the
negative side is limited to the clock interrupt frequency.
2009-02-07 01:50:29 +00:00
pooka 3e5a8e03e3 misc cleanup, mainly header polish 2009-01-13 02:03:13 +00:00
pooka e222420f88 CTASSERT kcondvar size 2008-12-19 09:50:04 +00:00
pooka cf6dee5091 fix build
(hi thorpej!  the first one is always free ;)
2008-12-19 09:33:40 +00:00
pooka a768afd60b __KERNEL_RCSID 2008-12-18 00:24:12 +00:00
pooka 22c85f18af Get rid of local machine/{mutex,rwlock}.h files by treating the
object storage as a single pointer (all archs have at least one
uintptr_t in the objects).
2008-12-13 15:34:48 +00:00
pooka 37e12a5643 Make kernel biglock recursecount volatile. 2008-12-10 14:55:25 +00:00
pooka b33ee0fb5c Support callouts and call callout_hardclock() from the timer
interrupt thread.

The sleepq implementation required for callouts is horrible, kludged
only for callouts, and generally unacceptable.  It needs revisiting,
but I'm not sure yet should rump or kern_timeout be improved.  It's
almost untested as of now, but committing this will give me some
maneuvering space while letting application compile.
2008-10-10 13:14:41 +00:00
pooka 01f8a524d4 Rewrite kernel lockus maximus handling to be correct. 2008-10-09 01:17:48 +00:00
pooka bdf6e0b034 Install rump libraries and utilities to the base system and remove the
private non-installed build infrastructure from sys/rump.

breakdown of commit:
  * install relevant headers into /usr/include/rump
  * build sys/rump/librump/rumpuser and sys/rump/librump/rumpkern
    from src/lib and install as librumpuser and librump, respectively
    + this retains the ability to test a librump build with just the
      kernel sources at hand
  * move sys/rump/fs/lib/libukfs and sys/rump/fs/lib/libp2k to src/lib
    for general consumption, they are not kernel-space dwellers anyway
  * build and install sys/rump/fs/lib/lib$fs as librumpfs_$fs
  * add chapter 3 manual pages for rump, rumpuser, ukfs and p2k
  * build and install userspace kernel file system daemons if MKPUFFS=yes
    is spexified
  * retire fsconsole for now, it will make a comeback with an actually
    implemented version shortly
2008-07-29 13:17:40 +00:00
pooka 28fdf2df68 support cv_has_waiters() 2008-07-18 16:19:12 +00:00
ad fdce452b03 Turn off DIAGNOSTIC so it builds. 2008-05-31 19:28:36 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 481e4d16cb More stubs. 2008-04-11 15:23:45 +00:00
drochner 76ad1614e9 remove useless passing of the lwp from the KERNEL_LOCK() ABI
(not the API; this would be easy as well)
agreed (a while ago) by ad
2008-04-01 19:49:31 +00:00
pooka a7ece3ec53 Backup some fixes for recent breakage from local tree. Also some
other improvements such as exporting the real kernel namei and
using that in ukfs instead of the homegrown heap'o hacks namei.
"etcetc".
2008-03-11 10:50:16 +00:00
ad 508b2997d7 Fix pasto. Spotted by pooka@ 2008-01-30 10:22:02 +00:00
ad 3490efcc63 Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
2008-01-30 09:50:19 +00:00
pooka 65a36d9ef8 In case cv_timedwait() gets ticks == 0, make sure we sleep eternally
(or at least until wakeup) instead of immediately waking up.

In other words, fix this after it broke when another piece of the
code was fixed.  Ain't programming fun?
2008-01-21 17:56:48 +00:00
ad 888ef28a4d Fix merge error. 2008-01-02 12:46:07 +00:00
ad 4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
pooka d89e3e05a2 emulate a couple more locking interfaces 2008-01-01 22:03:24 +00:00
pooka ec137c87f4 steal 1.4.2.1 from vmlocking2: cv_xwait_sig() 2007-12-30 03:35:20 +00:00
pooka 5251a48396 support cv_broadcast() 2007-11-19 14:17:22 +00:00
pooka 2632ba6df4 Implement cv_timedwait(), requested by Reinoud. 2007-11-17 20:50:18 +00:00
pooka 6fd64d7496 implement _kernel_lock{,_unlock}() 2007-11-07 16:24:22 +00:00
pooka 87f9ee4c42 Make it possible to run rumps multithreaded. This brings real
locking and makes it possible to run file systems which create
threads.  It also makes rump file system behaviour better match
file system behaviour in the kernel.
2007-10-31 15:57:19 +00:00