* virtio_pci: Question about virtio_pci kernel module refcnt
@ 2025-10-22 11:21 Zhang Tianci
2025-10-22 11:31 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: Zhang Tianci @ 2025-10-22 11:21 UTC (permalink / raw)
To: mst, jasowang, xuanzhuo, eperezma, virtualization
Cc: xieyongji, 天赐张
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.
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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: virtio_pci: Question about virtio_pci kernel module refcnt
2025-10-22 11:21 virtio_pci: Question about virtio_pci kernel module refcnt Zhang Tianci
@ 2025-10-22 11:31 ` Michael S. Tsirkin
2025-10-23 2:34 ` [External] " Zhang Tianci
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2025-10-22 11:31 UTC (permalink / raw)
To: Zhang Tianci; +Cc: jasowang, xuanzhuo, eperezma, virtualization, xieyongji
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.
> 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.
--
MST
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] Re: virtio_pci: Question about virtio_pci kernel module refcnt
2025-10-22 11:31 ` Michael S. Tsirkin
@ 2025-10-23 2:34 ` Zhang Tianci
2025-10-24 1:53 ` Jason Wang
0 siblings, 1 reply; 6+ messages in thread
From: Zhang Tianci @ 2025-10-23 2:34 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: jasowang, xuanzhuo, eperezma, virtualization, xieyongji
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@redhat.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?
Thanks,
Tianci
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] Re: virtio_pci: Question about virtio_pci kernel module refcnt
2025-10-23 2:34 ` [External] " Zhang Tianci
@ 2025-10-24 1:53 ` Jason Wang
2025-10-24 2:34 ` Zhang Tianci
0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2025-10-24 1:53 UTC (permalink / raw)
To: Zhang Tianci
Cc: Michael S. Tsirkin, xuanzhuo, eperezma, virtualization, xieyongji
On Thu, Oct 23, 2025 at 10:34 AM Zhang Tianci
<zhangtianci.1997@bytedance.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@redhat.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.
Thanks
>
> Thanks,
> Tianci
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] Re: virtio_pci: Question about virtio_pci kernel module refcnt
2025-10-24 1:53 ` Jason Wang
@ 2025-10-24 2:34 ` Zhang Tianci
2025-10-24 4:00 ` Jason Wang
0 siblings, 1 reply; 6+ messages in thread
From: Zhang Tianci @ 2025-10-24 2:34 UTC (permalink / raw)
To: Jason Wang
Cc: Michael S. Tsirkin, xuanzhuo, eperezma, virtualization, xieyongji,
gregkh, rafael, dakr, linux-kernel
Hi, thanks for your reply
On Fri, Oct 24, 2025 at 9:53 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Thu, Oct 23, 2025 at 10:34 AM Zhang Tianci
> <zhangtianci.1997@bytedance.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@redhat.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.
So I might need to consult the driver core maintainers?(I have cc'd
them in this email.)
Thanks,
Tianci
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] Re: virtio_pci: Question about virtio_pci kernel module refcnt
2025-10-24 2:34 ` Zhang Tianci
@ 2025-10-24 4:00 ` Jason Wang
0 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2025-10-24 4:00 UTC (permalink / raw)
To: Zhang Tianci
Cc: Michael S. Tsirkin, xuanzhuo, eperezma, virtualization, xieyongji,
gregkh, rafael, dakr, linux-kernel
On Fri, Oct 24, 2025 at 10:34 AM Zhang Tianci
<zhangtianci.1997@bytedance.com> wrote:
>
> Hi, thanks for your reply
>
> On Fri, Oct 24, 2025 at 9:53 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Thu, Oct 23, 2025 at 10:34 AM Zhang Tianci
> > <zhangtianci.1997@bytedance.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@redhat.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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-24 4:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 11:21 virtio_pci: Question about virtio_pci kernel module refcnt Zhang Tianci
2025-10-22 11:31 ` Michael S. Tsirkin
2025-10-23 2:34 ` [External] " Zhang Tianci
2025-10-24 1:53 ` Jason Wang
2025-10-24 2:34 ` Zhang Tianci
2025-10-24 4:00 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).