dragonfly.git
13 years agosh: Detect dividing the smallest integer by -1.
Peter Avalos [Sun, 13 Feb 2011 01:47:27 +0000 (15:47 -1000)]
sh: Detect dividing the smallest integer by -1.

Obtained-from: FreeBSD

13 years agokernel - Make most of the fork and exit paths MPSAFE
Matthew Dillon [Sat, 12 Feb 2011 22:20:09 +0000 (14:20 -0800)]
kernel - Make most of the fork and exit paths MPSAFE

* Remove the MP lock from numerous system calls (mainly socket calls) that
  no longer need it.

* Use proc_token in a couple of places that still need work (instead of
  the MP lock).  For example, the process group (pgrp) and several places
  which call pfind() still need to use the proc_token.

* Use the per-process p->p_token in fork1(), exit1(), and lwp_exit().
  The critical portions of these paths now have significant concurrency.

* Use the per-process p->p_token when traversing p->p_children, primarily
  aiding the kern_wait() code.  So the wait*() system calls should now
  have significant concurrency.

* Change the fgetown() API to avoid certain races.

* Add M_ZERO to the struct filedesc_to_leader allocation for safety
  purposes.

13 years agokernel - Fix list corruption in dsched
Matthew Dillon [Sat, 12 Feb 2011 22:17:01 +0000 (14:17 -0800)]
kernel - Fix list corruption in dsched

* dsched_thread_io_alloc() also needs to hold a context lock when
  doing an internal list operation.

13 years agokernel - Fix list corruption in dsched
Matthew Dillon [Sat, 12 Feb 2011 21:30:16 +0000 (13:30 -0800)]
kernel - Fix list corruption in dsched

* dsched_thread_ctx_alloc() was not acquiring the global lock across
  calls to dsched_thread_io_alloc(), creating a race condition in the
  call to TAILQ_INSERT_TAIL(&tdio->diskctx->tdio_list, ...).

  This case can occur under heavy fork/exit loads, particularly when
  (soon) fork and exit get out from the MP lock, but even with the MP
  lock on the frontend it can occur against the dsched backend.

* dsched_new_policy_thread_tdio() was not acquiring the global lock
  across its initial call to dsched_thread_io_alloc().  This case could
  only occur with extreme rarity.

13 years agokernel - Fix wild pointer in DDB trace
Matthew Dillon [Sat, 12 Feb 2011 20:59:19 +0000 (12:59 -0800)]
kernel - Fix wild pointer in DDB trace

* Pre-initialize result fields to NULL/0 because we do not check the return
  value from linker_ddb_symbol_values().  This way if the lookup fails we
  print a nice "(null)" out instead of faulting the debugger.

13 years agokernel - Add per-process token, adjust signal code to use it (2).
Matthew Dillon [Sat, 12 Feb 2011 16:46:18 +0000 (08:46 -0800)]
kernel - Add per-process token, adjust signal code to use it (2).

* In order to avoid a hard-code-section assertion from hardclock()'s
  itimer code the per-process token must be held on the call to ksignal().

13 years agox86_64: pmap_init() is called early enough for pmap_mapdev() to work
Sepherosa Ziehau [Sat, 12 Feb 2011 09:09:14 +0000 (17:09 +0800)]
x86_64: pmap_init() is called early enough for pmap_mapdev() to work

13 years agomadt: Structure renaming
Sepherosa Ziehau [Sat, 12 Feb 2011 08:40:43 +0000 (16:40 +0800)]
madt: Structure renaming

13 years agomadt: Support MADT rev 3 (used by ACPI 4.0)
Sepherosa Ziehau [Sat, 12 Feb 2011 07:27:52 +0000 (15:27 +0800)]
madt: Support MADT rev 3 (used by ACPI 4.0)

13 years agomadt: Function renaming
Sepherosa Ziehau [Sat, 12 Feb 2011 07:38:02 +0000 (15:38 +0800)]
madt: Function renaming

Prepare for the upcoming I/O APIC stuffs

13 years agoAdd regression tests for /bin/sh.
Peter Avalos [Sat, 12 Feb 2011 07:27:25 +0000 (21:27 -1000)]
Add regression tests for /bin/sh.

Obtained-from: FreeBSD

13 years agoacpi: Remove unused files
Sepherosa Ziehau [Sat, 12 Feb 2011 07:12:11 +0000 (15:12 +0800)]
acpi: Remove unused files

13 years agosh: Sync with FreeBSD
Peter Avalos [Mon, 7 Feb 2011 08:05:28 +0000 (22:05 -1000)]
sh: Sync with FreeBSD

This is a combination of 198 commits that enhances performance,
standards compliance, and bug fixes:

-Fix exit status of case statement.
-sh.1: Update markup.
-Fix PWD values.
-Fix null pointer dereferences.
-Fix bugs where arithmetic expansion$((...)) was truncated
-Pass the correct flags to expandarg() for NFROMFD and NTOFD.
-Add __dead2
-Fix $? at the first command of a function.
-Report error messages to stderr instead of stdout.
-Make alias builtin POSIX compliant.
-Improve the IFS handling of the read built-in.
-Don't let empty lines overwrite the result of the last command with 0.
-Fix the eval command in combination with set -e.
-Make read's timeout (-t) apply to the entire line.
-align local ckmalloc() with malloc(3) by using a size_t
-style(9) to enhance readability
-explicit 'unsigned int' instead of just 'unsigned'
-Mention the range for the exit status for the exit builtin
-Don't skip forking for an external command if any traps are active.
-Avoid leaving unnecessary waiting shells.
-Properly flush input after an error in backquotes
-Fix some issues with quoted output
-Fix race condition in noclobber option
-Improve handling of setjmp/longjmp volatile
-Do not fork for EV_EXIT.
-Quote -x tracing output so it is unambiguous.
-Designate special builtins as such in command -V and type.
-Fix crash when undefining or redefining an executing function.
-Fix memory leak when using a variable in arithmetic like $((x)).
-Use sigaction instead of signal/siginterrupt combination.
-Allow a newline before "in" in a for command, as required by POSIX.
-Some changes to stderr flushing.
-Handle current work directories of arbitrary length.
-trap: do not consider a bad signal name a fatal error.
-Ensure the same command input file is on top after execing builtin.
-Fix various things about SIGINT handling.
-Fix some cases where file descriptors from redirections leak to programs.
-Remove setting variables from dotcmd/exportcmd.
-Fix a memory leak when calling . with variable assignments.
-Constify various strings.
-Do not consider a tilde-prefix with expansions in it.
-Do not run callers' exception handlers in subshells.
-Remove declaration of function that no longer exists.
-WARNS fixes to reduce diffs to FreeBSD
-arith: Return only 0 and 1 from && and ||.
-Fix memory leak when parsing backticks (``).
-Ensure funcnest is decremented if there's an error in the function.
-Allow command -pv and command -pV
-Fix some bugs with backquoted builtins.
-Send the "not found" message for builtin <cmd> to redirected fd 2.
-Do not stat() $MAIL/$MAILPATH in non-interactive shells.
-Fix expansion of \W in prompt strings when the working directory is "/".
-Improve the command builtin:
-Make sure to popredir() even if a special builtin caused an error.
-Make sure to popredir() even if a function caused an error.
-Make parsebackq a function instead of an emulated nested function.
-Do not abort on a redirection error if there is no command word.
-Do not abort on a redirection error on a compound command.
-Treat unexpected newlines in substitutions as a syntax error.
-Fix various things about expansions.
-Remove special handling for ' and " in arithmetic.
-Allow quoting pattern match characters in ${v%pat} and ${v#pat}.
-Do tilde expansion in substitutions.
-Automatically enable -o emacs in interactive shells with terminals.
-On startup of the shell, use PWD from the environment if it is valid.
-Use stalloc for arith variable names.
-Apply locale vars on builtins, recognize LC_MESSAGES as a locale var.
-Have only one copy of _PATH_STDPATH in the binary.
-Fix "reserved word" vs "keyword" inconsistency.
-Fix pathname expansion with quoted slashes like *\/.
-Reap any zombies before forking for a background command.
-Rework documentation of shell variables.
-Recognize "--" in . and exec.
-Change interaction of command substitution and here documents.
-Fix a crash if a heredoc was not properly ended and parsing continued.
-Pass TERM changes to libedit.
-Pass through SIGINT from a child if interactive and job control is enabled.
-Forget about terminated background processes sooner.
-Use $PWD instead of getcwd() for the \w and \W prompt expansions.
-Allow a background command consisting solely of redirections.
-Fix crash due to uninitialized here-document.
-Return 0 from eval if no command was given.
-Remove unnecessary duplicate letters in mksyntax.c
-Fix heap-based buffer overflow in pathname generation.
-Fix shadowing of sigset.
-Fix break/continue/return sometimes not skipping the rest of dot script.
-Add a brief summary of arithmetic expressions.
-Remove remnants of '!!' to negate pattern.
-Do not use locale for determining if something is a name.
-Get rid of some magic numbers.
-Improve comments in expand.c.
-Fix 'read' if all chars before the first IFS char are backslash-escaped.
-Remove xrefs for expr(1) and getopt(1).
-Apply variable assignments left-to-right in bltinlookup().
-Fix exit status if return is used within a loop condition.
-Suggest that DEBUG_FLAGS be used to enable extra debugging
-Make DEBUG traces 64-bit clean.
-Remove the "STATIC" macro
-Fix a bug in STACKSTRNUL()
-Clarify subshells/processes for pipelines.
-There cannot be a TNOT in simplecmd(), remove checks.
-Change ! within a pipeline to start a new pipeline instead.
-Check whether dup2 was successful for >&FD and <&FD.
-Make sure defined functions can actually be called.
-Do not allow overriding a special builtin with a function.
-Ignore double-quotes in arithmetic rather than treating them as quotes.
-Make double-quotes quote a '}' inside ${v#...} and ${v%...}.
-Only accept a '}' inside ${v+-=?...} if double-quote state matches.
-Do IFS splitting on word in ${v+word} and ${v-word}.
-Fix some issues with CTL* bytes and ${var#pat}.
-Error out on various specials/keywords in the wrong place in backticks.
-Detect various additional errors in the parser.
-Reject function names ending in one of !%*+-=?@}~
-Tweak some string constants to reduce code size.
-Use iteration instead of recursion to evaluate semicolon lists.
-Reindent evaltree().
-Correct synopsis and make precise how $0 is set.
-Fix some issues with aliases and case, by importing dash checkkwd code.
-Modernize the introduction a bit.
-Remove unused man page for echo builtin.
-Do the additional actions if 'local -' restore changes -i/-m/-E/-V.
-Add binary buffered output for use by the printf builtin.
-document printf builtin
-Code size optimizations to buffered output.
-Remove the check that alpha/name/in_name chars are not CTL* bytes.
-Fix confusing behaviour if chdir succeeded but getcwd failed in cd -P.
-Code size optimizations to "stack string" memory allocation
-jobs -p: Do not ask the kernel for the pgid.
-Improve jobs output of pipelines.
-POSIX says there should not be a space between Done and (exitstatus).
-Improve internal-representation-to-text code to avoid binary output.
-Use vsnprintf() rather than crafting our own in fmtstr().
-Replace some macros and repeated code in expand.c with functions.
-Remove the herefd hack.
-Various simplifications to jobs.c
-Remove duplicate check, turning dead code into live code.
-Fix corruption of command substitutions with special chars after newline
-Remove dead code.
-arith: Disallow decimal constants starting with 0 (containing 8 or 9).
-Make warnings in the printf builtin non-fatal.
-Add a function to print warnings (with command name and newline).
-Add kill builtin.
-Explain why it is a bad idea to use aliases in scripts.
-Allow arbitrary large numbers in CHECKSTRSPACE.
-Make expansion errors in optimized command substitution non-fatal.
-Don't do optimized command substitution if expansions have side effects.
-Properly restore exception handler in fc.
-Avoid side effects from builtins in optimized command substitution.
-Check if dup2 for redirection from/to a file succeeds.
-Check readonly status for assignments on regular builtins.
-Do not call exitshell() from evalcommand() unless evalcommand() forked itself
-Make exit without parameters from EXIT trap POSIX-compliant.
-Remove special %builtin PATH entry.
-Make 'trap -l' look like 'kill -l'.
-Fix some things about -- in trap.
-If exit is used without args from a trap action, exit on the signal.
-Fix signal messages being sent to the wrong file sometimes.
-Send messages about signals to stderr.
-Return only 126 or 127 for execve() failures.
-Make sys_signame upper case.
-Remove special code for shell scripts without magic number.
-Do not try to execute binary files as scripts.
-Forget all cached command locations on any PATH change.
-Fix two things about {(...)} <redir.
-Import arithmetic expression code from dash.
-Install /bin/sh safely.

Obtained-from: FreeBSD

13 years agox86_64: Function renaming lapic_init -> lapic_map
Sepherosa Ziehau [Sat, 12 Feb 2011 07:05:17 +0000 (15:05 +0800)]
x86_64: Function renaming lapic_init -> lapic_map

Keep the function name as close to i386's as possible

13 years agomadt: Prepare to extract I/O APIC information from MADT
Sepherosa Ziehau [Sat, 12 Feb 2011 06:22:09 +0000 (14:22 +0800)]
madt: Prepare to extract I/O APIC information from MADT

- Run madt_probe() at BOOT2_PRESMP/ORDER_FIRST.
- Save MADT's physical address in global variable.
- Move preliminary LAPIC checks from MADT probing to MADT LAPIC
  enumerator's probing function.

13 years agomadt: Function renaming
Sepherosa Ziehau [Sat, 12 Feb 2011 02:52:10 +0000 (10:52 +0800)]
madt: Function renaming

13 years agokernel - Add per-process token, adjust signal code to use it.
Matthew Dillon [Fri, 11 Feb 2011 22:47:58 +0000 (14:47 -0800)]
kernel - Add per-process token, adjust signal code to use it.

* Add proc->p_token and use it to interlock signal-related operations.

* Remove the use of proc_token in various signal paths.  Note that proc_token
  is still used in conjuction with pfind().

* Remove the use of proc_token in CURSIG*()/issignal() sequences, which
  also removes its use in the tsleep path and the syscall path.  p->p_token
  is use instead.

* Move the automatic interlock in the tsleep code to before the CURSIG code,
  fixing a rare race where a SIGCHLD could race against a parent process
  in sigsuspend().  Also acquire p->p_token here to interlock LWP_SINTR
  handling.

13 years agoHAMMER Utility - Change the minimum UNDO/REDO FIFO from 100M to 500M
Matthew Dillon [Thu, 10 Feb 2011 22:32:25 +0000 (14:32 -0800)]
HAMMER Utility - Change the minimum UNDO/REDO FIFO from 100M to 500M

* The minimum undo/redo fifo really needs to be larger.  Don't play
  around, make it 500M.  People who want to run HAMMER on small hard
  drives or images need to be cognizent of the requirement.

* This partially solves (only partially) a FIFO overflow condition.
  Effectively the complexity of buffered operations hammer allows to
  build up in the kernel could easily overflow a minimally-sized on-media
  UNDO/REDO FIFO.  Upping the requirement makes the case less likely.

  The remainder of the resolution will require some fixes in the
  HAMMER VFS code.

Reported-by: Thomas Nikolajsen <thomas.nikolajsen@mail.dk>
13 years agoMerge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
Matthew Dillon [Thu, 10 Feb 2011 21:22:51 +0000 (13:22 -0800)]
Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly

13 years agokernel - Greatly reduce usched_bsd4_decay default
Matthew Dillon [Thu, 10 Feb 2011 21:15:51 +0000 (13:15 -0800)]
kernel - Greatly reduce usched_bsd4_decay default

* Reduce the usched_bsd4_decay default to 1.  It may be removed entirely
  in the future.

* This improves the dynamic priority handling by reducing ad-hoc estcpu
  decreases from the 1-second interval clock.  The tsleep code handles
  this a lot better already and the ad-hoc decreases don't do a good job
  handling the case where there are a very large number of runnable
  cpu-bound processes (because they don't actually get a lot of cpu but
  still eat a large proportion of the scheduled time in aggregate).

  Tested with blogbench during stage 1.  Prior to this fix the 100+ blogbench
  threads were being dropped down to almost realtime priorities even though
  they remained in a 100% 'R'un state.

* Also reduce the amount the parent process of a fork() is docked for cpu
  due to the fork.  The value was high enough that interactive sessions were
  being pushed up to batch priorities with only a moderate number of forks
  and not decaying quickly enough to stabilize.

  The child process is docked the same as before (handling the fork chaining
  case).

  Tested with blogbench and parallel makes of /usr/src/lib/libc.  The
  blogbench uniformly increases to batch priority and didn't need the
  higher boost the old values gave it while the parallel compile's fork
  chaining gave it a good shove towards batch priority while the repeated
  forks slowly pushed the higher level make and /bin/sh's to more batch-like
  priorities.

13 years agohammer.8: Note that 'recover' needs -f.
Sascha Wildner [Thu, 10 Feb 2011 11:37:10 +0000 (12:37 +0100)]
hammer.8: Note that 'recover' needs -f.

13 years agoacpi(4): Fix a bug in acpi_cpu_cstate.c (we have to write, and not to read).
Sascha Wildner [Wed, 9 Feb 2011 16:25:06 +0000 (17:25 +0100)]
acpi(4): Fix a bug in acpi_cpu_cstate.c (we have to write, and not to read).

Introduced with 10f976749fd9ad2e8642ea80ce533f7416910a65. The commit message
said "Sync ACPI with FreeBSD 7.2", even though FreeBSD 7.2 doesn't seem to
have this code at all, so I'm not sure about what the idea behind that
change was. I'm guessing it is a typo, since newer FreeBSDs call
AcpiWriteBitRegister() here too.

Reported-by: Andrea Magliano <masterblaster@tiscali.it>
13 years agoacpi/madt: Add definitation for interrupt source override MADT entry
Sepherosa Ziehau [Wed, 9 Feb 2011 14:42:33 +0000 (22:42 +0800)]
acpi/madt: Add definitation for interrupt source override MADT entry

13 years agoUpgrade to OpenSSL-1.0.0d.
Peter Avalos [Wed, 9 Feb 2011 05:13:12 +0000 (19:13 -1000)]
Upgrade to OpenSSL-1.0.0d.

This fixes CVE-2011-0014.

13 years agoMerge branch 'vendor/OPENSSL'
Peter Avalos [Wed, 9 Feb 2011 05:02:56 +0000 (19:02 -1000)]
Merge branch 'vendor/OPENSSL'

13 years agoImport OpenSSL-1.0.0d.
Peter Avalos [Wed, 9 Feb 2011 04:59:57 +0000 (18:59 -1000)]
Import OpenSSL-1.0.0d.

13 years agoBump .Dd in pkg_radd.1 manpage and make pkg_search working again.
Sascha Wildner [Tue, 8 Feb 2011 14:04:33 +0000 (15:04 +0100)]
Bump .Dd in pkg_radd.1 manpage and make pkg_search working again.

13 years agoDon't remove /etc/settings.conf via 'make upgrade' and rename it instead.
Sascha Wildner [Tue, 8 Feb 2011 13:59:53 +0000 (14:59 +0100)]
Don't remove /etc/settings.conf via 'make upgrade' and rename it instead.

13 years agoSync zoneinfo database with tzdata2011b from elsie.nci.nih.gov
Sascha Wildner [Mon, 7 Feb 2011 19:06:33 +0000 (20:06 +0100)]
Sync zoneinfo database with tzdata2011b from elsie.nci.nih.gov

northamerica:   8.39 -> 8.40
zone.tab:       8.38 -> 8.40

* northamerica: Add America/North_Dakota/Beulah (Mercer County,
    North Dakota, moved from Mountain to Central time at the
    end of DST in 2010). Also, use the actual version number
    rather than "%W%".

* zone.tab: Add America/North_Dakota/Beulah. Also, update
    Indonesian location names (with the old names retained in
    parentheses).

13 years agoRemove useless belt and suspenders include guards in some of our headers.
Sascha Wildner [Mon, 7 Feb 2011 15:42:58 +0000 (16:42 +0100)]
Remove useless belt and suspenders include guards in some of our headers.

For these headers:

/usr/include/machine/atomic.h
/usr/include/machine/bus_dma.h
/usr/include/machine/coredump.h
/usr/include/machine/cpufunc.h
/usr/include/machine/db_machdep.h
/usr/include/machine/elf.h
/usr/include/machine/endian.h
/usr/include/machine/frame.h
/usr/include/machine/limits.h
/usr/include/machine/npx.h
/usr/include/machine/profile.h
/usr/include/machine/segments.h
/usr/include/machine/stdarg.h
/usr/include/machine/stdint.h
/usr/include/machine/trap.h
/usr/include/machine/tss.h
/usr/include/machine/ucontext.h
/usr/include/machine/vframe.h
/usr/include/machine/vm86.h

All these headers #define _CPU_... and not _MACHINE_... even though they
are in /usr/include/machine. And the headers themselves have include
guards already. So there's little point in having them around the actual
#include additionally.

13 years agocat: Clean up whitespace.
Peter Avalos [Sun, 6 Feb 2011 00:22:40 +0000 (14:22 -1000)]
cat: Clean up whitespace.

13 years agoUpdating pkg_radd man page, pkg_search to reflect new config file.
Justin C. Sherrill [Mon, 7 Feb 2011 01:19:57 +0000 (17:19 -0800)]
Updating pkg_radd man page, pkg_search to reflect new config file.

13 years agoMerge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
Justin C. Sherrill [Mon, 7 Feb 2011 00:44:26 +0000 (16:44 -0800)]
Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly

Conflicts:
UPDATING

13 years agoMove pkg_radd config to a more obvious name; make sure settings.conf gets
Justin C. Sherrill [Mon, 7 Feb 2011 00:36:29 +0000 (16:36 -0800)]
Move pkg_radd config to a more obvious name; make sure settings.conf gets
cleaned out on upgrade, and stick a warning in UPGRADING so nobody
(hopefully) gets surprised when pkg_radd starts downloading from
mirror-master again.

13 years agowmake.1: Describe how to install stuff built with wmake.
Sascha Wildner [Mon, 7 Feb 2011 00:07:18 +0000 (01:07 +0100)]
wmake.1: Describe how to install stuff built with wmake.

Pointed-out-by: corecode
13 years agosecure/lib: Fix building of some cases that include lib/Makefile.inc.
Sascha Wildner [Sun, 6 Feb 2011 21:55:11 +0000 (22:55 +0100)]
secure/lib: Fix building of some cases that include lib/Makefile.inc.

13 years agolib: Move the definition of WARNS into lib/Makefile.inc.
Sascha Wildner [Sun, 6 Feb 2011 21:09:01 +0000 (22:09 +0100)]
lib: Move the definition of WARNS into lib/Makefile.inc.

13 years agolibncp: Fix format.
Sascha Wildner [Sun, 6 Feb 2011 21:06:59 +0000 (22:06 +0100)]
libncp: Fix format.

13 years agolibc/csu: Include <machine/tls.h> for some prototypes.
Sascha Wildner [Sun, 6 Feb 2011 21:05:59 +0000 (22:05 +0100)]
libc/csu: Include <machine/tls.h> for some prototypes.

13 years agoioapic/icu: Add irqmap
Sepherosa Ziehau [Sun, 6 Feb 2011 14:06:21 +0000 (22:06 +0800)]
ioapic/icu: Add irqmap

13 years agointr: Enable ELCR by default
Sepherosa Ziehau [Sun, 6 Feb 2011 11:19:24 +0000 (19:19 +0800)]
intr: Enable ELCR by default

13 years agolibc: Raise WARNS to 6.
Sascha Wildner [Sat, 5 Feb 2011 20:44:26 +0000 (21:44 +0100)]
libc: Raise WARNS to 6.

13 years agokernel - adjust devfs mount point according to init_chroot loader variable
YONETANI Tomokazu [Wed, 2 Feb 2011 09:45:16 +0000 (18:45 +0900)]
kernel - adjust devfs mount point according to init_chroot loader variable

/dev is mounted before /sbin/init is executed, so when it chroot() itself
and execute the shell, the chroot()'ed space doesn't contain the mounted
devfs inside it and the shell gets stuck.

13 years ago<cpu/ieeefp.h>: Use single-underscore instead of double.
Peter Avalos [Sat, 5 Feb 2011 06:52:56 +0000 (20:52 -1000)]
<cpu/ieeefp.h>:  Use single-underscore instead of double.

This prevents conflicts for when someone decides to #include <fenv.h>
and <cpu/ieeefp.h>.

13 years ago<cpu/ieeefp.h>: Sync i386 with x86_64.
Peter Avalos [Sat, 5 Feb 2011 04:24:43 +0000 (18:24 -1000)]
<cpu/ieeefp.h>: Sync i386 with x86_64.

The i386 fpget*() and fpset*() functions were obfuscated, and this
change reduces complexity and makes all the fp*() functions inline.

Update comments.

Obtained-from: FreeBSD

13 years agokern - aio - Add missing flags to objcache_get()
Samuel J. Greear [Sat, 5 Feb 2011 08:25:39 +0000 (08:25 +0000)]
kern - aio - Add missing flags to objcache_get()

13 years agokern - Convert NFS from zalloc to objcache
Samuel J. Greear [Sat, 5 Feb 2011 04:17:41 +0000 (04:17 +0000)]
kern - Convert NFS from zalloc to objcache

Sponsored-By: Google Code-In
13 years agokern - Convert crypto from zalloc to objcache
Samuel J. Greear [Sat, 5 Feb 2011 04:17:15 +0000 (04:17 +0000)]
kern - Convert crypto from zalloc to objcache

Sponsored-By: Google Code-In
13 years agokern - Convert aio from zalloc to objcache
Samuel J. Greear [Sat, 5 Feb 2011 04:16:45 +0000 (04:16 +0000)]
kern - Convert aio from zalloc to objcache

Sponsored-By: Google Code-In
13 years agokern - Convert ufs dirhash from zalloc to objcache
Samuel J. Greear [Sat, 5 Feb 2011 04:15:11 +0000 (04:15 +0000)]
kern - Convert ufs dirhash from zalloc to objcache

Sponsored-By: Google Code-In
13 years agoHAMMER VFS - Fix deadlock which can occur under severe filesystem pressure
Matthew Dillon [Fri, 4 Feb 2011 19:55:02 +0000 (11:55 -0800)]
HAMMER VFS - Fix deadlock which can occur under severe filesystem pressure

* Inode reflushes (a fsync occuring while the inode is still queued for
  a prior fsync) were not ensuring that the inode got pushed to the backend
  flusher.

  This could lead to deadlocks when the process trying to issue the flush
  is the syncer itself.

* The problem typically occured under filesystem loads where a large number
  of inodes (aka due to a bulk build) are being flushed at once, and the
  flush is unable to finish running before the next syncer cycle comes
  around.

13 years agokernel - Add missing vm_page_wakeup()
Matthew Dillon [Fri, 4 Feb 2011 19:51:26 +0000 (11:51 -0800)]
kernel - Add missing vm_page_wakeup()

* Fix a long-standing issue where a VM page is improperly left PG_BUSY
  when vm_page_try_to_cache() races the Modified bit in underlying PTEs.

* This could only occur during periods of severe memory pressure and
  would typically lead to a program getting stuck in "pgtblk".

Reported-by: Peter Avalos <peter@theshell.com>
13 years agops - Adjust field widths
Matthew Dillon [Fri, 4 Feb 2011 18:38:39 +0000 (10:38 -0800)]
ps - Adjust field widths

* Reduce VSZ, RSS, RSZ by one (its still wider than the original but now
  only 6 digits).  We will have to come up with another way to represent
  process sizes >= 1GB.

* Reduce the tty column to 2 chars

13 years agops - Support unix98 ttys for -t
Matthew Dillon [Fri, 4 Feb 2011 18:37:30 +0000 (10:37 -0800)]
ps - Support unix98 ttys for -t

* Support numeric ttys, e.g. ps xt5 specifies tty /dev/pts/5

13 years agovkernel64 - Raise the memory requirements to 64MB.
Antonio Huete Jimenez [Fri, 4 Feb 2011 17:37:28 +0000 (18:37 +0100)]
vkernel64 - Raise the memory requirements to 64MB.

13 years agovkernel - Avoid appending the error message in some cases.
Antonio Huete Jimenez [Fri, 4 Feb 2011 17:16:09 +0000 (18:16 +0100)]
vkernel - Avoid appending the error message in some cases.

13 years agokern - Clarify the description of hw.physmem.
Antonio Huete Jimenez [Fri, 4 Feb 2011 16:08:07 +0000 (17:08 +0100)]
kern - Clarify the description of hw.physmem.

13 years agovm - Correct sysctl output formatting for kvm_size and kvm_free
Antonio Huete [Fri, 4 Feb 2011 11:29:05 +0000 (12:29 +0100)]
vm - Correct sysctl output formatting for kvm_size and kvm_free

13 years agokern - Properly return the number of bytes in hw.physmem sysctl.
Antonio Huete [Fri, 4 Feb 2011 13:34:05 +0000 (14:34 +0100)]
kern - Properly return the number of bytes in hw.physmem sysctl.

- Changed physmem from int to long, now it can hold a
  really high number of pages.
- Return an unsigned long value with appropiate formatting
  for hw.physmem.
- Add description for it.

Based-upon: FreeBSD

13 years agokernel - Add options VM_PAGE_DEBUG
Matthew Dillon [Fri, 4 Feb 2011 07:25:41 +0000 (23:25 -0800)]
kernel - Add options VM_PAGE_DEBUG

* Add options VM_PAGE_DEBUG for kernel configs.  This requires a full kernel
  rebuild (if you use the option) and supplies additional information in
  the vm_page structure to help track down problems.

13 years agoieeefp.h: Remove i386 specifics.
Peter Avalos [Tue, 1 Feb 2011 07:59:03 +0000 (21:59 -1000)]
ieeefp.h: Remove i386 specifics.

Move the contents of <machine/floatingpoint.h> to <machine/ieeefp.h> for
i386 to match x86_64.

While I'm here, mark which versions of these files we have for x86_64.

Obtained-from: FreeBSD

13 years agostyle(9): Remove whitespace.
Peter Avalos [Tue, 1 Feb 2011 07:17:02 +0000 (21:17 -1000)]
style(9): Remove whitespace.

13 years agofenv: Explicitly specify sizes for control and status words.
Peter Avalos [Tue, 1 Feb 2011 07:06:52 +0000 (21:06 -1000)]
fenv: Explicitly specify sizes for control and status words.

Obtained-from: FreeBSD

13 years agolibc - fix handling of temporary file used by hash(3)
YONETANI Tomokazu [Thu, 3 Feb 2011 05:29:48 +0000 (14:29 +0900)]
libc - fix handling of temporary file used by hash(3)

This fixes applications using DB_HASH, such as tsort, to unexpectedly
try to open a temporary file in the current directory and fail if it
has no write permission there.

Obtained from FreeBSD, r190485, by delphij:

  db/btree/bt_open.c: check return value of snprintf() and return value
  if the result is truncated.

  db/hash/hash_page.c: use the same way to create temporary file as
  bt_open.c; check snprintf() return value.

  Obtained from:  OpenBSD

13 years agoBuild our GCCs with CSTD=gnu89.
Sascha Wildner [Thu, 3 Feb 2011 23:20:47 +0000 (00:20 +0100)]
Build our GCCs with CSTD=gnu89.

This fixes building of the GCCs using gcc44.

Reported-by: Max Herrgard <herrgard@gmail.com> and others
Submitted-by: Max Herrgard <herrgard@gmail.com>
Dragonfly-bug: <http://bugs.dragonflybsd.org/issue1978>

13 years agokernel - Fix physmap base calculation for x86-64
Matthew Dillon [Thu, 3 Feb 2011 18:52:34 +0000 (10:52 -0800)]
kernel - Fix physmap base calculation for x86-64

Reported-by: luxh, tuxillo
13 years agokernel - migrate knote from zone to kmalloc
Nicolas Thery [Fri, 28 Jan 2011 00:55:12 +0000 (01:55 +0100)]
kernel - migrate knote from zone to kmalloc

13 years agoacpi(4): Always compile the files dealing with ACPI_DEBUG into the module.
Sascha Wildner [Wed, 2 Feb 2011 18:04:16 +0000 (19:04 +0100)]
acpi(4): Always compile the files dealing with ACPI_DEBUG into the module.

Before this commit, one had to define ACPI_DEBUG as a make variable to
enable debugging support in the module, such as in:

$ make -DACPI_DEBUG buildkernel

Specifying ACPI_DEBUG in the kernel config alone did not enable it, but
our modules are supposed to honor kernel options. Also this was contrary
to what the manual page says.

So to make this work for ACPI_DEBUG too, we just put all the affected
source files into SRCS and always compile them. #ifdef's in these
source files will take care of enabling/disabling debugging support
so a module compiled without ACPI_DEBUG defined in the kernel or on the
command line will still not have support after this commit (I've checked
with nm(1)).

The only change for someone not using ACPI_DEBUG is a little bit of
additional buildkernel time.

FWIW, it is the same way in FreeBSD, too.

Reported-by: Andrea Magliano <masterblaster@tiscali.it>
13 years agointr: Further delay MachIntrABI.finalize()
Sepherosa Ziehau [Wed, 2 Feb 2011 15:55:43 +0000 (23:55 +0800)]
intr: Further delay MachIntrABI.finalize()

It only affects SMP case.  For ICU, it will be better if finalize()
is called after IMCR detection is done, though on most modern systems
IMCR does not exist.  For I/O APIC, finalize() _should_ be called
after BSP's LAPIC is initialized, since it alters BSP LAPIC's LINT0
and LINT1 configuration.

Add stabilize() ABI to MachIntrABI which is only implemented by ICU
currently and this ABI is called in the place where finalize() used
to be called.

13 years agoioapic: File renaming (apic -> ioapic)
Sepherosa Ziehau [Wed, 2 Feb 2011 13:44:25 +0000 (21:44 +0800)]
ioapic: File renaming (apic -> ioapic)

13 years agoicu: Add icu/icu_abi.h
Sepherosa Ziehau [Wed, 2 Feb 2011 13:20:48 +0000 (21:20 +0800)]
icu: Add icu/icu_abi.h

Mainly to avoid manually declaring MachIntrABI_ICU

13 years agoioapic: Function/variable renaming (apic -> ioapic)
Sepherosa Ziehau [Wed, 2 Feb 2011 12:46:18 +0000 (20:46 +0800)]
ioapic: Function/variable renaming (apic -> ioapic)

13 years agoapic_initialize: Adjust comment
Sepherosa Ziehau [Wed, 2 Feb 2011 09:41:17 +0000 (17:41 +0800)]
apic_initialize: Adjust comment

13 years agopowerd - Do a more sophisticated domain scan, use kern.usched_global_cpumask
Matthew Dillon [Wed, 2 Feb 2011 07:59:22 +0000 (23:59 -0800)]
powerd - Do a more sophisticated domain scan, use kern.usched_global_cpumask

* Do a more sophisticated domain scan, cpu domains do not necessarily start
  at 0.

* Handle the case where multiple cpus may belong to a single domain.

* Dynamically adjust kern.usched_global_cpumask to the number of cpus we
  are running at max frequency, leaving the remaining cpus set at their
  lowest frequency and left mostly idle.

* Tested on the 48-core monster and phenom x 6.

13 years agokernel - Add kern.usched_global_cpumask
Matthew Dillon [Wed, 2 Feb 2011 07:44:07 +0000 (23:44 -0800)]
kernel - Add kern.usched_global_cpumask

* Add sysctl kern.usched_global_cpumask, a global cpumask that restricts
  which cpus userland processes are allowed to run on.  This sysctl may be
  set dynamically.

* NOTE: This sysctl is intended to be used by powerd.  Setting it manually
  will only work properly if powerd is not running.

13 years agopf: Fix typo in pf_mask_del()
Sepherosa Ziehau [Wed, 2 Feb 2011 04:26:20 +0000 (12:26 +0800)]
pf: Fix typo in pf_mask_del()

Reported-by: Jan Lentfer <Jan.Lentfer@web.de>
Noticed-by: Joe Talbott <josepht@cstone.net>
13 years agokernrl: Fix LINT building for recent rn_inithead API change
Sepherosa Ziehau [Wed, 2 Feb 2011 04:14:12 +0000 (12:14 +0800)]
kernrl: Fix LINT building for recent rn_inithead API change

Reported-by: Thomas Nikolajsen <thomas.nikolajsen@mail.dk>
13 years agops - Increase selected field widths
Matthew Dillon [Tue, 1 Feb 2011 23:57:36 +0000 (15:57 -0800)]
ps - Increase selected field widths

* Increase field widths for STAT, XSTAT, VSZ, RSS, and RSZ to accomodate
  more typical program run sizes and to accomodate systems with more than
  10 cpus.

13 years agokernel64 - Greatly reduce memory probe times, remove basemem calculation
Matthew Dillon [Tue, 1 Feb 2011 22:23:29 +0000 (14:23 -0800)]
kernel64 - Greatly reduce memory probe times, remove basemem calculation

* Greatly reduce memory probe times by testing in multiples of 128K instead
  of multiples of 4K.  Also add cpu_mfence() instructions to flush the
  cpu store buffer.

  This greatly reduces the startup time for x86-64 on monster machines
  with lots of memory (tested w/64G).

* Remove the basemem calculation, it is no longer used.

13 years agopc32: Split out isa_intr.h and move isa/intr_machdep.h to include/
Sepherosa Ziehau [Tue, 1 Feb 2011 14:32:52 +0000 (22:32 +0800)]
pc32: Split out isa_intr.h and move isa/intr_machdep.h to include/

13 years agopc64: Split out isa_intr.h and move isa/intr_machdep.h to include/
Sepherosa Ziehau [Tue, 1 Feb 2011 13:49:34 +0000 (21:49 +0800)]
pc64: Split out isa_intr.h and move isa/intr_machdep.h to include/

13 years agointr: Add ELCR support
Sepherosa Ziehau [Tue, 1 Feb 2011 12:58:26 +0000 (20:58 +0800)]
intr: Add ELCR support

This device controls/shows ICU pin's trigger mode (level/edge).

Currently, it is not enabled by default.

Obtained-from: FreeBSD (jhb@freebsd.org)

13 years agoradix: Fix the non-per-cpu radix tree usage.
Sepherosa Ziehau [Tue, 1 Feb 2011 08:09:26 +0000 (16:09 +0800)]
radix: Fix the non-per-cpu radix tree usage.

- Install a mask radix tree in each radix tree, while, mask radix tree does
  not have mask radix tree (of course).
- rn_cpumaskhead() is added to provide the global per-cpu mask radix tree.
- rn_inithead() requires a mask radix tree as paramter.  Mask radix tree is
  initialized by passing NULL.  INET/INET6/ATALK pass the mask radix tree
  obtained from rn_cpumaskhead(), i.e. the old sementics.
- pf(4) now creates its own mask radix tree, and all of its internal radix
  trees will use that mask radix tree instead of the global per-cpu mask
  radix tree.  pf(4) radix tree operations are protected by its own token.
- rn_addmask() requires a mask radix tree, instead of using the global
  per-cpu mask radix tree.  For most cases, the caller has access to the
  radix tree that has a mask radix tree installed.  For _rtmask_lookup(),
  which is always called from route_output(), we could safely assume that
  global per-cpu mask radix tree is used.

This is mainly used to fix the following bug concerning global per-cpu
mask radix tree:
Before this commit, pf(4) could create mask on CPU0's mask radix tree,
while the deletion of the mask happens on other CPUs, which results pf(4)'s
radix tree operation to fail (can't locate the mask).

Dragonfly-bug: http://bugs.dragonflybsd.org/issue1969
Root-cause-found-by: Jan Lentfer <Jan.Lentfer@web.de>
13 years agokernel64 - Fix disabled interrupts during dbg/bpt trap
Matthew Dillon [Mon, 31 Jan 2011 21:40:55 +0000 (13:40 -0800)]
kernel64 - Fix disabled interrupts during dbg/bpt trap

* Interrupts were left improperly disabled during a dbg or bpt trap.
  i386 enables interrupts for these traps.  x86-64 needs to as well
  or it will hit an assertion in lwkt_switch() under certain circumstances.

* Make debug code in lwkt_switch() also require INVARIANTS to function.

  NOTE: This is temporary debug code and should be removed at some point
  after 48-core testing is complete.

13 years agokernel - Fix SMP assumption of at least 2 cpus w/TCP
Matthew Dillon [Mon, 31 Jan 2011 21:09:39 +0000 (13:09 -0800)]
kernel - Fix SMP assumption of at least 2 cpus w/TCP

* TCP was assuming at least 2 cpus on SMP builds and would panic if only
  1 cpu was available.

* Fix by testing ncpus even for SMP builds.

* This problem did not effect UP builds.

13 years agokernel - Fix stall after mountroot w/ SMP & ncpus == 1
Matthew Dillon [Mon, 31 Jan 2011 21:08:26 +0000 (13:08 -0800)]
kernel - Fix stall after mountroot w/ SMP & ncpus == 1

* Fix a degenerate case for SMP builds when ncpus == 1.  This effects
  both the vkernel and the normal kernel (when a SMP kernel is booted
  on a non-SMP box which has a LAPIC).

  The init process was not bring scheduled properly.

13 years agovkernel - Fix lwbuf build error for vkernel64
Matthew Dillon [Mon, 31 Jan 2011 07:56:13 +0000 (23:56 -0800)]
vkernel - Fix lwbuf build error for vkernel64

* Fix a compile error that was preventing vkernel64's from building.

13 years agoTurn off all warnings when compiling gdtoa sources.
Peter Avalos [Mon, 31 Jan 2011 07:37:38 +0000 (21:37 -1000)]
Turn off all warnings when compiling gdtoa sources.

Obtained-from: FreeBSD

13 years agoMerge branch 'vendor/GDTOA'
Peter Avalos [Mon, 31 Jan 2011 06:28:20 +0000 (20:28 -1000)]
Merge branch 'vendor/GDTOA'

13 years agoRemove unneeded files from contrib/gdtoa.
Peter Avalos [Mon, 31 Jan 2011 06:24:13 +0000 (20:24 -1000)]
Remove unneeded files from contrib/gdtoa.

Add a README.DELETED while I'm here.

13 years agokernel options: Add MCLSHIFT
Sepherosa Ziehau [Mon, 31 Jan 2011 05:55:00 +0000 (13:55 +0800)]
kernel options: Add MCLSHIFT

So on the system w/o wireless NICs, we could configure MCLBYTES to 2K
(options MCLSHIFT=11) instead of the default 4K

13 years agonetisr barrier: Prevent netisr_barrier_dispatch() from false wakeup
Sepherosa Ziehau [Mon, 31 Jan 2011 05:43:24 +0000 (13:43 +0800)]
netisr barrier: Prevent netisr_barrier_dispatch() from false wakeup

- Change wait states into wait flags, only test NOTDONE flag when
  being woken up.
- Simplify wakeup logic.

With-help-from: dillon@

13 years agoImport gdtoa-20101105.
Peter Avalos [Mon, 31 Jan 2011 05:00:55 +0000 (19:00 -1000)]
Import gdtoa-20101105.

13 years agonetisr barrier: Avoid lockless wakeup/tsleep race
Sepherosa Ziehau [Mon, 31 Jan 2011 03:09:35 +0000 (11:09 +0800)]
netisr barrier: Avoid lockless wakeup/tsleep race

Add a waiting state (NETISR_BR_WAITDONE), before it is set wakeup()
will not be called.  And use atomic_cmpset_int() to do the state
transition.

With-help-from: dillon@

13 years agonetisr: Make sure that netisr barrier's done is globally visible
Sepherosa Ziehau [Fri, 28 Jan 2011 06:43:05 +0000 (14:43 +0800)]
netisr: Make sure that netisr barrier's done is globally visible

13 years agonetisr: Make netisr barrier's done and cpumask volatile
Sepherosa Ziehau [Tue, 25 Jan 2011 05:35:11 +0000 (13:35 +0800)]
netisr: Make netisr barrier's done and cpumask volatile

So that the assignment to these two variables and the following wakeup()
will not get reordered.

13 years agotcp6: Set TF_SYNCACHE properly in tcp6_usr_listen()
Sepherosa Ziehau [Mon, 24 Jan 2011 08:48:04 +0000 (16:48 +0800)]
tcp6: Set TF_SYNCACHE properly in tcp6_usr_listen()

13 years agotcp: Make listen(2) socket close(2) MPSAFE
Sepherosa Ziehau [Mon, 24 Jan 2011 07:52:45 +0000 (15:52 +0800)]
tcp: Make listen(2) socket close(2) MPSAFE

- Cleanup the syncache entries on each CPU for this inp.
- Before whacking the inp, we unhook the inp wildcard hash and cleanup
  its syncache entries by using a synchronized message.
- Fix up comment.

Reported-by: pavalos@
DragonFly-bug: http://bugs.dragonflybsd.org/issue1960

13 years agotcp_usr_listen: Use domsg when duplicate listen socket's inp wildcard hash
Sepherosa Ziehau [Mon, 24 Jan 2011 07:39:54 +0000 (15:39 +0800)]
tcp_usr_listen: Use domsg when duplicate listen socket's inp wildcard hash

This makes sure that the each protocol threads sees the socket when
tcp_usr_listen() returns.

13 years agotcp: Don't abuse TF_SYNCACHE to ill-optimize syncache_destroy()
Sepherosa Ziehau [Fri, 21 Jan 2011 08:14:03 +0000 (16:14 +0800)]
tcp: Don't abuse TF_SYNCACHE to ill-optimize syncache_destroy()

- We now turn on TF_SYNCACHE when listen(2) is called.
- When a listen(2) socket is to be close(2), the syncache list on the
  current CPU is thoroughly iterated and all related syncache are marked
  to be dropped instead of the first syncache.