Commit the work that has been done so far:
- Switch the way we measure the time in callout(9) from ticks to bintime.
- Change some fields in the structures callout, callout_cpu and cc_mig_ent.
- callout_reset_on() now converts the argument to_ticks to some bintime
value before giving it to callout_cc_add(), which has been modified to
receive a struct bintime rather than a value in ticks.
- Add a new per-cpu list to handle pending callout requests rather than
processing them directly on the callwheel. This simplify the logic of
the softclock() handler.
- Refactor the callout_tick() and callout_tickstofirst() code to make them
aware of the bintime measurement.
- Workaround tcp_timer_to_xtimer() to survive to the aforementioned switch.
- Refactor the cpu_new_callout() function in order to update the timer in
one-shot fashion via loadtimer() function. Until now the timer was
reprogrammed every tick.

Discussed with:		mav
We need to figure out if the element we're trying to remove actually belongs
to the tail queue of one of the buckets of the callwheel or to the tail queue
introduced with r236315, to avoid random memory corruption and so some
unpredictable behaviour.
To avoid the entire scan of the two queues, a flag is added. This flags is
set or cleared depending to the queues to which the element actually belongs.

Discussed with:		mav
Provide a callout_hash() private function which is equivalent to the
get_bucket() one except than performing the division for the number of
buckets in the wheel. Inline the two aforementioned functions in order
to avoid the overhead due to function call.

Optimize the callout_tick() code. Right now it scans the entire wheel
only when it's needed (i.e. we wrapped around all the wheel). Otherwise
it scans only the buckets from the last examined in previous scan to the
one relative to present time.

Discussed with:		mav [1]
Suggested by:		mav [2]
Replace binuptime() with getbinuptime() because it's suitable for the
purpose and it's cheaper. Update the relative comment on precision error
during callwheel scan as well.

Move the exit condition for the wheel scan before the increment of the
bucket. Before this change, it may happen that the last slot of the wheel
is not examined.

Pointed out by:		mav
- Everytime callout_tick() is called it looks for the nearest future
event and communicate it to eventtimers subsystem via
via callout_new_inserted(). So, we don't need anymore to call
callout_tickstofirst() when we're in getnextcpuevent(), and we can get
rid of it.

- Completely refactor the cpu_new_callout() function (many thanks to
Alexander Motin that helped me there with this code).

- Switch back from getbinuptime() to binuptime() to measure present time in
callout_tick().

Pointed out by:		mav, bde
- Start to experiment an extension of the current KPI adding the
callout_reset_bt_on() in which we specify timeouts in terms of
struct bintime rather than ticks.

- Make the old callout_reset_on() just a wrapper to the new function.
There's no need to add one second to the event time in callout_cc_add()
if this one is scheduled in the past. This was a braino derived from my
previous experiments. Moreover, there's no need to call binuptime(), but,
in turn, event times in the past may be silently converted to
cc_softticks, avoiding the bintime() overhead.

As an added bonus, we can avoid to start our scan of the wheel 1/HZ
backward in the past, gaining in terms of performances.

Reported by:		mav
Add (experimentally) a function to the sleepqueue(9) KPI
sleepq_set_timeout_bt() in which the timeout may be specified in terms
of bintime rather than ticks, and which takes advantage of the new
precision capabilities of the callout subsystem.

Modify the kern_nanosleep() function so that it may rely on
sleepq_set_timeout_bt() rather than tsleep().
Implement support for SWI-less callouts, so that we can run callout directly
from hardware interrupt context rather than from SWI context.
In this way, under some conditions, there's no need to wake up another
CPU from sleep and perfor a context switch, avoiding a waste of time.

Discussed with:		mav
The cc_firsttick field in struct callout_cpu keeps track of the time at
which the nearest event in future should be fired. In case we're adding an
event which time associated is greater than cc_firsttick, there's no need
to call callout_new_inserted. While here, fix a style indentation bug
pointed out by Bruce Evans (bde@).
CTR4 has four arguments but we need five, change it to CTR5.
Modify some printed value to obtain more significant kernel traces.
While here, Bruce Evans told me that "unsigned int" is spelled "u_int" in
KNF, so replace it where needed.

Discussed with:		mav
The second argument of sleepq_timedwait_sig() is priority and it does not
concern signal caught in previous calls as I thought and the manpage says.
Fix kern_nanosleep() accordingly.

Reported by:		bde
Reviewed by:		bde
Fix (or at least, workaround) an include conflict in libprocstat which
causes buildworld to fail, after my recent changes to sys/sys/_callout.h
header.

Reviewed by:		stas
callwheelbits variable was introduced long time ago but it's not really used.
Get rid of it.

Discussed with:		Matt Dillon
- Extend the condvar(9) KPI introducing a new cv_timedwait_bt_sig()
function so that we can specify timeout precision in terms of struct
bintime.

- Now seltdwait() takes three argument rather than two so that their
consumers can specify if the timeout should be passed as ticks or bintime.

- Refactor the kern_select() and the sys_poll() code so that these two
services may rely on cv_timedwait_bt_sig() rather than on the previous less
precise cv_timedwait_sig().

- Rethink the sleepqueue(9) KPI in order to make an attempt of avoiding
both code duplication and breakages. Your mileage WILL vary, feel free to
comment.

Reviewed by:		mav
MFC as per r237201.
Don't compute the bucket applying the hash function if there's no need to
do this. While here, try to simplify the callout_tick() logic and fix
a couple of style bugs.

Discussed with:		mav
- Modify a bit the callout(9) public KPI to avoid code duplication and avoid
breakages, as recently done for sleepqueue(9)

- Rename the 'direct' argument in callout_reset_on() and friends into 'flags'
because it may used for furter enhancements, such as specify precision
specification, on which I'm currently woking on.

Suggested by:		attilio [1], mav [2]
Reviewed by:		mav
First commit that concerns event aggregation. Augment the callout structure
so that consumers other than actual time at which callout should fire may
specify a tolerance interval.

Rather than looking for the next callout event in callout_tick()
determine a range [t-delta;t'+delta'] deriving it from the tolerance
parameter specified by clients so that's suitable for a given number of events,
and schedule an interrupt in the middle of such range.

Add some comments to better specify what we're doing.

Suggested by:		mav
Reviewed by:		mav
General cleanup and cosmetic.

- Rename callout_tick() in a more appropriate callout_process. Rename also
some fields in the cpu_callout stucture. While here, trim an unused field.

- Remove a comment that is surely invalid in the new world order, and fix
some typos in another.

- Remove a redundant assignment in callout_cpu_init().

Reviewed by:		mav