Re: [PATCH] net/9p/trans_virtio.c: decrease the refcount of 9p virtio device when removing it

From: Dominique Martinet
Date: Wed Aug 08 2018 - 05:40:33 EST


piaojun wrote on Wed, Aug 08, 2018:
> I try to remove 9pnet_virtio.ko by 'rmmod 9pnet_virtio' as I want to
> replace it without rebooting system.

I do that all the time when testing, it works for me.
What exact kernel commit are you running?

> Here I have not mount 9pfs yet, so the refcount is still 0.
>
> Before rmmod:
> # lsmod | grep 9p
> 9pnet_virtio 20480 0
> 9pnet 106496 1 9pnet_virtio
> virtio_ring 28672 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net
> virtio 16384 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net
>
> After rmmod:
> # lsmod | grep 9p
> 9pnet_virtio 20480 0
> 9pnet 106496 1 9pnet_virtio
> virtio_ring 28672 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net
> virtio 16384 5 virtio_scsi,9pnet_virtio,virtio_pci,virtio_blk,virtio_net
>
> Normally 9pnet_virtio should be invisible after rmmod like this:
> # lsmod | grep 9p
> 9pnet 106496 0

Right, that obviously didn't work...

But on the other hand, if I apply your commit and load/unload
9pnet_virtio 5-10 times (I ran it in a loop) I get KASAN errors because
we put too many of these refs ; that doesn't happen without your patch
so it's apparently wrong.
I'm curious how that could make modprobe work better for you as well, it
shouldn't depend on that...

Maybe `modprobe -r` might give a better error, or something in dmesg?

--
Dominique