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
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to