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.
Hartmut Brandt [Tue, 27 Jan 2004 10:45:37 +0000 (10:45 +0000)]
Style: add __FBSDID, relocate some { that were on the wrong line,
correct some indendation, change __FUNCTION__ to __func__ and remove
a local KASSERT definition.
Bill Paul [Tue, 27 Jan 2004 09:08:12 +0000 (09:08 +0000)]
This should have been checked in as part of the last update to if_ndis.c:
add yet another member to the ndis_softc as part of the workaround for
the net80211 dain bramage.
Bill Paul [Tue, 27 Jan 2004 09:05:52 +0000 (09:05 +0000)]
Some Windows .INF files are deliberately sabotaged to prevent them from
loading on a particular version of Windows. For example, a .INF file
for a Windows 2000 driver may have an empty [foo.NT.5.1] section which
will be ingored on Win2K (whose .INF parser won't look for sections
decorated with .NT.5.1) in favor of a [foo] section. Likewise, a
WinXP file will have an empty [foo] section which will be ignored in
favor of [foo.NT.5.1].
The problem is, we can handle both Win2K and WinXP drivers, and we
don't want to exclude either one.
As a workaround, we try to pretend we are WinXP by default and search
for sections decorated with .NT.5.1, but if we don't turn up any records,
we assume that maybe we're being fooled by a sabotaged .INF file and
make one more pass looking for undecorated sections instead.
This allows us to parse the .INF files for both the Win2K and the WinXP
Centrino wireless drivers.
I'd give anything for 5 minutes alone in a room with whoever wrote
Microsoft's .INF file parser. Just 5 minutes. That's all.
Bill Paul [Tue, 27 Jan 2004 07:57:42 +0000 (07:57 +0000)]
Add a kludge to avoid having ndis_init() called needlessly by dhclient
on an SIOCSIFADDR (by way of brain damage in net80211).
Also, avoid trying to set NDIS_80211_AUTHMODE_AUTO since the Microsoft
documentation I have recommends not using it, and the Centrino driver
seems to dislike being told to use it.
Nate Lawson [Tue, 27 Jan 2004 06:04:15 +0000 (06:04 +0000)]
Document my adventures in newbus land. Clarify some examples, especially
that count is in bytes, not bits. There are some drivers that I think make
this mistake. (I've seen counts of 16 in the tree).
Robert Watson [Tue, 27 Jan 2004 04:40:19 +0000 (04:40 +0000)]
Stick two XXX's in the syscall() code: we call STOPEVENT() twice for
every system call, and that grabs and release the process lock each
time. Don't fix it (yet), but document it so we know to fix it.
Also should be a 5.3-RELEASE todo item.
Brooks Davis [Tue, 27 Jan 2004 03:15:09 +0000 (03:15 +0000)]
Clean up macro usage in if_attach():
- Use the system offsetof macro rather then making out own.
- undef ROUND after we use it rather then polluting the whole file.
Brooks Davis [Tue, 27 Jan 2004 01:43:14 +0000 (01:43 +0000)]
Use IFNAMSIZ instead of a magic value for the length of an interface
name.
Prevent the kernel from potentially overflowing the interface name
variable. The size argument of strlcpy is complex because the name is
not null-terminated in sdl_data.
Bill Paul [Mon, 26 Jan 2004 21:21:53 +0000 (21:21 +0000)]
Reorganize the timer code a little and implement NdisInitializeTimer()
and NdisCancelTimer(). NdisInitializeTimer() doesn't accept an NDIS
miniport context argument, so we have to derive it from the timer
function context (which is supposed to be the adapter private context).
NdisCancelTimer is now an alias for NdisMCancelTimer().
Also add stubs for NdisMRegisterDevice() and NdisMDeregisterDevice().
These are no-ops for now, but will likely get fleshed in once I start
working on the Am1771/Am1772 wireless driver.
John Baldwin [Mon, 26 Jan 2004 19:58:38 +0000 (19:58 +0000)]
Overhaul our boot floppy generation system so that it scales better and
requires minimal care and feeding for future releases.
- Consolidate multitude of floppy related constants down to a normal
FLOPPY set for 1.44 floppies and on PC98 a SMALLFLOPPY set for 1.2
floppies. Also, cleanup the i386 arch section by not duplicating
constants that are the same on both machine types (i386 and pc98).
- Update the ZIPNSPLIT macro to generate a file chunks that will actually
fit onto 1.44 floppies formatted with UFS1. Unfortunately, split(1)
seems to be somewhat buggy, so the files generated are slightly larger
than the argument passed to split.
- Split the release.10 target into 3 targers: floppies.1, floppies.2 and
floppies.3 that are added to EXTRAS only if NOFLOPPIES is defined.
floppies.1 builds the install floppies, floppies.2 builds the fixit
floppy, and floppies.3 generates the md5 sums and READMEs for the
floppies/ directory.
- Drop the by now largely obsolete and less useful boot.flp picture. This
was more useful when the mfsroot lived inside the kernel rather than
being loaded from a separate file by the loader.
- Only build a single mfsroot containing no modules that is used for all
installation methods.
- Use split-file.sh to split up a gzipped GENERIC kernel into however many
floppies it takes for the boot kernel. Currently, a stock 5.2 GENERIC
kernel including WITNESS, INVARIANTS, DDB, and other assorted bloat fits
onto 2 additional floppies besides the boot floppy with some room to
spare.
- If SPLIT_MFSROOT is defined, the mfsroot.gz file is similar split into
however many floppies are needed. Currently it is not defined as the
mfsroot.gz fits onto the current boot.flp with room to spare.
- Add a 'makeFloppySet' target which builds a floppy set for a file that
was split using split-file.sh.
- Rename the doMFSKERN target to 'buildBootFloppy' as that more closely
matches what it does now. We no longer build a custom BOOTMFS kernel for
each boot floppy.
- We no longer build a 2.88 boot.flp image to use with emulated CD booting.
The non-emulated cdboot works for almost everyone who boots off of CD and
if it doesn't work on a particular machine, the user can always boot from
the 1.44 floppy images.
- We no longer build a driver floppy or stick kernel modules in the mfsroot
since we now use a stock kernel when booting from floppy.
John Baldwin [Mon, 26 Jan 2004 19:45:09 +0000 (19:45 +0000)]
Add a script to split a single file up into chunks using split along with
a list file suitable for use with libstand's splitfs filesystem. The first
chunk of the file is 16k and has an extension of '.boot' and is meant to be
placed on the boot floppy. This is required because the current
implementations of gzipfs and bzipfs in libstand want to read in the header
of the file each time it is opened.
David E. O'Brien [Mon, 26 Jan 2004 19:40:47 +0000 (19:40 +0000)]
The problem Makefile rev 1.70 and fbsd-kgdb-i386.h rev 1.4 fixed is that
GDB was using the instruction pointer for 'calltrap', rather than the
infinitely more useful instruction pointer where the trap occurred.
Submitted by: Peter Edwards <pmedwards@eircom.net>
John Baldwin [Mon, 26 Jan 2004 19:34:24 +0000 (19:34 +0000)]
- Call acpi_Startup() before parsing interrupt-related APIC resources so we
can look at the ACPI tables. If the startup fails, we panic and tell the
user to try rebooting with ACPI disabled. Previously in this case we
would try to use $PIR interrupt routing which only works for the atpic
while using the apic to handle interrupts which would result in misrouted
interrupts and a hang at boot time with no error message.
- Read the SCI out of the FADT instead of hardcoding 9 when checking to see
if an interrupt override entry is for the SCI.
- Try to work around some BIOS brain damage for the SCI's programming by
forcing the SCI to be level triggered and active low if it is routed
to a non-ISA interrupt (greater than 15) or if it is identity mapped with
edge trigger and active high polarity. This should fix some of the hangs
with device apic and ACPI that some people see.
John Baldwin [Mon, 26 Jan 2004 19:29:04 +0000 (19:29 +0000)]
Move the code to initialize ACPI-CA into a separate acpi_Startup() function
that other modules can call to initialize ACPI-CA before the new-bus probe
and change acpi_identify() to call it.