John Baldwin a1febbf667 Fix two bugs that could result in PMC sampling effectively stopping.
In both cases, the the effect of the bug was that a very small positive
number was written to the counter. This means that a large number of
events needed to occur before the next sampling interrupt would trigger.
Even with very frequently occurring events like clock cycles wrapping all
the way around could take a long time. Both bugs occurred when updating
the saved reload count for an outgoing thread on a context switch.

First, the counter-independent code compares the current reload count
against the count set when the thread switched in and generates a delta
to apply to the saved count. If this delta causes the reload counter
to go negative, it would add a full reload interval to wrap it around to
a positive value. The fix is to add the full reload interval if the
resulting counter is zero.

Second, occasionally the raw counter value read during a context switch
has actually wrapped, but an interrupt has not yet triggered. In this
case the existing logic would return a very large reload count (e.g.
2^48 - 2 if the counter had overflowed by a count of 2). This was seen
both for fixed-function and programmable counters on an E5-2643.
Workaround this case by returning a reload count of zero.

PR:		198149
Differential Revision:	https://reviews.freebsd.org/D2557
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	Norse Corp, Inc.
2015-05-19 19:15:19 +00:00
..
2015-05-16 20:06:39 +00:00
2015-01-23 15:14:30 +00:00
2015-03-23 19:47:52 +00:00
2015-01-30 01:13:07 +00:00
2015-02-24 01:00:46 +00:00
2015-03-08 19:55:46 +00:00
2015-04-22 14:38:58 +00:00
2015-01-23 15:14:30 +00:00
2015-01-23 15:14:30 +00:00
2015-04-03 11:37:23 +00:00
2014-08-05 23:35:19 +00:00
2014-08-05 23:58:49 +00:00
2014-05-20 19:55:06 +00:00
2015-05-16 05:59:25 +00:00
2014-09-28 07:40:26 +00:00
2015-04-29 20:08:03 +00:00
2014-10-10 14:17:42 +00:00
2014-10-11 19:36:59 +00:00
2015-03-23 19:47:52 +00:00
2015-04-22 14:38:58 +00:00
2014-12-03 00:47:05 +00:00
2014-11-18 21:58:57 +00:00
2014-09-19 03:55:19 +00:00
2014-05-16 21:19:17 +00:00
2015-03-23 19:47:52 +00:00
2014-11-21 21:34:19 +00:00
2014-11-20 20:09:18 +00:00