Commit Graph

3337 Commits

Author SHA1 Message Date
dsl 6f803e005b Correct rewinding if FIONBIO or FIOASYNC fail in F_SETFL
(code use to always turn off FIONBIO if FIOASYNC fails)
(approved by christos)
2003-03-22 10:39:47 +00:00
dsl 1f2e35430b Change caddr_t to void * 2003-03-22 10:35:01 +00:00
dsl bd99e3429d Use 'void *' instead of 'caddr_t' in prototypes of VOP_IOCTL, VOP_FCNTL
and VOP_ADVLOCK, delete casts from callers (and some to copyin/out).
2003-03-21 23:11:19 +00:00
dsl 60418b39b7 Change 'data' argument to fo_ioctl and fo_fcntl from 'caddr_t' to 'void *'.
Avoids a lot of casting and removes the need for some line breaks.
Removed a load of (caddr_t) casts from calls to copyin/copyout as well.
(approved by christos - he has a plan to remove caddr_t...)
2003-03-21 21:13:50 +00:00
dsl 9c29dd1922 Indentation fixes 2003-03-19 20:35:04 +00:00
christos a56ea22f68 - use __predict_false for DIAGNOSTIC code.
- #ifdef out a DIAGNOSTIC printf() that was too annoying (rule of thumb,
  don't make DIAGNOSTIC printfs() that print *very* frequently...)
- fix DIAGNOSTIC test that would always get triggered on a new session.
2003-03-19 16:47:36 +00:00
christos 3bd89478f7 make this compile again (-DDIAGNOSTIC) 2003-03-19 16:02:31 +00:00
dsl 9be8ac5294 Alternative pid/proc allocater, removes all searches associated with pid
lookup and allocation, and any dependency on NPROC or MAXUSERS.
NO_PID changed to -1 (and renamed NO_PGID) to remove artificial limit
on PID_MAX.
As discussed on tech-kern.
2003-03-19 11:36:32 +00:00
christos 46bb05bc86 regen 2003-03-18 18:09:48 +00:00
christos 1623253ed2 _lwp_setprivate returns void 2003-03-18 18:08:49 +00:00
jdolecek 46eb0d5bf0 make it possible for UNION fs to be loaded via LKM - instead of
having some #ifdef UNION code in vfs_vnops.c, introduce variable
'vn_union_readdir_hook' which is set to address of appropriate
vn_readdir() hook by union filesystem when it's loaded & mounted
2003-03-17 09:11:29 +00:00
martin 358b4d4e49 When being passed bogus file descriptors make close(2) return EBADF.
From Stephen Ma in PR kern/20762.
2003-03-17 07:57:13 +00:00
jdolecek a0deb3e9c4 move union filesystem code from sys/miscfs/union to sys/fs/union 2003-03-16 08:26:46 +00:00
matt e86e032c61 Make cfroots const. 2003-03-16 08:09:58 +00:00
matt 137a763c9b Only define POOL_LOGSIZE/pool_size if POOL_DIAGNOSTIC is defined. 2003-03-16 08:06:51 +00:00
dsl a8a18df708 cpu times were miscalculated because 'usecs' could go -ve...
There is still a problem that 'st = (u * st) / tot;' can overflow,
but that is harder to fix, and requires cpu times of ~5days.
(approved by christos)
2003-03-14 21:38:26 +00:00
dsl a485005f79 Ensure that the pgid arg to TIOCSPGRP is in the current session.
Correctly treat a +ve value as a pgid and a -ve one as a pid.
2003-03-13 10:20:06 +00:00
dsl 741870b7ef Validate that pgid argument to TIOCSPGRP in part of current session.
Treat +ve numbers as process group ids and -ve as pids (see tcsetpgrp() in part of current session.
Treat +ve numbers as process group ids and -ve as pids - see tcsetpgrp(3).
(approved by christos)
2003-03-12 23:00:03 +00:00
dsl 5786e3a6e8 Add pgid_in_session() for validating TIOCSPGRP requests
(approved by christos)
2003-03-12 22:54:44 +00:00
dsl 8bf20eda9b KNF function prototypes 2003-03-12 16:39:01 +00:00
dsl 4f78d8c26a Need to call calcru while l->l_stat == LSONPROC 2003-03-12 15:26:33 +00:00
nathanw 11aebbf730 Change the contract for timer_settime() (the internal routine, not the
syscall sys_timer_settime()) to take an absolute value for realtime
timers. This avoids a pair of gratiuitous conversions with the
possibility that the timer's intermediate value would be 0.0, which
would signal timer_settime() to cancel the timer.

Adjust callers of timer_settime() to compensate; catch the case where
sys_timer_settime() with an absolute time value of now and a virtual
timer would also be subtracted down to a timer-cancelling 0.0.

This should fix the bug seen in libpthread's nanosleep() where certain
applications, such as xmms, would wedge with unexpired userlevel
alarms.
2003-03-10 21:49:56 +00:00
thorpej 9e7bb2595e Based on the feedback on wasabisystems.com!bsd-api-discuss (sure wish
people would read that list in a more timely fashion!), change the new
64-bit memory reporting sysctl nodes to report bytes.  This should not
be a problem, since it's only a week old, and no applications use the
new nodes yet.
2003-03-06 20:32:59 +00:00
darrenr bacf7b9b2b When unblocking threads, do not call setrunnable() on the thread we will
be returning because the code path that calls is will very likely call
setrunnable() again on the returned thread, leading to a panic because
the thread returned is already at LSRUN.  This fixes a problem where netbsd
would panic when using gdb (5.3) on a process with multiple lwp's like this:
% gdb program
(gdb) run
^C
(gdb) quit
2003-03-06 15:31:14 +00:00
matt 6221ccd63f Make sure to flush each line after printf. 2003-03-06 00:39:42 +00:00
dsl a5de203f9f Add do_setresuid() and do_setresgid() and implement sys_setuid, sys_seteuid,
sys_setreuid (and gid equivs) in terms of them.
2003-03-05 18:42:19 +00:00
mycroft adddd74e0e DANGER WILL ROBINSON!
We cannot store LWP pointers permanently in lock structures, for two reasons:
1) They are somewhat ephemeral.  Dangling pointers are bad.
2) A different LWP may issue the unlock, and in this case, we were not actually
   doing the unlock at all.  This was causing processes to exit without undoing
   fcntl(2) locks.  Furthermore, the locks are process-specific to begin with,
   so the test was just plain wrong.

Instead, we go back to storing a proc pointer for POSIX locks.  In addition, we
add an extra pointer to the LWP, which is used in deadlock detection.  After
the lock is granted, this pointer is 0ed and there is no reference to the LWP.

Now evolution can inc my mail again.
2003-03-05 18:28:22 +00:00
dsl 35df36296b Report correct values for p_uutime_{u}sec, p_ustime_{u}sec and p_uctime_{u}sec 2003-03-05 11:46:49 +00:00
dsl 15cb5a5b82 Apportion execution time evenly between stime and utime when the process
hasn't been interrupted by any profiling interrupts.
Collect time from all active LWPs.
2003-03-05 11:44:01 +00:00
dsl dc55700b28 Get processes execution time before the LWPs state is changed 2003-03-05 11:40:55 +00:00
jdolecek b83db8c688 only pull in/declare veriexec related stuff with VERIFIED_EXEC 2003-03-03 21:25:09 +00:00
enami ca4393664d ... and no need to aqcuire lock while free'ing old hash which no one
refers it.
2003-03-02 13:26:22 +00:00
enami e8083140e3 Cosmetic changes. 2003-03-01 23:48:44 +00:00
yamt ddb9465f5f make fdcheckstd f_slock friendly. 2003-03-01 09:19:53 +00:00
matt 6c3a6223d4 If we are doing TOPDOWN, we want to truncate the address downwards. If not,
we want to round the address upwards.  I hope this is the last change.
2003-03-01 05:55:51 +00:00
atatat 40f3045957 Add p_svuid and p_svgid to kinfo_proc2. Populate them in the kernel
and in libkvm.  Then teach ps how to show them to you.

Also, teach ps how to show the names for all the uids, the rest of the
group numbers, and the "group access list".
2003-03-01 05:41:55 +00:00
enami 5bb41745ed Cosmetic changes. 2003-02-28 23:24:40 +00:00
matt ad22a09f59 Make sure that the initial address is aligned correctly. Note that before
this alignment would have been backward into the dataspace covered by
MAXDSIZ.  Now the alignment is done forward.  XXX  It is expected that
in the TOPDOWN case, VM_DEFAULT_ADDRESS will make sure any address it
returns has the proper alignment for that architecure.
2003-02-28 19:44:42 +00:00
matt 261ba66908 When aligned to > PAGE_SIZE boundary, don't map any pages before where the
psection starts.  Allocate unused VA space between psections as unreadable.
2003-02-28 19:09:08 +00:00
matt f34e724286 Remove MAXDSIZ since VM_DEFAULT_ADDRESS adds it. Sigh. It was correct. 2003-02-28 00:11:14 +00:00
matt e39f39ac47 Note only trunc_page the psection vaddr, but truncate it accordoring to its
psection alignment.  XXX If the psection alignment is greater than the page
alignment, extra pages may be mapped that will never be needed.  This is
inefficient and wasteful of swap space and needs to be fixed.
2003-02-27 23:48:29 +00:00
matt 0731ed5a3d Fix a c&p bug when moving VM_DEFAULT_ADDRESS. (restore MAXDSIZ) 2003-02-27 23:10:52 +00:00
matt bc859d628d Remove VMCMD_TOPDOWN since it's no longer. Redo my last rework. Move
VM_DEFAULT_ADDRESS from elf*_makecmds to elf*_load_file.  In load_file,
actually determine ahead of time how much space will be needed and pass
that to VM_DEFAULT_ADDRESS.  Now we have a relatistic starting address
so we can do the loading of psections normally with no extra topdown
code in load_psection.  Also, if there is a gap in betweeen psections
zero map an inaccessible region between (just like ld.elf_so does) to
avoid inadvertant mmaps in the gap.
2003-02-27 01:58:56 +00:00
thorpej 922f0e9b78 Add hw.physpages and hw.userpages, which return the physmem and usermem
values as a u_quad (page count).  Necessary for reporting memory on systems
with >=4G.  Per disussion on wasabisystems.com!bsd-api-discuss.
2003-02-27 01:39:56 +00:00
thorpej b9d81d9cc9 Change a printf to an event counter. Callout event counters are conditional
on CALLOUT_EVENT_COUNTERS.
2003-02-26 23:13:19 +00:00
matt 9c3775aadf Make elf32 load_file work properly with TOPDOWN by mapping psections in
reverse order.  Remove TOPDOWN support from VMCMDs since elf32 does the
right stuff now.  With these changes, VAX can now use TOPDOWN.
2003-02-26 21:18:22 +00:00
matt a6c7337fa2 Remove leftover MBUFTRACE asserts. 2003-02-26 18:22:10 +00:00
drochner 72d6120d24 deactivate MBUFTRACE related KASSERT()s in the !MBUFTRACE case 2003-02-26 14:36:43 +00:00
matt 65e5548a17 Add MBUFTRACE kernel option.
Do a little mbuf rework while here.  Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *).  These are not performance critical and making them
call m_get saves considerable space.  Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
2003-02-26 06:31:08 +00:00
jdolecek 3f362c0871 it appears one list of vnode type names should be enough 2003-02-25 23:35:03 +00:00
jdolecek b06fa82f3e make iftovt_tab[] const 2003-02-25 23:01:39 +00:00
thorpej eb14e86676 Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it.  This fixes a few places where either b_dep or b_interlock were
not properly initialized.
2003-02-25 20:35:31 +00:00
pk f82deea4bf Fix a simple_lock() mismatch in unp_internalize().
We may need to merge the passes over the files contained in the message
as noted by enami tsugutomo on tech-smp.
2003-02-25 09:56:15 +00:00
atatat 524df47498 Tweak some comments so that they match the other comments more properly. 2003-02-25 05:27:35 +00:00
perseant bd6cf7e127 Allow filesystems' VOP_IOCTL to catch ioctl calls on directories and
regular files.  Approved thorpej, fvdl.
2003-02-24 08:34:30 +00:00
pk 025e435477 Protect the event queue with a simple mutex; this only partially addresses
MP-safety issues in the event handling system.
2003-02-23 22:05:35 +00:00
pk f326711134 Use splsched() instead of splhigh() to protect the triggered event queues. 2003-02-23 21:44:26 +00:00
pk 8f9c32194c Use splvm() instead of splhigh() when accessing the internal page header pool. 2003-02-23 21:25:19 +00:00
pk 2931081a79 Make updating a file's reference and use count MP-safe. 2003-02-23 14:37:32 +00:00
tsutsui d6458621a3 Fix too many arguments for format warning in #ifdef DIAGNOSTIC part
detected by gcc-3.x.
2003-02-22 12:42:28 +00:00
nathanw fb8a5b2205 Set P_WEXIT earlier; specifically, before a pool_get(, PR_WAITOK) that
could sleep.

Pointed out by enami.
2003-02-22 01:00:14 +00:00
jdolecek b4a06ab5af simplify timeout handling code in kqueue_scan() 2003-02-21 20:57:09 +00:00
skrll e8f64a20cb typo in comment. 2003-02-21 16:30:48 +00:00
matt b411ef736c In topdown mode, subtract the page rounded memory size of the psection,
not the rounded file size.  Otherwise if BSS needs more pages beyond
data you'll extend too far.
2003-02-21 03:53:43 +00:00
atatat df0a9badc6 Introduce "top down" memory management for mmap()ed allocations. This
means that the dynamic linker gets mapped in at the top of available
user virtual memory (typically just below the stack), shared libraries
get mapped downwards from that point, and calls to mmap() that don't
specify a preferred address will get mapped in below those.

This means that the heap and the mmap()ed allocations will grow
towards each other, allowing one or the other to grow larger than
before.  Previously, the heap was limited to MAXDSIZ by the placement
of the dynamic linker (and the process's rlimits) and the space
available to mmap was hobbled by this reservation.

This is currently only enabled via an *option* for the i386 platform
(though other platforms are expected to follow).  Add "options
USE_TOPDOWN_VM" to your kernel config file, rerun config, and rebuild
your kernel to take advantage of this.

Note that the pmap_prefer() interface has not yet been modified to
play nicely with this, so those platforms require a bit more work
(most notably the sparc) before they can use this new memory
arrangement.

This change also introduces a VM_DEFAULT_ADDRESS() macro that picks
the appropriate default address based on the size of the allocation or
the size of the process's text segment accordingly.  Several drivers
and the SYSV SHM address assignment were changed to use this instead
of each one picking their own "default".
2003-02-20 22:16:05 +00:00
jmc ff58e08182 Move simple_lock after the hashinit's to avoid possible sleeping/malloc'ing
with a simplelock held.
2003-02-20 02:49:51 +00:00
pk 9ead24ac7a Use lock_printf() in SPINLOCK_SPINCHECK() and SLOCK_TRACE(). 2003-02-19 22:34:42 +00:00
jdolecek 382f8f9883 if emulation uses elf32_copyargs(), it shouldn't use it's own idea
of how many AUX arguments are actually passed

this fixes PR kern/20423 by Shingo WATANABE
2003-02-19 09:44:42 +00:00
jdolecek 2e574d6a8b add "VT_SMBFS" to vnode_tags[]
constify vnode_tags[] and vnode_types[]
2003-02-18 20:37:38 +00:00
wiz 9ceb9b4b15 Add newline character to logname change warning.
Noted missing by Sean Davis on tech-kern.
2003-02-18 19:26:23 +00:00
dsl b80a5f24c5 KNF kern_prot.c 2003-02-18 08:37:41 +00:00
nathanw 0cfe2d1c69 Test p->p_sa instead of p->p_flag & P_SA, as the latter may have been
cleared by sigexit().
2003-02-17 23:45:47 +00:00
nathanw 1e8f36c002 Clear L_SA from all LWPs in sigexit() to prevent any upcalls or
sa_switch() invocations while exiting. Test P_SA instead of L_SA, out
of paranoia. Avoids a possible remrunqueue panic reported by Havard
Eidnes.

Release the kernel lock before calling the userret function to exit in
sigexit(). Problem noted by Paul Kranenburg.
2003-02-17 23:45:00 +00:00
nathanw a87506d477 Note yet another SMP danger spot. 2003-02-17 23:32:33 +00:00
christos e2b7a1ed43 Add a ttyprintf_nolock() to be called when we are printing the ttyinfo
stuff, since we already have the lock.
Adjust tputchar so that it does not lock, when NOLOCK is passed in flags.
2003-02-17 22:23:14 +00:00
christos e5323a474c - remove __STDC__ crap. It did not work anyway with pre-ansi compilers, since
va_start() takes one arg, and va_alist must be the only argument of a
  varyadic in the K&R world.
- pass flags to tputchar.
2003-02-17 22:21:52 +00:00
provos 9a5e533a1a do not demand LLSLEEP in p_stat; this does not seem to happen with lwps;
todo: a proper fix that takes lwps into consideration
2003-02-16 20:24:47 +00:00
jdolecek fa2b78c32c regen:
- added __sigtimedwait(2)
- g/c sigwaitinfo(2) slot, move sigqueue(2) slot and free slot #246
2003-02-15 20:56:48 +00:00
jdolecek c58bfd1c36 add __sigtimedwait(2) - wait for specified set of signals, with optional
timeout
the semantics of 'timeout' parameter differ to POSIX for the syscall
(not const, may be modified by kernel if interrupted from the wait) -
libc will provide appropriate wrapper

since sigwaitinfo(2) will be implemented as wrapper around sigtimedwait()
too, remove it's reserved slot and move sigqueue slot 'up', freeing
slot #246
2003-02-15 20:54:38 +00:00
dsl 9926e89884 Fix support for 16 character lognames
(approved by christos)
2003-02-15 18:47:41 +00:00
dsl aed442201d Fix support of 15 and 16 character lognames.
Warn if the logname is changed within a session - usually a missing setsid.
(approved by christos)
2003-02-15 18:10:15 +00:00
pk 9ca040e74e Make the memory allocation code MP-safe. 2003-02-14 21:51:36 +00:00
pk 9a853301e6 Use a mutex to protect the global list of open files. 2003-02-14 21:50:10 +00:00
pk 87978ebf11 Make cache insertion, removal and lookup MP-safe. 2003-02-14 21:39:46 +00:00
nathanw 49f53e20ea Make sa_yieldcall also allocate a new LWP for the cache if it's empty.
(XXX sa_yieldcall() and sa_switchcall() should be combined and take
arg as the function to call, but I'm somewhat nervous about void *
vs. void (*)()).
2003-02-14 20:45:12 +00:00
drochner 36e90ce9e3 fix typo in comment 2003-02-14 18:25:34 +00:00
pk d2b7e43b18 On pipe reads, check for EOF before FNONBLOCK to avoid spurious EAGAIN errors. 2003-02-14 13:16:44 +00:00
dsl db17a870e0 Split sys_wait4 so that code isn't duplicated in compat tree.
(approved by christos)
2003-02-14 10:11:56 +00:00
pk 3cba4a9f1b Make the pipe code mostly MP-safe. There are a few unaddressed race
conditions at points where it's necessary to access both the up-stream
and down-stream parts of the bi-directional pipe data structure. These
are marked `XXXSMP' in the code.

Also, since the changes are pretty invasive, there little point in keeping
all the "#ifdef FreeBSD" code around; so all of that has been stripped out.
2003-02-12 21:54:15 +00:00
yamt f4585f067a - don't compare c_time directly.
- in callout_hardclock, test if timeout_todo is empty or not
  before release the lock.
2003-02-11 09:43:37 +00:00
nathanw 158b157b2a Move stack allocation in case 1 of sa_switch() to after the
sau == NULL check, to avoid a stack leak in the error case.

Spotted by enami.
2003-02-11 00:03:47 +00:00
drochner d229e1e550 replace &(a?b:c) by (a?&b:&c), so that it looks more like an lvalue
(to lint at least)
approved by thorpej
2003-02-10 19:18:56 +00:00
nathanw 695bc028ab Since sadata_upcall_alloc(1) can sleep, call it before checking the
supply of stacks, to avoid a race. Problem pointed out by Lars
Heidieker on current-users.
2003-02-10 19:02:52 +00:00
atatat a8481319cb Add a kern.dump_on_panic sysctl variable (and documentation, and a
kernel config option) that controls whether the kernel dumps to the
dump device on panic.  Dumps can still be forced via the ``sync''
command from ddb.  Defaults to ``on''.
2003-02-10 00:35:15 +00:00
jdolecek 573bb6afc9 const msgs[] some more 2003-02-09 09:14:58 +00:00
nathanw b5a9638ee1 Adapt to the new conventions of proc_unstop() and don't try to call
setrunnable(NULL).
2003-02-07 21:44:45 +00:00
nathanw 4c99df7fcc Two fixes:
* Change the semantics of proc_unstop() slightly, so that it is
   responsible for making all stopped LWPs runnable, instead of
   all-but-one. Return value is a LWP that can be interrupted if doing
   so is necessary to take a signal. Adjust callers of proc_stop() to
   the new, simpler semantics.

 * When a non-continue signal is delivered to a stopped process and
   there is a LWP sleeping interruptably, call setrunnable() (by way
   of the 'out:' target in psignal1) instead of calling unsleep() so
   that it becomes LSSTOP in issignal() and continuable by
   proc_unstop(). Addresses PR kern/19990 by Martin Husemann, with
   suggestions from enami tsugutomo.
2003-02-07 21:43:18 +00:00
jdolecek 018aae11cd use LIST_FOREACH() macro in proc_stop()/proc_unstop()
rewrite contents of the loop in proc_unstop to be a bit more easily
comprehensible
2003-02-07 09:02:14 +00:00
pk 9d74642196 XXX ttioctl(): some drivers call back on us from t_param(), so delay acquiring
tty spin lock until after t_param() returns.

Require t_param() to unlock upon callback?
2003-02-06 12:21:21 +00:00
pk 1262bf7cb5 bdwrite(): remove check for MFS major device number (why was 255 changed
to 4096?). In any case, bdevsw_lookup() will take care of it.
2003-02-06 11:46:49 +00:00