Re: panic: curthread not pinned

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Tue, 01 Oct 2024 11:47:32 UTC
On Tue, Oct 01, 2024 at 11:53:33AM +0300, Konstantin Belousov wrote:
> On Tue, Oct 01, 2024 at 01:16:31PM +0700, dsdqmzk@hotmail.com wrote:
> > Hyper-V Gen2 VM, 8 cores, 8GB RAM.  The panic is reproducible while
> > running `make -j8 buildworld`.  Initially installed from
> > FreeBSD-15.0-CURRENT-amd64-20240926-6a4f0c063718-272495-disc1.iso,
> > updating the kernel (that I could build) to b35f0aa4952 does not help.
> > 
> > panic: curthread not pinned
> > cpuid = 3
> > time = 1727763183
> > KDB: stack backtrace:
> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame
> > 0xfffffe008e34a1f0
> > vpanic() at vpanic+0x13f/frame 0xfffffe008e34a320
> > panic() at panic+0x43/frame 0xfffffe008e34a380
> > smp_targeted_tlb_shootdown_native() at
> > smp_targeted_tlb_shootdown_native+0x472/frame 0xfffffe008e34a4c0
> > pmap_remove_all() at pmap_remove_all+0x560/frame 0xfffffe008e34a540
> 
> Can you obtain the core dump and then backtrace from kgdb?

I think I found a place where this occurs.  Please try the patch below.

commit 6dcffb980fa3026092f79107ee7668918c9f5490
Author: Konstantin Belousov <kib@FreeBSD.org>
Date:   Tue Oct 1 14:45:23 2024 +0300

    hyperv: call smp_targeted_tlb_shootdown_native() with pin
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week

diff --git a/sys/dev/hyperv/vmbus/hyperv_mmu.c b/sys/dev/hyperv/vmbus/hyperv_mmu.c
index 7c29fe294093..8e982974161c 100644
--- a/sys/dev/hyperv/vmbus/hyperv_mmu.c
+++ b/sys/dev/hyperv/vmbus/hyperv_mmu.c
@@ -241,7 +241,6 @@ hv_vm_tlb_flush(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2,
 	critical_exit();
 	return;
 native:
-	sched_unpin();
 	critical_exit();
 	return smp_targeted_tlb_shootdown_native(pmap, addr1,
 	    addr2, curcpu_cb, op);