Commit Graph

6746 Commits

Author SHA1 Message Date
dyoung
37dcd495a0 Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL.  No functional change intended.
2008-10-24 22:23:20 +00:00
wrstuden
0a30ab777e toall signals really are toall. The fact we're sa doesn't matter.
They are start/stop signals, and need to impact more than just
blessed lwps.
2008-10-24 18:07:36 +00:00
christos
bc44c7d780 don't hold locks in ddb (call ksyms_getval_unlocked()), pointed out by ad. 2008-10-24 13:55:42 +00:00
christos
ff0507541f don't expose ksyms_lock 2008-10-23 20:41:13 +00:00
blymn
57614abcf2 Conditionalise bypass of veriexec routines on veriexec_strict to prevent
loophole if tables fail to load and strict is then raised.
2008-10-23 13:18:14 +00:00
ad
71781b4471 Set kern.posix_semaphores are runtime so it can be a module.
(Picked wrong header the last time.)
2008-10-22 11:25:19 +00:00
ad
52e9644b6b Make MODCTL_LOAD_FORCE do something. 2008-10-22 11:19:15 +00:00
ad
c81717a5e1 Set kern.posix_semaphores are runtime so it can be a module. 2008-10-22 11:17:08 +00:00
ad
7b228b5a9c - Be clear about whether module load is explicit or system initiated (auto).
- Require that module_lock is held to autoload, so that any preconditions
  can be safely checked.
2008-10-22 11:16:29 +00:00
matt
8f23ec634b Only define/use saemul_netbsd if KERN_SA is defined. (maybe this should be
moved to compat_sa.c)
2008-10-21 20:52:11 +00:00
matt
6e1d2d17ef Only init ksyms mutex if ksyms is present in the kernel 2008-10-21 20:51:11 +00:00
ad
a9327b33e2 Undo revivesa damage to userret(). 2008-10-21 11:51:23 +00:00
ad
19463db480 Correct an error message. 2008-10-20 20:07:35 +00:00
ad
ee66516bfd PR kern/38814 ksyms needs locking
- Make ksyms MT safe.
- Fix deadlock from an operation like "modload foo.lkm < /dev/ksyms".
- Fix uninitialized structure members.
- Reduce memory footprint for loaded modules.
- Export ksyms structures for kernel grovellers like savecore.
- Some KNF.
2008-10-20 10:24:18 +00:00
christos
90b563e4cb rename proc_representative_lwp to proc_active_lwp and clarify it is for
ps display purposes. suggested by rmind.
2008-10-19 03:10:09 +00:00
christos
6b9261b24b Select a "representative" lwp instead of the first lwp in the list. The
first lwp in the list is the last created and in the firefox and gtk-gnash
case this is usually a zombie, so the status in ps was ZLl. This now picks
the lwp in order ONPROC > RUN > SLEEP > STOP > SUSPENDED > IDL > DEAD > ZOMB
and breaks ties using cpticks.
2008-10-19 01:43:25 +00:00
rmind
a8552a3a74 Obviously intention was to check for SCHED_OTHER, not SCHED_FIFO. 2008-10-18 19:24:04 +00:00
rmind
b5eb577d50 - Initialize pool subsystem and kmem(9) earlier, when UVM is up enough.
- Remove uao_hashinit() workaround used for anon-objects.
- Replace malloc with kmem.

OK by <yamt>.
2008-10-18 03:46:22 +00:00
rmind
65af07bb0c Make SCHED_M2 nice with nice(1). Closes PR/38048. 2008-10-18 03:44:04 +00:00
rmind
d5ea013e1d Disallow user priority adjustments for SCHED_OTHER policy, simplify
convert_pri().  Sync schedctl(8) with the change.  Closes PR/38009.
2008-10-18 03:40:18 +00:00
wrstuden
7e10f527c2 Regen syscall tables. I forgot to do it after revivesa. While pooka
did some, not all are regenerated. Do them all at once for consistency.
2008-10-16 20:12:23 +00:00
pooka
e3b0fcf963 One more rump syscall: ioctl (required for interface configuration) 2008-10-16 19:30:49 +00:00
wrstuden
27724c38ae Adjust locking on the sadata::sa_vps list. The main time we
walk the list, we're looking for a vp to do something with. We do
this in the signal code and in the timer code. The signal code already
runs with proc::p_lock held, so it's a very natural lock to use. The
timer code, however, calls into the sa timer code with a spinlock held.
Since proc::p_lock is an adaptable mutex, we can sleep to get it. Sleeping
with a spinlock is BAD. So proc::p_lock is _not_ the right lock there,
and something like sadata::sa_mutex would be best.

Address this difficulty by noting that both uses actually just read
the list. Changing the list of VPs is rare - once one's added, it stays
until the process ends. So make the locking protocol that to write the
list you have to hold both proc::p_lock and sadata::sa_mutex (taken
in that order). Thus holding either one individually grants read access.

This removes a case where we could sleep with timer_lock, a spinlock at
IPL_SCHED (!!), while trying to get p_lock. If that ever happened, we'd
pretty much be dead. So don't do that!

This fixes a merge botch from how I handled our gaining p_lock - p_lock
should not have simply replaced p_smutex.

While here, tweak the sa_unblock_userret() code for the case
when the blessed vp is actually running (on another CPU). Make its
resched RESCHED_IMMED so we whack the CPU. Addresses a hang I've
observed in starting firefox on occasion when I see one thread running
in userland and another thread sitting in lwpublk, which means it's on
the list of threads for which we need an unblocked upcall. This list is
one on which things should NOT linger.
2008-10-16 18:21:45 +00:00
ad
ad507e54f8 _lwp_kill: set SI_LWP in the siginfo, not SI_USER. 2008-10-16 08:47:07 +00:00
wrstuden
e27861f46e Add a weak alias for ktr_saupcall, so things build w/o KTRACE compiled. 2008-10-15 16:03:29 +00:00
pooka
d31071b90c Mark a few network-related calls as RUMP (needs more work) 2008-10-15 13:01:15 +00:00
ad
b5ff001c46 Correction to previous. 2008-10-15 08:25:28 +00:00
ad
1ec58d56ef - Rename cpu_lookup_byindex() to cpu_lookup(). The hardware ID isn't of
interest to MI code. No functional change.
- Change /dev/cpu to operate on cpu index, not hardware ID. Now cpuctl
  shouldn't print confused output.
2008-10-15 08:13:17 +00:00
wrstuden
fc7511b00e Merge wrstuden-revivesa into HEAD. 2008-10-15 06:51:17 +00:00
pooka
2002727b2c Give maximum level of network softinterrupts a symbolic constant
(which happened to get bumbed from 32 to 33 (AF_MAX) now).
2008-10-14 17:15:20 +00:00
pooka
a44cdde52c M_IOV is used all over the place, so stuff it in with malloc_stdtypes 2008-10-14 14:17:49 +00:00
ad
82e3c0b1ac Accept filters:
- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.
2008-10-14 13:45:26 +00:00
ad
a68a7877a5 Correction to previous. 2008-10-14 09:17:23 +00:00
ad
a65f991bb4 Redo kern_resource.c:1.146 by pooka@: change ui_sbsize to a u_long. 2008-10-14 09:16:32 +00:00
pooka
3a64aae825 Fix previous: weak symbols work so much better if they are exported
from the object as weak symbols...

There's also something to be said about "cosmetic" tweaks after
testing, but I do think I'll bother.
2008-10-13 18:16:33 +00:00
pooka
cf05fbf706 Weak alias all rump system calls to rump_enosys() 2008-10-13 16:25:12 +00:00
plunky
c827b856f4 fix problem pointed out by ad where sockopt may end up sleeping
inappropriately with the socket lock held.

    sockopt_init() may sleep

    sockopt_set() will not sleep

    sockopt_getmbuf() for legacy code will not sleep
2008-10-12 09:26:50 +00:00
tls
cef30423d3 Address problems with accept filters noted by ad in his source-changes
mail: http://mail-index.netbsd.org/source-changes/2008/10/10/msg211109.html

	* Scary-looking socket locking stubs (changed to KASSERT of locked)

	* depends on INET inappropriately (though now you must add new
	  accept filter names to the uipc_accf.c line in conf/files if
	  you aren't using dataready or httpready)

	* New code uses MALLOC/FREE -- changed to kmem_alloc/kmem_free;
	  could be pool_cache, these are all fixed-size allocations.

We need to verify that this works as expected with protocols with per-socket
locking, like PF_LOCAL.  I'm a little concerned about the case where the
lock on the listen socket isn't the same lock as on the eventual connected
socket.
2008-10-11 16:39:07 +00:00
pooka
7e5aba5af0 Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.
2008-10-11 13:40:57 +00:00
pooka
dc2ebb63b8 Put ui_lock back and use it to modify the socket buffer size.
Typecasting quad_t * to long * and using atomic_add_long can't
possibly be expected to work!

Another fine error caught by the gcc type-punning warning.  That
really really should be on by default in the kernel.
2008-10-11 13:04:39 +00:00
skrll
af82972758 RCSID police. 2008-10-10 23:09:19 +00:00
plunky
d56f5b8302 use kmem_alloc/kmem_free rather than malloc() for sockokpt 2008-10-10 19:49:49 +00:00
ad
22191248b6 Update CALLOUT_INVOKING correctly, seems to have been lost. 2008-10-10 11:42:58 +00:00
ad
fbc0e2e6d3 Redo 1.169 correctly (dsl's fix doesn't do what I intended, either!). 2008-10-10 11:20:15 +00:00
pooka
6dbf67cea1 Atomic ops are unnecessary here. pointed out by ad 2008-10-09 12:14:06 +00:00
pooka
225570303b Rewrite once to use global locks and atomic ops to get rid of the
static simplelock initializer (and simplelock too).  The fastpath
is still lockless, so doesn't make a difference in terms of
performance.

Also fixes a hanging bug if the once routine returned an error.
It does not retry after an error occurs, as I can't really imagine
fruitful semantics for that.
2008-10-09 10:48:21 +00:00
rmind
337b081fed - Replace lwp_t::l_sched_info with union: pointer and timeslice.
- Change minimal time-quantum to ~20 ms.
- Thus remove unneeded pool in M2, and unused sched_lwp_exit().
- Do not increase l_slptime twice for SCHED_4BSD (regression fix).
2008-10-07 09:48:27 +00:00
rmind
68121d6afa - Allow changing of kern.ipc.shmmax, just to avoid confusion.
- Change type of kern.ipc.shmmax to CTLTYPE_QUAD.
2008-10-07 09:35:03 +00:00
ad
139d645eee PR kern/39681 ddb doesn't work with new MODULAR modules
Complete initialization of new symbol table record.
2008-10-06 11:49:44 +00:00
ad
1b31761afa kobj_read: plug a leak. 2008-10-06 10:46:58 +00:00
pooka
b9a8d2f75a hardclock() itself doesn't schedule callout softintrs any more,
so update comment - less is more.
2008-10-05 21:57:20 +00:00
njoly
ab896e4008 Small fix to make setpriority(2) with PRIO_PROCESS return ESRCH when
no valid process can be found.
2008-09-30 17:28:47 +00:00
rmind
ae626d791a - Schedule bound threads even if CPU is offline. Might be revisited later,
when decision what to do with already bound threads will be made.
- Do not allow to assign offline CPU to the processor-set.

Quick fix for PR/39349.
2008-09-30 16:28:45 +00:00
njoly
6d60715500 Make setpriority(2) return EINVAL for incorrect which values. 2008-09-29 21:30:12 +00:00
rmind
03fe669395 - Fix message queue permissions problems.
- Rake into account umask when creating mqueue.
- Restore DDB command, which was accidentally lost (hi martin).
- Misc.
2008-09-29 10:27:53 +00:00
pooka
a709cdbf1f RCS Id polizei 2008-09-27 16:58:03 +00:00
reinoud
fec4bb5bba Add generic FS agnostic directory hashing support. Currently only in use by
UDF. Future users could be msdosfs, ufs, nilfs2 (when ready), cd9660 etc.

Note that its not the same as UFS's DIRHASH support; UFS would need a good
cleanup/splitout of directory operations to adopt to this new directory
hashing support since most directory operations are interweaved with the
vnops itself. This is a TODO.
2008-09-27 13:01:07 +00:00
wrstuden
53908c9c0a Pull in a fix from wrstuden-revivesa:
Let's look for threads in the TARGET process, not in the
debugger process (gdb). Noticed when a KASSERT fired while
running gdb on a threaded app.

I will adjust wrstuden-revivesa-base-3 to include this change.
2008-09-27 03:52:24 +00:00
pooka
44367b7199 Split rate-checking routines into their own module for easier reuse. 2008-09-25 17:17:10 +00:00
pooka
dd1721fa8d Move global malloc types from kern_malloc into a separate module. 2008-09-25 16:23:45 +00:00
wiz
43a9cced05 Fix typo in comment. 2008-09-25 14:37:30 +00:00
ad
43f2119341 PR kern/39307 (mfs will sometimes panic at umount time)
Change dounmount() so that it never drops the caller provided reference.
Garbage collecting 'struct mount' is up to the caller.
2008-09-25 14:17:29 +00:00
ad
c63b8853fe PR kern/30525 remounting ffs read-only (mount -ur) does not sync metadata
Prevent r/w to r/o downgrade until such time as someone has verified all
the relevant file system code.
2008-09-24 10:07:19 +00:00
ad
b72735bab2 PR kern/39307 mfs will sometimes panic at umount time
Don't drop reference to the mount if VFS_START() fails - that's for unmount
to do.
2008-09-24 09:44:09 +00:00
ad
edd4d8eda9 PR kern/39307 mfs will sometimes panic at umount time
In vfs_destroy, assert that the refcount is not dropping below zero.
2008-09-24 09:33:40 +00:00
hannken
bc62834f44 Resolve a race when physio_done signals completion before it tries to
free a buffer.  This will fail if the buffer owner has a chance to
modify the BC_DONTFREE flag before putphysbuf() examines it.

Fix by removing get/putphysbuf() and BC_DONTFREE.  Physio_done() now
has an explicit test for a buffer coming from the call of physio().

Observed by Lars Nordlund when writing a DVD with growisofs, see PR kern/39536.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>
2008-09-24 08:19:19 +00:00
pooka
2134732d08 Move [hH][eE][xX][dD][iI][gG][iI][tT][sS](*) from subr_prf to subr_prf2
for use with rumps.

*) yes, I just had to.  Notably though, there were only two
   symbols instead of 128.
2008-09-23 22:20:24 +00:00
christos
93aed8f8e3 fix half-assed change usec -> nsec that broke non-real timers. 2008-09-23 16:44:49 +00:00
rmind
ea71ae9284 Fix the aligning of memory blocks again, finally...
Tested by <martin> on his sparc64 box.
2008-09-19 11:21:33 +00:00
hannken
8de1a273e1 Replace the fss unmount hook with a vfs_hook.
fssvar.h:       struct device * -> device_t.
fss.c:          establish unmount hook on first attach, remove on last detach.
vfs_syscalls.c: remove the call of fss_umount_hook().
vfs_trans.c:    destroy cow handlers on unmount as fstrans_unmount() will be
                called before vfs_hooks.
2008-09-17 14:49:25 +00:00
pooka
66523e99f5 remove M_PIPE (hi rmind!) 2008-09-17 14:00:41 +00:00
rmind
ffb8ec88e1 Replace intptr_t with uintptr_t in few more places.
OK by <matt>.
2008-09-15 18:12:56 +00:00
rmind
38d7b7ba2e Replace intptr_t in few places to uintptr_t. 2008-09-15 10:43:29 +00:00
christos
0ff103ebea - remove dup code
- make sure that sigput always initializes ksi
- initialize si_code with SI_NOINFO instead of lying (SI_USER)
- if a process is being ktraced, make siginfo available
- always pass the available siginfo to ktrace, even if it has SI_NOINFO
2008-09-12 21:33:39 +00:00
hannken
3034f37f42 nestiobuf_setup(): Initialize b_dev from master buffer. 2008-09-11 09:14:46 +00:00
blymn
6a3775d153 * Fix from Elad to correct a couple of places where functions exited
without releasing locks.
* Corrected a panic caused by veriexec_file_verify() not setting the
  returned struct veriexec_file_entry **vfep in all cases.

Thanks to Stathis Kamperis for finding the issues and testing the fixes.
2008-09-10 16:36:54 +00:00
cube
1e807cbeed Remove what seems to be a debug printf committed by accident. 2008-09-07 22:36:36 +00:00
pooka
23bef54996 For rumpsyscalls, properly return -1 in case of error. 2008-09-07 19:27:58 +00:00
tron
b7cced0000 Remove duplicate definition of "specfs_lock".
Patch provided by Juan RP in PR kern/39493.
2008-09-07 13:09:36 +00:00
rmind
b37999b4b5 Add few KASSERTs. 2008-09-06 23:08:54 +00:00
rmind
7e456140b3 Replace malloc with kmem. 2008-09-06 23:05:52 +00:00
drochner
6d1cbe3695 Make ioctl(FIONREAD) on the master side of a pty return the amount of
data which can be read, as expected. Before, the call fell through a
"case" statement and was forwarded to the slave side, returning the
data which can be read by the slave.
The new behaviour also matches Linux and OSF/1.
2008-09-03 16:47:34 +00:00
drochner
0fd378606e fix the logics of device memory deallocation
(non-split devices paniced a diagnostic kernel)
2008-09-01 19:44:05 +00:00
njoly
1215ed4c88 Make dup(2) return the correct error value, not 0. 2008-08-31 20:55:55 +00:00
reinoud
031c718bd6 Revert previous change and clarify meaning of RNG 2008-08-30 09:20:13 +00:00
reinoud
bd424bd73b Accidental commit, but asserts buffer cache lock held 2008-08-30 08:55:53 +00:00
reinoud
c68a9bd2ec Fix simple typo:
-       rnd_init();             /* initialize RNG */
+       rnd_init();             /* initialize RND */
2008-08-30 08:55:52 +00:00
yamt
75734d288f process_stoptrace: fix a locking botch. 2008-08-28 06:23:42 +00:00
yamt
52bfe81965 cpu_xc_offline: fix races with eg. sleepq_remove. 2008-08-28 06:18:26 +00:00
christos
f4f1ff39a4 Writing 0 bytes on an O_APPEND file should not affect the offset 2008-08-27 06:28:09 +00:00
christos
520c3612c2 better debugging messages. 2008-08-27 05:40:25 +00:00
pooka
3e7c7228f4 Release vnode in cache_lookup() error branch if locking fails. 2008-08-20 15:34:59 +00:00
pooka
0f85a5be83 Remove my development ifdefs. (hi simon!) 2008-08-20 14:06:35 +00:00
matt
6ba7748097 Don't call null handlers 2008-08-15 03:14:20 +00:00
matt
78ab21fced Change subr_autoconf.c to use kmem_{*alloc,free}.
in pmf_deregister, don't constantly realloc.  just shift everything closer
to the front.  and then if empty, free.  When adding, add space for 4 more
entries.
Instead of n * sizeof(type) use C99 sizeof(type [n]).
2008-08-15 03:08:26 +00:00
matt
726d1181a8 Use __arraycount when appropriate 2008-08-15 01:31:02 +00:00
matt
e79910d9d4 Only deallocate dv_private if we had allocated it. 2008-08-14 21:51:08 +00:00
thorpej
8d9a49fc0e turnstile_block(): When an LWP puts its turnstile onto a sync object's
turnstile chain, assert that its turnstile's free list pointer is NULL.
2008-08-12 14:13:34 +00:00
yamt
a5cd2e50c6 make pcg_dummy const to catch bugs earlier. 2008-08-11 02:48:42 +00:00
yamt
53d1c25e34 add some KASSERTs. 2008-08-11 02:46:40 +00:00
yamt
ae231875d3 fix a comment. 2008-08-11 02:45:27 +00:00
yamt
eee9e229a0 lf_setlock: g/c dead code. 2008-08-11 02:44:28 +00:00
yamt
6198e821cb sleepq_block: fix a bug to lose biglocks in the case of recursive calls.
this fixes pf rb-tree corruption on my box.
2008-08-11 02:36:25 +00:00
skrll
e7901782b3 Comment whitespace. 2008-08-08 16:58:01 +00:00
christos
f6e1114503 Fix broken setitimer(). (Sverre Froyen) 2008-08-08 16:44:52 +00:00
uebayasi
714c16bc3e ttywrite: g/c an unused variable (cnt). 2008-08-08 07:18:03 +00:00
skrll
371a852414 memcpy'ing a sleepq (TAILQ) doesn't work.
Re-init the condvar after memcpy'ing so that the TAILQ is valid.

regress/sys/kern/lockf now completes rather than failing in cv_wait_sig
with KASSERT(cv_has_waiters()).
2008-08-07 07:42:06 +00:00
matt
13d044e16f Pages mapped by debug_malloc are PMAP_KMPAGE so tell the pmap that. 2008-08-07 01:40:21 +00:00
plunky
fd7356a917 Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
2008-08-06 15:01:23 +00:00
tls
717f903a98 Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things).  Manual pages to follow
in a day or so.

OK core@.
2008-08-04 03:55:47 +00:00
pooka
bcfb021366 rumpify sys___sysctl 2008-08-01 19:32:35 +00:00
pooka
b629cd421b expose module_compatible() 2008-08-01 14:05:15 +00:00
skrll
6fd21ccbbf Improve the debug output ever so slightly. 2008-08-01 07:11:24 +00:00
simonb
2a3d67b697 Remove needless white-space change that crept in through wapbl branch
merge.
2008-07-31 08:42:01 +00:00
simonb
36d65f1138 Merge the simonb-wapbl branch. From the original branch commit:
Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
   journaling code.  Originally written by Darrin B. Jewell while
   at Wasabi and updated to -current by Antti Kantee, Andy Doran,
   Greg Oster and Simon Burge.

OK'd by core@, releng@.
2008-07-31 05:38:04 +00:00
uebayasi
d1dfd4fec7 Display t_outcv* channels as "ttyout*", not "ttycan*". 2008-07-31 01:46:40 +00:00
thorpej
261002c777 rw_vector_exit(): When doing direct hand-off to a writer, only set
RW_WRITE_WANTED if there are additional writers waiting.
2008-07-29 16:13:39 +00:00
drochner
a17262c3e3 Avoid NULL pointer dereference on power handler deregistration if
it was not registered before. I assume that a lot of drivers do not
proper bookkeeping in the case the attach() exits early due to
errors. This is hard to fix and to test, so just be generous here.
2008-07-28 14:22:14 +00:00
pooka
f06b295c56 Adjust comment location to make it make sense.
no functional change
2008-07-27 15:08:37 +00:00
dsl
c43281ec80 Remove all the pending connections in soclose().
'continue' in 'do .. while (0)' doesn't do what ad@ intended.
2008-07-25 22:45:58 +00:00
uwe
4691dacd78 Declare lwp_exit_switchaway() __dead. Add infinite loop at the end of
lwp_exit_switchaway() to convince gcc that cpu_switchto(NULL, ...) is
really not going to return in that case.  Exposed by gcc4.3.

Reported on tech-kern by Alexander Shishkin.
2008-07-25 00:48:59 +00:00
apb
7cb9e72bbb Avoid using \$ in an awk script. Instead, store '$NetBSD$'
in an awk variable and interpolate it where needed.

Based on the patch by Martin Husemann in PR 38766.
2008-07-23 21:17:25 +00:00
christos
0f5d35d8d1 report local symbols too. 2008-07-22 21:18:35 +00:00
blymn
762e875434 Add locking around veriexec operations to prevent all sorts of badness
happening.  This fixes kern/38646.
2008-07-20 08:50:20 +00:00
kardel
ccab995bc6 Initialize timecounter_lock at IPL_HIGH. Prevents a "locking against myself"
when com.c (options PPS_SYNC) delivers a PPS time stamp during clock
interupt processing.
2008-07-19 10:33:58 +00:00
christos
dac1180a87 fix debugging printf 2008-07-18 21:29:48 +00:00
rmind
a7fc471680 PR/39155: Wolfgang Solfrank: Invalid parameter to turnstile_exit in rw_downgrade. 2008-07-17 23:00:01 +00:00
pooka
cc7d901591 vfs_subr2 has lost its will to live. vfs_subr was originally split
into two parts so that some of the routines could be used by rump.
Now that rump uses both vfs_subr and vfs_subr2 and there is no
reason to keep two files lying around, re-unite them.
2008-07-16 20:06:19 +00:00
drochner
8b720093a8 wipe out tty buffer contents after read, to avoid keeping possibly
sensitive information in memory longer than necessary
(We could make this depend on ~ECHO or so, but this would be an API
change and I don't think it is worth the effort.)
2008-07-16 18:27:49 +00:00
pooka
b09210ace9 rumpalooza sys_fsync 2008-07-16 15:42:54 +00:00
christos
460ae70d0a make l_flags contain more stuff. Fixes top thread display where system processes
were always displayed.
2008-07-15 22:25:30 +00:00
christos
aa389c698d Use more timespecs internally. From Alexander Shishkin and me.
Welcome to 4.99.70, 30 more to go for 100.
2008-07-15 16:18:08 +00:00
hannken
0d6dbadf45 bdwrite(): The COWDONE check may fire for special vnodes with mounted
non-ffs file system.  Remove VBLK vnodes from the check.

Should fix PR kern/38892
2008-07-14 16:22:42 +00:00
rmind
7c330ba82f Fix the locking against oneself, migrate LWPs only from runqueue.
Part of the fix for PR/38882.
2008-07-14 01:27:15 +00:00
rmind
4f91cff093 - Disallow setting of affinity for zombie LWPs.
- Fix the possible NULL dereference when LWP exiting.
- Fix the inhertance of affinity.
2008-07-14 01:19:37 +00:00
rmind
d489642431 sched_migratable: add KASSERT since this function cannot be called
without lock held now.  Few cosmetic changes, while here.
2008-07-14 01:18:10 +00:00
yamt
e4fb48bcaf pool_do_put: fix a pool corruption bug discovered by
the recent exec_pool changes.
2008-07-09 02:43:53 +00:00
christos
7f6e74c46e Fix to bug reported and tested by Alexander Shishkin. struct ptimer has
a union that contains either a callout [for CLOCK_REALTIME] or a flag
and a list [for other clock types]. Make sure we perform the right actions
on the right union member depending on the clock type. Otherwise this would
result in crashes.
2008-07-08 20:53:02 +00:00
pooka
fc6faa2baf Force vrele_thread to run in vflush() only if there is vrele_pending.
Makes unmounting a file system in a forcibly singlethreaded rump
invocation work.
2008-07-07 14:15:41 +00:00
yamt
03bb7555b4 fix pool corruption bugs in subr_pool.c 1.162. 2008-07-07 12:27:19 +00:00
pooka
21730363f8 Expose utimes() and lutimes() to rump.
from Arnaud Ysmal
2008-07-07 09:01:40 +00:00
bouyer
52346627a5 kern/39052: fix broken assertion. We can have a BC_BUSY buffer in the LRU
queue, if it's being flushed. But in this case, we'll also have B_VFLUSH.

While there fix checkfreelist() so that it can be used to check that a
buffer is not in the free lists.
2008-07-06 15:00:45 +00:00
ad
6c6c91b240 Move an assignment later. 2008-07-04 16:41:00 +00:00
ad
46587f3717 - Keep cache locked while allocating a cache group - later we might want
to automatically tune the group sizes at run time.
- Fix broken assertion.
- Avoid another test+branch.
2008-07-04 16:38:59 +00:00
ad
9d573e640e Remove a bunch of conditional branches from the pool_cache fast path. 2008-07-04 13:28:08 +00:00
ad
2526653044 vinvalbuf: broken assertion. 2008-07-03 12:37:09 +00:00
rmind
b7cdc71cd2 mq_open: fix confusion of FREAD/FWRITE and VREAD/VWRITE. 2008-07-02 20:06:09 +00:00
rmind
30dfdb2897 lwp_migrate: if LWP is still on the CPU (LP_RUNNING), it must be handled
like LSONPROC.  Should fix PR/38588.  OK by <ad>.
2008-07-02 19:53:12 +00:00
rmind
160268aca6 Remove proc_representative_lwp(), use a simple LIST_FIRST() instead.
OK by <ad>.
2008-07-02 19:49:58 +00:00
rmind
73f3b7bb31 Remove outdated comments, and historical CCPU_SHIFT. Make resched_cpu static,
const-ify ccpu.  Note: resched_cpu is not correct, should be revisited.

OK by <ad>.
2008-07-02 19:44:10 +00:00
rmind
61fc86b29b Remove locking of p_stmutex from sched_pstats(), protect l_pctcpu with p_lock,
and make l_cpticks lock-less.  Should fix PR/38296.

Reviewed (slightly different version) by <ad>.
2008-07-02 19:38:37 +00:00
ad
b94f79f0e8 Replce exec_map with a pool. Proposed on tech-kern@, reviewed by chs@. 2008-07-02 17:28:54 +00:00
matt
7408df1239 Change {ff,fd}_exclose and ff_allocated to bool. Change exclose arg to
fd_dup to bool.  Switch assignments from 1/0 to true/false.

This make alpha kernels compile.  Bump kern to 4.99.69 since structure
changed.
2008-07-02 16:45:19 +00:00
matt
1906aa3e59 Switch from KASSERT to CTASSERT for those asserts testing sizes of types. 2008-07-02 14:47:34 +00:00
pooka
1805817468 Adjust rump syscalls: remove a few pointless ones and add a few
missing ones.
2008-07-01 13:03:08 +00:00
matt
5a4f0c6b2b Change tree op members/typedefs to rbto_compare_* from rb_compare_* 2008-06-30 20:14:09 +00:00
pooka
d496f014ff Don't compile kern_lock for rump any more, it's no longer required.
Allows us to get rid of the incorrect _RUMPKERNEL ifdefs outside sys/rump.
2008-06-25 13:16:58 +00:00
ad
40818746b1 Use pool_cache. 2008-06-25 11:05:46 +00:00
ad
d23ae8da8d sigpending1: don't subtract the sigmask (!!). 2008-06-25 11:04:24 +00:00
ad
80892cd092 Use pool_cache. 2008-06-24 18:50:30 +00:00
ad
8c5bcce4b9 execve1:
- Properly terminate the fake argument list.
- Fix two double-frees.
2008-06-24 18:04:52 +00:00
ad
9993bc6d33 Nothing uses getsock/getvnode any more. 2008-06-24 11:21:46 +00:00
gmcgarry
8cead24f2a The conversion to c99-style designated initialisers brought in the gcc
extension of specifying an array range.  Revert to runtime initialization
of limit0.

See here for details: http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
2008-06-24 10:31:05 +00:00
gmcgarry
a7edd5ccdd Replace gcc-style designated initialisers with c99-style. 2008-06-24 10:27:35 +00:00
gmcgarry
8b957c9d45 ioctl commands are unsigned long. Changes ABI for fsetown() and fgetown() on 64-bit architectures. 2008-06-24 10:26:26 +00:00
gmcgarry
fb6bc48511 ioctl commands are unsigned long. 2008-06-24 10:24:21 +00:00
rmind
59a180ac8f sysctl_proc_stop: fix a lock-leak when kauth returns an error.
From <kefren>.
2008-06-23 20:04:36 +00:00
ad
aed68d2d63 getvnode -> fd_getvnode 2008-06-23 11:30:41 +00:00
ad
29957bec2e sys_fcntl: use l_fd, not p_fd. 2008-06-23 11:26:53 +00:00
ad
7756789d3a PR kern/38990: Unmounting a disk fails the first time
vflush: process vrele_list at least once before looking at the mount.
2008-06-23 11:23:39 +00:00
ad
bce675d015 When offlining a CPU, ensure that at least one other CPU within the same
processor set remains online, otherwise the system can deadlock.
2008-06-22 13:59:06 +00:00
ad
53db9954a3 - Ensure that at least one cpu stays in the default pset, otherwise the
system will lock up.
- Use cpu_lock, there's no need for a seperate psets_lock.
- Add a sysctl to return the list of psets as a string.
2008-06-22 12:59:18 +00:00
christos
1d875fc75f Adjust to separate kcpuset_t and cpuset_t. 2008-06-22 00:06:36 +00:00
christos
5e865a2f1b Also enforce that cm->cmsg_len >= CMSG_ALIGN(sizeof cmsghdr), from
Michael van Elst
2008-06-20 15:27:50 +00:00
christos
db982eb35b Don't require cm->cmsg_len == control->m_len, just that the cm->cmsg_len
<= control->m_len, like FreeBSD does. Idea from Taylor R Campbell.
2008-06-20 15:18:38 +00:00
mlelstv
8b80c3645f reassignbuf() is called by bdirty() from within biodone processing.
It can have waiters.
2008-06-18 18:11:25 +00:00
yamt
fff57c5525 merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@.  requested by core@
2008-06-18 09:06:25 +00:00
christos
ffabbaf7c6 set mtime/atime properly, not backwards. 2008-06-17 21:02:08 +00:00
mlelstv
76a664c61a Drop !cv_has_waiters assertion.
bdirty() is called from within biodone() processing before
waiters have been woken up and removed.

N.B. it is also used by smbfs.
2008-06-17 19:14:14 +00:00
christos
f5be32608a PR/38942: Pedro F. Giffuni: no support for birthtime in utimes(2). 2008-06-17 16:18:01 +00:00
tsutsui
d7d2a525b1 Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t. 2008-06-17 16:17:21 +00:00
tsutsui
2bc3b0c694 Regen from syscalls.master rev 1.204:
> Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
2008-06-17 16:07:57 +00:00
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