Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 May 2016 12:06:57 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300604 - head/sys/kern
Message-ID:  <201605241206.u4OC6vxt066392@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Tue May 24 12:06:56 2016
New Revision: 300604
URL: https://svnweb.freebsd.org/changeset/base/300604

Log:
  Limit calling pmc_hook to when the interrupt comes while running userspace.
  We may enable interrupts from within the callback, e.g. in a data abort
  during copyin. If we receive an interrupt at that time pmc_hook will be
  called again and, as it is handling userspace stack tracing, will hit a
  KASSERT as it checks if the trapframe is from userland.
  
  With this I can run hwpmc with intrng on a ThunderX and have it trace all
  CPUs.
  
  Obtained from:	ABT Systems Ltd
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/subr_intr.c

Modified: head/sys/kern/subr_intr.c
==============================================================================
--- head/sys/kern/subr_intr.c	Tue May 24 11:47:14 2016	(r300603)
+++ head/sys/kern/subr_intr.c	Tue May 24 12:06:56 2016	(r300604)
@@ -317,7 +317,8 @@ intr_irq_handler(struct trapframe *tf)
 	td->td_intr_frame = oldframe;
 	critical_exit();
 #ifdef HWPMC_HOOKS
-	if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
+	if (pmc_hook && TRAPF_USERMODE(tf) &&
+	    (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
 		pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, tf);
 #endif
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605241206.u4OC6vxt066392>