Bruce Evans [Thu, 29 Jan 2004 12:35:11 +0000 (12:35 +0000)]
Fixed breakage of scheduling in rev.1.29 of subr_4bsd.c. The
"scheduler" here has very little to do with scheduling. It is actually
the swapper, and it really must be the last SYSINIT'ed item like its
comment says, since proc0 metamorphoses into swapper by calling
scheduler() last in mi_start(), and scheduler() never returns.. Rev.1.29
of subr_4bsd.c broke this by adding another SI_ORDER_FIRST item
(kproc_start() for schedcpu_thread() onto the SI_SUB_RUN_SCHEDULER_LIST.
The sorting of SYSINITs with identical orders (at all levels) is
apparently nondeterministic, so this resulted in schedule() sometimes
being called second last and schedcpu_thread() not being called at all.
This quick fix just changes the code to almost match the comment
(SI_ORDER_FIRST -> SI_ORDER_ANY). "LAST" is misspelled "ANY", and
there is no way to ensure that there is only 1 very lst SYSINIT.
A more complete fix would remove the SYSINIT obfuscation.
Mike Makonnen [Thu, 29 Jan 2004 12:03:17 +0000 (12:03 +0000)]
I update the rwlock code in libthr to be more standards compliant and
what do I get for my troubles? libc breaks offcourse!
Reimplement a hack (in libthr) that allows libc to use
rwlocks without initializing them first. The hack was reimplemented
so that only a private libc version of the rwlock locking functions
initializes an uninitialized rwlock. The application version will
correctly fail.
Mike Makonnen [Thu, 29 Jan 2004 09:44:36 +0000 (09:44 +0000)]
When suspending a thread if the timeout was very short or
the system call got interrupted and the absolute timeout is
converted to a relative timeout, it may happen that we get a
negative number. In such a case, simply set the timeout to
zero so that if the event that the thread wants to wait for has
happened it can still return successfully, but if it hasn't
happened then the thread doesn't suspend indefinitely. This should
fix certain applications (including mozilla) that seem to hang
indefinitely sometimes.
Noticed and debugged by: Morten Johansen <root@morten-johansen.net>
Bill Paul [Thu, 29 Jan 2004 03:16:58 +0000 (03:16 +0000)]
Go back to using AUTHMODE_AUTO if WEP is on. In some cases, the Centrino
won't associate in BSS mode if you use AUTHMODE_SHARED. I probably don't
understand enough to know when SHARED should be used vs. OPEN or WPA.
For now, go back to what works.
Matt Jacob [Thu, 29 Jan 2004 02:40:43 +0000 (02:40 +0000)]
Fix longstanding buglet- for centrally handled CTIO2s we were checking the wrong
bit for this being the last CTIO2. It didn't matter since it really was the
last CTIO2 and the resources recycled, but still....
Peter Grehan [Thu, 29 Jan 2004 00:45:41 +0000 (00:45 +0000)]
When UMA_MD_SMALL_ALLOC is defined, pmap_kextract will be called
for direct-mapped addresses. Assume that any address less than KVA
is one of these and return it. Also assert that an address is KVA
does have a valid mapping - callers of pmap_kextract don't check
the return value, since they assume that they have a valid virtual
address.
Peter Grehan [Thu, 29 Jan 2004 00:32:22 +0000 (00:32 +0000)]
Implement UMA_MD_SMALL_ALLOC, since the BAT registers allow direct
addressing of memory. Makes a substantial improvement for apps that
stress the limited amount of KVM on PPC (e.g. untarring the ports tree).
Peter Wemm [Thu, 29 Jan 2004 00:07:29 +0000 (00:07 +0000)]
Re-add debug register support.
Some other minor tweaks snuck in here, including supporting more
discontiguous memory segments and some cosmetic tweaks.
Peter Wemm [Thu, 29 Jan 2004 00:02:54 +0000 (00:02 +0000)]
Take another shot at the invariants calls to __panic. They hadn't been
updated for the regparm ABI on amd64.
Context switch debug regs.
Update for fpu simplification
Don't needlessly reload %cr3, in case the cpu has the tlb flush filter
turned off. Re-add LAZY_SWITCH stubs.
Robert Watson [Wed, 28 Jan 2004 22:11:53 +0000 (22:11 +0000)]
Add a reset sysctl for mutex profiling: zeros all of the mutex
profiling buffers and hash table. This makes it a lot easier to
do multiple profiling runs without rebooting or performing
gratuitous arithmetic. Sysctl is named debug.mutex.prof.reset.
John Baldwin [Wed, 28 Jan 2004 20:44:41 +0000 (20:44 +0000)]
Move the loadav() callout into its own kthread since it uses allproc_lock
which is a sleepable lock and thus is not safe to acquire from a callout
routine.
John Baldwin [Wed, 28 Jan 2004 20:39:57 +0000 (20:39 +0000)]
Rework witness_lock() to make it slightly more useful and flexible.
- witness_lock() is split into two pieces: witness_checkorder() and
witness_lock(). Witness_checkorder() determines if acquiring a specified
lock at the time it is called would result in a lock order. It
optionally adds a new lock order relationship as well. witness_lock()
updates witness's data structures to assume that a lock has been acquired
by stick a new lock instance in the appropriate lock instance list.
- The mutex and sx lock functions now call checkorder() prior to trying to
acquire a lock and continue to call witness_lock() after the acquire is
completed. This will let witness catch a deadlock before it happens
rather than trying to do so after the threads have deadlocked (i.e. never
actually report it).
- A new function witness_defineorder() has been added that adds a lock
order between two locks at runtime without having to acquire the locks.
If the lock order cannot be added it will return an error. This function
is available to programmers via the WITNESS_DEFINEORDER() macro which
accepts either two mutexes or two sx locks as its arguments.
- A few simple wrapper macros were added to allow developers to call
witness_checkorder() anywhere as a way of enforcing locking assertions
in code that might acquire a certain lock in some situations. The
macros are: witness_check_{mutex,shared_sx,exclusive_sx} and take an
appropriate lock as the sole argument.
- The code to remove a lock instance from a lock list in witness_unlock()
was unnested by using a goto to vastly improve the readability of this
function.
Nate Lawson [Wed, 28 Jan 2004 19:01:10 +0000 (19:01 +0000)]
Use sys_nsig instead of NSIG for the length of the signal arrays. This
is important if we add new signals later. From DragonflyBSD:
jobs.c:1.4, trap.c:1.3.
Martin Cracauer [Wed, 28 Jan 2004 18:22:19 +0000 (18:22 +0000)]
The PR diff I committed recently had one bug noticed by
Joe Marcus Clarke <marcus@FreeBSD.ORG>, subshells could lose a
non-zero exit status.
This commit is Joe's proposed patch. Thanks!
I verified that the problem Joe found is fixed and I ran a full world
with this patch.
I don't plan to ever commit language patches to /bin/sh again. It is
a minefield too big to navigate without a full-time committment, which
I am not willing to do on our /bin/sh.
Under normal circumstances I would recommend using NetBSD's sh which
has a lot of language fixes (like the ones what these patches were
about) but unfortunately they had implemented broken signal behaviour
for shellscript containing interactive programs. Similar issues apply
to pdksh which is OpenBSD's sh.
From my perspective bash2 is the only really working bourne sh out
there and that one is GPLed. Oh well.
Ruslan Ermilov [Wed, 28 Jan 2004 10:15:47 +0000 (10:15 +0000)]
Put slattach(8), camcontrol(8), usbd(8), and usbdevs(8) onto the
MFS root file system now that these architectures always use the
GENERIC kernel for installs.
Ruslan Ermilov [Wed, 28 Jan 2004 09:19:16 +0000 (09:19 +0000)]
Revert revision 1.833 -- the reinstallkernel.debug target calls the
installkernel.debug target (in the kernel build directory) which is
only defined if the kernel was configured for debugging which it is
not the case for GENERIC kernels on release branches.
Don Lewis [Wed, 28 Jan 2004 08:02:15 +0000 (08:02 +0000)]
Change KASSERT() in feed_vchan16() into an explicit test and call to
panic() so that the buffer overflow just beyond this point is always
caught, even when the code is not compiled with INVARIANTS.
Change chn_setblocksize() buffer reallocation code to attempt to avoid
the feed_vchan16() buffer overflow by attempting to always keep the
bufsoft buffer at least as large as the bufhard buffer.
Print a diagnositic message
Danger! %s bufsoft size increasing from %d to %d after CHANNEL_SETBLOCKSIZE()
if our best attempts fail. If feed_vchan16() were to be called by
the interrupt handler while locks are dropped in chn_setblocksize()
to increase the size bufsoft to match the size of bufhard, the panic()
code in feed_vchan16() will be triggered. If the diagnostic message
is printed, it is a warning that a panic is possible if the system
were to see events in an "unlucky" order.
Change the locking code to avoid the need for MTX_RECURSIVE mutexes.
Add the MTX_DUPOK option to the channel mutexes and change the locking
sequence to always lock the parent channel before its children to avoid
the possibility of deadlock.
Actually implement locking assertions for the channel mutexes and fix
the problems found by the resulting assertion violations.
Clean up the locking code in dsp_ioctl().
Allocate the channel buffers using the malloc() M_WAITOK option instead
of M_NOWAIT so that buffer allocation won't fail. Drop locks across
the malloc() calls.
Add/modify KASSERTS() in attempt to detect problems early.
Abuse layering by adding a pointer to the snd_dbuf structure that points
back to the pcm_channel that owns it. This allows sndbuf_resize() to do
proper locking without having to change the its API, which is used by
the hardware drivers.
Don't dereference a NULL pointer when setting hw.snd.maxautovchans
if a hardware driver is not loaded. Noticed by Ryan Sommers
<ryans at gamersimpact.com>.
Tested by: Stefan Ehmann <shoesoft AT gmx.net>
Tested by: matk (Mathew Kanner)
Tested by: Gordon Bergling <gbergling AT 0xfce3.net>
Nate Lawson [Wed, 28 Jan 2004 06:51:18 +0000 (06:51 +0000)]
If not in the debugger or if the user requests it with the
debug.ddb_use_printf sysctl, output kernel debugger data to both the
console and kernel message buffer via printf. This fixes the case where
backtrace() went directly to the console and should help debugging greatly.
Thanks to Ian Dowse for the work, minor edits or any bugs are by myself.
Alexander Kabaev [Wed, 28 Jan 2004 06:06:04 +0000 (06:06 +0000)]
Move the part of the comment which applies to osigsuspend where
it belongs. The current sigsuspend syscall does expect a pointer
to the mask as argument.
Submitted by: Igor Sysoev <is at rambler-co dot ru>
Tim J. Robbins [Wed, 28 Jan 2004 05:55:13 +0000 (05:55 +0000)]
Merge from NetBSD rev. 1.2 (drochner): Do the address calculations inside
the data delivered by SIOCGIFCONF correctly (this isn't a plain array!),
and sort the checks a bit to avoid duplicates in the interface list.
Marcel Moolenaar [Wed, 28 Jan 2004 03:38:25 +0000 (03:38 +0000)]
Fix an uninitialized variable bug that caused write_pmbr() to bogusly
return an error value that made Write_Disk() abort. While on the
subject, improve the initialization of the error variable in read_gpt()
and update_gpt() even though nothing was broken there.
Greg Lehey [Wed, 28 Jan 2004 00:02:10 +0000 (00:02 +0000)]
Remove trailing white space.
Sort SEE ALSO by section number first, not alphabetically.
Remove period at end SEE ALSO to make it look less like a sentence.
Ruslan Ermilov [Tue, 27 Jan 2004 23:22:15 +0000 (23:22 +0000)]
Fixed bogus ${FOO:Mbar} tests where the actual intent is to check
if the result set is empty. While here, replaced non-bogus empty
string comparisons with equivalent empty() checks.
Ruslan Ermilov [Tue, 27 Jan 2004 20:25:14 +0000 (20:25 +0000)]
- Added three new interfaces, NgAllocRecvMsg(), NgAllocRecvAsciiMsg(),
and NgAllocRecvData(), that dynamically allocate buffer for a binary
message, an ascii message, and a data packet, respectively. The size
of the allocated buffer is equal to the socket's receive buffer size
to guarantee that a message or a data packet is not truncated.
- Get rid of the static size buffer in NgSendAsciiMsg().
Robert Watson [Tue, 27 Jan 2004 20:21:07 +0000 (20:21 +0000)]
Allow the use of a stale p_stops value in STOPEVENT(), grabbing
the proc lock only if we actually need to perform a stop. This
avoids two locks and unlocks of the process lock each system call,
and wins me about 20% on a simply system call test (getuid(),
which would otherwise require no locking). This also has a net
improvement of about 10MB/s on some of the SMP bandwidth tests
I'm running.
Brooks Davis [Tue, 27 Jan 2004 19:35:05 +0000 (19:35 +0000)]
Cleanup malloc() use in if_attach():
- malloc() returns a void* and does not need a cast
- when called with M_WAITOK, malloc() can not return NULL so don't
check for that case. The result of the check was bogus anyway since
it would leave the interface broken.
Colin Percival [Tue, 27 Jan 2004 17:50:47 +0000 (17:50 +0000)]
Back out part of 1.21, since it breaks `script interactive-program`. This
re-breaks non-interactive portupgrade (or at least old versions of
portupgrade); I'll see if I can put together a solution which avoids
breaking anything later.
Approved by: rwatson (mentor)
Noticed by: Stefan Farfeleder, Joshua Goodall
Rename the kern.vm.kmem.size tunable to the more logical vm.kmem_size. To
assure backward compatibility (conditional on !BURN_BRIDGES), look it up
by its old name first, and log a warning (but accept the setting) if it
was found. If both the old and new name are defined, the new name takes
precedence.
Also export vm.kmem_size as a read-only sysctl variable; I find it hard to
tune a parameter when I don't know its default value, especially when that
default value is computed at boot time.
While USB keyboards attach as ukbd[0-9]+, the device node created by
kbd_attach() is called kbd[0-9]+, with a different unit number. This
makes it impossible to write a devd rule which will automatically
switch to a USB keyboard when one is attached, because there is no way
to guess the correct device node to pass to kbdcontrol.
Therefore, change kbd_attach() to create a device node using the
keyboard device's real name (atkbd0, ukbd0...), and create the
kbd[0-9]+ node as an alias for backward compatibility.