Commit Graph

7148 Commits

Author SHA1 Message Date
bouyer 6b8161200e getcleanvnode(): don't vclean() the vnode if it has gained another
reference while we were getting the v_interlock.
vget(): attempt prevent it from returning a clean vnode:
  if the vnode is being inactivated (by vrelel()), wait for
  vrelel() to complete (or return EBUSY if we can't wait), and return
  ENOENT if the vnode has been vclean'ed by vrelel()
Fix kern/41147 in a better way, hopefully fix other related race conditions.
2009-11-05 08:18:02 +00:00
rmind 4c1098f541 do_sys_wait(): fix previous by checking for ru != NULL. Noticed by
Onno van der Linden.  Also, remove redundant arguments (seems that
was_zombie was not used since rev 1.177 ?).
2009-11-04 21:23:02 +00:00
pooka fcc20a4ba1 Split uiomove() and high-level copy routines out of the crowded
kern_subr and into their own cozy home in subr_copy.
2009-11-04 16:54:00 +00:00
pooka ab72032a6c nuke unused local variable 2009-11-04 15:35:09 +00:00
pooka 83685e650c Heave-ho mutex/rwlock object routines into separate modules -- they
don't have anything to do with the lock internals.
2009-11-04 13:29:45 +00:00
dyoung e48f8429d1 Add a kernel configuration flag, SPLDEBUG, that activates a per-CPU log
of transitions to IPL_HIGH from lower IPLs.  SPLDEBUG is only available
on i386 and Xen kernels, today.

'options SPLDEBUG' adds instrumentation to spllower() and splraise() as
well as routines to start/stop debugging and to record IPL transitions:
spldebug_start(), spldebug_stop(), spldebug_raise(), spldebug_lower().
2009-11-03 05:23:27 +00:00
dyoung 648f423c6f Make lockdebug_lock_print(NULL, ...) dump all locks. Now, in ddb,
'show lock 0x0' dumps all of the locks.

XXX I still need to fix 'show all lock'.
2009-11-03 00:29:11 +00:00
rmind b9a294cf04 - Move inittimeleft() and gettimeleft() to subr_time.c, where they belong.
- Move abstimeout2timo() there too and export.  Use it in lwp_park().
2009-11-01 21:46:09 +00:00
rmind 1ceff942e5 Move common logic in selcommon() and pollcommon() into sel_do_scan().
Avoids code duplication.  XXX: pollsock() should be converted too, except
it's a bit ugly.
2009-11-01 21:14:21 +00:00
rmind 1ff7612225 do_sys_wait: clear rusage, instead of returning garbage. Patch from
dholland@ via PR/40717, with minor change by me.
2009-11-01 21:05:30 +00:00
rmind 5ccbe1e208 orphanpg: remove no longer user variable. 2009-11-01 20:59:24 +00:00
njoly b83467c466 Make flock(2) more robust to invalid operation, such as
(LOCK_EX|LOCK_SH).
2009-10-28 18:24:44 +00:00
rmind e4be2748a3 - Amend fd_hold() to take an argument and add assert (reflects two cases,
fork1() and the rest, e.g. kthread_create(), when creating from lwp0).

- lwp_create(): do not touch filedesc internals, use fd_hold().
2009-10-27 02:58:28 +00:00
rmind 0ca6708c13 - Use pool(9) for pmf_event_workitem_t, instead of pool_cache(9). Still,
meta-data of this pool takes more space than the actual data..

- Reduce lowat/hiwat to 1..8, since intensity is very low.

- Remove unused pew_next_free from pmf_event_workitem_t.
2009-10-27 02:55:07 +00:00
rmind c32b625d4c Update comment about proc0_init(). 2009-10-26 19:03:17 +00:00
rmind 554a0142dc Initialise struct emul members by name (it is readable now and one can search
them in the tree).
2009-10-25 01:14:03 +00:00
rmind 33963b1448 Avoid #ifndef __NO_CPU_LWP_FREE, only ia64 is missing cpu_lwp_free
routines and it can/should provide stubs.
2009-10-22 22:28:57 +00:00
rmind 30d0b02e57 Make lwp_park_sobj and lwp_park_tab static.
Wrap long lines while here.
2009-10-22 13:12:47 +00:00
rmind 40cf6f3659 Remove uarea swap-out functionality:
- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code.  Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
2009-10-21 21:11:57 +00:00
jym de3d6f78cf Fix a bug where on MP systems, pool_cache_invalidate(9) could be called
early during boot, just after CPUs are attached but before they are marked
as running.

This will result in a list of CPUs without the SPCF_RUNNING flag set, and
will trigger the 'KASSERT(xc_tailp < xc_headp)' in xc_lowpri() as no cross
call is issued.

Bug reported and patch tested by tron@.

See also http://mail-index.netbsd.org/tech-kern/2009/10/19/msg006293.html
2009-10-20 17:24:22 +00:00
snj 07ce40632e Follow upstream's lead and remove third and fourth clauses (except on
from usr.sbin/mopd/common/pf.c, where only the ad clause is removed,
because it has a shared UCB copyright) on Mats O Jansson's files.

thorpej OK'd usr.sbin/rpc.yppasswdd/yppasswdd_mkpw.c, where he shares
copyright.
2009-10-20 00:51:13 +00:00
snj 4968c04d96 Move Eduardo Horvath's license to 2 clause. OK eeh@. 2009-10-19 18:12:37 +00:00
jnemeth 30d0592bd3 allow passing a NULL proplib dictionary to modctl(MODCTL_LOAD, ...) 2009-10-16 00:27:07 +00:00
thorpej 1f59a448f4 - pool_cache_invalidate(): broadcast a cross-call to drain the per-CPU
caches before draining the global cache.
- pool_cache_invalidate_local(): remove.
2009-10-15 20:50:12 +00:00
pooka 624234c0c5 Generate scheduling points around rump vnode operations. 2009-10-15 00:29:40 +00:00
dsl 931ac5949a Error out of ptcread() if the uio length supplied is zero before the code
has a chance to panic in ureadc().
2009-10-14 19:25:39 +00:00
pooka ddc943db02 regen: fix rump varargs syscalls prototypes 2009-10-13 21:57:52 +00:00
pooka 0d8bdf6131 For varargs syscalls, create rump prototypes which match the regular
system call counterparts, e.g.:
open(const char *, int, mode_t) -> open(const char *, int, ...)
2009-10-13 21:54:29 +00:00
yamt e894729250 sys___aio_suspend50, sys_lio_listio:
- fix the buffer sizes.
	- use kmem_alloc instead of kmem_zalloc for buffers which we will
	  overwrite soon.
2009-10-12 23:43:13 +00:00
yamt 29e552b036 wrap long lines. no functional changes. 2009-10-12 23:38:08 +00:00
yamt b8562be527 make aio_worker static. 2009-10-12 23:36:56 +00:00
yamt 5873138145 constify 2009-10-12 23:36:02 +00:00
yamt 28bf72b353 fix KMEM_SIZE vs KMEM_GUARD 2009-10-12 23:35:09 +00:00
yamt de25ce6a4c remove no longer necessary include of drvctl.h 2009-10-12 23:33:02 +00:00
yamt 199e4526f3 aio_suspend1: fix a double free bug. 2009-10-12 23:31:59 +00:00
dsl 65dd100015 Check for zero length read here - and return zero.
Most times we've come through spec_read() which has already done the test,
but not always (eg pty with ptsfs mounted).
Without this there is a simple local-user panic in ureadc().
Noted Matthew Mondor on tech-kern.
2009-10-11 17:20:48 +00:00
dsl 270307174b Fix locking when collecting pt_read and pt_ucntl. 2009-10-11 08:08:32 +00:00
jym 31629a1342 Add pool_cache_invalidate_local() to the pool_cache(9) API, to permit
per-CPU objects invalidation when cached in the pool cache.

See http://mail-index.netbsd.org/tech-kern/2009/10/05/msg006206.html .

Reviewed by bouyer@. Thanks!
2009-10-08 21:54:45 +00:00
elad 2cb56be586 Add a (weak aliased) machdep_init() as a place to do machdep initialization
that can't happen as early as the other init functions as called from
cpu_startup() -- for example, register kauth(9) listeners.

Put unprivileged policy in the x86 code; used by i386, amd64, and xen.
2009-10-06 21:07:05 +00:00
elad 756638cf95 Factor out a block of code that appears in three places (Veriexec, keylock,
and securelevel) so that others can use it as well.
2009-10-06 04:28:10 +00:00
rmind c9a5a18df3 mq_timedsend/mq_timedreceive: timeout value is absolute, not relative.
While here, drop unecessary (since fdesc API changes) lwp_t arguments.

Bug reported by Stathis Kamperis, thanks!
2009-10-05 23:49:46 +00:00
rmind 5503429772 shmexit: simplify a lot by avoiding unnecessary memory allocations, since
it is a last reference, just re-lock and check mapping list again.  Often
there wont be re-locks at all, moreover, shm_lock is not contended at all.
2009-10-05 23:47:04 +00:00
rmind c3a98b4c87 semu_alloc: simplify a little. 2009-10-05 23:46:02 +00:00
rmind ac8f63538a Convert cpu_number(), which can be sparse, to cpu_index(), which is MI. 2009-10-05 23:39:27 +00:00
elad 4c9fcb77c3 - Add usermount_common_policy() that implements some common (everything
but access control) user mounting policies: enforced MNT_NOSUID and
  MNT_NODEV, no MNT_EXPORT, MNT_EXEC propagation. This can be useful for
  secmodels that are interested in simply adding finer grained user mount
  support.

- Add a mount subsystem listener for KAUTH_REQ_SYSTEM_MOUNT_GET.
2009-10-05 04:20:13 +00:00
elad fa69dc186a Install floppies (haha) don't get built with ktrace/ptrace, so they don't
include kern/sys_process.c. Move proc_uidmatch() to kern/kern_proc.c which
always gets built instead.

Pointed out by Kurt Schreiner on current-users@:

    http://mail-index.netbsd.org/current-users/2009/10/03/msg010745.html
2009-10-04 03:15:08 +00:00
elad b2f3768346 - Move sched_listener and co. from kern_synch.c to sys_sched.c, where it
really belongs (suggested by rmind@),

- Rename sched_init() to synch_init(), and introduce a new sched_init()
  in sys_sched.c where we (a) initialize the sysctl node (no more
  link-set) and (b) listen on the process scope with sched_listener.

Reviewed by and okay rmind@.
2009-10-03 22:32:56 +00:00
elad 458410e7b5 Oops, forgot to make sched_listener static. Pointed out by rmind@, thansk! 2009-10-03 21:21:56 +00:00
elad 54d08ac134 Update a comment. No functional change. 2009-10-03 21:03:55 +00:00
elad a39251ecc2 Introduce time_wraps() to check if setting the time will wrap it (or
close to it). Useful for secmodels.

Replace open-coded form with it in secmodel code (securelevel, keylock).

Note: I need to find a way to make secmodel_keylock.c ~<100 lines.
2009-10-03 20:48:42 +00:00