Bug 248757

Summary: panic: waiting too long for pmc to be free
Product: Base System Reporter: Leandro Lupori <luporl>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: cem, emaste
Priority: --- Keywords: crash
Version: CURRENT   
Hardware: amd64   
OS: Any   

Description Leandro Lupori freebsd_committer freebsd_triage 2020-08-19 17:40:59 UTC
When executing the commands below, sometimes the system panics:

stress -c 1 -t 10 &
pmcstat -t stress -p mem_load_retired.l2_miss sleep 3

panic: [pmc,2749] (ri17, rc1) waiting too long for pmc to be free              
cpuid = 2
time = 1597858367
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe005fc9a760 
vpanic() at vpanic+0x182/frame 0xfffffe005fc9a7b0                              
panic() at panic+0x43/frame 0xfffffe005fc9a810                                 
pmc_wait_for_pmc_idle() at pmc_wait_for_pmc_idle+0xa2/frame 0xfffffe005fc9a840 
pmc_release_pmc_descriptor() at pmc_release_pmc_descriptor+0x204/frame 0xfffffe0
pmc_syscall_handler() at pmc_syscall_handler+0x4be/frame 0xfffffe005fc9a9d0    
amd64_syscall() at amd64_syscall+0x140/frame 0xfffffe005fc9aaf0                
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe005fc9aaf0     
--- syscall (0, FreeBSD ELF64, nosys), rip = 0x800a8a96a, rsp = 0x7fffffffe368,-
KDB: enter: panic
[ thread pid 1852 tid 100126 ]
Stopped at      kdb_enter+0x37: movq    $0,0x10bc706(%rip)                     
db>

I'm running -CURRENT on an amd64 VM (qemu with kvm).
I've performed several different tests with pmcstat and stress and got no panics.