Commit Graph

3890 Commits

Author SHA1 Message Date
cl f1bacc8b38 disable SA upcalls during "systrmsg" sleep
-> improves problem from PR bin/23429
2004-03-14 00:48:58 +00:00
cl 63fe298156 regen after:
g/c sys_sa_unblockyield which has been unused since 2004/01/02
2004-03-14 00:47:25 +00:00
cl 919b9e33c4 g/c sys_sa_unblockyield which has been unused since 2004/01/02 2004-03-14 00:45:21 +00:00
matt 879040549d Only do the pmap_procwr if the uvm_io succeeded. 2004-03-13 18:43:18 +00:00
christos 7bd0e983e2 PR/24750: Frank Kardel: panic when process is signalled during
proc initialization.
2004-03-11 22:34:26 +00:00
christos cde926b610 PR/24745: Jared Momose: kernel prompts for a root device when using md_root 2004-03-11 15:17:55 +00:00
yamt f75335b469 - add a function prototype.
- consitify.
2004-03-09 12:23:07 +00:00
yamt cd9b5b72f5 m_cat: assert mbuf types only when coalescing them by copying.
mbuf n often have 0-sized "headers" and their types don't matter much.

PR/24713 from Darrin B. Jewell.
2004-03-09 06:37:59 +00:00
dbj 7a30c4a987 add more spltty() calls around TTY_LOCK/UNLOCK where needed 2004-03-09 05:30:24 +00:00
junyoung 70706199eb Whitespaces. 2004-03-09 02:35:45 +00:00
dbj 436daafe7e add splvm() around a few pa_slock and psppool calls since they
may be shared with pools that can be used in interrupt context.
2004-03-08 22:48:09 +00:00
atatat 73c41a46cc Some optimization for sysctl_locate() 2004-03-08 03:31:26 +00:00
junyoung 0f89803028 Drop trailing spaces. 2004-03-05 11:30:50 +00:00
junyoung 103afd6ebf lwp_exit2(): set lwp state to SZOMB at more appropriate point. 2004-03-05 11:17:41 +00:00
dbj f8e0478668 add some spltty() calls around TTY_LOCK() calls that didn't have them 2004-03-05 07:27:22 +00:00
matt 1b4f540b78 Look at _UC_STACK to decide whether the process' SS_ONSTACK state needs to
be updated.  (This is needed to be compatible with how pre-SIGINFO signals
operated.  If you siglongjmp out of a signal handler, the SS_ONSTACK state
needs to be cleared.  This commit restores that functionality).
2004-03-04 00:05:58 +00:00
dsl 1288fac2ba No need to initialise [rw]pipe twice.
Initialise locks before trying to allocate pipe buffer, when allocate
fails we'll not explode trying to acquire the locks when tidying up.
2004-03-03 22:00:34 +00:00
christos 08230af71c initialize rpipe and wpipe to NULL, so that they are initialized in the
error path.
2004-03-03 21:35:52 +00:00
yamt 471ef5f249 once exit1() releases big kernel lock, the struct proc can be freed and
re-used by another cpu immediately.  in that case, lwp_exit2() will
access freed memory.  to fix this:

- remove curlwp from p_lwps in exit1() rather than letting lwp_exit2() do so.
- add assertions to ensure freed proc has no lwps.

kern/24329 from me and kern/24574 from Havard Eidnes.
2004-03-02 09:15:26 +00:00
yamt 395e9958f2 change the way to handle NEW_BUFQ_STRATEGY option.
instead of putting #ifdefs into each drivers,
use a global variable to indicate default strategy.

XXX should have a way to specify other strategies.
2004-02-28 06:28:47 +00:00
junyoung d177d4c744 More typos in comments. 2004-02-27 02:43:25 +00:00
junyoung c5a0b24bb5 pgrpdump() is gone. 2004-02-26 11:29:41 +00:00
junyoung 213495299b - Fix typos.
- De-__P().
- Remove trailing spaces.
2004-02-26 11:20:08 +00:00
jdolecek 52197d307a pipelock() must release the pipe simplelock during tsleep()
fixes PR kern/24551 by Havard Eidnes
2004-02-26 08:15:31 +00:00
itojun efcd57f822 m_cat() - if it is safe, copy data portion into 1st mbuf even if 1st mbuf
is M_EXT mbuf.
2004-02-26 02:30:04 +00:00
enami dab2cb5bb0 Whitespace nits. 2004-02-25 21:40:40 +00:00
enami f7b4bb80a5 Make ktrwrite() and ktrinitheader() private again. ktrsyscall32() no longer
exists.
2004-02-25 21:34:18 +00:00
dbj 5fd36718ae fix typo in comment s/MNT_LAXY/MNT_LAZY/ 2004-02-25 04:10:28 +00:00
christos 7088db9a48 remove error(1) comment. 2004-02-24 20:57:26 +00:00
wiz f05e6f1a3a occured -> occurred. From Peter Postma. 2004-02-24 15:12:51 +00:00
jdolecek 4d49760268 use the new NOTE_SUBMIT to flag if the locking is necessary
for EVFILT_READ/EVFILT_WRITE knotes

fixes PR kern/23915 by Martin Husemann (pipes), and similar locking problem
in tty code
2004-02-22 17:51:25 +00:00
jdolecek 2ae728e7ef mount(2): if vinvalbuf() fails, we must also vput() the mountpoint vnode
fixes stale vnode lock after attempt to mount something on a NTFS directory
2004-02-22 09:56:26 +00:00
dan 5819919614 micro-optimisation - if we're going to return 0, do so before doing
other unnecessary work
2004-02-22 01:00:41 +00:00
enami 06107df871 Modify pool page header allocation strategy as follows:
In addition to current one (i.e., don't wast so large part of the page),
- if the header fitsin the page without wasting any items, put it there.
- don't put the header in the page if it may consume rather big item.

For example, on i386, header is now allocated in the page for the pools
like fdescpl or sigapl, and allocated off the page for the pools like
buf1k or buf2k.
2004-02-22 00:19:48 +00:00
atatat 56392ab40b Use KERN_PROCSLOP for struct kinfo_proc and KERN_LWPSLOP for
struct kinfo_lwp, and not vice versa.

Should solve the issue with top dying because it's unable to "allocate
memory".
2004-02-21 03:27:57 +00:00
atatat 42d379d041 Use new PTRTOUINT64() macro instead of local PTRTOINT64() macro. 2004-02-19 03:57:56 +00:00
atatat caea20e952 Add PTRTOUINT64() and UINT64TOPTR() macros to sys/sysctl.h for use by
kern.proc, kern.proc2, kern.lwp, and kern.buf.

Define more MIB for kern.buf so that specific buffers can be selected
(only all/all is supported right now), and use a 32/64 bit agnostic
structure for communcating buffer information to userland.

Convert systat to the new kern.buf method.

Clean up the vm.buf* handling a little.  There's no actual need to
record the dynamically assigned OIDs, since sysctl_data can tell us
what we're looking at.

Oh, and fix a typo in a comment.
2004-02-19 03:56:30 +00:00
matt cb57c6f8e9 Move detection of a special symbol into a separate function. Add some more
special symbols.
2004-02-19 03:42:01 +00:00
matt f01501b2c6 Support really large LKMs. Find out how much space is needed for symbols
and then allocate it on demand.  Rename some common symbols (__bss_start,
_edata, _end, __start_link_set_*, __stop_link_set_*) so that ".<module>"
is appended to them.  This shrinks an amd64 kernel by 20KB of BSS.
2004-02-18 23:44:49 +00:00
matt 004f0d503a s/sumbols/symbols/ 2004-02-18 20:41:09 +00:00
hannken c59d4851b8 Run pmap_deactivate() earlier in exit1(). Prevents a panic on sparc MP
where p->p_vmspace was 0xdeadbeef in pmap_deactivate().

Approved by: YAMAMOTO Takashi <yamt@netbsd.org>
2004-02-18 14:42:20 +00:00
simonb d7ee872c5f Don't shadow a function name with a parameter. 2004-02-17 11:36:01 +00:00
tron 7008209ace Include "sys/systm.h" to get the prototype for panic() which is required
for diagnostic kernels.
2004-02-17 08:22:12 +00:00
rtr 8845b1e975 split off the evcnt code (which is unrelated to autoconfiguration)
into a separate file

approved by simonb@
2004-02-17 05:03:15 +00:00
enami 456851e71a Some whitespace fix. 2004-02-17 01:45:34 +00:00
enami d59c88c291 The vnode capability id is gone. 2004-02-17 01:35:33 +00:00
enami 6a268a570b Rewind the `bp' advanced backward by cache_revlookup() if getcwd_getcache()
finally returns cache miss.

# Slightly modified from posted version so that it is cleanly patchable
# at least on 1.6 branch.
2004-02-17 01:29:39 +00:00
yamt 0e9e078e22 - raise ipl when calling buf_canrelease() because it traverses buffer queue.
- correct/add comments on buf_canrelease().
2004-02-16 09:34:15 +00:00
jdolecek 159f41eca4 allocate wired memory for the marker kevent in kqueue_scan() instead
of using on-stack memory, so that this wouldn't eventually cause kernel
panic if the process get swapped out and another process runs kqueue_scan()
problem pointed out in kern/24220 by Stephan Uphoff
2004-02-14 11:56:28 +00:00
hannken 142e9d5deb Add a generic copy-on-write hook to add/remove functions that will be
called with every buffer written through spec_strategy().

Used by fss(4). Future file-system-internal snapshots will need them too.

Welcome to 1.6ZK

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
2004-02-14 00:00:56 +00:00
wiz d20841bb64 Uppercase CPU, plural is CPUs. 2004-02-13 11:36:08 +00:00
enami 7ff66821f4 Also defer the writing of KTR_EMUL entry. Otherwise, the parent process
may sleep with setting KTRFAC_ACTIVE of child process and the child will
run without emitting any ktrace entry.
2004-02-12 23:47:21 +00:00
tls eb9b96577c Fix bug noted by yamt@netbsd.org: the UVM free target is in *pages*,
so the last change has us comparing pages to bytes instead of pages
to buffers!  The consequence was to try to free radically less memory
than UVM wanted us to -- though always at least one buffer, which is
probably why the results weren't dire.

This does suggest that buf_canrelease() could be a *lot* more
conservative about how much to release than "2 * page deficit".  In
fact, serious trouble seems to ensue if it's not -- when anything
else on the system demands enough pages, we slam down to the low
water mark nd stay there.  I've adjusted it to use min(page defecit,
buffer memory / 16), which still isn't quite right but seems better.

Another change: consider the case of an infinite loop that does
"tar xzf pkgsrc.tar.gz ; rm -rf pkgsrc".  Each time the rm runs,
all the dead metadata will go on the AGE list -- and, until we hit
the high-water mark, stay there, at which point it may be slowly
recycled.  Two adjustments seem to solve this:  1) whack buf_lotsfree()
to return 0 if there's anything on the AGE list; 2) whack buf_canrelease()
to count the memory used by the AGE list and always return at least
that much.

This basically turns the AGE list into a "delayed free" list, since we
can't entirely eliminate it as we can't free pool items from interrupt
context (e.g. from biodone()).

To consider: with the bookkeeping corrected, should buf_drain() move
back to the _end_ of the pagedaemon, and should the calculation then
try to give back at least the current defecit?
2004-02-11 17:36:31 +00:00
yamt 1e18e59746 - borrow vmspace0 in uvm_proc_exit instead of uvmspace_free.
the latter is not a appropriate place to do so and it broke vfork.
- deactivate pmap before calling cpu_exit() to keep a balance of
  pmap_activate/deactivate.
2004-02-09 13:11:21 +00:00
yamt fa47baddee lwp_exit2: grab kernel_lock to preserve locking order. 2004-02-09 13:02:48 +00:00
yamt a45adbd9c7 don't deactivate pmap in exit1 because we'll touch the pmap later.
instead, borrow vmspace0 immediately before destroying the pmap
in uvmspace_free.
2004-02-07 10:05:52 +00:00
christos 13057976a6 include <uvm/uvm_object.h> for the benefit of ports that don't include
it in <machine/pmap.h>
2004-02-06 13:46:27 +00:00
junyoung 48d5030e12 ANSIfy & zap some blank lines. 2004-02-06 08:08:46 +00:00
junyoung 9a410f9ed0 Rename es_check in struct execsw to es_makecmds. 2004-02-06 08:02:58 +00:00
pk f092315b50 pg_delete: re-arrange SESSRELE() calls to allow for better code generation. 2004-02-06 06:59:33 +00:00
pk 7026ce08c8 ioctl TIOCSCTTY: re-arrange SESSHOLD() calls to allow for better code generation. 2004-02-06 06:58:21 +00:00
christos 0283dcd8a6 - Don't use uao_ functions directly; use them through the pgops methods.
- Fix missing reference leak in the error path of shmat() mentioned in
  Full-Disclosure.
2004-02-05 22:28:33 +00:00
christos 6b1b54b981 Don't use uao_reference, directly use the pgops instead. XXX: we should
prolly make all the uao_ functions used in pgops static.
2004-02-05 22:26:52 +00:00
tls aeaf748ff2 Buffer cache fixes to avoid thrashing between high and low water marks
and uncontrolled growth.

The key fix is from Dan Carasone, who noticed that buf_canfree() was
counting in _bytes_ but freeing in _buffers_, which caused the instant
drop to lowater observed by some users.

We now control the rate of growth; the probability of getting a new
allocation is inversely proportional to the current size of the
cache.  This idea is from a long-ago conversation with Kirk McKusick
and, if memory serves, was used for the file-system cache in some
other BSD variant at some point in history.

With growth and shrinkage more or less dealt with, we return the
default maximum cache size to 15%.  The default _minimum_ cache size
is raised from 1/16 of the maximum cache size to 1/8, since 1/16 was
chosen when the maximum size was 30% of memory.

Finally, after observing the behaviour of the pagedaemon and the
buffer cache drainer under pathological workloads (e.g. a benchmark
that steps through 75% of available memory backwards) I have moved
the call to buf_drain() to the beginning of the pagedaemon from the
end; if the pagedaemon bogs down, it still won't get run as often
as it should, but at least this way it will see the state of the
free count and free target _before_ the scan step does its thing.
2004-01-30 11:32:16 +00:00
tsarna 72489e1ea0 uuidgen(2) syscall. Originally from FreeBSD, ported by John Franklin in
PR#23470, with minor updates by me. This is only the syscall support
from that PR, for now.

Changes: port over fix from FreeBSD for multicast address generation.
Changed bcopy to memcpy.  For now, #ifdef notyet the portions of
kern_uuid.c that are meant to be used by (currently nonexistent) other
things in the kernel.  Added syscall to COMPAT_FREEBSD as well, though
that's currently not useful, as any program new enough to use this call
also uses other syscalls we don't (yet) emulate.
2004-01-29 02:00:02 +00:00
dan c6ba3edf9d Reduce the default BUFCACHE to 10% for now. Too many users are
tripping over this getting too large, and suffering other performance
problems due to the lack of good backpressure shrinking the bufcache
when other memory is required.  Again, this tunable should be
revisited when the backpressure mechanism has been improved.

sysctl vm.bufcache can be used to manually tune those rare machines
that might need more than this.

See comments in rev 1.106 for more detail.
2004-01-27 11:35:23 +00:00
hannken 3db4e2acd8 Make VOP_STRATEGY(bp) a real VOP as discussed on tech-kern.
VOP_STRATEGY(bp) is replaced by one of two new functions:

- VOP_STRATEGY(vp, bp)  Call the strategy routine of vp for bp.
- DEV_STRATEGY(bp)      Call the d_strategy routine of bp->b_dev for bp.

DEV_STRATEGY(bp) is used only for block-to-block device situations.
2004-01-25 18:06:48 +00:00
hannken d7f6cbf8bc Make VOP_STRATEGY(bp) a real VOP as discussed on tech-kern. 2004-01-25 18:02:04 +00:00
hannken b1cb363c11 Make VOP_STRATEGY(bp) a real VOP as discussed on tech-kern.
VOP_STRATEGY(bp) is replaced by one of two new functions:

- VOP_STRATEGY(vp, bp)  Call the strategy routine of vp for bp.
- DEV_STRATEGY(bp)      Call the d_strategy routine of bp->b_dev for bp.

DEV_STRATEGY(bp) is used only for block-to-block device situations.
2004-01-25 18:02:03 +00:00
wiz f62661e104 Add semicolons after variable declarations; closes PR 24201. 2004-01-24 01:40:57 +00:00
simonb 2763a4b916 Fix NTP PPSAPI support (enabled with "options PPS_SYNC"):
From PR kern/13702 from Charles Carvalho.  Tested on alpha and
i386 with a Laipac TF10 PPS-capable GPS.  The com.c change was
copied wholesale from Charles' z8530tty.c patch.
2004-01-23 05:01:19 +00:00
atatat 4fe5b245f9 Fix the kern.mbuf tunables. 2004-01-21 02:11:20 +00:00
yamt ce0a402d3c bufpool_page_alloc: for no-wait allocations, specify UVM_KMF_TRYLOCK as well. 2004-01-19 11:57:42 +00:00
atatat 47768f08f2 In sysctl_locate(), use "rnode" like everywhere else, don't call it
"rv".

In sysctl_destroyv(), deal with deleting alias nodes, and pass a token
size_t to sysctl_destroy().

In sysctl_free(), check that "node" has not reached "rnode", not that
"pnode" has.

In sysctl_realloc(), don't bother setting sysctl_clen...the value is
unchanged.
2004-01-17 04:01:14 +00:00
atatat 5d3b89e2f4 Avoid dereferencing l...it might be NULL 2004-01-17 03:33:24 +00:00
yamt 047fc0b378 - fix locking order problem. (pa_slock -> pr_slock)
- protect pr_phtree with pr_slock.
- add some LOCK_ASSERTs.
2004-01-16 12:47:37 +00:00
mrg 23884e8622 clean up a little:
- delete ktrsyscall32()
- add a check #ifdef _LP64 to do the conversion if P_32 is set to the
standard ktrsyscall()
- add a couple of similar _LP64/P_32 checks to the systrace code.

this should get systrace working for 32 bit apps as well as complete
ktrace support for "trace_enter/trace_exit" using platforms such as amd64.

XXX: systrace isn't supported on sparc64 currently... (it doesn't use
trace_enter/trace_exit, or have it's own calls to systrace_xxx()...)
2004-01-16 05:03:02 +00:00
mrg 4c2a3c644a export ktrinitheader() and ktrwrite() for ktrsyscall32(), which is used
to write 32 bit syscall arguments in a 64 bit format.
2004-01-15 14:29:20 +00:00
enami 9e2ac76ac4 Obviously, sizeof(u_int) is not enough to copy struct buf.
Prevents ``sysctl -a'' from dumping core.
2004-01-15 09:03:26 +00:00
yamt 7f20b0c529 bump vnode hold count for page cache as well
to resolve unfairness between page cache and traditional buffer cache.
pointed by enami tsugutomo on current-users@.
2004-01-14 11:28:04 +00:00
jdolecek 475a5858bf g/c process state SDEAD - it's not used anymore after 'reaper' removal 2004-01-11 19:39:48 +00:00
jdolecek a1090edbd2 fix assertion - non-alive processes are in SZOMB state now
fixes PR kern/24033 by Martin Husemann
2004-01-11 18:51:15 +00:00
hannken ed68c4e34c Allow vfs_write_suspend() to wait if the file system is already
suspending.

Move vfs_write_suspend() and vfs_write_resume() from kern/vfs_vnops.c
to kern/vfs_subr.c.

Change vnode write gating in ufs/ffs/ffs_softdep.c (from FreeBSD).

When vnodes are throttled in softdep_trackbufs() check for
file system suspension every 10 msecs to avoid a deadlock.
2004-01-10 17:16:38 +00:00
yamt a3b2d1879c add a new bufq strategy, BUFQ_PRIOCSCAN (per-priority CSCAN).
discussed on tech-kern@
2004-01-10 14:49:44 +00:00
yamt 8c55727694 reset i/o priority in geteblk() as well. 2004-01-10 14:43:05 +00:00
yamt 7266a95907 store a i/o priority hint in struct buf for buffer queue discipline. 2004-01-10 14:39:50 +00:00
thorpej 4aeba6790d Initialize buffer pools with PR_IMMEDRELEASE. Don't use pool_reclaim()
on those pools; it is no longer necessary.
2004-01-09 19:01:01 +00:00
thorpej 7f125220f4 Add a new pool initialization flag, PR_IMMEDRELEASE. This flag causes
idle pool pages to be returned to the system immediately upon becoming
de-fragmented.

Also, in pool_do_put(), don't free back an idle page unless we are over
our minimum page claim.
2004-01-09 19:00:16 +00:00
tls e4758a97ae Change BUFCACHE (default hard limit on physmem consumption by metadata
cache) from 30% to 20%.  This seems to significantly smooth the oscillation
between "almost no memory available" and "UVM free target available" caused
by the current sudden, heavy backpressure on the metadata cache.  We should
revisit this again once the backpressure mechanism is better tuned; ideally,
the hard limit should almost never come into play, because the metadata
cache should gradually give back pages as buffers hit the AGE list and as
the page cache demands them, rather than giving back a big slug of pages
all at once when UVM decides it's in a hurry and fires off the page daemon.

Just how well this adjustment works is likely to vary significantly from
machine to machine depending on I/O mix, filesystem frag size, and total
memory.  However, 20% seems to be quite a bit better than 30% on several
systems I've tested and is, coincidentally, more than enough to cache
the entire metadata working set of the AnonCVS server with 100 clients,
which is a useful worst-case stake in the ground...
2004-01-09 06:26:15 +00:00
tls 0d6723b09f Bump default size of vnode cache to 1% of physical memory, instead of
0.5%, based on some quick measurements on a number of workstations and
small fileservers (including my home fileserver running simultaneous
builds of the NetBSD source tree and several NetBSD kernels).  This
brings the hit rate on my machines from below 70% to above 90%.  We
should be able to tune this as we run, by tracking the hit rate and
increasing the size of the cache if memory permits.

Some systems will still require significantly larger cache sizes.  Some
ports -- notably the 64-bit ones -- probably should use more than 1% of
physmem as the default due to the larger size of struct vnode.
2004-01-09 00:04:53 +00:00
tls 28364b01be Add pool_reclaim() on pool to which we just pool_put() a buffer in
buf_mrelease().  Without this, though the pages are returned to the
relevant *pool*, they are never available for any other use in the
system.

Now the backpressure on the physical size of the buffer cache through
the buf_drain() call in the pagedaemon works correctly.  If anything,
it may be a bit more aggressive than intended.  On my 256MB system,
with vm.bufcache set to the default 30% of physmem, a kernel with this
fix can do 5 simultaneous config/makedep/builds of different NetBSD
kernels in 1313 seconds; with the "traditional" buffer cache code it
requires 1320 seconds.  Running "find / -type d -exec ls -l {}" while
the build is going demonstrates that the backpressure is working
correctly: free memory oscillates slowly between close to none and
the UVM target free, and vmstat -m shows a large number of releases
for the buffer pools.

For future work: how is "bufpl" memory returned to the system?  This
is not obvious to me (I must be looking in the wrong place).  Also,
buf_mrelease() is also called from brelse() in some cases.  Would it
be better to add a pool flag causing automatic release of full pages
as they become available (not fragmented)?  Jason Thorpe proposed this
and it seems more elegant than cleaning the _entire_ pool only upon
memory pressure.

Greg Oster did a lot of the work of figuring this out.  Jason proposed
the use of pool_reclaim as a way to fix it.
2004-01-08 23:41:14 +00:00
cube 3bf5e4c13b If ksyms have not been initialized, return ENXIO in ksymsopen instead of
ksymsread, because ksyms client test availability with open() and not
read().
2004-01-08 22:48:26 +00:00
thorpej d76fa360ef Back out >2 PT_LOAD changes from rev 1.96. They cause older GCC3-compiled
PowerPC binaries to fail.  The compiler has since been fixed, but
compatibility with older binaries needs to be maintained.

PR kern/23758.
2004-01-07 16:42:53 +00:00
jdolecek 26767eb2ae fix F_MAXFD fcntl - it returned the value as errno instead
of return value from the syscall
from mouss <usebsd at free dot fr>
2004-01-07 09:26:29 +00:00
atatat 5efc584023 Expose the buf_map symbol so that pmap(1) can find it.
Split the sysctl setup routine into two routines, one for each
"subtree".  Perhaps it's a little pedantic, but it's cleaner.  Also,
assert that the "kern" and "vm" nodes exist.
2004-01-06 13:51:09 +00:00
lukem 7bb9d6c875 Store the copyright text in conf/copyright, and use conf/newvers.sh
to generate the appropriate  const char copyright[] = "...";
statement instead of hard coding it into kern/init_main.c.
Idea from Simon Burge.
2004-01-05 03:33:06 +00:00
christos b76a454b90 Ad F_CLOSEM, F_MAXFD from Matt Thomas. 2004-01-05 00:36:49 +00:00
pk 90cc172b86 bufpool_page_free: pass `buf_map' to uvm_km_free(). 2004-01-04 16:17:13 +00:00
kleink 1b16e3f0a3 ; may be a comment character in assembly, use \n as a separator instead. 2004-01-04 13:27:53 +00:00
jdolecek 089abdad44 Rearrange process exit path to avoid need to free resources from different
process context ('reaper').

From within the exiting process context:
* deactivate pmap and free vmspace while we can still block
* introduce MD cpu_lwp_free() - this cleans all MD-specific context (such
  as FPU state), and is the last potentially blocking operation;
  all of cpu_wait(), and most of cpu_exit(), is now folded into cpu_lwp_free()
* process is now immediatelly marked as zombie and made available for pickup
  by parent; the remaining last lwp continues the exit as fully detached
* MI (rather than MD) code bumps uvmexp.swtch, cpu_exit() is now same
  for both 'process' and 'lwp' exit

uvm_lwp_exit() is modified to never block; the u-area memory is now
always just linked to the list of available u-areas. Introduce (blocking)
uvm_uarea_drain(), which is called to release the excessive u-area memory;
this is called by parent within wait4(), or by pagedaemon on memory shortage.
uvm_uarea_free() is now private function within uvm_glue.c.

MD process/lwp exit code now always calls lwp_exit2() immediatelly after
switching away from the exiting lwp.

g/c now unneeded routines and variables, including the reaper kernel thread
2004-01-04 11:33:29 +00:00
jdolecek 6ea538748e constify a bit 2004-01-03 20:10:01 +00:00
jdolecek 1d86b1f39f fix some comments, use NULL instead of 0 for pointer comparison 2004-01-03 19:43:55 +00:00
cl d5645dec8e regen 2004-01-02 18:53:45 +00:00
cl e7045955c7 kernel part of no-syscall upcall stack return: libpthread registers
an offset between ss_sp and struct sa_stackinfo_t (located in struct
__pthread_st) when calling sa_register.  The kernel increments the
sast_gen counter in struct sastack when an upcall stack is used.
libpthread increments the sasi_stackgen counter in struct
sa_stackinfo_t when an upcall stack is freed.  The kernel compares the
two counters to decide if a stack is free or in use.

- add struct sa_stackinfo_t with sasi_stackgen to count stack use in
  userland
- add sast_gen to struct sastack to count stack use in kernel
- add SA_FLAG_STACKINFO to enable the stackinfo_offset argument in the
  sa_register syscall
- add sa_stackinfo_offset to struct sadata for offset between ss_sp
  and struct sa_stackinfo_t
- add ssize_t stackinfo_offset argument to sa_register, initialize
  struct sadata's sa_stackinfo_offset from it if SA_FLAG_STACKINFO is
  set
- add sa_getstack, sa_getstack0, sa_stackused and sa_setstackfree
  functions to find/use/free upcall stacks and use these where
  appropriate
- don't record stack for upcall in sa_upcall0
- pass sau to sa_switchcall instead of l2 (l2 = curlwp in sa_switchcall)
- add sa_vp_blocker to struct sadata to pass recently blocked lwp to
  sa_switchcall
- delay finding a stack for blocked upcalls to sa_switchcall
- add sa_stacknext to struct sadata pointing to next most likely free
  upcall stack; also g/c sa_stackslist in struct sadata and sast_list
  in struct sastack
- add L_SA_WOKEN flag: LWP is on sa_woken queue
- add L_SA_RECYCLE flag: LWP should be recycled in sa_setwoken
- replace l_upcallstack with L_SA_WOKEN/L_SA_RECYCLE/L_SA_BLOCKING
  flags
- g/c now unused sast_blocker in struct sastack
- make sa_switchcall, sa_upcall0 and sa_upcall_getstate static in
  kern_sa.c
- call sa_upcall_userret only once in userret
- split sa_makeupcalls out of sa_upcall_userret and use to process
  the sa_upcalls queue
- on process exit: mark LWPs sleeping in saunblock interruptible; also
  there are no LWPs sleeping on l->l_upcallstack anymore; also clear
  sa_wokenq_head to prevent unblocked upcalls

additional changes:
- cleanup timerupcall sa_vp == curlwp check
- add check in sa_yield if we didn't block on our way here and we
  wouldn't any longer be the LWP on the VP
- invalidate sa_vp_ofaultaddr after resolving pagefault
2004-01-02 18:52:17 +00:00
mycroft a9866938b5 Welcome to 2004! 2004-01-01 00:00:05 +00:00
pk dc6d5d0dd1 getnewbuf: return buffer locked. 2003-12-31 14:37:17 +00:00
thorpej 7e958083b1 Consistently use ANSI-style function decls. 2003-12-30 20:40:39 +00:00
thorpej 6a833751e0 Remove allocsys(); nothing uses it anymore. 2003-12-30 18:29:43 +00:00
pk 70f20a1217 Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.

This allows better utilization of memory because buffers can now be allocated
with a granularity finer than the system's native page size (useful for
filesystems with e.g. 1k or 2k fragment sizes).  It also avoids fragmentation
of virtual to physical memory mappings (due to the former fixed virtual
address reservation) resulting in better utilization of MMU resources on some
platforms.  Finally, the scheme is more flexible by allowing run-time decisions
on the amount of memory to be used for buffers.

On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
2003-12-30 12:33:13 +00:00
martin 44b17951f2 Avoid using m_clget() on a mbuf already in use, especially when we
need the data in the mbuf later and m_clget() changes some fields
overlaid to regular mbuf data. Instead, rearange code a bit, create
data into a new allocated buffer and and use MEXTADD to attach it to
the mbuf, if the mbuf internal space is not sufficient.

This fixes a crash on sparc64 (and probably all other archs where
sizeof(int) != sizeof(struct file *)) when running
regress/sys/kern/unfdpass.

Idea for solution from Matt Thomas, with additional input from YAMAMOTO
Takashi.
2003-12-29 22:08:02 +00:00
yamt 192843ffc2 pool_prime_page: initialize ph_time to mono_time instead of zero
as it's a mono_time relative value.
2003-12-29 16:04:58 +00:00
atatat 1cab3635c2 Avoid dereferencing l in sysctl_lookup(), because it can be NULL.
Note one point where a possibility of a fault exists.
2003-12-29 04:19:28 +00:00
atatat 74dad84b6e Remove two uses of uvm_kernacc(), which wasn't quite getting the job
done anyway.  On a related change, use kcopy() instead of memcpy() for
kernel-to-kernel copying so that the same service warranty can be
given.
2003-12-29 04:16:25 +00:00
atatat b1c111a62a Sysctl functions called for "generic" nodes should forward "query"
requests (where possible), rather than returning errors.
2003-12-28 22:36:37 +00:00
atatat 0f7550bbf8 Adjust error returns in kern.cp_time when a specific processor is
being requested so that (1) the uniprocessor case and the
multiprocessor case are more similar and (2) so that we return ENOENT
when a non-existent processor is requested (which is both more
sensible and follows the general order of things anyway).
2003-12-28 22:24:12 +00:00
atatat c703d9821f Rename sysctl_kern_hostname() to sysctl_setlen() and use it also for
domainname.  Note that there's no need to copy rnode since we're not
changing any of it, nor protecting anything from change.

Thanks to martin for initial work.
2003-12-28 22:19:59 +00:00
atatat 8e0c1f1594 RCSid police 2003-12-28 22:12:00 +00:00
martin c22fd25c47 After changing hostname, adjust hostnamelen.
This closes PR kern/23907.
2003-12-28 14:39:36 +00:00
martin be59b63fe2 Make kern.rtc_offset writable at securelevel <= 0.
This allows boot-time adjustment when a machine runs other OSes with
RTC == localtime.
2003-12-26 23:49:39 +00:00
manu ffb3de5522 Move the sigfilter hook to a more adequate location, and rename it to better
fit what it does.

The softsignal feature is used in Darwin to trace processes. When the
traced process gets a signal, this raises an exception. The debugger will
receive the exception message, use ptrace with PT_THUPDATE to pass the
signal to the child or discard it, and then it will send a reply to the
exception message, to resume the child.

With the hook at the beginnng of kpsignal2, we are in the context of the
signal sender, which can be the kill(1) command, for instance. We cannot
afford to sleep until the debugger tells us if the signal should be
delivered or not.

Therefore, the hook to generate the Mach exception must be in the traced
process context. That was we can sleep awaiting for the debugger opinion
about the signal, this is not a problem. The hook is hence located into
issignal, at the place where normally SIGCHILD is sent to the debugger,
whereas the traced process is stopped. If the hook returns 0, we bypass
thoses operations, the Mach exception mecanism will take care of notifying
the debugger (through a Mach exception), and stop the faulting thread.
2003-12-24 22:53:59 +00:00
manu 54db0e51ad Split sys_lwp_suspend, just like sys_lwp_unsuspend is split. We get
sys_lwp_suspend, with the sanity checks, and lwp_suspend, with the
actual implementation.
2003-12-24 22:42:11 +00:00
simonb 16846040d7 Remove trailing blank line. 2003-12-21 11:54:16 +00:00
fvdl d99705e941 Put back Emmanuel's sigfilter hooks, as decided by Core. 2003-12-20 19:01:29 +00:00
manu b23b73b953 Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.
2003-12-20 18:22:16 +00:00
yamt 8b9614a490 update a comment to match with the previous change (rev.1.12). 2003-12-20 07:33:03 +00:00
yamt 4dd4230680 restore functionality to decrease kern.maxvnodes which
has been backed out during sysctl rework.
2003-12-20 07:26:27 +00:00
dsl 97356a5fa8 Defer writing of KTR_EMUL entry until first trace done by target process.
Stops ktrops sleeping with the pid table locked.
2003-12-14 22:56:45 +00:00
simonb 701a167dd3 In sysctl_kern_lwp adjust offsets into the mib entries so that
they are now correct.  Fixes problems with "ps -s" not working.
Also use KERN_LWPSLOP instead of KERN_PROCSLOP.

Both changes from Andrew Brown.
2003-12-12 23:21:44 +00:00
atatat e3796202c5 Make kern.dump_on_panic writeable again, too 2003-12-10 14:16:12 +00:00
agc 7db1d33cba Modify the licences of code written by Theo De Raadt from a 4-clause
to a 2-clause licence (retaining UCB clauses (1) and (2)), per PR
22409 from Joel Baker, approved by Theo de Raadt, and ratified by
myself - the only discrepancy being the handling of the original
clause 3 in src/usr.sbin/yppoll/yppoll.c.
2003-12-10 12:06:25 +00:00
hannken fbae381aaa The file system snapshot pseudo driver.
Uses a hook in spec_strategy() to save data written from a mounted
file system to its block device and a hook in dounmount().

Not enabled by default in any kernel config.

Approved by: Frank van der Linden <fvdl@netbsd.org>
2003-12-10 11:40:11 +00:00
atatat 38f213672c Make kern.sbmax writeable again as well.
From a follow-on to PR kern/23695 by a Mr. Davis, which I missed at a
quick glance.
2003-12-09 01:52:07 +00:00
atatat a5d6d5ebfd Make kern.logsigexit writeable again.
Fixes PR kern/23695.
2003-12-09 01:25:33 +00:00
hannken 37efcf9045 Fix the last commit(s). On machines with sizeof(long) != sizeof(int)
the hash compare would fail.
2003-12-08 14:23:33 +00:00
hannken 10654a5c0a Fix last commit. The current spl was an implicit argument to the ACQUIRE
macro.  With help and approval from YAMAMOTO Takashi <yamt@netbsd.org>
2003-12-08 14:21:25 +00:00
martin 8c36f2238a Add missing break. 2003-12-07 10:33:03 +00:00
he 073a54fdfa Also make declaration of sysctl_kern_maxptys() depend on NPTY > 0.
Makes the mvme68k RAMDISK kernel compile again.
2003-12-07 10:31:32 +00:00
chs 291c877a9c add support for more than 2 PT_LOAD sections. from OpenBSD. 2003-12-07 02:18:53 +00:00
martin c70b2edfae Fix kern.cp_time for MULTIPROCESSOR kernels: calculate size of result
correctly, free original instead of incremented pointer, copy results for
n = -2 case too, so top shows correct stats.
Additionaly, rearange code for better readability (from Andrew).
2003-12-06 21:33:51 +00:00
fvdl 150a6bd869 Include opt_posix.h for the P1003_1B_SEMAPHORE define.
Include <machine/cpu.h> just to be sure.
2003-12-06 20:06:11 +00:00
yamt 8e92859632 rev.1.55 didn't handle BUFQ_SORT_CYLINDER case correctly.
pointed by Juergen Hannken-Illjes.  patch provided by him.
2003-12-06 17:23:22 +00:00
yamt 88046c4ce5 fix a debug code to follow recent change about tailing slashes. 2003-12-06 14:17:13 +00:00
yamt e5d5094296 - turn non-verbose parts of NAMEI_DIAGNOSTIC into normal DEBUG.
- comments on #endif.
2003-12-06 14:16:11 +00:00
martin fb5bbc3d78 We can not count CPUs at sysctl initialization time - so don't make
hw.ncpu an immediate value.
2003-12-06 09:36:34 +00:00
atatat 936b72608c Don't need those any more 2003-12-06 04:25:57 +00:00
atatat 44f5f6b89b The missing pieces of PROC_PID_STOPEXIT/P_STOPEXIT, a sysctl tweakable
flag that makes a process stop as it exits.
2003-12-06 04:16:33 +00:00
atatat 4673a65de6 #include "opt_multiprocessor.h"
This makes hw.ncpu and kern.cp_time work better on those platforms.
2003-12-06 02:52:29 +00:00
simonb efee714557 Wrap long line. 2003-12-06 01:53:14 +00:00
he b2518d1259 Make sure buf_inorder() returns a value under all conditions. 2003-12-06 01:21:23 +00:00
jdolecek 43dfb7e7a8 add #ifdef DEBUG segnum sanity check in shm_delete_mapping() 2003-12-05 22:09:56 +00:00