svn commit: r340149 - head/sys/dev/hwpmc

Matt Macy mmacy at FreeBSD.org
Mon Nov 5 08:11:17 UTC 2018


Author: mmacy
Date: Mon Nov  5 08:11:16 2018
New Revision: 340149
URL: https://svnweb.freebsd.org/changeset/base/340149

Log:
  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

Modified:
  head/sys/dev/hwpmc/hwpmc_mod.c

Modified: head/sys/dev/hwpmc/hwpmc_mod.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_mod.c	Mon Nov  5 06:59:41 2018	(r340148)
+++ head/sys/dev/hwpmc/hwpmc_mod.c	Mon Nov  5 08:11:16 2018	(r340149)
@@ -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


More information about the svn-src-all mailing list