18 years agoPer-CPU VFS Namecache Effectiveness Statistics:
Hiten Pandya [Fri, 2 Apr 2004 05:46:03 +0000 (05:46 +0000)]
Per-CPU VFS Namecache Effectiveness Statistics:

* Convert nchstats into a CPU indexed array

* Export the per-CPU nchstats as a sysctl vfs.cache.nchstats
  and let user-land aggregate them.

* Add a function called kvm_nch_cpuagg() to libkvm; it is
  shared by systat(1) and vmstat(1) and the ncache-stats test
  program.  As the function name suggests, it aggregates
  the per-CPU nchstats.

* Move struct nchstats into a separate header to avoid
  header file namespace pollution; sys/nchstats.h.

* Keep a cached copy of the globaldata pointer in the VFS
  specific LOOKUP op, and use that to increment the
  namecache effectiveness counters (nchstats).

* Modify systat(1) and vmstat(1) to accomodate the new
  behavior of accessing nchstats.  Remove a (now) redundant
  sysctl to get the cpu count (hw.ncpu), instead we just divide
  the total length of the nchstats array returned by sysctl
  by sizeof(struct nchstats) to get the CPU count.

* Garbage-collect unused variables and fix nearby warnings
  in systat(1) an vmstat(1).

* Add a very-cool test program, that prints the nchstats
  per-CPU statistics to show CPU distribution.  Here is the
  output it generates on an 2-processor SMP machine:

  gray# ncache-stats
  VFS Name Cache Effectiveness Statistics
     4207370 total name lookups
  COUNTER             CPU-1       CPU-2           TOTAL
  goodhits            2477657     1060677         (3538334  )
  neghits             107531      47294           (154825   )
  badhits             28968       7720            (36688    )
  falsehits           0           0               (0        )
  misses              339671      137852          (477523   )
  longnames           0           0               (0        )
  passes 2            13104       6813            (19917    )
  2-passes            25134       15257           (40391    )

The SMP machine used for testing this commit was proudly presented
by David Rhodus <drhodus@dragonflybsd.org>.

Reviewed-by: Matthew Dillon <dillon@backplane.com>

18 years agoConsolidate length checks in ip_demux().
Jeffrey Hsu [Thu, 1 Apr 2004 23:04:50 +0000 (23:04 +0000)]
Consolidate length checks in ip_demux().

18 years agoStyle(9) cleanup to src/sys/vfs, stage 3/21: fdesc.
Chris Pressey [Thu, 1 Apr 2004 19:08:15 +0000 (19:08 +0000)]
Style(9) cleanup to src/sys/vfs, stage 3/21: fdesc.

- Convert K&R-style function definitions to ANSI style.

Submitted-by: Andre Nathan <andre@digirati.com.br>
Additional-reformatting-by: cpressey
18 years agoEnhance the pmap_kenter*() API and friends, separating out entries which
Matthew Dillon [Thu, 1 Apr 2004 17:58:08 +0000 (17:58 +0000)]
Enhance the pmap_kenter*() API and friends, separating out entries which
only need invalidation on the local cpu against entries which need invalidation
across the entire system, and provide a synchronization abstraction.

Enhance sf_buf_alloc() and friends to allow the caller to specify whether the
sf_buf's kernel mapping is going to be used on just the current cpu or
whether it needs to be valid across all cpus.  This is done by maintaining
a cpumask of known-synchronized cpus in the struct sf_buf

Optimize sf_buf_alloc() and friends by removing both TAILQ operations in the
critical path.  TAILQ operations to remove the sf_buf from the free queue
are now done in a lazy fashion.  Most sf_buf operations allocate a buf,
work on it, and free it, so why waste time moving the sf_buf off the freelist
if we are only going to move back onto the free list a microsecond later?

Fix a bug in sf_buf_alloc() code as it was being used by the PIPE code.
sf_buf_alloc() was unconditionally using PCATCH in its tsleep() call, which
is only correct when called from the sendfile() interface.

Optimize the PIPE code to require only local cpu_invlpg()'s when mapping
sf_buf's, greatly reducing the number of IPIs required.  On a DELL-2550,
a pipe test which explicitly blows out the sf_buf caching by using huge
buffers improves from 350 to 550 MBytes/sec.  However, note that buildworld
times were not found to have changed.

Replace the PIPE code's custom 'struct pipemapping' structure with a
struct xio and use the XIO API functions rather then its own.

18 years agoFix an unused variable warning (non-operational).
Matthew Dillon [Thu, 1 Apr 2004 17:41:19 +0000 (17:41 +0000)]
Fix an unused variable warning (non-operational).

18 years agoImplement a convenient gd_cpumask so we don't have to do 1 << gd->gd_cpuid
Matthew Dillon [Thu, 1 Apr 2004 17:40:59 +0000 (17:40 +0000)]
Implement a convenient gd_cpumask so we don't have to do 1 << gd->gd_cpuid
all the time.

18 years agoConvert sis(4) from vtophys to busdma.
Joerg Sonnenberger [Thu, 1 Apr 2004 16:24:57 +0000 (16:24 +0000)]
Convert sis(4) from vtophys to busdma.

Obtained-from: FreeBSD 5

18 years agoKObj extension stage II/III
Joerg Sonnenberger [Thu, 1 Apr 2004 13:50:47 +0000 (13:50 +0000)]
KObj extension stage II/III

Tokenize kobj to make it SMP safe. This is based on the assumption that
drivers are responsible for not removing active devices. This allows us
to avoid all locks / critical sections for method lookup and object
instantiation / uninstanziation, leaving only the class management.

18 years agoKObj extension stage I/III
Joerg Sonnenberger [Thu, 1 Apr 2004 08:41:24 +0000 (08:41 +0000)]
KObj extension stage I/III

Isolate the reference counting for kobj classes in special functions to
allow clean locking in the next step.

Merge all calls of kobj_class_compile either into the new
kobj_class_instantiate or into kobj_init and make it static. Same for

Remove kobj_class_compile_static, it wasn't used and is pretty pointless
since the kobj framework is not used before the VM subsystem has been

18 years agoRemove struct driver and make driver_t directly defined as kobj_class.
Joerg Sonnenberger [Thu, 1 Apr 2004 07:33:18 +0000 (07:33 +0000)]
Remove struct driver and make driver_t directly defined as kobj_class.
The additional *priv field is only used by the ISA/PCI compat shims and
those can use a local struct instead.

18 years agoAdd the "struct ucred *" argument to the remaining nic ioctls in LINT.
Joerg Sonnenberger [Thu, 1 Apr 2004 07:27:17 +0000 (07:27 +0000)]
Add the "struct ucred *" argument to the remaining nic ioctls in LINT.

18 years agoFix warning about unused variable
Joerg Sonnenberger [Thu, 1 Apr 2004 06:52:45 +0000 (06:52 +0000)]
Fix warning about unused variable

18 years agoRemove unused obsolete drivers.
Joerg Sonnenberger [Thu, 1 Apr 2004 06:23:18 +0000 (06:23 +0000)]
Remove unused obsolete drivers.

18 years agoGet rid of the upper-end malloc() limit for the pipe throughput test.
Matthew Dillon [Thu, 1 Apr 2004 01:47:44 +0000 (01:47 +0000)]
Get rid of the upper-end malloc() limit for the pipe throughput test.

18 years agoRemove the ip_mthread_enable sysctl option. Enough code has been converted
Jeffrey Hsu [Thu, 1 Apr 2004 01:38:53 +0000 (01:38 +0000)]
Remove the ip_mthread_enable sysctl option.  Enough code has been converted
over to threads and message-passing that true dispatching is required for
proper synchronization.

Approved by: Matt Dillon

18 years agoStyle(9) cleanup.
Chris Pressey [Wed, 31 Mar 2004 23:20:22 +0000 (23:20 +0000)]
Style(9) cleanup.

- Convert K&R-style function definitions to ANSI style.
- Remove `register' keywords.
- Remove casts to void when ignoring return values.
- Remove explicit `return' at end of void functions.
- Additional minor whitespace and formatting adjustments.
- No functional changes.

18 years agoStyle(9) cleanup to src/sys/vfs, stage 2/21: deadfs.
Chris Pressey [Wed, 31 Mar 2004 23:13:43 +0000 (23:13 +0000)]
Style(9) cleanup to src/sys/vfs, stage 2/21: deadfs.

- Convert K&R-style function definitions to ANSI style.

Submitted-by: Andre Nathan <andre@digirati.com.br>
Additional-reformatting-by: cpressey
18 years agoAdd missing sf_buf_free()'s.
Matthew Dillon [Wed, 31 Mar 2004 22:08:32 +0000 (22:08 +0000)]
Add missing sf_buf_free()'s.

Reported-by: Jonathan Lemon <jlemon@flugsvamp.com>
18 years agoCorrect type slippage in previous commit: a u_int was accidentally
Chris Pressey [Wed, 31 Mar 2004 21:03:38 +0000 (21:03 +0000)]
Correct type slippage in previous commit: a u_int was accidentally
turned into a u_long.  Change it back.

18 years agoCleanup the forking behavior of the CAPS client test program.
Matthew Dillon [Wed, 31 Mar 2004 20:27:34 +0000 (20:27 +0000)]
Cleanup the forking behavior of the CAPS client test program.

18 years agoAllow the child priority (receive side of the pipe test) to be specified
Matthew Dillon [Wed, 31 Mar 2004 20:27:09 +0000 (20:27 +0000)]
Allow the child priority (receive side of the pipe test) to be specified
on the command line.  Default it to be the same as the parent.

18 years agoClarify the purpose of liby:
Chris Pressey [Wed, 31 Mar 2004 20:25:37 +0000 (20:25 +0000)]
Clarify the purpose of liby:

- Mention it in the FILES section of the yacc(1) man page.
- Create an MLINK from liby.3 -> yacc.1 so users can `man liby'.

Approved-by: dillon
18 years agoCleanup libcaps to support recent LWKT changes. Add TDF_SYSTHREAD back
Matthew Dillon [Wed, 31 Mar 2004 20:23:42 +0000 (20:23 +0000)]
Cleanup libcaps to support recent LWKT changes.  Add TDF_SYSTHREAD back
to sys/thread.h (libcaps needs it).

18 years agoRemove `-ly' and `${LIBY}' from our Makefiles. Linking to liby is not
Chris Pressey [Wed, 31 Mar 2004 20:22:14 +0000 (20:22 +0000)]
Remove `-ly' and `${LIBY}' from our Makefiles.  Linking to liby is not
necessary for any of our programs, as they all supply their own main()
and yyerror() functions.

Also add $DragonFly$ to these files as needed for the commit.

Approved-by: dillon
18 years agoTrash the vmspace_copy() hacks that CAPS was previously using. No other
Matthew Dillon [Wed, 31 Mar 2004 19:29:26 +0000 (19:29 +0000)]
Trash the vmspace_copy() hacks that CAPS was previously using.  No other
subsystem uses these hacks and the new XIO mechanism is far, far superior.

18 years agoChange CAPS over to use XIO instead of the vmspace_copy() junk it was using
Matthew Dillon [Wed, 31 Mar 2004 19:28:29 +0000 (19:28 +0000)]
Change CAPS over to use XIO instead of the vmspace_copy() junk it was using
before.  This almost doubles CAPS IPC messaging performance.

Also correct a number of memory leaks due to incorrect reference counting.

18 years agoHook XIO up to the kernel build.
Matthew Dillon [Wed, 31 Mar 2004 19:24:28 +0000 (19:24 +0000)]
Hook XIO up to the kernel build.

18 years agoInitial XIO implementation. XIOs represent data through a list of VM pages
Matthew Dillon [Wed, 31 Mar 2004 19:24:17 +0000 (19:24 +0000)]
Initial XIO implementation.  XIOs represent data through a list of VM pages
rather then mapped KVM, allowing them to be passed between threads without
having to worry about KVM mapping overheads, TLB invalidation, and so forth.

This initial implementation supports creating XIOs from user or kernel data
and copying from an XIO to a user or kernel buffer or a uio.  XIO are intended
to be used with CAPS, PIPES, VFS, DEV, and other I/O paths.

The XIO concept is an outgrowth of Alan Cox'es unique use of target-side
SF_BUF mapping to improve pipe performance.

18 years agoM_NOWAIT => M_INTWAIT conversion. This subsystems are way too crucial to
Joerg Sonnenberger [Wed, 31 Mar 2004 16:39:20 +0000 (16:39 +0000)]
M_NOWAIT => M_INTWAIT conversion. This subsystems are way too crucial to
have failing memory allocations. At least some of same are handled via
panic anyway.

18 years agoThe existing hash algorithm in bufhash() does not distribute entries
David Rhodus [Wed, 31 Mar 2004 15:32:53 +0000 (15:32 +0000)]
The existing hash algorithm in bufhash() does not distribute entries
very well across buckets, especially in the case of cylinder group blocks
which are located at a sequence of locations that are a multiple of a large
power of two apart.  In the case of large file systems, one or possibly
a few of the hash chains can get excessively long.  Replace the existing
hash algorithm with a variation on the Fibonacci hash.

Merged from FreeBSD

18 years agoOnly enter into wildcard hash table if bind succeeds.
Jeffrey Hsu [Wed, 31 Mar 2004 10:23:10 +0000 (10:23 +0000)]
Only enter into wildcard hash table if bind succeeds.

18 years agoOnly enter into wildcard hash table if bind succeeds.
Jeffrey Hsu [Wed, 31 Mar 2004 07:21:38 +0000 (07:21 +0000)]
Only enter into wildcard hash table if bind succeeds.

18 years agoStyle(9) cleanup to src/sys/vfs, stage 1/21: coda.
Chris Pressey [Wed, 31 Mar 2004 02:34:37 +0000 (02:34 +0000)]
Style(9) cleanup to src/sys/vfs, stage 1/21: coda.

- Convert K&R-style function definitions to ANSI style.

Submitted-by: Andre Nathan <andre@digirati.com.br>
Minor-whitespace-tweaks-by: cpressey
18 years agoOnly enter wildcard sockets into the wildcard hash table.
Jeffrey Hsu [Wed, 31 Mar 2004 00:43:09 +0000 (00:43 +0000)]
Only enter wildcard sockets into the wildcard hash table.

18 years agoSecond major scheduler patch. This corrects interactive issues that were
Matthew Dillon [Tue, 30 Mar 2004 19:14:18 +0000 (19:14 +0000)]
Second major scheduler patch.  This corrects interactive issues that were
introduced in the pipe sf_buf patch.

Split need_resched() into need_user_resched() and need_lwkt_resched().
Userland reschedules are requested when a process is scheduled with a higher
priority then the currently running process, and LWKT reschedules are
requested when a thread is scheduled with a higher priority then the
currently running thread.  As before, these are ASTs, LWKTs are not
preemptively switch while running in the kernel.

Exclusively use the resched wanted flags to determine whether to reschedule
or call lwkt_switch() upon return to user mode.  We were previously also
testing the LWKT run queue for higher priority threads, but this was causing
inefficient scheduler interactions when two processes are doing tightly
bound synchronous IPC (e.g. using PIPEs) because in DragonFly the LWKT
priority of a thread is raised when it enters the kernel, and lowered when
it tries to return to userland.  The wakeups occuring in the pipe code
were causing extra quick-flip thread switches.

Introduce a new tsleep() flag which disables the need_lwkt_resched() call
when the sleeping thread is woken up.   This is used by the PIPE code in
the synchronous direct-write PIPE case to avoid the above problem.

Redocument and revamp the ESTCPU code.  The original changes reduced the
interrupt rate from 100Hz (FBsd-4 and FBsd-5) to 20Hz, but did not compensate
for the slower ramp-up time.  This commit introduces a 'virtual' ESTCPU
frequency which compensates without us having to bump up the actual systimer
interrupt rate.

Redo the P_CURPROC methodology, which is used by the userland scheduler
to manage processes running in userland.  Create a globaldata->gd_uschedcp
process pointer which represents the current running-in-userland (or about
to be running in userland) process, and carefully recode acquire_curproc()
to allow this gd_uschedcp designation to be stolen from other threads trying
to return to userland without having to request a reschedule (which would
have to switch back to those threads to release the designation).  This
reduces the number of unnecessary context switches that occur due to
scheduler interactions.  Also note that this specifically solves the case
where there might be several threads running in the kernel which are trying
to return to userland at the same time.  A heuristic check against gd_upri
is used to select the correct thread for schedling to userland 'most of the
time'.  When the correct thread is not selected, we fall back to the old
behavior of forcing a reschedule.

Add debugging sysctl variables to better track userland scheduler efficiency.

With these changes pipe statistics are further improved.  Though some
scheduling aberrations still exist(1), the previous scheduler had totally
broken interactive processes and this one does not.

MBytes/s MBytes/s MBytes/s 3200+ FN85MB
    (64KB L1, 1MB L2)
256KB 1900 2200 2250
 64KB 1800 2200 2250
 32KB - - 3300
 16KB 1650 2500-3000 2600-3200
  8KB 1400 2300 2000-2400(1)
  4KB 1300 1400-1500 1500-1700

18 years agoAdd SI_SUB_LOCK as sysinit priority for the initialisation of tokens and
Joerg Sonnenberger [Tue, 30 Mar 2004 17:18:58 +0000 (17:18 +0000)]
Add SI_SUB_LOCK as sysinit priority for the initialisation of tokens and
lockmgr locks. This priority should not be abused, since it is higher then

18 years agoStyle(9) cleanup.
Chris Pressey [Tue, 30 Mar 2004 02:59:00 +0000 (02:59 +0000)]
Style(9) cleanup.

- Convert K&R-style function definitions to ANSI style.
- Remove ``register'' keywords.
- Remove casts to (void) when ignoring return values.
- Sort #include's.
- Minor whitespace adjustments.
- No functional changes.

18 years agoStyle(9) cleanup.
Chris Pressey [Tue, 30 Mar 2004 02:30:59 +0000 (02:30 +0000)]
Style(9) cleanup.

- Sort #include's.
- Convert to fully ANSI function definitions: use (void) instead of ()
- No functional changes.

18 years agoStyle(9) cleanup.
Chris Pressey [Tue, 30 Mar 2004 01:14:22 +0000 (01:14 +0000)]
Style(9) cleanup.

- Convert K&R-style function definitions to ANSI style.
- Remove ``register'' keywords.
- char *argv[] -> char **argv
- No functional changes.

18 years agoProtect the mntvnode scan for coda with the proper token. Since we do not
Matthew Dillon [Mon, 29 Mar 2004 20:52:17 +0000 (20:52 +0000)]
Protect the mntvnode scan for coda with the proper token.  Since we do not
block we do not need to use the vmntvnodescan() facility (as long as we
take the appropriate precautions), and we can remove the v_mount != mp

18 years agoCount vnodes held on the mount list simply by using the
Matthew Dillon [Mon, 29 Mar 2004 20:43:52 +0000 (20:43 +0000)]
Count vnodes held on the mount list simply by using the
mp->mnt_nvnodelistsize field, instead of physically looping on the
vnode list.

Suggested-by: someone, not sure. Hiten or David maybe.
18 years agoMove vm_fault_quick() out from the machine specific location
David Rhodus [Mon, 29 Mar 2004 17:30:23 +0000 (17:30 +0000)]
Move vm_fault_quick() out from the machine specific location
as the function is now cpu agnostic.

18 years agoMake sure the ELF header size is not too large. This fixes a potential over
David Rhodus [Mon, 29 Mar 2004 17:17:09 +0000 (17:17 +0000)]
Make sure the ELF header size is not too large. This fixes a potential over
flow that could happen in a number of places. In DragonFly we rely that the
ELF header will be in the first page. Though the ABI specification does not
require this it is always true in practice.

Glanced at FreeBSD but found it be incomplete. Possibly more bounds
checking is needed for other things here, though futher investigation is
needed first.

18 years agoUDF was not properly cleaning up getblk'd buffers in the face of error
Matthew Dillon [Mon, 29 Mar 2004 16:38:36 +0000 (16:38 +0000)]
UDF was not properly cleaning up getblk'd buffers in the face of error
conditions.  In some places it was assuming that getblk() would not
return a buffer on error, but in fact getblk() generally always returns
a buffer whether an error occurs or not (and always on an I/O error).

Reported-by: David Rhodus <drhodus@crater.dragonflybsd.org>
18 years agoBring in a bunch of well tested MPIPE changes. Preallocate a minimum
Matthew Dillon [Mon, 29 Mar 2004 16:22:23 +0000 (16:22 +0000)]
Bring in a bunch of well tested MPIPE changes.  Preallocate a minimum
number of mpipe elements when it is initialized.  Use an array to cache
free MPIPE buffers nad remove the data structure overloading that was
previously occuring on the buffer itself.  Add a deconstructor.  Separate
the blocking and non-blocking allocation APIs into their own functions.

The new code still needs Giant, but it's getting a lot closer to being
lock free.

18 years agoGenerally bring in additional sf_buf improvements from FreeBSD-5. Separate
Matthew Dillon [Mon, 29 Mar 2004 15:46:21 +0000 (15:46 +0000)]
Generally bring in additional sf_buf improvements from FreeBSD-5.  Separate
the wiring used by sendfile into its own mbuf_ext support code and remove it
from the sf_buf code.  Alan Cox's uiomove_fromphys() was expecting to use
the cleaner version of sf_buf.  This fixes a long standing bug related to
multiple mbuf refs in the sendfile() code and also fixes recent bugs
introduced to the PIPE code from the importation of uiomove_fromphys() (due
to differences in the sf_buf API).  The sf_buf API is now more normalized
towards FBSD-5.

Note that the mbuf_ext API has not changed, and is very differnt from
FBSD-5 in regards to handling multiple references.  Introduce some temporary
hacks to sf_buf to get around the fact which will be pulled when the
mbuf_ext API is updated later on.

18 years ago* Change the offset alignment in vn_rdwe_inchunks()
David Rhodus [Mon, 29 Mar 2004 15:21:42 +0000 (15:21 +0000)]
* Change the offset alignment in vn_rdwe_inchunks()
This is primarily used by the ELF image activator.

FreeBSD src repository

  Modified files:
    sys/kern             vfs_vnops.c
  Align the offset in vn_rdwr_inchunks() so that at most the first and
  the last chunk are misaligned relative to a MAXBSIZE byte boundary.
  vn_rdwr_inchunks() is used mainly for elf core dumps, and elf sections
  are usually perfectly misaligned relative to MAXBSIZE, and chunking
  prevents the file system from doing much realigning.

  This gives a surprisingly large speedup for core dumps -- from 50 to
  13 seconds for a 512MB core dump here.  The pessimization was mostly
  from an interaction of the misalignment with IO_DIRECT.  It increased
  the number of i/o's for each chunk by a factor of 5 (3 writes and 2
  read-before-writes instead of 1 write).

18 years ago* Fix an off-by-one problem.
David Rhodus [Mon, 29 Mar 2004 15:17:51 +0000 (15:17 +0000)]
* Fix an off-by-one problem.

* Don't sleep on NULL anymore.

Merged from FreeBSD

18 years agoRevert last commit. This should not have happened.
Joerg Sonnenberger [Mon, 29 Mar 2004 14:16:32 +0000 (14:16 +0000)]
Revert last commit. This should not have happened.

18 years agoRemove the old locking based on memory flags by lockmgr based code.
Joerg Sonnenberger [Mon, 29 Mar 2004 14:08:09 +0000 (14:08 +0000)]
Remove the old locking based on memory flags by lockmgr based code.

Initial effort by Eirik Nygaard.

18 years agokern_sysctl.c
Joerg Sonnenberger [Mon, 29 Mar 2004 14:06:31 +0000 (14:06 +0000)]

18 years agoInitialize the pcpu clocks after we've activated the cpu bit in
Matthew Dillon [Mon, 29 Mar 2004 07:36:48 +0000 (07:36 +0000)]
Initialize the pcpu clocks after we've activated the cpu bit in
smp_active_mask rather then before.

18 years agoAdd functionality to binutils 2.14's ld to scan /var/run/ld-elf.so.hints
Joerg Sonnenberger [Sun, 28 Mar 2004 16:26:33 +0000 (16:26 +0000)]
Add functionality to binutils 2.14's ld to scan /var/run/ld-elf.so.hints
for dependencies of shared libraries.

Submitted-By: Andreas Hauser <andy@splashground.de>
Obtained-From: FreeBSD / in-tree binutils 2.12

18 years agoAdd the pipe2 sysperf test. This test issues block writes from parent to
Matthew Dillon [Sun, 28 Mar 2004 09:21:53 +0000 (09:21 +0000)]
Add the pipe2 sysperf test.  This test issues block writes from parent to
child over a pipe and reports on the overhead and data rate.  The block size
is specified on the command line.

18 years agoUpdate to style(9) guidelines.
Chris Pressey [Sun, 28 Mar 2004 09:10:03 +0000 (09:10 +0000)]
Update to style(9) guidelines.

- Explicitly state that the ``register'' keyword should be avoided.
- Correct example and description of preferred indentation when wrapping
  function arguments over multiple lines.
- Resolve contradictions in guidelines for ``return''.
- Explicitly state whitespace rules for commas, semicolons, ``->'' and
  ``.'' operators.
- General clarifications.

Approved-by: dillon
18 years agoImport Alan Cox's /usr/src/sys/kern/sys_pipe.c 1.171. This rips out
Matthew Dillon [Sun, 28 Mar 2004 08:25:54 +0000 (08:25 +0000)]
Import Alan Cox's /usr/src/sys/kern/sys_pipe.c 1.171.  This rips out
writer-side KVA mappings and replaces them with writer-side vm_page wiring
(left intact from before) plus reader-side SF_BUF copies.

Import 1.141, which is a simple patch which removes a blocking condition
when space is available in the pipe's write buffer which was causing
non-blocking I/O select-based writes to spin-wait unnecessarily.  1.171
rips out writer-side KVA mappings and replaces them

Import FreeBSD-5.x's uiomove_fromphys(), which sys_pipe.c now uses.  This
procedure could become very useful in a number of DragonFly subsystems.

This greatly improves PIPE performance for the direct-mapped case (moderate
to large reads and writes).  Additionally, recent scheduler fixes greatly
improve PIPE performance for both the direct-mapped and small-buffer cases.

NOTE: wired page limits for pipes have not yet been imported, and the heavy
use of sf_buf's may require some tuning in the many-pipes case.

MBytes/s MBytes/s Tests on AMD64/3200+ FN85 MB
    ------- ------ ------ (64KB L1, 1MB L2)
    256KB 1900 2200
     64KB 1800 2200
     16KB 1650 2500-3000
      8KB 1400 2300
      4KB 1300 1400-1500 (note 1)

    note 1: The 4KB case is not a direct-write case, the results are due to
    the scheduler fixes only.

Obtained-from: FreeBSD-5.x / FreeBSD's Alan Cox

18 years agoDo some major performance tuning of the userland scheduler.
Matthew Dillon [Sun, 28 Mar 2004 08:03:05 +0000 (08:03 +0000)]
Do some major performance tuning of the userland scheduler.

When determining whether to reschedule, use a relative priority comparison
against PPQ rather then a queue index comparison to avoid the edge case
where two processes are only a p_priority of 1 apart, but fall into
different queues.  This reduces unnecessary preemptive context switches.
Also change the sense of test_resched() and document it.

Properly incriement p_ru.ru_nivcsw (involuntary context switches stat counter).

Fix uio_yield().  We have to call lwkt_setpri_self() to cycle our thread
to the end of its runq, and we do not need to call acquire_curproc() and
release_curproc() after switching.

When returning to userland, lower our priority and call lwkt_maybe_switch()
BEFORE acquiring P_CURPROC.  Before we called lwkt_maybe_switch() after we
acquired P_CURPROC which could result in us holding P_CURPROC, switching to
another thread which itself returns to usermode at a higher priority, and
that thread having to switch back to us to release P_CURPROC and then us back
to the other thread again.  This reduces the number of unnecessary context
switches that occur in certain situations.  In particular, this cuts the
number of context switches in PIPE situations by 50-75% (1/2 to 2/3).

18 years agoProtect v_usecount with a critical section for now (we depend on the BGL),
Matthew Dillon [Sun, 28 Mar 2004 07:54:00 +0000 (07:54 +0000)]
Protect v_usecount with a critical section for now (we depend on the BGL),
and assert that it does not drop below 0.

Suggested-by: David Rhodus <drhodus@machdep.com>
18 years agoStyle(9) cleanup.
Chris Pressey [Sun, 28 Mar 2004 01:02:54 +0000 (01:02 +0000)]
Style(9) cleanup.

- Remove ``register'' keyword.
- Remove casts to (void) when ignoring return values.
- Add ``static'' to internal function prototypes.
- Change an occurance of 1 to STDOUT_FILENO.
- Change an occurance of BUFSIZ to sizeof(ibuf).
- No functional changes.

18 years agoCorrect misspelling of "orphan" and fix up comment structure.
Chris Pressey [Sun, 28 Mar 2004 00:48:00 +0000 (00:48 +0000)]
Correct misspelling of "orphan" and fix up comment structure.

Obtained-from: NetBSD, src/sys/coda/coda_vfsops.c revision 1.32

18 years agoChange sendfile() to send the header out coaleseced with the data.
Jeffrey Hsu [Sat, 27 Mar 2004 21:01:03 +0000 (21:01 +0000)]
Change sendfile() to send the header out coaleseced with the data.

Inspired by Mike Silbersack's FreeBSD rev 1.171 to uipc_syscalls.c.

18 years agoPull out m_uiomove() functionality from sosend().
Jeffrey Hsu [Sat, 27 Mar 2004 11:50:45 +0000 (11:50 +0000)]
Pull out m_uiomove() functionality from sosend().

18 years agoGive UDP its own sosend() function.
Jeffrey Hsu [Sat, 27 Mar 2004 11:48:48 +0000 (11:48 +0000)]
Give UDP its own sosend() function.

18 years agoCorrect a typo that was introduced in revision 1.2.
Chris Pressey [Sat, 27 Mar 2004 01:46:10 +0000 (01:46 +0000)]
Correct a typo that was introduced in revision 1.2.
In makeargv(), 'margv' should have been 'margc'.
Compiles without warnings now.

Confirmed-with: FreeBSD CVSweb,
                /src/usr.sbin/timed/timedc/timedc.c revision 1.5

18 years agoStyle(9) cleanup: remove ``register'' keywords.
Chris Pressey [Sat, 27 Mar 2004 01:39:13 +0000 (01:39 +0000)]
Style(9) cleanup: remove ``register'' keywords.

18 years agoMake the .nx/.no native program helper binaries work and add some missing
Matthew Dillon [Fri, 26 Mar 2004 21:58:13 +0000 (21:58 +0000)]
Make the .nx/.no native program helper binaries work and add some missing
header file dependancies.

18 years agoThe NXCC (native C compiler) misnamed OBJFORMATPATH, it neesd to be
Matthew Dillon [Fri, 26 Mar 2004 21:57:23 +0000 (21:57 +0000)]
The NXCC (native C compiler) misnamed OBJFORMATPATH, it neesd to be
OBJFORMAT_PATH, causing 'missing crt1.o' from ld in the buildworld
includes stage.

18 years agoChange this vnode check inside of the VFS_BIO_DEBUG
David Rhodus [Fri, 26 Mar 2004 17:23:42 +0000 (17:23 +0000)]
Change this vnode check inside of the VFS_BIO_DEBUG
code path to check for erroneous hold counts from the
reference count check that was an el-relevant check here.

18 years agoUpdate rc.d scripts to use the correct path for the named pidfile.
David Rhodus [Fri, 26 Mar 2004 13:32:27 +0000 (13:32 +0000)]
Update rc.d scripts to use the correct path for the named pidfile.

Sent in by: Craig Dooley <craig@xlnx-x.net>

18 years agoStyle(9) cleanup.
Chris Pressey [Fri, 26 Mar 2004 00:30:13 +0000 (00:30 +0000)]
Style(9) cleanup.

- Convert K&R-style function definitions to ANSI style.
- Remove ``register'' keywords.
- Adjust whitespace and parens w.r.t. style(9) and remove casts to
  (void) when ignoring return values (time.c only.)

18 years agoFour new features and a bugfix.
Chris Pressey [Thu, 25 Mar 2004 23:55:13 +0000 (23:55 +0000)]
Four new features and a bugfix.

- Center the clock on the user's terminal.
- Check that the terminal is sufficiently large to fully display the
  clock (about 61x9.)  If not, exit immediately with an error.
- Introduce a short delay in the scrolling when -s is given, so that
  it can be better appreciated on syscons(4) and local xterm(1).  The
  default delay is 120 milliseconds.
- Add a new option, -d, to allow changing the scroll delay to any
  duration from 0 to 5000 milliseconds.  The -d option implies -s.
- Make it so that, when the optional argument is omitted, the clock
  really does run forever.  (Before this, it would have stopped after
  about 65536 seconds due to wraparound.)

18 years agoAttach mount_udf to the buildworld process now.
David Rhodus [Thu, 25 Mar 2004 22:07:21 +0000 (22:07 +0000)]
Attach mount_udf to the buildworld process now.

18 years agoFix a missing makewhatis related change so buildworld works again.
Matthew Dillon [Thu, 25 Mar 2004 20:52:43 +0000 (20:52 +0000)]
Fix a missing makewhatis related change so buildworld works again.

Reported-by: Chris Pressey <cpressey@catseye.mine.nu>
18 years agomake -j N support, the generated lib_gen.c and nomacros.h files depend
Matthew Dillon [Thu, 25 Mar 2004 18:07:27 +0000 (18:07 +0000)]
make -j N support, the generated lib_gen.c and nomacros.h files depend
on ncurses_def.h.

18 years agoReplace the Perl scripts makewhatis(1), makewhatis.local(8) and catman(1)
Joerg Sonnenberger [Thu, 25 Mar 2004 18:05:49 +0000 (18:05 +0000)]
Replace the Perl scripts makewhatis(1), makewhatis.local(8) and catman(1)
by C programs.

Submitted by: Dheeraj Reddy <dheerajs@comcast.net>
Taken from: FreeBSD

In contrast to FreeBSD, put makewhatis.local under src/libexec and put
makewhatis into src/usr.sbin. Update man pages accordingly.

18 years agoNext time I'll run cvs update to make sure I've added
David Rhodus [Thu, 25 Mar 2004 16:41:01 +0000 (16:41 +0000)]
Next time I'll run cvs update to make sure I've added
all the new files.

18 years agoChange whereis(1) over from a perl script to a C program.
David Rhodus [Thu, 25 Mar 2004 16:39:40 +0000 (16:39 +0000)]
Change whereis(1) over from a perl script to a C program.

Patch sent in by: Dheeraj Reddy <dheerajs@comcast.net>

18 years agoChange which(1) over from a perl script to a C program.
David Rhodus [Thu, 25 Mar 2004 16:18:40 +0000 (16:18 +0000)]
Change which(1) over from a perl script to a C program.

Patch sent in by: Dheeraj Reddy <dheerajs@comcast.net>

18 years agoCorrect obvious typo in comment.
Chris Pressey [Thu, 25 Mar 2004 07:30:45 +0000 (07:30 +0000)]
Correct obvious typo in comment.

18 years agoReturn a low priority for the "hostb%d" catch-all for pci busses, which will
Matthew Dillon [Thu, 25 Mar 2004 01:39:27 +0000 (01:39 +0000)]
Return a low priority for the "hostb%d" catch-all for pci busses, which will
allow compiled-in bus device drivers such as AGP to attach first.  Without
this the probe order is half hazzard and in particular SMP boxes may attach
"hostb" first, preventing AGP from attaching.

Note that AGP will still not load properly from loader.conf or after booting
with kldload.  Removing the "hostb" catch-all entirely solves that problem
but some additional investigation must be done first.

AGP-problems-reported-by: Adam K Kirchhoff <adamk@voicenet.com>
18 years agoDirectly call pru_control until copyin problem is resolved.
Jeffrey Hsu [Wed, 24 Mar 2004 21:58:44 +0000 (21:58 +0000)]
Directly call pru_control until copyin problem is resolved.

18 years agoNeed header file to deference proc structure.
Jeffrey Hsu [Wed, 24 Mar 2004 21:46:07 +0000 (21:46 +0000)]
Need header file to deference proc structure.

Reported by: drhodus

18 years agoFix malloc semantics (M_NOWAIT->M_INTWAIT/M_WAITOK).
Matthew Dillon [Wed, 24 Mar 2004 20:42:12 +0000 (20:42 +0000)]
Fix malloc semantics (M_NOWAIT->M_INTWAIT/M_WAITOK).

18 years agoagp_nvidia.c was not being linked into the module build.
Matthew Dillon [Wed, 24 Mar 2004 20:40:33 +0000 (20:40 +0000)]
agp_nvidia.c was not being linked into the module build.

18 years agoFix malloc semantics, M_NOWAIT->M_WAITOK.
Matthew Dillon [Wed, 24 Mar 2004 20:34:08 +0000 (20:34 +0000)]
Fix malloc semantics, M_NOWAIT->M_WAITOK.

18 years agoShould have been on last commit.
David Rhodus [Wed, 24 Mar 2004 20:26:10 +0000 (20:26 +0000)]
Should have been on last commit.
This allows LINT to build with UDF.

18 years agoStyle(9) cleanup.
Chris Pressey [Wed, 24 Mar 2004 18:23:47 +0000 (18:23 +0000)]
Style(9) cleanup.

- Convert K&R-style function definitions to ANSI style.
- Remove ``register'' keywords.
- (fdformat only) Remove/add whitespace around operators, add parens
  after sizeof and return, use NULL instead of O for null pointer,
  and remove (void) casts on ignored return values,
- Move local variable out of redundant inner block.
- Remove redundant return from end of void functions.
- *argv[] -> **argv.
- Correct wording of #endif hint-comment to __DragonFly__.

18 years agoStyle(9) cleanup.
Chris Pressey [Wed, 24 Mar 2004 17:46:23 +0000 (17:46 +0000)]
Style(9) cleanup.

- Convert K&R-style function definitions to ANSI style.
- Remove ``register'' keywords.
- Add needed static prototypes.
- Sort and space #include's as per style(9).
- Adjust indentation issues in a few places.
- Fix two typos in comments.
- Add $DragonFly$ tags.

18 years agoHook in UDF to the build process.
David Rhodus [Wed, 24 Mar 2004 17:39:51 +0000 (17:39 +0000)]
Hook in UDF to the build process.

18 years agoCorrect a bug in vm_page_cache(). We should make sure that a held
Hiten Pandya [Wed, 24 Mar 2004 17:06:44 +0000 (17:06 +0000)]
Correct a bug in vm_page_cache().  We should make sure that a held
page is not being added to the cache queue; they are no different
from wired or busy pages.

Do this by checking the page'hold_count' element.

18 years agomake -j N support, add a required dependancy.
Matthew Dillon [Wed, 24 Mar 2004 07:04:28 +0000 (07:04 +0000)]
make -j N support, add a required dependancy.

18 years agoEliminate use of curproc and curthread by propagating thread pointer down
Jeffrey Hsu [Wed, 24 Mar 2004 02:08:33 +0000 (02:08 +0000)]
Eliminate use of curproc and curthread by propagating thread pointer down
the call chain.

18 years agoPass the credentials along when available.
Jeffrey Hsu [Wed, 24 Mar 2004 01:58:01 +0000 (01:58 +0000)]
Pass the credentials along when available.

18 years agoANSIfication (procedure args) cleanup.
Matthew Dillon [Tue, 23 Mar 2004 22:54:32 +0000 (22:54 +0000)]
ANSIfication (procedure args) cleanup.

Submitted-by: Andre Nathan <andre@digirati.com.br>
18 years agoDo all the length checks before returning even if "ip_mthread_enable"
Jeffrey Hsu [Tue, 23 Mar 2004 22:30:49 +0000 (22:30 +0000)]
Do all the length checks before returning even if "ip_mthread_enable"
is not enabled.

18 years agoEliminate use of curthread in if_ioctl functions by passing down the
Jeffrey Hsu [Tue, 23 Mar 2004 22:19:08 +0000 (22:19 +0000)]
Eliminate use of curthread in if_ioctl functions by passing down the
ucred structure.

18 years agoStyle(9) cleanup.
Chris Pressey [Tue, 23 Mar 2004 18:34:41 +0000 (18:34 +0000)]
Style(9) cleanup.

- Split deeply nested code into its own function, draw_row().
- Remove pleonastic wrapper function movto().
- Convert K&R-style function declarations to ANSI style.
- Remove (void) cast when ignoring return value.
- Fix indentation and whitespace around operators.
- Remove once-humourous comments that have now fallen out of context.

18 years agoAdd -w, which prints the full width of the data being represented even if
Matthew Dillon [Tue, 23 Mar 2004 18:25:51 +0000 (18:25 +0000)]
Add -w, which prints the full width of the data being represented even if
it overflows the column, and do not truncate the base domain from displayed
host names.  This is for programmatic interfaces and for sysops
who really want to see the whole host name.

18 years agoMake the Destination and Gateway columns wider when printing FQDNs so
Matthew Dillon [Tue, 23 Mar 2004 18:00:48 +0000 (18:00 +0000)]
Make the Destination and Gateway columns wider when printing FQDNs so
the hostnames do not get cut-off too badly.

18 years agoAdd 'route show' to the route command, plus style cleanups.
Matthew Dillon [Tue, 23 Mar 2004 17:56:29 +0000 (17:56 +0000)]
Add 'route show' to the route command, plus style cleanups.

Submitted-by: Andre Nathan <andre@digirati.com.br>
Taken-from: OpenBSD and NetBSD