hwpmc: limit wait for user callchain collection to 1 tick

The hwpmc pcpu sample buffer is prone to head of line blocking
when waiting for user process to return to user space and
collect a pending callchain. If more than one tick has elapsed
between the time the sample entry was marked for collection and
the time that the hardclock pmc handler runs to copy the records
to a larger temporary buffer, mark the sample entry as not in
use.

This changes reduces the number of samples marked as not valid
when collecting under load from ~99.5% to 5-20%.

Reported by:	mjg@
MFC after:	3 days
This commit is contained in:
Matt Macy 2018-11-05 08:11:16 +00:00
parent b465e0bb56
commit acf50a7f68
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=340149

View File

@ -4949,8 +4949,11 @@ pmc_process_samples(int cpu, ring_type_t ring)
/* If there is a pending AST wait for completion */
if (ps->ps_nsamples == PMC_USER_CALLCHAIN_PENDING) {
/* if sample is more than 65 ms old, drop it */
if (ticks - ps->ps_ticks > (hz >> 4)) {
/* if we've been waiting more than 1 tick to
* collect a callchain for this record then
* drop it and move on.
*/
if (ticks - ps->ps_ticks > 1) {
/*
* track how often we hit this as it will
* preferentially lose user samples