dragonfly.git
11 years agokernel - usched_dfly revamp (4), improve tail
Matthew Dillon [Mon, 24 Sep 2012 20:32:11 +0000 (13:32 -0700)]
kernel - usched_dfly revamp (4), improve tail

* Improve tail performance (many more cpu-bound processes than available
  cpus).

* Experiment with removing the LWKT priority adjustments for kernel vs user.
  Instead give LWKT a hint about the user scheduler when scheduling a thread.
  LWKT's round-robin is left unhinted to hopefully round-robin starved LWKTs
  running in kernel mode.

* Implement a better calculation for the per-thread uload than the priority.
  Instead, use estcpu.

* Adjust default weigntings for new uload calculation scale.

11 years agosystat - Ensure vmmeter output separates fields by at least one space.
Matthew Dillon [Mon, 24 Sep 2012 17:31:47 +0000 (10:31 -0700)]
systat - Ensure vmmeter output separates fields by at least one space.

* Ensure vmmeter output separates fields by at least one space.

* Fix minor formatting issue with token names.

11 years agosystat - Display colliding token
Matthew Dillon [Mon, 24 Sep 2012 17:27:32 +0000 (10:27 -0700)]
systat - Display colliding token

* Display the colliding token when a non-zero token collision count is
  reported.  This is somewhat statistical but should still provide good
  information on MP bottlenecks.

11 years agokernel - Add v_token_name to gd_cnt
Matthew Dillon [Mon, 24 Sep 2012 17:26:28 +0000 (10:26 -0700)]
kernel - Add v_token_name to gd_cnt

* Copy the tok->t_desc field into the gd_cnt.v_token_name buffer
  when a token collides so systat -pv 1 can pick it up.

11 years agousr.sbin/Makefile: Remove an obsolete old comment.
Sascha Wildner [Mon, 24 Sep 2012 12:45:04 +0000 (12:45 +0000)]
usr.sbin/Makefile: Remove an obsolete old comment.

11 years agopnpinfo(8): Don't build/install for x86_64.
Sascha Wildner [Mon, 24 Sep 2012 12:44:16 +0000 (12:44 +0000)]
pnpinfo(8): Don't build/install for x86_64.

It crashes and isn't really useful. FreeBSD did so, too.

11 years agovlan: Dispatch mbuf to be sent to physical interface's start cpu
Sepherosa Ziehau [Sun, 23 Sep 2012 09:12:52 +0000 (17:12 +0800)]
vlan: Dispatch mbuf to be sent to physical interface's start cpu

11 years agobridge: Utilize netisr to run physical interface's if_start
Sepherosa Ziehau [Sun, 23 Sep 2012 09:08:22 +0000 (17:08 +0800)]
bridge: Utilize netisr to run physical interface's if_start

11 years agoaue/lgue: Utilize netisr to run if_start
Sepherosa Ziehau [Sun, 23 Sep 2012 09:07:01 +0000 (17:07 +0800)]
aue/lgue: Utilize netisr to run if_start

11 years agoif: Defer if_start to netisr instead of ifnet for further processing
Sepherosa Ziehau [Sun, 23 Sep 2012 09:04:48 +0000 (17:04 +0800)]
if: Defer if_start to netisr instead of ifnet for further processing

11 years agoifpoll: Use u_long for statistics
Sepherosa Ziehau [Sun, 23 Sep 2012 07:59:03 +0000 (15:59 +0800)]
ifpoll: Use u_long for statistics

11 years agoifpoll: Reorder iopoll fields a little bit
Sepherosa Ziehau [Sun, 23 Sep 2012 07:48:31 +0000 (15:48 +0800)]
ifpoll: Reorder iopoll fields a little bit

11 years agoifpoll: Simplify TX polling logic
Sepherosa Ziehau [Sun, 23 Sep 2012 07:42:14 +0000 (15:42 +0800)]
ifpoll: Simplify TX polling logic

11 years agotop - Fix -t / -S
Matthew Dillon [Sun, 23 Sep 2012 02:07:02 +0000 (19:07 -0700)]
top - Fix -t / -S

* -t to show threads now just shows threaded processes (all LWPs),
  and no longer also shows system processes.

* -s to show system threads now works as expected.

11 years agotop - Adjust top to account for kernel changes
Matthew Dillon [Sun, 23 Sep 2012 02:00:12 +0000 (19:00 -0700)]
top - Adjust top to account for kernel changes

* ccpu no longer exists

* if top is out of sync with the system, fix a seg-fault which can occur
  when it tries to use lwp_stat as an array indx.

11 years agops - Adjust ps to account for kernel changes
Matthew Dillon [Sun, 23 Sep 2012 01:59:26 +0000 (18:59 -0700)]
ps - Adjust ps to account for kernel changes

* ccpu no longer exists.

* pctcpu is now accurate regardless of the lwp's state.

11 years agokernel - usched_dfly revamp (3), fix estcpu
Matthew Dillon [Sun, 23 Sep 2012 01:57:06 +0000 (18:57 -0700)]
kernel - usched_dfly revamp (3), fix estcpu

* Fix the estcpu calculation, which previously assumed only a single
  runq (in usched_dfly there is a runq per cpu).

* Add a global atomic int accounting for all running and runnable lwp's.

* Fix cpu-hogging issues for bursty processes by creating a fast-decay-mode
  for estcpu when a thread first starts up, or after it has been asleep
  for more than 1 seconds.

11 years agoemx: Allow user to specify RX/TX processing CPU's offset
Sepherosa Ziehau [Sat, 22 Sep 2012 13:45:43 +0000 (21:45 +0800)]
emx: Allow user to specify RX/TX processing CPU's offset

11 years agokernel - usched_dfly revamp (2), reduce token collisions
Matthew Dillon [Sat, 22 Sep 2012 01:34:09 +0000 (18:34 -0700)]
kernel - usched_dfly revamp (2), reduce token collisions

* Add wakeup_start_delayed() and wakeup_end_delayed().  These functions
  will attempt to delay any wakeup() calls made between them.

  Use the functions in the unix domain socket send code.

* This removes a lot of volatility from monster's 48:48 pgbench tests by
  delaying the wakeup()s related to a unix domain socket write until after
  the pool token has been released.

* Adjust usched_dfly parameters.  In particular, weight2 can be higher now.

11 years agokernel - Add vmmeter counter for token collisions
Matthew Dillon [Fri, 21 Sep 2012 23:53:37 +0000 (16:53 -0700)]
kernel - Add vmmeter counter for token collisions

* Add vmmeter counter for token collisions.

* Add token collisions to systat -pv's display.

11 years agokernel - usched_dfly revamp
Matthew Dillon [Fri, 21 Sep 2012 23:09:25 +0000 (16:09 -0700)]
kernel - usched_dfly revamp

* NOTE: This introduces a few regressions at high loads.  They've been
  identified and will be fixed in another iteration.

  We've identified an issue with weight2.  When weight2 successfully
  schedules a process pair on the same cpu it can lead to inefficiencies
  elsewhere in the scheduler related to user-mode and kernel-mode
  priority switching.  In this situation testing pgbench/postgres pairs
  (e.g. -j $ncpus -c $ncpus) we sometimes see some serious regressions on
  multi-socket machines, and other times see remarkably high performance.

* Fix a reported panic.

* Revamp the weights and algorithms signficantly.  Fix algorithmic errors
  and improve the accuracy of weight3.  Add weight4 which basically tells
  the scheduler to try harder to find a free cpu to schedule the lwp on
  when the current cpu is busy doing something else.

11 years agokdump - cleanup cpu-stamp formatting
Matthew Dillon [Fri, 21 Sep 2012 23:07:00 +0000 (16:07 -0700)]
kdump - cleanup cpu-stamp formatting

* %2d instead of %d so columns align.

11 years agops - Show cpu# even when process is sleeping
Matthew Dillon [Fri, 21 Sep 2012 23:05:50 +0000 (16:05 -0700)]
ps - Show cpu# even when process is sleeping

* Show the cpu# the process is scheduled on even when it is sleeping.

* Add a 'Q' flag for 'R'unnable processes, indicating that it is runnable
  but on the user scheduler runq and does not actually have cpu at the
  moment.

11 years agosysctl - Allow integers to use hex
Matthew Dillon [Fri, 21 Sep 2012 20:16:56 +0000 (13:16 -0700)]
sysctl - Allow integers to use hex

* Allow integers to be specified in hex using a 0x or 0X prefix.

11 years agonrelease: Remove the obsolete -scmgit-gui option from the build.
Sascha Wildner [Thu, 20 Sep 2012 20:45:13 +0000 (22:45 +0200)]
nrelease: Remove the obsolete -scmgit-gui option from the build.

Its presence was breaking snapshot building.

It is no longer necessary to prevent gitk from being built along
with git using '-scmgit-gui', because pkgsrc now has a separate
scmgit-gitk package for it.

Since we used to build our GUI distribution without -scmgit-gui
(meaning with gitk), add scmgit-gitk to the GUI build.

11 years agokernel - Improve regressions in usched_dfly (2)
Matthew Dillon [Thu, 20 Sep 2012 18:35:21 +0000 (11:35 -0700)]
kernel - Improve regressions in usched_dfly (2)

* Allow various fork() behaviors to be supported via
  kern.usched_dfly.features.

* Set the default to place the newly forked process on
  a random cpu instead of the current cpu.

  The bsd4 scheduler had a global queue and could just signal
  a random helper to pick up the thread.  The dfly scheduler
  has per-cpu queues and must actually enqueue the thread to
  another cpu.

  The bsd4 scheduler is still slightly superior here because
  if the parent running on the current cpu immediately waits
  for the child, the child is able to run on the current cpu.
  However, randomization works quite well and this removes
  nearly all of the make -j N regression.

11 years agokdump - Add options to print physical cpu
Matthew Dillon [Thu, 20 Sep 2012 18:33:52 +0000 (11:33 -0700)]
kdump - Add options to print physical cpu

* -c option adds the physical cpu to the output

* -a option humanform.  This options turns on -c and -R.

11 years agokernel - Include physical cpu in ktrace header
Matthew Dillon [Thu, 20 Sep 2012 18:33:03 +0000 (11:33 -0700)]
kernel - Include physical cpu in ktrace header

* Record which cpu the system call (etc) is running on
  in the ktrace header.

11 years agowmesg - Increase to 8 chars from 7
Samuel J. Greear [Thu, 20 Sep 2012 07:52:58 +0000 (01:52 -0600)]
wmesg - Increase to 8 chars from 7

* Increase top from 7 to 8 and use the WMESGLEN define in ps (previously 6).

11 years agokernel - Add usched_dfly algorith, set as default for now (9)
Matthew Dillon [Thu, 20 Sep 2012 07:37:40 +0000 (00:37 -0700)]
kernel - Add usched_dfly algorith, set as default for now (9)

* Code cleanup, remove bits that shouldn't matter any more.

11 years agokernel - Improve regressions in usched_dfly (1)
Matthew Dillon [Thu, 20 Sep 2012 07:31:43 +0000 (00:31 -0700)]
kernel - Improve regressions in usched_dfly (1)

* The new scheduler is MP locked at a very fine-grain.  The old scheduler
  had a global spinlock which effectively serialized competing cores during
  exit/wait sequences.

  With the new scheduler this serialization is gone and resulted in a
  vfork performance regression due to a fallback tsleep loop in the
  reaper.

* This fixes the problem with an explicit signal bit for tsleep/wakeup.
  The sequence is avoided if the reaper determines the thread has
  already completed its exit.

11 years agokernel - Add usched_dfly algorith, set as default for now (8)
Matthew Dillon [Thu, 20 Sep 2012 04:37:18 +0000 (21:37 -0700)]
kernel - Add usched_dfly algorith, set as default for now (8)

* Fix additional edge cases, in particular improving the process pairing
  algorithm to reduce flapping.

* Reorder conditionals in dd->uschedcp assignment to improve the hot path.

* Rewrite the balancing rover.  The rover will now move one process per
  tick from a very heavily loaded cpu queue to a lightly loaded cpu queue.
  Each cpu target is iterated by the rover, one target per tick.

* Reformulate dfly_chooseproc_locked() and friends.  Add a capability to
  choose the 'worst' process (from the end of the queue), which is used
  by the rover.

* When pulling a random thread we require the queue it is taken from to
  be MUCH more heavily loaded than our own queue, which avoids ping-ponging
  processes back and forth when the load is not balanced against the number
  of cpu cores (e.g. 6 servers, 4 cores).

11 years agokernel - Add lwkt_yield_quick()
Matthew Dillon [Thu, 20 Sep 2012 04:33:54 +0000 (21:33 -0700)]
kernel - Add lwkt_yield_quick()

* Add a quick version of lwkt_yield() which does not try to round-robin
  LWKT threads at the same priority.

11 years agokernel - Don't call lwkt_user_yield() in uiomove() unless xfer is big
Matthew Dillon [Thu, 20 Sep 2012 04:33:03 +0000 (21:33 -0700)]
kernel - Don't call lwkt_user_yield() in uiomove() unless xfer is big

* Only call lwkt_user_yield() in uiomove() when the xfer is big.

11 years agokernel - Add usched_dfly algorith, set as default for now (7)
Matthew Dillon [Wed, 19 Sep 2012 18:25:09 +0000 (11:25 -0700)]
kernel - Add usched_dfly algorith, set as default for now (7)

* Reenable weight2 (the process pairing heuristic) and fix the
  edge cases associated with it.

* Change the process pulling behavior.  Now we pull the 'worst' thread
  from some other cpu instead of the best (duh!), we only pull when a
  cpu winds up with no designated user threads, or we pull via a
  schedulerclock-implemented rover.

  The schedulerclock-implemented rover will allow ONE cpu to pull the
  'worst' thread across all cpus (with some locality) once every
  round-robin ticks (4 scheduler ticks).

  The rover is responsible for taking excess processes that are unbalancing
  one or more cpu's (for example, you have 6 running batch processes and
  only 4 cpus) and slowly moving them between cpus.  If we did not do this
  the 'good' processes running on the unbalanced cpus are put at an unfair
  disadvantage.

* This should fix all known edge cases, including ramp-down edge cases.

11 years agokernel - Add usched_dfly algorith, set as default for now (6)
Matthew Dillon [Wed, 19 Sep 2012 12:10:21 +0000 (05:10 -0700)]
kernel - Add usched_dfly algorith, set as default for now (6)

* Fix an edge case where the pairing could cause flapping.

* Fix an edge case where user processes were interrupting each other
  when they were in the same queue, which could cause a synchronous
  process like a postgres server to lose cpu while holding internal
  locks during a short operation.

11 years agokernel - Add usched_dfly algorith, set as default for now (5)
Matthew Dillon [Wed, 19 Sep 2012 11:41:27 +0000 (04:41 -0700)]
kernel - Add usched_dfly algorith, set as default for now (5)

* Do a better job pushing threads to the correct cpu.  Keep the load
  factor live even when the thread goes to sleep, until some other thread
  tries to go to sleep on the same cpu.

* Handle an edge case where a cpu-bound thread needs to be moved to
  another cpu.

* Pull once a second and on-demand.

11 years agokernel - Add usched_dfly algorith, set as default for now (4)
Matthew Dillon [Wed, 19 Sep 2012 03:55:18 +0000 (20:55 -0700)]
kernel - Add usched_dfly algorith, set as default for now (4)

* Fix fork regression with usched_dfly.  Most fork/exec sequences involve
  the parent waiting.  The new scheduler was placing the newly forked
  process on another cpu which is non-optimal if the parent is going
  to immediately wait.

  Instead if there is nothing else waiting to run on the current cpu,
  leave the forked process on the current cpu initially.  If the parent
  waits quickly the forked process will get cpu, otherwise it will get
  scheduled away soon enough.  If the parent forks additional children
  then we find there is something on the queue now (the first child) and
  put the additional children on other cpus.

Reported-by: thesjg
11 years agokernel - Increase machdep.cpu_idle_repeat from 4 to 750
Matthew Dillon [Tue, 18 Sep 2012 21:18:24 +0000 (14:18 -0700)]
kernel - Increase machdep.cpu_idle_repeat from 4 to 750

* Increase machdep.cpu_idle_repeat from 4 to 750.  It now takes longer
  before the kernel will move from HLT/MONITOR/MWAIT to ACPI-based halting.

* Improves benchmark performance significantly on recent cpus without
  eating up too much extra power, but laptop tests are still pending.

* Laptop users can always set it back to 4.

11 years agousched - Add usched utility
Matthew Dillon [Tue, 18 Sep 2012 20:58:11 +0000 (13:58 -0700)]
usched - Add usched utility

* Currently must run as root

* usched {bsd4,dfly} program args...

11 years agotuning(7): shm_use_phys is now enabled by default
François Tigeot [Tue, 18 Sep 2012 20:38:59 +0000 (22:38 +0200)]
tuning(7): shm_use_phys is now enabled by default

11 years agokernel - Account for file reads that take the VM shortcut
Matthew Dillon [Tue, 18 Sep 2012 18:45:19 +0000 (11:45 -0700)]
kernel - Account for file reads that take the VM shortcut

* Account for file reads that take the VM shortcut in hammer's statistics.

11 years agokernel/usched_dfly: Small UP compilation fix.
Sascha Wildner [Tue, 18 Sep 2012 18:18:35 +0000 (20:18 +0200)]
kernel/usched_dfly: Small UP compilation fix.

11 years agokernel - Add usched_dfly algorith, set as default for now (3)
Matthew Dillon [Tue, 18 Sep 2012 18:01:35 +0000 (11:01 -0700)]
kernel - Add usched_dfly algorith, set as default for now (3)

* Add a field to the thread structure, td_wakefromcpu.  All wakeup()
  family calls will load this field with the cpu the thread was woken
  up FROM.

* Use this field in usched_dfly to weight scheduling such that pairs
  of synchronously-dependent threads (for example, a pgbench thread
  and a postgres server process) are placed closer to each other in
  the cpu topology.

* Weighting:

  - Load matters the most
  - Current cpu thread is scheduled on is next
  - Synchronous wait/wakeup weighting is last

* Tests on monster yield better all-around results with a new all-time
  high w/ pgbench -j 40 -c 40 -T 60 -S bench:

  25% idle at 40:40 tps = 215293.173300 (excluding connections establishing)

  Without the wait/wakeup weighting (but with allwload and current cpu
  weighting):

  41% idle at 40:40 tps = 162352.813046 (excluding connections establishing)

  Without wait/wakeup or current-cpu weighting.  Load balancing only:

  43% idle at 40:40 tps = 159047.440641 (excluding connections establishing)

11 years agoMention KTR_USCHED_DFLY in the manpage and in the LINTs.
Sascha Wildner [Tue, 18 Sep 2012 17:01:42 +0000 (19:01 +0200)]
Mention KTR_USCHED_DFLY in the manpage and in the LINTs.

11 years agokernel/usched_dfly: #if 0 all unused KTR_INFOs (fixes build with KTR).
Sascha Wildner [Tue, 18 Sep 2012 17:01:11 +0000 (19:01 +0200)]
kernel/usched_dfly: #if 0 all unused KTR_INFOs (fixes build with KTR).

11 years agokernel/usched_bsd4: Declare the KTR_INFO_MASTER(usched) as extern.
Sascha Wildner [Tue, 18 Sep 2012 16:57:11 +0000 (18:57 +0200)]
kernel/usched_bsd4: Declare the KTR_INFO_MASTER(usched) as extern.

It is shared with usched_dfly.

11 years agokernel - add usched_dfly algorith, set as default for now (3)
Matthew Dillon [Tue, 18 Sep 2012 16:25:03 +0000 (09:25 -0700)]
kernel - add usched_dfly algorith, set as default for now (3)

* UP compile fixes.

Reported-by: swildner
11 years agokernel - add usched_dfly algorith, set as default for now (2)
Matthew Dillon [Tue, 18 Sep 2012 06:54:07 +0000 (23:54 -0700)]
kernel - add usched_dfly algorith, set as default for now (2)

* Bug fix to the load accounting code, which effects cpu selection.

11 years agokernel - add usched_dfly algorith, set as default for now
Matthew Dillon [Tue, 18 Sep 2012 06:17:51 +0000 (23:17 -0700)]
kernel - add usched_dfly algorith, set as default for now

* Fork usched_bsd4 for continued development.

* Rewrite the bsd4 scheduler to use per-cpu spinlocks and queues.

* Reformulate the cpu selection algorithm using the topology info.
  We now do a top-down iteration instead of a bottom-up iteration
  to calculate the best cpu node to schedule something to.

  Implements both thread push to remote queue and pull from remote queue.

* Track a load factor on a per-cpu basis.

11 years agoifpoll: Setup if_start cpuid for NPOLLING properly
Sepherosa Ziehau [Tue, 18 Sep 2012 01:08:57 +0000 (09:08 +0800)]
ifpoll: Setup if_start cpuid for NPOLLING properly

11 years agoixgbe.4: Use .Dx
Sascha Wildner [Mon, 17 Sep 2012 21:13:26 +0000 (23:13 +0200)]
ixgbe.4: Use .Dx

11 years agokernel - usched_bsd4 algorith fixes & improvements
Matthew Dillon [Mon, 17 Sep 2012 16:32:53 +0000 (09:32 -0700)]
kernel - usched_bsd4 algorith fixes & improvements

* Fix a bug in the checks loop where the loop counter would be reset
  whenever it moved to a new queue.

* Improve the min_level_lwp selec code by also testing lwp_priority.

* Add code to kick the helper threads for the processes that weren't
  selected.

* Clean up some code syntax.

11 years agomsgport.9: Some mdoc and typo fixes.
Sascha Wildner [Mon, 17 Sep 2012 14:51:34 +0000 (16:51 +0200)]
msgport.9: Some mdoc and typo fixes.

11 years agoem.4: Mention TSO support.
Sascha Wildner [Mon, 17 Sep 2012 13:49:58 +0000 (15:49 +0200)]
em.4: Mention TSO support.

11 years agoixgbe: Remove the link handler tasklet
François Tigeot [Tue, 11 Sep 2012 20:25:27 +0000 (22:25 +0200)]
ixgbe: Remove the link handler tasklet

There's no need for it, the job can be done just as well in regular
interrupt threads.

11 years agokernel: Remove some unused variables.
Sascha Wildner [Mon, 17 Sep 2012 12:22:02 +0000 (14:22 +0200)]
kernel: Remove some unused variables.

11 years agokernel/ipx: Remove #ifdef lint checks (and add #endif comments).
Sascha Wildner [Mon, 17 Sep 2012 12:20:13 +0000 (14:20 +0200)]
kernel/ipx: Remove #ifdef lint checks (and add #endif comments).

11 years agoifpoll: Field renaming; if_qpoll -> if_npoll
Sepherosa Ziehau [Mon, 17 Sep 2012 09:30:09 +0000 (17:30 +0800)]
ifpoll: Field renaming; if_qpoll -> if_npoll

Consistent w/ IFF_NPOLLING flag

11 years agoifpoll: Don't limit number of CPUs that perform polling
Sepherosa Ziehau [Mon, 17 Sep 2012 09:13:32 +0000 (17:13 +0800)]
ifpoll: Don't limit number of CPUs that perform polling

11 years agomsgport.9: Catch up with recent changes to lwkt_initport_spin().
Nuno Antunes [Mon, 17 Sep 2012 05:16:52 +0000 (06:16 +0100)]
msgport.9: Catch up with recent changes to lwkt_initport_spin().

11 years agomsgport: Always save owner thread for threads' msgports
Sepherosa Ziehau [Mon, 17 Sep 2012 01:29:28 +0000 (09:29 +0800)]
msgport: Always save owner thread for threads' msgports

This unbreaks the assertion in dropmsg for spin msgport.  Also for shared
spin msgport don't allow dropmsg.

While im here, add comment for mp_dropmsg and adjust comment about mpu_td

Reported-by: pavalos@
11 years agofortune(6)/mutex.9: s/is is/is/
Sascha Wildner [Mon, 17 Sep 2012 00:55:36 +0000 (02:55 +0200)]
fortune(6)/mutex.9: s/is is/is/

11 years agoem.4: Add some words about emx(4) and create MLINKS.
Sascha Wildner [Mon, 17 Sep 2012 00:26:06 +0000 (02:26 +0200)]
em.4: Add some words about emx(4) and create MLINKS.

11 years agoUpdate the pciconf(8) database.
Sascha Wildner [Sun, 16 Sep 2012 15:25:58 +0000 (17:25 +0200)]
Update the pciconf(8) database.

September 14, 2012 snapshot from http://pciids.sourceforge.net/

11 years agokernel - Add vm.read_shortcut_enable
Matthew Dillon [Sun, 16 Sep 2012 03:52:45 +0000 (20:52 -0700)]
kernel - Add vm.read_shortcut_enable

* Add vm.read_shortcut_enable (disabled by default for now).  Set to 1 to
  enable this feature.

  This enables a helper function which HAMMER1 now uses to short-cut read()
  operations on files.  This feature only works on x86-64.

* When enabled this feature allows file read() requests to be satisfied
  directly from the VM page cache using lwbuf's, completely bypassing the
  buffer cache and also bypassing most of the VFS's VOP_READ code.

  The result is an approximate doubling of read() performance in cases
  where the buffer cache is too small to fit the hot data set, but the VM
  page cache is not.

  This feature is able to avoid the buffer cache and thus prevent buffer
  cycling within it which, due to the constant installation and
  deinstallation of pages in KVM cause a great deal of SMP page table
  page invalidations.

11 years agohammer - Adjust record and dirtybuf limits to handle large buffer caches
Matthew Dillon [Sun, 16 Sep 2012 01:43:26 +0000 (18:43 -0700)]
hammer - Adjust record and dirtybuf limits to handle large buffer caches

* Adjust record and dirtybuf limits such that they don't blow up a hammer
  volume if the system's buffer cache is very large.

11 years agortld: Don't call process_nodelete with NULL object pointer
John Marino [Sat, 15 Sep 2012 21:36:39 +0000 (23:36 +0200)]
rtld: Don't call process_nodelete with NULL object pointer

If object loading and relocation fail, the obj pointer will be NULL when
then process_nodelete function is reached.  A crash will occur if the
function is called with a null pointer, so ensure that it doesn't.

Taken-from: FreeBSD SVN 239470 (20 Aug 2012)

11 years agokernel - fix builds
Matthew Dillon [Sat, 15 Sep 2012 20:50:38 +0000 (13:50 -0700)]
kernel - fix builds

* Fix a few kprintf()'d %d -> %ld for nbufs.

Reported-by: vsrinivas
11 years agosystat - remove bounds on buffer cache nbuf count for 64-bit
Matthew Dillon [Sat, 15 Sep 2012 17:04:30 +0000 (10:04 -0700)]
systat - remove bounds on buffer cache nbuf count for 64-bit

* Adjust systat to the new kernel reality.

11 years agokernel - remove bounds on buffer cache nbuf count for 64-bit
Matthew Dillon [Sat, 15 Sep 2012 17:00:54 +0000 (10:00 -0700)]
kernel - remove bounds on buffer cache nbuf count for 64-bit

* Remove arbitrary 1GB buffer cache limitation

* Adjusted numerous 'int' fields to 'long'.  Even though nbuf is not
  likely to exceed 2 billion buffers, byte calculations using the
  variable began overflowing so just convert that and various other
  variables to long.

* Make sure we don't blow-out the temporary valloc() space in early boot
  due to nbufs being too large.

* Unbound 'kern.nbuf' specifications in /boot/loader.conf as well.

11 years agoipcs - Fix kvm accesses for new semid structures
Matthew Dillon [Sat, 15 Sep 2012 07:11:04 +0000 (00:11 -0700)]
ipcs - Fix kvm accesses for new semid structures

* semid_ds -> semid_pool, primarily.

11 years agokernel - Implement segment pmap optimizations for x86-64 (6)
Matthew Dillon [Sat, 15 Sep 2012 06:44:10 +0000 (23:44 -0700)]
kernel - Implement segment pmap optimizations for x86-64 (6)

* Improve process exit.  When the last process referencing a shared
  anonymous memory VM object exits the kernel destroys the object
  and its shared pmap.

  Removal of pages from the shared pmap was causing the system to IPI
  EVERY cpu for EACH pte.  Needless to say this caused a process to take
  ~2 minutes to remove a ~6GB shared segment.  Optimize this case by
  not bothering the do the IPI/invlpg invalidations since the pmap is not
  actually active.

* This also applies to any exiting process.  When cleaning out the pmap
  we no longer invlpg each pte, since nobody is referencing the pmap except
  the current thread in the kernel doing the exit.  It will simply issue
  a cpu_invltlb() when it is all done.

11 years agokernel - Enhance sysv semaphore performance (2)
Matthew Dillon [Sat, 15 Sep 2012 06:43:04 +0000 (23:43 -0700)]
kernel - Enhance sysv semaphore performance (2)

* Change SEMMAP default from 30 to 128.  Also note that most other
  semaphore-related defaults were increased significantly in prior
  commits.

11 years agokernel - Enhance sysv semaphore performance
Matthew Dillon [Sat, 15 Sep 2012 05:05:13 +0000 (22:05 -0700)]
kernel - Enhance sysv semaphore performance

* Make the locks used by the semaphore module significantly more
  fine-grained.

* Reorganize the semaphore related structures significantly to
  reduce locking conflicts.

* Reduce overhead and improve performance for handling SEM_UNDO semops.

11 years agokernel - Add kern.gettimeofday_quick sysctl
Matthew Dillon [Sat, 15 Sep 2012 05:03:39 +0000 (22:03 -0700)]
kernel - Add kern.gettimeofday_quick sysctl

* Add a sysctl that forces gettimeofday() to return a coarse timestamp
  instead of a fine-grained timestamp.

  This sysctl is mainly intended for performance debugging.

11 years agokernel - Use pool tokens to protect unix domain PCBs (2)
Matthew Dillon [Fri, 14 Sep 2012 17:13:39 +0000 (10:13 -0700)]
kernel - Use pool tokens to protect unix domain PCBs (2)

* Fix mismatched token unlock in last commit.

11 years agokernel - Use pool tokens to protect unix domain PCBs
Matthew Dillon [Fri, 14 Sep 2012 16:10:06 +0000 (09:10 -0700)]
kernel - Use pool tokens to protect unix domain PCBs

* The read, status, and write paths now use per-pcb pool tokens
  instead of the global unp_token.  The global token is still used
  for accept, connect, disconnect, etc.

* General semantics for making this SMP safe is to obtain a pointer
  to the unp from so->so_pcb, then obtain the related pool token,
  then re-check that so->so_pcb still equals unp.

* Pool token protects the peer pointer, unp->unp_conn.  Any change
  to unp->unp_conn requires both the pool token and the global token.

* This should improve concurrent reading and writing w/unix domain
  sockets.

11 years agokernel - Fix unix domain socket portfn routing
Matthew Dillon [Fri, 14 Sep 2012 08:47:19 +0000 (01:47 -0700)]
kernel - Fix unix domain socket portfn routing

* sonewconn_faddr() / sonewconn() was improperly overriding the sync_port
  setting for unix domain sockets, causing unnecessary netmsg traffic to
  the netisr threads.

* This should significantly improve unix domain socket performance.

With-help-from: sephe

11 years agopci/mptable: Let parent route the interrupt before using the intline
Sepherosa Ziehau [Fri, 14 Sep 2012 01:48:28 +0000 (09:48 +0800)]
pci/mptable: Let parent route the interrupt before using the intline

Tested-by: swildner@
11 years agols - Add -I to reverse -A
Matthew Dillon [Fri, 14 Sep 2012 00:51:13 +0000 (17:51 -0700)]
ls - Add -I to reverse -A

* ls implies -A when run as root. Add the -I option
  which disables this behavior.

* Note that -A and -I will override each other on the
  command line.

11 years agokernel - Implement segment pmap optimizations for x86-64 (5)
Matthew Dillon [Thu, 13 Sep 2012 20:47:03 +0000 (13:47 -0700)]
kernel - Implement segment pmap optimizations for x86-64 (5)

* Fix self-deadlock in pmap_remove_*() sequence.  The sequence calls
  pmap_remove_callback() -> pmap_release_pv(proc_pt_pv) but the caller
  may already be holding the parent, proc_pd_pv, locked.  If
  pmap_release_pv() needs to get the parent it deadlocks.

  Fixed by passing the parent into pmap_release_pv() for this case.

11 years agokernel - Implement segment pmap optimizations for x86-64 (4)
Matthew Dillon [Thu, 13 Sep 2012 18:39:11 +0000 (11:39 -0700)]
kernel - Implement segment pmap optimizations for x86-64 (4)

* Fix pmap_pte_quick() when it is called on a VM object's simple pmap.
  Fixes a panic during postgres init w/ postgres/mmap.  Simple pmaps
  do not have PDP or PML4 pages or pv_entry's, only from PD on down.

* Do some minor API work on the pte-indexing functions.

11 years agoMerge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
Matthew Dillon [Thu, 13 Sep 2012 18:38:22 +0000 (11:38 -0700)]
Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly

11 years agokernel - Implement segment pmap optimizations for x86-64 (3)
Matthew Dillon [Thu, 13 Sep 2012 17:58:19 +0000 (10:58 -0700)]
kernel - Implement segment pmap optimizations for x86-64 (3)

* Fix pmap optimization bugs triggered by XORG (startx) and postgres/mmap

* The simple-mode pmaps embedded in VM objects do not have the PML4 or PDP
  layer.  This caused pmap_scan() to miss pages, resulting in an assertion
  and panic during object frees if the objects were large enough.

* Improve postgres 9.2/mmap, still more work to go.

11 years agoSync zoneinfo database with tzdata2012f from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Thu, 13 Sep 2012 17:06:15 +0000 (19:06 +0200)]
Sync zoneinfo database with tzdata2012f from ftp://ftp.iana.org/tz/releases

* australasia (Pacific/Fiji): Fiji DST is October 21 through January 20
    this year.  (Thanks to Steffen Thorsen.)

* Theory: Correct a typo.

11 years agoExpand a comment in lwkt_switch().
Nuno Antunes [Thu, 13 Sep 2012 07:07:08 +0000 (08:07 +0100)]
Expand a comment in lwkt_switch().

11 years agokernel: remove useless for (;;).
Nuno Antunes [Wed, 12 Sep 2012 11:25:39 +0000 (12:25 +0100)]
kernel: remove useless for (;;).

Discussed-with: dillon

11 years agokernel: Use NULL instead of 0 for pointers, part 2/x.
Sascha Wildner [Thu, 13 Sep 2012 09:57:19 +0000 (11:57 +0200)]
kernel: Use NULL instead of 0 for pointers, part 2/x.

Found-with: Coccinelle (http://coccinelle.lip6.fr/)

11 years agokernel - Implement segment pmap optimizations for x86-64 (2)
Matthew Dillon [Thu, 13 Sep 2012 09:38:36 +0000 (02:38 -0700)]
kernel - Implement segment pmap optimizations for x86-64 (2)

* Reorder code to fix an assertion when a non-optimized PT belonging
  to the process pmap needs to be replaced by an optimized PT belonging
  to a shared pmap.

Reported-by: ftigeot
11 years agokernel - Add sysctls and tunables for [ALT_]BREAK_TO_DEBUGGER, change
Matthew Dillon [Thu, 13 Sep 2012 09:10:38 +0000 (02:10 -0700)]
kernel - Add sysctls and tunables for [ALT_]BREAK_TO_DEBUGGER, change
 serial console

* Add kern.break_to_debugger and kern.alt_break_to_debugger sysctls and
  /boot/loader.conf tunables.

* Allows enabling of these features without having to specify the
  related options in the kernel config.

* Do not override current sio settings when checking, inputting, and
  outputing characters via the console functions.  The serial port
  will be set up initially according to the console specs.

11 years agokernel - Implement segment pmap optimizations for x86-64 (1)
Matthew Dillon [Thu, 13 Sep 2012 07:23:00 +0000 (00:23 -0700)]
kernel - Implement segment pmap optimizations for x86-64 (1)

* Relax the mmap() size requirement when auto-aligning the address.
  Also auto-align to a segment boundary if the size is > 16 * SEG_SIZE.
  It previously only allowed size to be an exact multiple of SEG_SIZE.

* Some pages at the end won't be optimized, but the bulk of the mmap()
  will be.

11 years agokernel - Implement segment pmap optimizations for x86-64
Matthew Dillon [Thu, 13 Sep 2012 01:25:19 +0000 (18:25 -0700)]
kernel - Implement segment pmap optimizations for x86-64

* Implement 2MB segment optimizations for x86-64.  Any shared read-only
  or read-write VM object mapped into memory, including physical objects
  (so both sysv_shm and mmap), which is a multiple of the segment size
  and segment-aligned can be optimized.

* Enable with sysctl machdep.pmap_mmu_optimize=1

  Default is off for now.  This is an experimental feature.

* It works as follows:  A VM object which is large enough will, when VM
  faults are generated, store a truncated pmap (PD, PT, and PTEs) in the
  VM object itself.

  VM faults whos vm_map_entry's can be optimized will cause the PTE, PT,
  and also the PD (for now) to be stored in a pmap embedded in the VM_OBJECT,
  instead of in the process pmap.

  The process pmap then creates PT entry in the PD page table that points
  to the PT page table page stored in the VM_OBJECT's pmap.

* This removes nearly all page table overhead from fork()'d processes or
  even unrelated process which massively share data via mmap() or sysv_shm.
  We still recommend using sysctl kern.ipc.shm_use_phys=1 (which is now
  the default), which also removes the PV entries associated with the
  shared pmap.  However, with this optimization PV entries are no longer
  a big issue since they will not be replicated in each process, only in
  the common pmap stored in the VM_OBJECT.

* Features of this optimization:

  * Number of PV entries is reduced to approximately the number of live
    pages and no longer multiplied by the number of processes separately
    mapping the shared memory.

  * One process faulting in a page naturally makes the PTE available to
    all other processes mapping the same shared memory.  The other processes
    do not have to fault that same page in.

  * Page tables survive process exit and restart.

  * Once page tables are populated and cached, any new process that maps
    the shared memory will take far fewer faults because each fault will
    bring in an ENTIRE page table.  Postgres w/ 64-clients, VM fault rate
    was observed to drop from 1M faults/sec to less than 500 at startup,
    and during the run the fault rates dropped from a steady decline into
    the hundreds of thousands into an instant decline to virtually zero
    VM faults.

  * We no longer have to depend on sysv_shm to optimize the MMU.

  * CPU caches will do a better job caching page tables since most of
    them are now themselves shared.  Even when we invltlb, more of the
    page tables will be in the L1, L2, and L3 caches.

* EXPERIMENTAL!!!!!

11 years agokernel - Segment-align mmap and sysv_shm when possible
Matthew Dillon [Thu, 13 Sep 2012 01:20:51 +0000 (18:20 -0700)]
kernel - Segment-align mmap and sysv_shm when possible

* Segment align mmap and sysv_shm mappings which are large enough
  and whos size is a multiple of the segment-size.

  NOTE: MAP_FIXED mappings will not be segment-aligned, but the
optimization will sitll work if the passed address is already
segment-aligned.

* This will allow them to be optimized automatically by
  machdep.pmap_mmu_optimize.

11 years agokernel: Remove unused headers.
Sascha Wildner [Wed, 12 Sep 2012 21:42:18 +0000 (23:42 +0200)]
kernel: Remove unused headers.

11 years agokernel: Remove some unused variables.
Sascha Wildner [Wed, 12 Sep 2012 17:58:43 +0000 (19:58 +0200)]
kernel: Remove some unused variables.

11 years agohammer(8): add HAMMER_RSH environment variable support.
Chris Turner [Wed, 12 Sep 2012 13:11:31 +0000 (13:11 +0000)]
hammer(8): add HAMMER_RSH environment variable support.

Add support for a HAMMER_RSH environment variable which can be used
to select an alternate remote shell to be used for hammer remote operations,
change remote shell invocation to rsh(1) style '-l user host' instead of
ssh-style user@host to permit usage of rsh(1) as an alternate HAMMER_RSH
without the need for a wrapper script. Also change exec call of subshell
to use execvp instead of a hardcoded path to facillitate this change.

Update hammer.8 docs, along with minor formatting fix to environment
variable summary header sentence.

11 years agohammer - Add ssh-remote directive
Matthew Dillon [Tue, 11 Sep 2012 21:39:17 +0000 (14:39 -0700)]
hammer - Add ssh-remote directive

* Adds a feature that allows you to set up a command="..." prefix for a
  ssh key in your ~/.ssh/authorized_keys file that only runs the hammer
  utility and only with specific commands and filesystem paths.

  For example:

  command="/sbin/hammer ssh-remote mirror-read,mirror-write /path/" ssh-rsa...

  Currently requires a trailing '/' if you want to restrict the path to
  a subdirectory.  Multiple commands can be listed but the filesystem path
  restriction is only currently tested for mirror-read and mirror-write.

* This allows ssh to be used for mirroring without having to give shell
  access to the remote.

11 years agohammer - Add scoreboard file option
Matthew Dillon [Tue, 11 Sep 2012 16:54:02 +0000 (09:54 -0700)]
hammer - Add scoreboard file option

* Add -e <scoreboardfile> option for mirror-stream, so one can see the
  progress of mirror-streams running in the background.

11 years agonetisr: rename cpu_portfn() to netisr_portfn().
Nuno Antunes [Tue, 11 Sep 2012 10:49:51 +0000 (11:49 +0100)]
netisr: rename cpu_portfn() to netisr_portfn().

No functional change.

Searched and replaced with:
find sys/ -type f -exec sed -i "" 's/cpu_portfn/netisr_portfn/g' '{}' \;