dragonfly.git
12 years agokernel - Major vm_page, lwkt thread, and other changes
Matthew Dillon [Wed, 26 Oct 2011 18:26:48 +0000 (11:26 -0700)]
kernel - Major vm_page, lwkt thread, and other changes

* Remove the rest of the LWKT fairq code, it may be added back in a different
  form later.  Go back to the strict priority model with round-robining
  of same-priority LWKT threads.

  Currently the model scans gd_tdrunq for sort insertion, which is probably
  a bit too inefficient.

* Refactor the LWKT scheduler clock.  The round-robining is now based on
  the head of gd->gd_tdrunq and the lwkt_schedulerclock() function will
  move it.  When a thread not on the head is selected to run (because
  the head is contending on a token), the round-robin tick will force a
  resched on the next tick.  As before, we never reschedule-ahead the
  kernel scheduler helper thread or threads that have already dropped
  to a user priority.

* The token code now tries a little harder to acquire the token before
  giving up, controllable with lwkt.token_spin and lwkt.token_delay
  (token_spin is the number of times to try and token_delay is the delay
  between tries, in nanoseconds).

* Fix a serious bug in usched_bsd4.c which improperly reassigned the 'dd'
  variable and caused the scheduler helper to monitor the wrong dd
  structure.

* Refactor the vm_page coloring code.  On SMP systems we now use the
  coloring code to implement cpu localization when allocating pages.
  The pages are still 'twisted' based on their physical address so both
  functions are served, but cpu localization is now the more important
  function.

* Implement NON-OBJECT vm_page allocations.  NULL may now be passed, which
  allocates a VM page unassociated with any VM object.  This will be
  used by the pmap code.

* Implement cpu localization for zalloc() and friends.  This removes a major
  contention point when handling concurrent VM faults.  The only major
  contention point left is the PQ_INACTIVE vm_page_queues[] queue.

* Temporarily remove the VM_ALLOC_ZERO request.  This will probably be
  reenabled in a later commit.

* Remove MSGF_NORESCHED (it is not being used) and simplify related
  lwkt scheduler functions.

* schedcpu_stats() and schedcpu_resource() no longer stall the callout
  kernel threads when scanning allproc, if they are unable to acquire
  proc->p_token.

* Move the need_lwkt_resched() from hardclock() to lwkt_schedulerclock()
  (which hardclock() calls).

12 years agokernel - Make the itimers MPSAFE
Matthew Dillon [Wed, 26 Oct 2011 18:23:03 +0000 (11:23 -0700)]
kernel - Make the itimers MPSAFE

* Use the per-process p_token instead of the MP lock for per-process
  itimers.

12 years agokernel - Optimize spinlocks for 48-core contention
Matthew Dillon [Wed, 26 Oct 2011 18:18:54 +0000 (11:18 -0700)]
kernel - Optimize spinlocks for 48-core contention

* Change the spinlock algorithm to do a read-test before atomic_swap_int().
  This has no effect on single-chip cpus (tested on phenom II quad-core),
  but has a HUGE HUGE HUGE effect on multi-chip/many-core systems.  On
  monster (48-core opteron / 4 x 12-core chips) concurrent kernel compile
  time is reduced from 170 seconds to 75 seconds with this one change.
  That's well over 100%.

  The reason the change is important is because it unloads the hardware
  cache coherency bus and communication by creating a closed-loop with
  the pre-read, which essentially passively waits for the cache update
  instead of actively issuing a locked bus cycle memory op.  This prevents
  total armagheddon on the memory busses when a substantial number of
  cores are doing real work.

* Increase the number of pool spinlocks from 1024 to 8192.  We need them
  now that vm_page's use pool spinlocks.

12 years agokernel - limit allproc_scan() to snapshot
Matthew Dillon [Wed, 26 Oct 2011 18:15:47 +0000 (11:15 -0700)]
kernel - limit allproc_scan() to snapshot

* Limit the allproc_scan() to (roughly) a snapshot of nprocs processes.
  If we don't do this it is possible for the scan to race fork/exec'ing
  programs and essentially run forever.

12 years agokernel - Fix cumulative nprocs bug
Matthew Dillon [Wed, 26 Oct 2011 18:13:56 +0000 (11:13 -0700)]
kernel - Fix cumulative nprocs bug

* nprocs requires atomic ops now that the related code is MPSAFE.

* Fixes issue reported w/pkgbox64 of the machine running out of processes
  unexpectedly.

* Also move a wakeup() to outside p->p_token to improve concurrency and
  other minor adjustments.

12 years agokernel - callout_init() -> callout_init_mp() in selected cases
Matthew Dillon [Wed, 26 Oct 2011 18:12:17 +0000 (11:12 -0700)]
kernel - callout_init() -> callout_init_mp() in selected cases

* Use callout_init_mp() in numerous cases where the BGL is not
  needed.  There are still a lot more left.

12 years agolibc -- string: strspn should return 0 for empty match strings, not string len.
Venkatesh Srinivas [Wed, 26 Oct 2011 14:37:39 +0000 (07:37 -0700)]
libc -- string: strspn should return 0 for empty match strings, not string len.

Reported-by: lentferj
12 years agopf.conf.5/swapcache.8: Fix some typos (verses -> versus).
Sascha Wildner [Wed, 26 Oct 2011 13:11:56 +0000 (15:11 +0200)]
pf.conf.5/swapcache.8: Fix some typos (verses -> versus).

12 years agolibrt -- aio: lio_listio: Do not dereference NULL sigevp.
Venkatesh Srinivas [Wed, 26 Oct 2011 12:35:59 +0000 (05:35 -0700)]
librt -- aio: lio_listio: Do not dereference NULL sigevp.

Reported-by: Z`
12 years agolibhammer - HAMMER filesystem library.
Antonio Huete Jimenez [Tue, 25 Oct 2011 22:34:24 +0000 (00:34 +0200)]
libhammer - HAMMER filesystem library.

Initial work to bring a library to help operating
HAMMER filesystems from userland.

It's barebones as of now, only "info" directive is
adapted, progressively the rest of the directives
will be migrated

Help-from: @swildner, @sjg

12 years agokernel -- lwbuf: Convert cmpxchg loop to LOCK OR; we are just setting a bit.
Venkatesh Srinivas [Tue, 25 Oct 2011 17:48:20 +0000 (10:48 -0700)]
kernel -- lwbuf: Convert cmpxchg loop to LOCK OR; we are just setting a bit.

12 years agoSync zoneinfo database with tzdata2011m from munnari.oz.au
Sascha Wildner [Tue, 25 Oct 2011 13:26:02 +0000 (15:26 +0200)]
Sync zoneinfo database with tzdata2011m from munnari.oz.au

asia:           8.68 -> 8.69
australasia:    8.27 -> 8.28
backward:       8.9  -> 8.10
europe:         8.38 -> 8.39
northamerica:   8.49 -> 8.50
southamerica:   8.50 -> 8.52
zone.tab:       8.49 -> 8.50

* asia, australasia, northamerica: Bump version for tzdata2011l.

* europe, backward: Pridnestrovian Moldavian Republic (Europe/Tiraspol)
    has followed much of Russia, and will retain "summer time" year round
    (that is no time transition is due Oct 30). This reintroduces a zone
    that had earlier been removed, and so removes the "backward" link.

    On the other hand, Ukraine have decided not to follow, so the change
    which had been made in preparation for that in tzdata2011k is now
    reverted, and there will be a transition on Oct 30.

* southamerica: The change to Bahia, Brazil, that introduced summer time
    (following the regular Brazil rules, so commencing this year on
    Oct 16 - last SUnday) that was mooted before tzdata2011l was released,
    but withdrawn because the change was not yet official, has now been
    ratified.

12 years agoperiodic/daily: Fix the check for denied zone transfers (AXFR and IXFR).
Sascha Wildner [Tue, 25 Oct 2011 12:08:22 +0000 (14:08 +0200)]
periodic/daily: Fix the check for denied zone transfers (AXFR and IXFR).

Just use grep -E here (fgrep -E seems to have stopped working at some
point anyway).

12 years agotmpfs: Implement vptofh, so programs open files in tmpfs could coredump
Sepherosa Ziehau [Tue, 25 Oct 2011 11:57:33 +0000 (19:57 +0800)]
tmpfs: Implement vptofh, so programs open files in tmpfs could coredump

Submitted-by: Tim Bissont <bissont@mac.com>
12 years agokernel - Increase VM page free minimums for allocations
Matthew Dillon [Tue, 25 Oct 2011 04:53:43 +0000 (21:53 -0700)]
kernel - Increase VM page free minimums for allocations

* Recent work removed the global vm_token and moved to per-vm_page_queue
  spin locks, which allows cpus to allocate VM pages concurrently.  This
  could result in a situation where remaining free pages got blown out
  without giving the system a chance to replentish them.

* Symptoms included the BUF/BIO system complaining of memory exhaustion
  and the pageout daemon deadlocking on low memory (which would deadlock
  the whole machine in a memory-exhausted state).

* Increase minimums to prevent this.  In particular, the interrupt_free_min
  was previously hardwired to a value of 2.. as in 2 pages (8192 bytes),
  which is an excessively low value.  The new calculations place this value
  (typically) around a few-hundred pages.

12 years agoMerge branch 'devel'
Sepherosa Ziehau [Mon, 24 Oct 2011 12:10:07 +0000 (20:10 +0800)]
Merge branch 'devel'

12 years agotcp: Aggregate the mbuf in sosendtcp() a little bit
Sepherosa Ziehau [Mon, 24 Oct 2011 11:21:37 +0000 (19:21 +0800)]
tcp: Aggregate the mbuf in sosendtcp() a little bit

This greatly reducse the ipi interrupts caused by ipi sending (both
domsg and sendmsg), thus improves overall performance a bit.

net.inet.tcp.sosnd_agglim is added to tune how much mbuf should be
aggregated; it is default to 2.  Setting this sysctl to 1 restores
the old behaviour: one full mbuf at a time.

On Phenom 9550 (4 core, 2.2GHz):
8 parallel netperf -H 127.0.0.1 -P0 (4 runs, unit; Mbps)

                                              IPIs/s (sum of 4 core)
 1 mbuf  6735.98  6903.13  6971.89  7056.66   ~400K
 2 mbuf  7675.47  7757.28  7815.45  7514.50   ~240K
 4 mbuf  7895.33  7584.22  7704.12  7723.33   ~180K
 8 mbuf  8006.94  8077.87  7701.23  8061.12   ~120K
16 mbuf  8151.68  8023.03  7972.42  8046.13   ~100K

The default value (2) for the sosnd_agglim improve the whole
performance by ~10%.  IPI rate is also reduce greatly.

It has no obvious impact on 1000BaseT or 100baseTX network performace.

12 years agotcp: Let sosendtcp() call tcp_usrreq.pru_send asynchronous
Sepherosa Ziehau [Sun, 23 Oct 2011 12:55:16 +0000 (20:55 +0800)]
tcp: Let sosendtcp() call tcp_usrreq.pru_send asynchronous

- Embed netmsg_pru_send into mbuf.m_hdr, which shares the space with
  netmsg_pru_packet.
- Use the newly added netmsg_pru_send in mbuf to perform asynchronous
  pru_send.  For asynchronous pru_send, PRUS_NOREPLY is added, which
  prevents pru_send to reply the message.
- In sosendtcp(), if we have more data to call pru_send, we call it
  asynchronously.  The last piece of data or OOB data will still be
  passed to pru_send synchronously.

On Phenom 9550 (4 core, 2.2GHz):
8 parallel netperf -H 127.0.0.1 (4 runs, unit: Mbps)

old  5863.85  5773.13  5534.14  5506.72
new  6735.98  6903.13  6971.89  7056.66

This give ~20% performance improvement.

It has no obvious impact on 1000BaseT or 100baseTX network performace.

12 years agotcp: Add sosendtcp for further optimization
Sepherosa Ziehau [Sun, 23 Oct 2011 10:30:39 +0000 (18:30 +0800)]
tcp: Add sosendtcp for further optimization

Currently:
- Cleanup the 'atomic' logic
- Free the 'control' earlier
- Remove the "implied connection" related bits

12 years agoRemove some EISA remains in a couple of manual pages.
Sascha Wildner [Sun, 23 Oct 2011 06:13:51 +0000 (08:13 +0200)]
Remove some EISA remains in a couple of manual pages.

12 years agotest - Little program to list processes from coredumps or kmem.
Antonio Huete Jimenez [Sat, 22 Oct 2011 21:21:49 +0000 (23:21 +0200)]
test - Little program to list processes from coredumps or kmem.

12 years agokern - Do not allow calls to vmspace_president_count() from userland.
Antonio Huete Jimenez [Sat, 22 Oct 2011 10:20:29 +0000 (12:20 +0200)]
kern - Do not allow calls to vmspace_president_count() from userland.

- Processes' vm_map is not read in by kvm_proclist() thus we cannot
  call vmspace_president_count() which entirely relies on that.
- This fixes segfaults in ps(1), w(1) and fstat(1) when using -M
  and -N parameters.

Help-from: @corecode

12 years agokernel - Fix null-pointer crash in i386/pmap.c
Matthew Dillon [Sat, 22 Oct 2011 21:07:29 +0000 (14:07 -0700)]
kernel - Fix null-pointer crash in i386/pmap.c

* Related to recent work, check that m->object is not NULL

12 years agoaccept_filter.9: Add missing include.
Sascha Wildner [Sat, 22 Oct 2011 18:13:02 +0000 (20:13 +0200)]
accept_filter.9: Add missing include.

12 years agotcp: We have dropped T/TCP for a long time; remove the implied connection
Sepherosa Ziehau [Sat, 22 Oct 2011 11:49:01 +0000 (19:49 +0800)]
tcp: We have dropped T/TCP for a long time; remove the implied connection

The hack padding at the end of the struct netmsg_pru_send is also removed,
since connect will not happen on the sending path at all.

12 years agotcp: We have dropped T/TCP for a long time; remove the implied connection
Sepherosa Ziehau [Sat, 22 Oct 2011 11:49:01 +0000 (19:49 +0800)]
tcp: We have dropped T/TCP for a long time; remove the implied connection

The hack padding at the end of the struct netmsg_pru_send is also removed,
since connect will not happen on the sending path at all.

12 years agoRemove some duplicate includes in sys/kern.
Sascha Wildner [Sat, 22 Oct 2011 09:27:10 +0000 (11:27 +0200)]
Remove some duplicate includes in sys/kern.

12 years agoDRM - Fix LINT build
Samuel J. Greear [Fri, 21 Oct 2011 04:31:34 +0000 (22:31 -0600)]
DRM - Fix LINT build

12 years agoDRM from FreeBSD current, tested for r600
David Shao [Fri, 9 Apr 2010 06:29:53 +0000 (23:29 -0700)]
DRM from FreeBSD current, tested for r600

Author:    David Shao <davshao@gmail.com>

12 years agokernel: Move GPL'd kernel files to sys/gnu to have them all in one place.
Sascha Wildner [Fri, 21 Oct 2011 02:09:25 +0000 (04:09 +0200)]
kernel: Move GPL'd kernel files to sys/gnu to have them all in one place.

This affects files in sys/dev/sound/pci/gnu and sys/vfs/gnu/ext2fs.

sys/gnu is analogous to the gnu directory for userland, i.e. below it, we
follow the same hierarchy as in /usr/src/sys.

This commit changes the location of the ext2fs headers, which are public,
so I've bumped __DragonFly_version in order to have something to patch
against in pkgsrc, in case this causes build breakage for any packages.

12 years agoSome cleanup after addition of TRIM support.
Sascha Wildner [Thu, 20 Oct 2011 04:30:42 +0000 (06:30 +0200)]
Some cleanup after addition of TRIM support.

* Remove unused -R option in newfs(8).

* Miscellaneous small cosmetics.

12 years agospinlock.9: A little cleanup.
Sascha Wildner [Thu, 20 Oct 2011 04:26:38 +0000 (06:26 +0200)]
spinlock.9: A little cleanup.

12 years agoRevert "LINT/LINT64: Add ext2fs."
Sascha Wildner [Wed, 19 Oct 2011 18:44:43 +0000 (20:44 +0200)]
Revert "LINT/LINT64: Add ext2fs."

This reverts commit 66e5c582e6f9262370509511dd7f4f1f1793df1b.

I overlooked that it was already present.

12 years agoLINT/LINT64: Add ext2fs.
Sascha Wildner [Wed, 19 Oct 2011 18:40:09 +0000 (20:40 +0200)]
LINT/LINT64: Add ext2fs.

12 years agoLINT/LINT64: Sort filesystems.
Sascha Wildner [Wed, 19 Oct 2011 18:25:49 +0000 (20:25 +0200)]
LINT/LINT64: Sort filesystems.

12 years agokernel - Move a vm_object_pip_wakeup() call
Matthew Dillon [Wed, 19 Oct 2011 15:22:26 +0000 (08:22 -0700)]
kernel - Move a vm_object_pip_wakeup() call

* Move a vm_object_pip_wakeup() call from before the related vm_page has
  been woken up to afterwords.  Since the vm_page was already busied I
  don't think this fixes anything in particular, but it is more correct.

12 years agokernel - Fix long-standing vfork/exec bug
Matthew Dillon [Wed, 19 Oct 2011 15:19:01 +0000 (08:19 -0700)]
kernel - Fix long-standing vfork/exec bug

* Fix an issue where the parent process can get stuck in the "ppwait"
  state due to a tsleep/wakeup race with its child.

* This bug was present but masked by other tokens prior to a few patches
  ago.  With those tokens now gone this bug reared its face.

12 years agokernel - Increase exec args cache on 64-bit boxes
Matthew Dillon [Wed, 19 Oct 2011 15:17:35 +0000 (08:17 -0700)]
kernel - Increase exec args cache on 64-bit boxes

* Increase the exec args cache on 64-bit boxes with more than 4G of ram.
  This increases the number of concurrent applicationss which can be
  undergoing an exec.

12 years agokernel - Fix latency issue with many cores contending on a token
Matthew Dillon [Wed, 19 Oct 2011 04:06:49 +0000 (21:06 -0700)]
kernel - Fix latency issue with many cores contending on a token

* Fix a latency issue when many cores are contending on the same token.
  This can be tested e.g. by setting an interface to use polling mode
  and then pinging it from the outside.  Ping times in excess of 60 seconds
  (yes, seconds!) could occur.

* The problem turns out to be in usched_bsd4.c in the loop that tries to
  acquire the current process designation.  This loop runs in a critical
  section (and probably its caller too) and while it checks for the
  LWKT thread reschedule flag it fails to call splz() to process pending
  interrupts (like IPIs) that might SET the flag.

  Adding a single splz() prior to the lwkt reschedule check greatly
  reduces the latency problem.

12 years agokernel - pmap_spin needed for UP build
Matthew Dillon [Wed, 19 Oct 2011 01:12:25 +0000 (18:12 -0700)]
kernel - pmap_spin needed for UP build

* Place the pmap_spin declaration outside the #ifdef SMP sequence for UP.

12 years agokernel - Major SMP performance patch / VM system, bus-fault/seg-fault fixes
Matthew Dillon [Tue, 18 Oct 2011 17:36:11 +0000 (10:36 -0700)]
kernel - Major SMP performance patch / VM system, bus-fault/seg-fault fixes

This is a very large patch which reworks locking in the entire VM subsystem,
concentrated on VM objects and the x86-64 pmap code.  These fixes remove
nearly all the spin lock contention for non-threaded VM faults and narrows
contention for threaded VM faults to just the threads sharing the pmap.

Multi-socket many-core machines will see a 30-50% improvement in parallel
build performance (tested on a 48-core opteron), depending on how well
the build parallelizes.

As part of this work a long-standing problem on 64-bit systems where programs
would occasionally seg-fault or bus-fault for no reason has been fixed.  The
problem was related to races between vm_fault, the vm_object collapse code,
and the vm_map splitting code.

* Most uses of vm_token have been removed.  All uses of vm_spin have been
  removed.  These have been replaced with per-object tokens and per-queue
  (vm_page_queues[]) spin locks.

  Note in particular that since we still have the page coloring code the
  PQ_FREE and PQ_CACHE queues are actually many queues, individually
  spin-locked, resulting in very excellent MP page allocation and freeing
  performance.

* Reworked vm_page_lookup() and vm_object->rb_memq.  All (object,pindex)
  lookup operations are now covered by the vm_object hold/drop system,
  which utilize pool tokens on vm_objects.  Calls now require that the
  VM object be held in order to ensure a stable outcome.

  Also added vm_page_lookup_busy_wait(), vm_page_lookup_busy_try(),
  vm_page_busy_wait(), vm_page_busy_try(), and other API functions
  which integrate the PG_BUSY handling.

* Added OBJ_CHAINLOCK.  Most vm_object operations are protected by
  the vm_object_hold/drop() facility which is token-based.  Certain
  critical functions which must traverse backing_object chains use
  a hard-locking flag and lock almost the entire chain as it is traversed
  to prevent races against object deallocation, collapses, and splits.

  The last object in the chain (typically a vnode) is NOT locked in
  this manner, so concurrent faults which terminate at the same vnode will
  still have good performance.  This is important e.g. for parallel compiles
  which might be running dozens of the same compiler binary concurrently.

* Created a per vm_map token and removed most uses of vmspace_token.

* Removed the mp_lock in sys_execve().  It has not been needed in a while.

* Add kmem_lim_size() which returns approximate available memory (reduced
  by available KVM), in megabytes.  This is now used to scale up the
  slab allocator cache and the pipe buffer caches to reduce unnecessary
  global kmem operations.

* Rewrote vm_page_alloc(), various bits in vm/vm_contig.c, the swapcache
  scan code, and the pageout scan code.  These routines were rewritten
  to use the per-queue spin locks.

* Replaced the exponential backoff in the spinlock code with something
  a bit less complex and cleaned it up.

* Restructured the IPIQ func/arg1/arg2 array for better cache locality.
  Removed the per-queue ip_npoll and replaced it with a per-cpu gd_npoll,
  which is used by other cores to determine if they need to issue an
  actual hardware IPI or not.  This reduces hardware IPI issuance
  considerably (and the removal of the decontention code reduced it even
  more).

* Temporarily removed the lwkt thread fairq code and disabled a number of
  features.  These will be worked back in once we track down some of the
  remaining performance issues.

  Temproarily removed the lwkt thread resequencer for tokens for the same
  reason.  This might wind up being permanent.

  Added splz_check()s in a few critical places.

* Increased the number of pool tokens from 1024 to 4001 and went to a
  prime-number mod algorithm to reduce overlaps.

* Removed the token decontention code.  This was a bit of an eyesore and
  while it did its job when we had global locks it just gets in the way now
  that most of the global locks are gone.

  Replaced the decontention code with a fall back which acquires the
  tokens in sorted order, to guarantee that deadlocks will always be
  resolved eventually in the scheduler.

* Introduced a simplified spin-for-a-little-while function
  _lwkt_trytoken_spin() that the token code now uses rather than giving
  up immediately.

* The vfs_bio subsystem no longer uses vm_token and now uses the
  vm_object_hold/drop API for buffer cache operations, resulting
  in very good concurrency.

* Gave the vnode its own spinlock instead of sharing vp->v_lock.lk_spinlock,
  which fixes a deadlock.

* Adjusted all platform pamp.c's to handle the new main kernel APIs.  The
  i386 pmap.c is still a bit out of date but should be compatible.

* Completely rewrote very large chunks of the x86-64 pmap.c code.  The
  critical path no longer needs pmap_spin but pmap_spin itself is still
  used heavily, particularin the pv_entry handling code.

  A per-pmap token and per-pmap object are now used to serialize pmamp
  access and vm_page lookup operations when needed.

  The x86-64 pmap.c code now uses only vm_page->crit_count instead of
  both crit_count and hold_count, which fixes races against other parts of
  the kernel uses vm_page_hold().

  _pmap_allocpte() mechanics have been completely rewritten to remove
  potential races.  Much of pmap_enter() and pmap_enter_quick() has also
  been rewritten.

  Many other changes.

* The following subsystems (and probably more) no longer use the vm_token
  or vmobj_token in critical paths:

  x The swap_pager now uses the vm_object_hold/drop API instead of vm_token.

  x mmap() and vm_map/vm_mmap in general now use the vm_object_hold/drop API
    instead of vm_token.

  x vnode_pager

  x zalloc

  x vm_page handling

  x vfs_bio

  x umtx system calls

  x vm_fault and friends

* Minor fixes to fill_kinfo_proc() to deal with process scan panics (ps)
  revealed by recent global lock removals.

* lockmgr() locks no longer support LK_NOSPINWAIT.  Spin locks are
  unconditionally acquired.

* Replaced netif/e1000's spinlocks with lockmgr locks.  The spinlocks
  were not appropriate owing to the large context they were covering.

* Misc atomic ops added

12 years agosyscons - Avoid potential blocking issue.
Antonio Huete Jimenez [Tue, 18 Oct 2011 10:09:36 +0000 (12:09 +0200)]
syscons - Avoid potential blocking issue.

- kbd_ioctl() uses it's own locking via lockmgr() and the
  syscons softc is protected using a mutex, so we better
  avoid both locks at once due possible blocking issues.
  In fact, in my particular case the panic only occurs in
  real hardware, while on a VMWare VM I had a lockup.
- Only found in 4-CPU SMP setups.
- Discovered via DEBUG_LOCKS option.

DragonFly-bug: <http://bugs.dragonflybsd.org/issue2148>
Reviewed-by: @dillon, @sjg
12 years agopmap - Missing critical section when calling lwkt_ipiq_process().
Antonio Huete Jimenez [Mon, 17 Oct 2011 19:26:22 +0000 (12:26 -0700)]
pmap - Missing critical section when calling lwkt_ipiq_process().

- pmap_interlock_wait() explicitly calls lwkt_process_ipiq() which expects to
be in a critical section. We still need cpu_ccfence() to guarantee that
pmap->pm_active is always read inside the loop.

- Sync pmap_interlock_wait's comment for both i386 and x86_64.

DragonFly-bug: <http://bugs.dragonflybsd.org/issue2152>

Reviewed by: @dillon, @vsrinivas

12 years agoloader(8): Update: add more text on kenv vs local variables etc.
Thomas Nikolajsen [Sun, 16 Oct 2011 21:03:40 +0000 (23:03 +0200)]
loader(8): Update: add more text on kenv vs local variables etc.
 - Add missing kenv variables to assignment white list;
all kenv variables which are used in loader(8) source are added.
 - Inhibiting loading of acpi(4) needs to use `lunset acpi_load',
not `unset', as `loadall' uses local variables; ditto for ehci.
 - Add info to loader.8 & help files on variables ($VAR / ${VAR}) in
command arguments and assignment; these are kenv variables.
 - Add description of vfs.root.realroot
 - Fix some whitespace style(7).
DragonFly-bug: <http://bugs.dragonflybsd.org/issue2141>

12 years agolgue(4): Fix an issue and do some cleanup.
Sascha Wildner [Sun, 16 Oct 2011 16:48:57 +0000 (18:48 +0200)]
lgue(4): Fix an issue and do some cleanup.

In lgue_getmtu(), ced->wMaxSegmentSize was being referenced with ced
being either uninitialized or NULL.

While here, remove an unused variable and remove an extra 0 in the
USB_DEVICE().

12 years agoi386/sys/sbrk.S: extra "end" symbol removed
John Marino [Sat, 15 Oct 2011 09:13:22 +0000 (11:13 +0200)]
i386/sys/sbrk.S: extra "end" symbol removed

The i386 version of sbrk.S has carried an extra end symbol since the
first import.  It seems to have been an oversight to leave it there.

reported by: Francois Tigeot
Addresses: Failed heimdal build on i386

12 years agocrt1.o: provide symbol definition of environ
John Marino [Sat, 15 Oct 2011 00:45:14 +0000 (02:45 +0200)]
crt1.o: provide symbol definition of environ

Provide duplicate definition of char **environ to prevent linker choking
on version scripts ending with "local: *".

12 years agocrt1.o: provide symbol definition of __progname
John Marino [Fri, 14 Oct 2011 23:38:11 +0000 (01:38 +0200)]
crt1.o: provide symbol definition of __progname

When the linker version script requests "local: *", the linker chokes on
it because the weak __progname crt1.o symbol comes back undefined.

This is a duplicate definition to the ones provided by csu, but harmless
since the linker resolves it.

Also cleaned up some files involving libc_private.h that should have been
updated in previous changesets.

12 years agoath(4): Remove a debug message (not in FreeBSD's either).
Sascha Wildner [Fri, 14 Oct 2011 23:21:02 +0000 (01:21 +0200)]
ath(4): Remove a debug message (not in FreeBSD's either).

Reported-by: Juan Francisco Cantero Hurtado <iam@juanfra.info>
Dragonfly-bug: <http://bugs.dragonflybsd.org/issue2149>

12 years agoAdd PCI MMC/SD drivers to our standard kernel configurations.
Sascha Wildner [Fri, 14 Oct 2011 21:25:18 +0000 (23:25 +0200)]
Add PCI MMC/SD drivers to our standard kernel configurations.

12 years agosyscons - Fix comments related to do_switch_scr()
Antonio Huete Jimenez [Fri, 14 Oct 2011 19:46:49 +0000 (21:46 +0200)]
syscons - Fix comments related to do_switch_scr()

do_switch_scr() no longer releases critical sections so all
the comments remarking this are now wrong, remove them.

Most of the code uses now tty_token for the non-critical paths
and it no longer needs a critical section.

Pointed-out-by: @dillon
12 years agosyscons - Fix comment.
Antonio Huete Jimenez [Fri, 14 Oct 2011 19:19:41 +0000 (21:19 +0200)]
syscons - Fix comment.

12 years agoipiq: Remove an extra semicolon that was messing up an if.
Sascha Wildner [Fri, 14 Oct 2011 02:46:46 +0000 (04:46 +0200)]
ipiq: Remove an extra semicolon that was messing up an if.

Submitted-by: c <c@137.org>
Dragonfly-bug: <http://bugs.dragonflybsd.org/issue2147>

12 years agokernel/tmpfs: Remove a useless (and wrong, anyway) header.
Sascha Wildner [Thu, 13 Oct 2011 19:25:00 +0000 (21:25 +0200)]
kernel/tmpfs: Remove a useless (and wrong, anyway) header.

12 years agosdiff: fix wcwidth recursion
John Marino [Wed, 12 Oct 2011 22:39:51 +0000 (00:39 +0200)]
sdiff: fix wcwidth recursion

Apparently trying to diff non-UTF8 documents caused a stack overflow.
The culprit was correctly identified by Yonetani as the redefinition
of wcwidth in the wcwidth.c file.  Within that function, it calls itself
recursively forever.  I'm not sure how this would work differently
(macro or not) on another system.

My solution was to stop redefining wcwidth and just create a separate
function, one that will call the system wcwidth function as needed.

reported by: Peter Avalos
http://bugs.dragonflybsd.org/issue2134

12 years agoSync zoneinfo database with tzdata2011l from munnari.oz.au
Sascha Wildner [Mon, 10 Oct 2011 17:58:54 +0000 (19:58 +0200)]
Sync zoneinfo database with tzdata2011l from munnari.oz.au

* asia: Changed the end date for West Bank's Summer Time for
    this year (2011) to match reality reported by Steffen Thorsen.

* australasia: Adjust the end date for Summer time in Fiji in
    2012 (Feb) as reported by Steffen Thorsen.

* northamerica: Corrected typo in (ancient) LMT zone offset as
    detected by Zefram.

* southamerica: Resume Summer Time in Bahia, Brazil (following the
    standard Brazil algorithm, which causes Summer time to start
    Oct 16 this year, which matches the report.)

12 years agoMerge branch 'devel'
Sepherosa Ziehau [Tue, 11 Oct 2011 13:38:35 +0000 (21:38 +0800)]
Merge branch 'devel'

12 years agolegacy devices: Utilize bus_alloc_legacy_irq_resource()
Sepherosa Ziehau [Tue, 11 Oct 2011 13:14:58 +0000 (21:14 +0800)]
legacy devices: Utilize bus_alloc_legacy_irq_resource()

12 years agopsm: Utilize bus_alloc_legacy_irq_resource
Sepherosa Ziehau [Tue, 11 Oct 2011 11:24:50 +0000 (19:24 +0800)]
psm: Utilize bus_alloc_legacy_irq_resource

12 years agoatkbd: Utilize bus_alloc_legacy_irq_resource()
Sepherosa Ziehau [Tue, 11 Oct 2011 11:24:29 +0000 (19:24 +0800)]
atkbd: Utilize bus_alloc_legacy_irq_resource()

12 years agobus: Add bus_alloc_legacy_irq_resource()
Sepherosa Ziehau [Tue, 11 Oct 2011 11:23:12 +0000 (19:23 +0800)]
bus: Add bus_alloc_legacy_irq_resource()

This is a convenient wrapper function for legacy (mainly ISA) drivers to
alloc IRQ resource

12 years agokernel/drm: Clean up the Makefiles a bit.
Sascha Wildner [Tue, 11 Oct 2011 03:09:45 +0000 (05:09 +0200)]
kernel/drm: Clean up the Makefiles a bit.

12 years agokernel/ufs: Fix mount_point access in ffs_blkfree() when using softdep.
Sascha Wildner [Mon, 10 Oct 2011 20:42:55 +0000 (22:42 +0200)]
kernel/ufs: Fix mount_point access in ffs_blkfree() when using softdep.

Was going through inode->vnode->v_mount, but vnode was bad so
v_mount was NULL reference.

New way to get mount point: inode->i_devvp->v_mount.

Reported-by: Thomas Nikolajsen
Dragonfly-bug: <http://bugs.dragonflybsd.org/issue2142>
Submitted-by: Tim Bisson <bissont@mac.com>
12 years agopadlock(4): Match ENTRY()s with END()s.
Sascha Wildner [Mon, 10 Oct 2011 20:20:09 +0000 (22:20 +0200)]
padlock(4): Match ENTRY()s with END()s.

12 years agolibc_r/libstand/libthread_xu: Match ENTRY()s with END()s.
Sascha Wildner [Mon, 10 Oct 2011 20:10:00 +0000 (22:10 +0200)]
libc_r/libstand/libthread_xu: Match ENTRY()s with END()s.

12 years agoatkbd: Interrupt resource is not shareable
Sepherosa Ziehau [Mon, 10 Oct 2011 13:41:36 +0000 (21:41 +0800)]
atkbd: Interrupt resource is not shareable

12 years agonexus: Log invalid target CPUID for interrupt resource
Sepherosa Ziehau [Mon, 10 Oct 2011 11:58:21 +0000 (19:58 +0800)]
nexus: Log invalid target CPUID for interrupt resource

12 years agopsm: Set the interrupt's target CPU properly
Sepherosa Ziehau [Mon, 10 Oct 2011 11:56:39 +0000 (19:56 +0800)]
psm: Set the interrupt's target CPU properly

12 years agoatkbd: Set the interrupt's target CPU properly
Sepherosa Ziehau [Mon, 10 Oct 2011 11:56:04 +0000 (19:56 +0800)]
atkbd: Set the interrupt's target CPU properly

12 years agoDocument spin_pool_lock(9) and spin_pool_unlock(9).
Venkatesh Srinivas [Mon, 10 Oct 2011 02:29:54 +0000 (19:29 -0700)]
Document spin_pool_lock(9) and spin_pool_unlock(9).

12 years agolibm: Match ENTRY()s with END()s.
Sascha Wildner [Sun, 9 Oct 2011 22:36:08 +0000 (00:36 +0200)]
libm: Match ENTRY()s with END()s.

12 years agoresource: Per-CPU hardware resources support, step 5 of many
Sepherosa Ziehau [Sun, 9 Oct 2011 14:00:33 +0000 (22:00 +0800)]
resource: Per-CPU hardware resources support, step 5 of many

Fix up cpuid parameter passed to resource_list_add() after
bus_set_resource and bus_alloc_resource DEVMETHODs have cpuid
parameter.

12 years agoresource: Per-CPU hardware resources support, step 4 of many
Sepherosa Ziehau [Sun, 9 Oct 2011 11:06:25 +0000 (19:06 +0800)]
resource: Per-CPU hardware resources support, step 4 of many

Add cpuid parameter to bus_alloc_resource DEVMETHOD, so cpuid
could be passed all the way to the nexus

12 years agorman: Record owner CPUID during initialization
Sepherosa Ziehau [Sun, 9 Oct 2011 09:27:29 +0000 (17:27 +0800)]
rman: Record owner CPUID during initialization

12 years agolibc: Remove the CVS ID in the recently changed files, too.
Sascha Wildner [Sat, 8 Oct 2011 14:36:27 +0000 (16:36 +0200)]
libc: Remove the CVS ID in the recently changed files, too.

12 years agoAdd missing END() macros to libc i386 .S files
François Tigeot [Sat, 8 Oct 2011 13:55:34 +0000 (15:55 +0200)]
Add missing END() macros to libc i386 .S files

They were already present in the x86_64 versions of these files

12 years agoFix the i386 buildworld.
Sascha Wildner [Sat, 8 Oct 2011 11:50:11 +0000 (13:50 +0200)]
Fix the i386 buildworld.

Reported-by: Joachim de Groot <jdegroot@web.de>
12 years agoTRIM support
Tim [Fri, 7 Oct 2011 18:27:15 +0000 (11:27 -0700)]
TRIM support

Signed-off-by: Samuel J. Greear <sjg@thesjg.com>
12 years agokernel -- Resolve NULL ptr dereference in fill_kinfo_proc.
Venkatesh Srinivas [Fri, 7 Oct 2011 19:45:03 +0000 (12:45 -0700)]
kernel -- Resolve NULL ptr dereference in fill_kinfo_proc.

Reported-by: Justin Sherrill
12 years agokernel - Fix bug in lwkt_token_swap()
Matthew Dillon [Fri, 7 Oct 2011 07:22:09 +0000 (00:22 -0700)]
kernel - Fix bug in lwkt_token_swap()

* Fix a bug where lwkt_token_swap() would incorrectly assign the ref
  pointer when the top two tokens on the stack are the same token.

  When swapping the top two tokens where tok1 == tok2, the token
  can wind up being repointed to the top ref instead of the deeper
  ref.  When the top ref is released this caused the token to also
  release even though there was another deeper ref to the same
  token.

* Effected the vm_object traversal code and could cause an object token
  to be effectively lost without triggering a panic, resulting in
  corruption.

12 years agox86_64 - Remove unneeded globaldata.c file.
Antonio Huete Jimenez [Thu, 6 Oct 2011 15:46:52 +0000 (17:46 +0200)]
x86_64 - Remove unneeded globaldata.c file.

Functions globaldata_find(), cpu_gdinit() and is_globaldata_space()
are correctly defined in machdep.c.

12 years agokernel -- Add pool spinlocks interface.
Venkatesh Srinivas [Thu, 6 Oct 2011 01:40:03 +0000 (18:40 -0700)]
kernel -- Add pool spinlocks interface.

12 years agoMake pkgsrc-2011q3 default instead of 2011q1.
Justin C. Sherrill [Wed, 5 Oct 2011 14:18:04 +0000 (10:18 -0400)]
Make pkgsrc-2011q3 default instead of 2011q1.

12 years agokernel - Fix spin lock held across contigfree/kfree in bounce code
Matthew Dillon [Tue, 4 Oct 2011 14:58:38 +0000 (07:58 -0700)]
kernel - Fix spin lock held across contigfree/kfree in bounce code

* Fix an issue where a spin lock is being held across too-complex a
  procedure call.  The bounce page is isolated once removed from its
  list so we can release the lock while issuing the calls, then
  re-acquire it.

Reported-by: Antonio Huete Jimenez <tuxillo@quantumachine.net>
12 years agoresource: Per-CPU hardware resources support, step 3 of many
Sepherosa Ziehau [Tue, 4 Oct 2011 08:15:27 +0000 (16:15 +0800)]
resource: Per-CPU hardware resources support, step 3 of many

- Add cpuid parameter to bus_set_resource() and bus_set_resource
  DEVMETHOD; Pass this parameter to resource_list_add()
- Obtain interrupt resource's owner CPU, i.e. target CPU, from
  MachIntrABI and pass it to bus_set_resource(), so that the owner
  CPU of the interrupt resource could be correctly setup
- Rest of types of resources, e.g. IOPORT, MEMORY and DRQ, are
  shared across CPUs, so their cpuids are set to -1

12 years agoImport proplib from NetBSD
François Tigeot [Sat, 1 Oct 2011 11:07:35 +0000 (13:07 +0200)]
Import proplib from NetBSD

- main change: fix for an implementation inconsistency with the
prop_*_send_syscall() and prop_*_recv_syscall() functions
NetBSD commit message:
http://mail-index.netbsd.org/source-changes/2011/09/30/msg027701.html

- some unrelated minor fixes

12 years agoRaise default .Os value for the manual pages to 2.13 on master.
Sascha Wildner [Tue, 4 Oct 2011 05:33:45 +0000 (07:33 +0200)]
Raise default .Os value for the manual pages to 2.13 on 

12 years ago2.13 update.
Justin C. Sherrill [Tue, 4 Oct 2011 02:45:25 +0000 (19:45 -0700)]
2.13 update.

12 years agoMachIntrABI: Add method to return IRQ's target CPU
Sepherosa Ziehau [Mon, 3 Oct 2011 14:28:38 +0000 (22:28 +0800)]
MachIntrABI: Add method to return IRQ's target CPU

12 years agoresource: Per-CPU hardware resources support, step 2 of many
Sepherosa Ziehau [Mon, 3 Oct 2011 14:05:56 +0000 (22:05 +0800)]
resource: Per-CPU hardware resources support, step 2 of many

Add cpuid parameter to resource_list_alloc, so that this parameter could
be passed to bus_alloc_resource DEVMETHOD

12 years agoresource: Per-CPU hardware resources support, step 1 of many
Sepherosa Ziehau [Mon, 3 Oct 2011 12:41:03 +0000 (20:41 +0800)]
resource: Per-CPU hardware resources support, step 1 of many

- Add cpuid in the resource list entry, which points to the
  resource's owner CPU
- Add cpuid parameter to resource_list_add(), which could be used to
  set the resource's owner CPU

12 years agofsdb(8): Raise WARNS to 1.
Sascha Wildner [Sat, 1 Oct 2011 19:28:37 +0000 (21:28 +0200)]
fsdb(8): Raise WARNS to 1.

12 years agokernel - VM MPSAFE fixes
Venkatesh Srinivas [Fri, 30 Sep 2011 12:42:00 +0000 (05:42 -0700)]
kernel - VM MPSAFE fixes

* Apply amd64 PMAP fixes from a5fc46c91597d0af0cfa8fd257b4a8ed6e1cf341 to i386

* Hold vm_object in vm_swapcache_cleaning()

12 years agokernel - Numerous VM MPSAFE fixes
Matthew Dillon [Thu, 29 Sep 2011 21:46:42 +0000 (14:46 -0700)]
kernel - Numerous VM MPSAFE fixes

* Remove most critical sections from the VM subsystem, these are no longer
  applicable (vm_token covers the access).

* _pmap_allocpte() for x86-64 - Conditionalize the zeroing of the vm_page
  after the grab.  The grab can race other threads and result in a page
  which had already been zero'd AND populated with pte's, so we can't just
  zero it.

  Use m->valid to determine if the page is actually newly allocated or not.

  NOTE: The 32 bit code already properly zeros the page by detecting whether
the pte has already been entered or not.  The 64-bit code couldn't
do this neatly so we used another method.

* Hold the pmap vm_object in pmap_release() and pmap_object_init_pt() for
  the x86-64 pmap code.  This prevents related loops from blocking on the
  pmap vm_object when freeing VM pages which is not expected by the code.

* pmap_copy() for x86-64 needs the vm_token, critical sections are no longer
  sufficient.

* Assert that PG_MANAGED is set when clearing pte's out of a pmap via the
  PV entries.  The pte's must exist in this case and it's a critical panic
  if they don't.

* pmap_replacevm() for x86-64 - Adjust newvm->vm_sysref prior to assigning
  it to p->p_vmspace to handle any potential MP races with other sysrefs
  on the vmspace.

* faultin() needs p->p_token, not proc_token.

* swapout_procs_callback() needs p->p_token.

* Deallocate the VM object associated with a vm_page after freeing the
  page instead of before freeing the page.  This fixes a potential
  use-after-refs-transition-to-0 case if a MP race occurs.

12 years agoResurrect z*grep script to support gzip'ped files.
YONETANI Tomokazu [Thu, 29 Sep 2011 00:00:41 +0000 (09:00 +0900)]
Resurrect z*grep script to support gzip'ped files.

12 years agohammer(8): snaprm: fix edge case
Thomas Nikolajsen [Tue, 27 Sep 2011 05:35:01 +0000 (07:35 +0200)]
hammer(8): snaprm: fix edge case

Ensure that @@transid is at end of symlink.

12 years agohammer(8): fix snaprm argument parsing
Thomas Nikolajsen [Mon, 26 Sep 2011 19:20:27 +0000 (21:20 +0200)]
hammer(8): fix snaprm argument parsing

Parse arguments according to SYNOPSIS.
snaprm didn't parse arguments fully:
e.g. PFS symlink was deleted if given as only argument.

DragonFly-bug: <http://bugs.dragonflybsd.org/issue2111>
Submitted-by: fix based on patch from "sgaerner@gmx.net"
12 years agohammer(8): whitespace cleanup: delete blank at end of line
Thomas Nikolajsen [Mon, 26 Sep 2011 19:18:11 +0000 (21:18 +0200)]
hammer(8): whitespace cleanup: delete blank at end of line

12 years agoSync zoneinfo database with tzdata2011k from elsie.nci.nih.gov
Sascha Wildner [Mon, 26 Sep 2011 15:27:01 +0000 (17:27 +0200)]
Sync zoneinfo database with tzdata2011k from elsie.nci.nih.gov

asia:           8.65 -> 8.68
europe:         8.34 -> 8.38
northamerica:   8.48 -> 8.49
zone.tab:       8.47 -> 8.49

* asia: Palestine suspends DST during Ramadan in 2011; Gaza and Hebron
    split in 2011, leading to a new Asia/Hebron zone (thanks to
    Steffen Thorsen and Alexander Krivenshev). The different end of DST
    in Gaza and Hebron in 2008 is also reflected.

* europe: Belarus adopts permanent DST in 2011 (thanks to Yauhen Kharuzhy,
    Alexander Bokovoy, Alexander Krivenyshev, and Kirill A. Shutemov).
    Ukraine adopts permanent DST in 2011 (thanks to Alexander Krivenyshev).
    "Russia" rules changed to reflect end of use in 2010. "FET" used as
    abbreviation for Belarus, Ukraine, and western Russia (thanks to
    Paul Eggert). Also: a comment typo is fixed.

* northamerica: Updated comment on Newfoundland's 2011 change of time of
    day when DST starts and ends (thanks to Michael Pelley).

* zone.tab: New Asia/Hebron zone (thanks to Alexander Krivenshev).

12 years agokernel -- vfs_bio.c: Rework bread() in terms of breadn().
Venkatesh Srinivas [Mon, 26 Sep 2011 02:12:20 +0000 (19:12 -0700)]
kernel -- vfs_bio.c: Rework bread() in terms of breadn().