librt/aio_cancel(): Set errno to EBADF if the fd is not valid.
Move AIO manual pages to librt.

While doing it, remove aio_waitcomplete(), as it has no librt (or POSIX)
counterpart.
aio*.3: Some cleanup, wording improvement, etc.
kernel/clock: Remove some pointless #include/#ifdef.
aio_write.3: Bring back a bit that should not have been deleted.
libpthread: Add sem_timedwait().

It was commented out and I'm not sure why.

It needed a bit of adjustment to properly check the nanoseconds field but
with that, it passes all eleven tests of the Open POSIX Test Suite. Other
people (thesjg, vsrinivas) have tested and used it too in the past.

While here, also add a manual page (taken from FreeBSD).

In-discussion-with: vsrinivas
kernel/powernow: Remove two unused variables.
Merge branch 'master' into gsocdrm_merger
ifq/staging: Initial implementation of IFQ packet staging mechanism

The packets enqueued into IFQ are staged to a certain amount before the
ifnet's if_start is called.  In this way, the driver could avoid writing
to hardware registers upon every packet, instead, hardware registers
could be written when certain amount of packets are put onto hardware
TX ring.  The measurement on several modern NICs (emx(4), igb(4), bnx(4),
bge(4), jme(4)) shows that the hardware registers writing aggregation
could save ~20% CPU time when 18bytes UDP datagrams are transmitted at
1.48Mpps.

IFQ packets staging is performed for direct ifnet's if_start calling,
i.e. ifq_try_ifstart()

IFQ packets staging will be stopped upon any of the following conditions:
- If the count of packets enqueued on the current CPU is great than or
  equal to ifq_stage_cntmax.
- If the total length of packets enqueued on the current CPU is great
  than or equal to the hardware's MTU - max_protohdr.  max_protohdr is
  cut from the hardware's MTU mainly bacause a full TCP segment's size
  is usually less than hardware's MTU.
- if_start interlock (if_snd.altq_started) is not released.
- The if_start_rollup(), which is registered as low priority netisr
  rollup function, is called; probably because no more work is pending
  for netisr.

Currently IFQ packet staging is only performed in netisr threads.

Inspired-by: Luigi Rizzo's netmap paper
    (http://info.iet.unipi.it/~luigi/netmap/)
Also-Suggested-by: dillon@
polling: Perform RX polling before TX polling
if_start: Use if_start_schedule in if_start_dispatch

Ease further optimization.
ifq/staging: Perform IFQ packet staging for if_start scheduling

IFQ packets staging is now performed for ifnet's if_start scheduling,
i.e. if_start_schedule(), in addition to direct ifnet's if_start calling.

IFQ packets staging stopping condition
- if_start interlock (if_snd.altq_started) is not released.
is now changed to
- if_start_schedule() is not pending on the current CPU and if_start
  interlock (if_snd.altq_started) is not released.

By setting net.link.stage_cntmax to 8 and hw.igbX.tx_wreg_nsegs to 16,
following performance improvement is gained:
+80Kpps for normal IP forwarding
+30Kpps for fast IP forwarding
ifq/staging: Increase ifq_maxlen a little bit for packets get staged

Increase ifq_maxlen by the amount that IFQ packet staging will take.

There are several places in the tree that if_snd.ifq_maxlen is set
directly instead of using ifq_set_maxlen().  These will be fixed in
some later commits.
ifq/staging: Clean up IFQ packet staging resources

- Make sure pending if_start scheduling IPIs are synchronized
- Make sure IFQ packets are no longer staged on any CPUs
- Free IFQ packet staging bookkeeping memory
ifq/staging: Remove debug code
ifq/staging: Add comment about IFQ packet staging mechanism
ifq: Use ifq_set_maxlen for ifnet.if_snd
sctp: Don't test ifq_len against ifq_maxlen; let IFQ make the decision
ip6: Don't test ifq_len against ifq_maxlen; let IFQ make the decision
ifq: Move ifq_set_maxlen declaration to the declaration code block