Commit Graph

2568 Commits

Author SHA1 Message Date
thorpej 80cc38a1af Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads.  What we do is stick descriptors in the table, but
mark them as "larval".  This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again.  When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
2001-06-14 20:32:41 +00:00
nathanw 9e8fb68348 The trace_req() function is a no-op; garbage collect it. 2001-06-13 16:06:27 +00:00
tron 848a0e68f6 Lower interrupt priortiy properly if setting the setting the kernel time
is denied in a securelevel above 1. This fixes PR kern/13158.
2001-06-11 07:07:12 +00:00
mrg 7a84fc0483 use real \n's copyright[]; avoids gcc 3.0-prerelease warnings. 2001-06-08 12:53:30 +00:00
thorpej d9b3317e3e Rework fdalloc() even further: split fdalloc() into fdalloc() and
fdexpand().  The former will return ENOSPC if there is not space
in the current filedesc table.  The latter performs the expansion
of the filedesc table.  This means that fdalloc() won't ever block,
and it gives callers an opportunity to clean up before the
potentially-blocking fdexpand() call.

Update all fdalloc() callers to deal with the need-to-fdexpand() case.

Rewrite unp_externalize() to use fdalloc() and fdexpand() in a
safe way, using an algorithm suggested by Bill Sommerfeld:
- Use a temporary array of integers to hold the new filedesc table
  indexes.  This allows us to repeat the loop if necessary.
- Loop through the array of file *'s, assigning them to filedesc table
  slots.  If fdalloc() indicates expansion is necessary, undo the
  assignments we've done so far, expand, and retry the whole process.
- Once all file *'s have been assigned to slots, update the f_msgcount
  and unp_rights counters.
- Right before we return, copy the temporary integer array to the message
  buffer, and trim the length as before.
Note that once locking is added to the filedesc array, this entire
operation will be `atomic', in that the lock will be held while
file *'s are assigned to embryonic table slots, thus preventing anything
else from using them.
2001-06-07 01:29:16 +00:00
mrg 1ce89f683e in coredump() remove the COMPAT_NETBSD32 #ifdef, and replace it with a hook.
move coredump32() into compat/netbsd32.
2001-06-06 21:37:19 +00:00
thorpej c55795d055 Change fdalloc() to return ERESTART if we had to reallocate the
descriptor array, which may have blocked.  Change callers of
fdalloc() to restart whatever they\'re doing if this condition
happens.  (XXX unp_externalize() needs some work, but that will
be tackled later.)

Change finishdup() to close the descriptor in the `new\' slot if
one exists, and change sys_dup2() accordingly.

Closes a race condition when using kernel-assisted user threads.

While here, garbage-collect UF_MAPPED -- it is not used anywhere.
2001-06-06 17:00:00 +00:00
thorpej f1c14428bb Do the reentrancy checking if POOL_DIAGNOSTIC, not DIAGNOSTIC. Prevents
ABI change for diagnostic vs. non-diagnostic kernels.
2001-06-05 18:51:03 +00:00
mrg b49770c009 add a DEBUG for why the lkm entry point failed. 2001-06-05 12:36:08 +00:00
thorpej e93d1531c2 Avoid a sleeping malloc call while holding the spechash_slock.
XXX This is kinda gross, but prevents complete lossage on an
XXX MP system.
From Bill Sommerfeld.
2001-06-05 04:42:05 +00:00
thorpej 47c29f3cbe Assert that no locks are held if we're called with PR_WAITOK.
From Bill Sommerfeld.
2001-06-05 04:40:39 +00:00
thorpej 2fbef8e269 Assert that no locks are held if we're called with EX_WAITSPACE.
From Bill Sommerfeld.
2001-06-05 04:39:56 +00:00
thorpej 67a875a8c9 Assert that no locks are held if we're called with M_WAITOK. 2001-06-05 04:39:02 +00:00
thorpej 31769952ca Add a simple_lock_only_held() LOCKDEBUG routine, which allows code
to assert that exactly zero or one (and a specific one) locks are
held.

From Bill Sommerfeld.
2001-06-05 04:38:08 +00:00
chs 821ec03ed9 replace vm_map{,_entry}_t with struct vm_map{,_entry} *. 2001-06-02 18:09:08 +00:00
lukem d84d2c6c85 add missing #include "opt_kgdb.h" 2001-05-30 15:24:23 +00:00
mrg 09cf52ad81 regen. 2001-05-30 11:48:07 +00:00
mrg 72d327d434 use _KERNEL_OPT not _KERNEL&&|_LKM 2001-05-30 11:27:46 +00:00
chs 187cadcb77 don't define bpendtsleep in profiling kernels since it confuses gprof. 2001-05-28 22:20:03 +00:00
thorpej 442a329915 Statically-initialize `allevents' so that events can be registered
very early (before main() is called).
2001-05-28 16:40:31 +00:00
thorpej 9ec2953eef Make "reboot" an option at the root device/filesystem prompt (we
already had a "halt").
2001-05-27 01:29:50 +00:00
chs c90ead639a regen. 2001-05-26 21:34:04 +00:00
chs 07cabef8a2 replace vm_page_t with struct vm_page *. 2001-05-26 21:33:11 +00:00
chs 11a9651c8f replace vm_page_t with struct vm_page *. 2001-05-26 21:27:10 +00:00
kristerw 76475ad726 Removed an incorrect use of __CONCAT when formatting panic messages.
The ISO C standard says in 6.10.3.3 that if the result of using the
'##' operator "is not a valid preprocessing token, the behaviour is
undefined." Gcc 3.0 warns about this.
2001-05-24 10:33:08 +00:00
lukem c9b9613b3e for FIOGETOWN, only change the sign of *data if fo_ioctl returned without error 2001-05-24 06:52:43 +00:00
lukem 0fd012d03b regen for whitespace cleanup 2001-05-24 06:44:30 +00:00
manu a3703d68ef Backed out a previous commit that was incomplete and hence broke several
emulation package build
2001-05-19 17:28:33 +00:00
manu 37a42fd1bf Moved e_flags outsied of ifdef __HAVE_MINIMAL_EMUL in struct emul
and removed an ifdef that was taking care of this problem
2001-05-19 08:52:05 +00:00
perry 4be93c9ed7 Add a /* LINTSTUB: include <foo.h> */ mechanism. 2001-05-16 04:17:04 +00:00
perry bf16779f43 allow long typed functions 2001-05-16 03:58:14 +00:00
perry 3fe923fc2c I -> Ignore 2001-05-15 22:32:02 +00:00
perry 7cb4818421 awk script to automatically generate lint stub files from stylized
comments in .S files.
2001-05-15 22:23:09 +00:00
lukem 6cb5e77db5 remove use of gcc syntax for designated initialisers when initialising
unions `union_elem: ...', and use c99 syntax `.union_elem = ...' only
where necessary.
in this case, there's no need to tag elf_probe_func because that's the
first union element, and therefore, the implicit case. only specifically
mention ecoff_probe_func where necessary.

if we decide to not use this c99 feature for now, at least there's now
less stuff to rip out.
2001-05-15 02:00:12 +00:00
sommerfeld b4c4ecb455 Make this build again ifdef DIAGNOSTIC (oops) 2001-05-13 17:17:34 +00:00
sommerfeld 5b2241ad77 Remove pool reentrancy testing overhead unless DIAGNOSTIC is defined.
Previously, we passed __FILE__ and __LINE__ on all pool_get/pool_set calls.

This change results in a measured 1.2% performance improvement in
ping-flood packets-per-second as reported by ping(8).
2001-05-13 17:06:58 +00:00
thorpej 2f58df9a8f Rearrange the code that adds pages of objects to the pool; require
that the caller allocate the pool_item_header when it allocates the
pool page, so we can avoid a locking pitfall (sleeping with a simple
lock held).

Also revive pool_prime(), as there are some letigimate uses of it,
but in doing so, eliminate some of the bogosities of the old version
(i.e. don't do an implicit "setlowat", just prime the pool, and incr
the minpages for each additional page we add, and compute the number
of pages to prime in a way that callers would expect).
2001-05-10 04:51:41 +00:00
thorpej 6ec67f871a Use POOL_NEEDS_CATCHUP() in one more place. 2001-05-10 02:19:32 +00:00
thorpej db26619a5e Encapsulate the test for a pool needing a pool_catchup() in a macro. 2001-05-10 01:37:40 +00:00
thorpej 627edfcb50 Remove pool_create() and pool_prime(). Nothing except pool_create()
used pool_prime(), and no one uses pool_create() anymore.

This makes it easier to fix a locking pitfall.
2001-05-09 23:46:02 +00:00
thorpej 626cb1c3ce Use pool_init() rather then pool_create(). 2001-05-09 23:38:20 +00:00
jdolecek 27a5a43c04 In the check_header() function, bump the number of allowed section headers
to 512. Apparently, there are ELF binaries with more than 128 section
headers - an example is one of Linux Word Perfect 8 utilities.

This fixes kern/12455 by Mark Davies.
2001-05-07 17:09:13 +00:00
manu 7e6929fe90 Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.
2001-05-07 09:55:12 +00:00
lukem 5b2ac78763 regen from vnode_if.sh rev 1.29 2001-05-07 08:48:07 +00:00
lukem e1adc31453 delint: vop_default_desc was declared const but not defined const. 2001-05-07 08:46:02 +00:00
enami 8e5a4722c5 Make this file *just* compiles again when __HAVE_MINIMAL_EMUL is defined. 2001-05-07 02:51:53 +00:00
enami 362af21bc7 Fix broken indentation introduced by previous commit. 2001-05-07 02:28:55 +00:00
manu 573ce64c6b implement the recently introduced EMUL_BSD_ASYNCIO_PIPE emulation package
flag.

EMUL_BSD_ASYNCIO_PIPE notes that the emulated binaries expect the original
BSD pipe behavior for asynchronous I/O, which is to fire SIGIO on read() and
write(). OSes without this flag do not expect any SIGIO to be fired on
read() and write() for pipes, even when async I/O was requested. As far as
we know, the OSes that need EMUL_BSD_ASYNCIO_PIPE are NetBSD, OSF/1 and
Darwin.
2001-05-06 19:22:32 +00:00
manu 5a6b8191b5 Added two flags to emulation packages:
EMUL_BSD_ASYNCIO_PIPE notes that the emulated binaries expect the original
BSD pipe behavior for asynchronous I/O, which is to fire SIGIO on read() and
write(). OSes without this flag do not expect any SIGIO to be fired on
read() and write() for pipes, even when async I/O was requested. As far as
we know, the OSes that need EMUL_BSD_ASYNCIO_PIPE are NetBSD, OSF/1 and
Darwin.

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.
2001-05-06 19:09:52 +00:00
simonb cbbd901bdc Declare schedhz. 2001-05-06 13:46:34 +00:00