Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Feb 2020 20:07:49 -0800
From:      Gleb Smirnoff <glebius@freebsd.org>
To:        Kristof Provost <kp@freebsd.org>
Cc:        freebsd-net <freebsd-net@freebsd.org>
Subject:   Re: vtnet IFF_NEEDSEPOCH?
Message-ID:  <20200221040749.GM5741@FreeBSD.org>
In-Reply-To: <CB21E2A0-48DF-46CC-BFC2-31A105B7C865@FreeBSD.org>
References:  <B45B8E77-CDB2-450E-951C-1E6E6BCC2527@FreeBSD.org> <20200218193708.GH5741@FreeBSD.org> <5520BD42-7D17-4561-A2CD-C690B159D15E@FreeBSD.org> <20200219224845.GI5741@FreeBSD.org> <CB21E2A0-48DF-46CC-BFC2-31A105B7C865@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Feb 20, 2020 at 12:16:06PM +0100, Kristof Provost wrote:
K> On 19 Feb 2020, at 23:48, Gleb Smirnoff wrote:
K> > On Tue, Feb 18, 2020 at 10:08:50PM +0100, Kristof Provost wrote:
K> > K> So I suspect our call stack is something like virtqueue_intr() ->
K> > K> vtnet_rx_vq_intr() -> vtnet_rxq_eof() -> vtnet_rxq_input() ->
K> > K> ether_input().
K> > K> I don’t see anything entering epoch in that path, which presumably
K> > explains
K> > K> the panic, but I still don’t understand why my bhyve current vm
K> > doesn’t
K> > K> panic in the same way.
K> > 
K> > On bhyve we enter it through interrupt handler, and this is where we
K> > enter the epoch. Does RISC-V has interrupt handling by the MI code
K> > in sys/kern/kern_intr.c as other platforms?
K> > 
K> It does, yes, but that was the hint I needed. I didn’t know that we entered
K> net_epoch automagically based on the interrupt type.
K> 
K> The difference between the two is that Bhyve uses virtio_pci, and in my
K> qemu case we run through the virtio_mmio path. In that path we always set
K> INTR_TYPE_MISC, so we never set INTR_TYPE_NET, even for if_vtnet, so we
K> never entered epoch.
K> 
K> This is the correct fix:
K> 
K> 	diff --git a/sys/dev/virtio/mmio/virtio_mmio.c
K> b/sys/dev/virtio/mmio/virtio_mmio.c
K> 	index 95eb8647052..ccafe326868 100644
K> 	--- a/sys/dev/virtio/mmio/virtio_mmio.c
K> 	+++ b/sys/dev/virtio/mmio/virtio_mmio.c
K> 	@@ -196,7 +196,7 @@ vtmmio_setup_intr(device_t dev, enum intr_type type)
K> 	                return (ENXIO);
K> 	        }
K> 
K> 	-       if (bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE,
K> 	+       if (bus_setup_intr(dev, sc->res[1], type | INTR_MPSAFE,
K> 	                NULL, vtmmio_vq_intr, sc, &sc->ih)) {
K> 	                device_printf(dev, "Can't setup the interrupt\n");
K> 	                return (ENXIO);

Thanks a lot for the fix, Kristof!

-- 
Gleb Smirnoff



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