[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACGkMEt41L4pmMcE9zSJ5tVU-Tj0zGEoLqvsktbKWf=gEGphww@mail.gmail.com>
Date: Fri, 24 Oct 2025 12:00:50 +0800
From: Jason Wang <jasowang@...hat.com>
To: Zhang Tianci <zhangtianci.1997@...edance.com>
Cc: "Michael S. Tsirkin" <mst@...hat.com>, xuanzhuo@...ux.alibaba.com, eperezma@...hat.com,
virtualization@...ts.linux.dev, xieyongji@...edance.com,
gregkh@...uxfoundation.org, rafael@...nel.org, dakr@...nel.org,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [External] Re: virtio_pci: Question about virtio_pci kernel
module refcnt
On Fri, Oct 24, 2025 at 10:34 AM Zhang Tianci
<zhangtianci.1997@...edance.com> wrote:
>
> Hi, thanks for your reply
>
> On Fri, Oct 24, 2025 at 9:53 AM Jason Wang <jasowang@...hat.com> wrote:
> >
> > On Thu, Oct 23, 2025 at 10:34 AM Zhang Tianci
> > <zhangtianci.1997@...edance.com> wrote:
> > >
> > > Hi, thank you for your reply, but I still have a few questions:
> > >
> > > On Wed, Oct 22, 2025 at 7:31 PM Michael S. Tsirkin <mst@...hat.com> wrote:
> > > >
> > > > On Wed, Oct 22, 2025 at 07:21:45PM +0800, Zhang Tianci wrote:
> > > > > Hi,
> > > > > I noticed that the reference count of the virtio_pci kernel module
> > > > > in the VM is always 0, even though there are at least two
> > > > > virtio block devices and one virtiofs device in the VM.
> > > > >
> > > > > Using rmmod virtio_pci can unload the virtio_pci module,
> > > > > but this renders the virtio block devices unusable.
> > > >
> > > > it removes them. you can put it back in and you will
> > > > get devices again.
> > >
> > > But I can't do it anymore because the rootfs is no longer available,
> > > or rather, the OS is no longer available.
> > >
> > > >
> > > > > I wonder if this result is expected? Why don't the virtio block devices
> > > > > and virtiofs device hold a reference count to the virtio_pci kernel module?
> > > >
> > > > because they don't have to.
> > >
> > > Is it due to design reasons or implementation reasons?
> > > Is it because the semantics of kernel module refcnt does not include such
> > > logical dependency?
> >
> > Note that virito has a bus so it follows the device/driver model so if
> > I was not wrong the refcnt was handled by the driver core.
>
> Let's look at an example:
>
> $ lsmod | grep virtio
> virtio_balloon 20480 0
> virtio_console 40960 1
> virtiofs 32768 1 <- one virtiofs
> fuse 172032 2 virtiofs
> virtio_net 73728 0
> net_failover 20480 1 virtio_net
> virtio_blk 32768 2 <- two block devices
> virtio_pci 24576 0
> virtio_pci_legacy_dev 16384 1 virtio_pci
> virtio_pci_modern_dev 16384 1 virtio_pci
> virtio 16384 6
> virtio_console,virtio_balloon,virtiofs,virtio_pci,virtio_blk,virtio_net
> virtio_ring 49152 6
> virtio_console,virtio_balloon,virtiofs,virtio_pci,virtio_blk,virtio_net
>
> There are two virtio_blk devices which are vda and vdb, and one virtiofs device.
> We can find the block device and fs instance are holding virtio_blk
> and virtiofs' refcnts.
> But they don't hold virtio_pci(pci bus) or virtio(virtio bus) refcnts
> even though they logically depend on
> them.
My understanding is the driver must be unregistered while the device
is being unregistered.
> So I might need to consult the driver core maintainers?(I have cc'd
> them in this email.)
>
> Thanks,
> Tianci
>
Thanks
Powered by blists - more mailing lists