Bug 204273 - panic: [pmc,4204] cpu 0 didn't find a sample to collect
Summary: panic: [pmc,4204] cpu 0 didn't find a sample to collect
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Andrew Turner
URL: https://reviews.freebsd.org/D6581
Keywords:
Depends on:
Blocks: 203349
  Show dependency treegraph
 
Reported: 2015-11-04 01:01 UTC by Ed Maste
Modified: 2016-05-29 21:08 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2015-11-04 01:01:21 UTC
pmccontrol -L - see the things
pmcstat -S CPU_CYCLES -T -w 1

.. and panic.

panic: [pmc,4204] cpu 0 didn't find a sample to collect                [71/1850]
cpuid = 0
KDB: stack backtrace:
db_trace_self() at db_trace_self_wrapper+0x28
         pc = 0xffffff80004d6254  lr = 0xffffff800006d888
         sp = 0xffffff87cc2156f0  fp = 0xffffff87cc215810

db_trace_self_wrapper() at vpanic+0x170
         pc = 0xffffff800006d888  lr = 0xffffff800025abd0
         sp = 0xffffff87cc215820  fp = 0xffffff87cc2158a0

vpanic() at kassert_panic+0x160
         pc = 0xffffff800025abd0  lr = 0xffffff800025aa5c
         sp = 0xffffff87cc2158b0  fp = 0xffffff87cc215970

kassert_panic() at pmc_capture_user_callchain+0x134
         pc = 0xffffff800025aa5c  lr = 0xffffff8047e2b1e8
         sp = 0xffffff87cc215980  fp = 0xffffff87cc2159d0

pmc_capture_user_callchain() at pmc_hook_handler+0x4a0
         pc = 0xffffff8047e2b1e8  lr = 0xffffff8047e296e8
         sp = 0xffffff87cc2159e0  fp = 0xffffff87cc215a60

pmc_hook_handler() at ast+0x14cCYCLES -T -w 1                          [48/1850]
         pc = 0xffffff8047e296e8  lr = 0xffffff80002a5c20
         sp = 0xffffff87cc215a70  fp = 0xffffff87cc215aa0

ast() at handle_el0_irq+0x88
         pc = 0xffffff80002a5c20  lr = 0xffffff80004d72e8
         sp = 0xffffff87cc215ab0  fp = 0x0000007fffff40e0

KDB: enter: panic
[ thread pid 3341 tid 100475 ]
Stopped at      kdb_enter+0x40:
db> call doadump
Dumping 3761 out of 131034 MB:..1%(ada0:ahcich0:0:0:0): WRITE_DMA. ACB: ca 00 40
 9d ca 46 00 00 00 00 08 00
(ada0:ahcich0:0:0:0): CAM status: CCB request was invalid
(ada0:ahcich0:0:0:0): Error 22, Unretryable error
Aborting dump due to I/O error.

** DUMP FAILED (ERROR 22) **
= 0x16
db>
Comment 1 Andrew Turner freebsd_committer 2015-11-04 11:18:03 UTC
As a workaround I commented the KASSERT out with no ill effects.
Comment 2 commit-hook freebsd_committer 2016-05-28 13:06:25 UTC
A commit references this bug:

Author: andrew
Date: Sat May 28 13:05:40 UTC 2016
New revision: 300902
URL: https://svnweb.freebsd.org/changeset/base/300902

Log:
  Don't panic in hwpmc when stopping sampling.

  When hwpmc stops sampling it will set the pm_state to something other
  than PMC_STATE_RUNNING. This means the following sequence can happen:

  CPU 0: Enter the interrupt handler
  CPU 0: Set the thread TDP_CALLCHAIN pflag
  CPU 1: Stop sampling
  CPU 0: Call pmc_process_samples, sampling is stopped so clears ps_nsamples
  CPU 0: Finishes interrupt processing with the TDP_CALLCHAIN flag set
  CPU 0: Call pmc_capture_user_callchain to capture the user call chain
  CPU 0: Find all the pmc sample are free so no call chains need to be captured
  CPU 0: KASSERT because of this

  This fixes the issue by checking if any of the samples have been stopped
  and including this in te KASSERT.

  PR:		204273
  Reviewed by:	bz, gnn
  Obtained from:	ABT Systems Ltd
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D6581

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