From: "Michael S. Tsirkin" <mst@redhat.com>
To: 谢永吉 <xieyongji@bytedance.com>
Cc: jasowang@redhat.com, akpm@linux-foundation.org,
linux-mm@kvack.org, virtualization@lists.linux-foundation.org
Subject: Re: [External] Re: [RFC 3/4] vduse: grab the module's references until there is no vduse device
Date: Mon, 19 Oct 2020 12:41:46 -0400 [thread overview]
Message-ID: <20201019123835-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACycT3vG+ZEhn3SYy=7c5rkMz4XRbQZL21NdpPozPnH_x6Srhg@mail.gmail.com>
On Mon, Oct 19, 2020 at 11:56:35PM +0800, 谢永吉 wrote:
>
>
>
> On Mon, Oct 19, 2020 at 11:47 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Mon, Oct 19, 2020 at 11:44:36PM +0800, 谢永吉 wrote:
> >
> >
> > On Mon, Oct 19, 2020 at 11:05 PM Michael S. Tsirkin <mst@redhat.com>
> wrote:
> >
> > On Mon, Oct 19, 2020 at 10:56:22PM +0800, Xie Yongji wrote:
> > > The module should not be unloaded if any vduse device exists.
> > > So increase the module's reference count when creating vduse
> > > device. And the reference count is kept until the device is
> > > destroyed.
> > >
> > > Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
> > > ---
> > > drivers/vdpa/vdpa_user/vduse_dev.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/
> vdpa_user/
> > vduse_dev.c
> > > index 6787ba66725c..f04aa02de8c1 100644
> > > --- a/drivers/vdpa/vdpa_user/vduse_dev.c
> > > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
> > > @@ -887,6 +887,7 @@ static int vduse_destroy_dev(u32 id)
> > > kfree(dev->vqs);
> > > vduse_iova_domain_destroy(dev->domain);
> > > vduse_dev_destroy(dev);
> > > + module_put(THIS_MODULE);
> > >
> > > return 0;
> > > }
> > > @@ -931,6 +932,7 @@ static int vduse_create_dev(struct
> vduse_dev_config
> > *config)
> > >
> > > dev->connected = true;
> > > list_add(&dev->list, &vduse_devs);
> > > + __module_get(THIS_MODULE);
> > >
> > > return fd;
> > > err_fd:
> >
> > This kind of thing is usually an indicator of a bug. E.g.
> > if the refcount drops to 0 on module_put(THIS_MODULE) it
> > will be unloaded and the following return will not run.
> >
> >
> >
> > Should this happen? The refcount should be only decreased to 0 after the
> > misc_device is closed?
> >
> > Thanks,
> > Yongji
> >
>
> OTOH if it never drops to 0 anyway then why do you need to increase it?
>
>
>
> To prevent unloading the module in the case that the device is created, but no
> user process using it (e.g. the user process crashed).
>
> Thanks,
> Yongji
Looks like it can drop to 0 if that is the case then?
>
> >
> >
> > > --
> > > 2.25.1
> >
> >
>
>
next prev parent reply other threads:[~2020-10-19 16:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 14:56 [RFC 0/4] Introduce VDUSE - vDPA Device in Userspace Xie Yongji
2020-10-19 14:56 ` [RFC 1/4] mm: export zap_page_range() for driver use Xie Yongji
2020-10-19 15:14 ` Matthew Wilcox
2020-10-19 15:36 ` [External] " 谢永吉
2020-10-19 14:56 ` [RFC 2/4] vduse: Introduce VDUSE - vDPA Device in Userspace Xie Yongji
2020-10-19 15:08 ` Michael S. Tsirkin
2020-10-19 15:24 ` Randy Dunlap
2020-10-19 15:46 ` [External] " 谢永吉
2020-10-19 15:48 ` 谢永吉
2020-10-19 14:56 ` [RFC 3/4] vduse: grab the module's references until there is no vduse device Xie Yongji
2020-10-19 15:05 ` Michael S. Tsirkin
2020-10-19 15:44 ` [External] " 谢永吉
2020-10-19 15:47 ` Michael S. Tsirkin
2020-10-19 15:56 ` 谢永吉
2020-10-19 16:41 ` Michael S. Tsirkin [this message]
2020-10-20 7:42 ` Yongji Xie
2020-10-19 14:56 ` [RFC 4/4] vduse: Add memory shrinker to reclaim bounce pages Xie Yongji
2020-10-19 17:16 ` [RFC 0/4] Introduce VDUSE - vDPA Device in Userspace Michael S. Tsirkin
2020-10-20 2:18 ` [External] " 谢永吉
2020-10-20 2:20 ` Jason Wang
2020-10-20 2:28 ` 谢永吉
2020-10-20 3:20 ` Jason Wang
2020-10-20 7:39 ` [External] " Yongji Xie
2020-10-20 8:01 ` Jason Wang
2020-10-20 8:35 ` Yongji Xie
2020-10-20 9:12 ` Jason Wang
2020-10-23 2:55 ` Yongji Xie
2020-10-23 8:44 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201019123835-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jasowang@redhat.com \
--cc=linux-mm@kvack.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=xieyongji@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).