From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: kvm@vger.kernel.org, netdev@vger.kernel.org,
Gautam Dawar <gdawar.xilinx@gmail.com>,
linux-kernel@vger.kernel.org, gdawar@xilinx.com,
virtualization@lists.linux-foundation.org, martinh@xilinx.com,
hanand@xilinx.com
Subject: Re: [PATCH] vhost-vdpa: log warning message if vhost_vdpa_remove gets blocked
Date: Sat, 3 Jul 2021 04:11:45 -0400 [thread overview]
Message-ID: <20210703041124-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <aa866c72-c3d9-9022-aa5b-b5a9fc9e946a@redhat.com>
On Tue, Jun 15, 2021 at 10:33:22PM +0800, Jason Wang wrote:
>
> 在 2021/6/6 下午9:29, Gautam Dawar 写道:
> > From: Gautam Dawar <gdawar@xilinx.com>
> >
> > If some module invokes vdpa_device_unregister (usually in the module
> > unload function) when the userspace app (eg. QEMU) which had opened
> > the vhost-vdpa character device is still running, vhost_vdpa_remove()
> > function will block indefinitely in call to wait_for_completion().
> >
> > This causes the vdpa_device_unregister caller to hang and with a
> > usual side-effect of rmmod command not returning when this call
> > is in the module_exit function.
> >
> > This patch converts the wait_for_completion call to its timeout based
> > counterpart (wait_for_completion_timeout) and also adds a warning
> > message to alert the user/administrator about this hang situation.
> >
> > To eventually fix this problem, a mechanism will be required to let
> > vhost-vdpa module inform the userspace of this situation and
> > userspace will close the descriptor of vhost-vdpa char device.
> > This will enable vhost-vdpa to continue with graceful clean-up.
> >
> > Signed-off-by: Gautam Dawar <gdawar@xilinx.com>
> > ---
> > drivers/vhost/vdpa.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > index bfa4c6ef554e..572b64d09b06 100644
> > --- a/drivers/vhost/vdpa.c
> > +++ b/drivers/vhost/vdpa.c
> > @@ -1091,7 +1091,11 @@ static void vhost_vdpa_remove(struct vdpa_device *vdpa)
> > opened = atomic_cmpxchg(&v->opened, 0, 1);
> > if (!opened)
> > break;
> > - wait_for_completion(&v->completion);
> > + wait_for_completion_timeout(&v->completion,
> > + msecs_to_jiffies(1000));
> > + dev_warn_ratelimited(&v->dev,
> > + "%s waiting for /dev/%s to be closed\n",
> > + __func__, dev_name(&v->dev));
Can fill up the kernel log in this case ... dev_warn_once seems more
appropriate.
> > } while (1);
> > put_device(&v->dev);
>
>
> Acked-by: Jason Wang <jasowang@redhat.com>
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Gautam Dawar <gdawar.xilinx@gmail.com>,
martinh@xilinx.com, hanand@xilinx.com, gdawar@xilinx.com,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost-vdpa: log warning message if vhost_vdpa_remove gets blocked
Date: Sat, 3 Jul 2021 04:11:45 -0400 [thread overview]
Message-ID: <20210703041124-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <aa866c72-c3d9-9022-aa5b-b5a9fc9e946a@redhat.com>
On Tue, Jun 15, 2021 at 10:33:22PM +0800, Jason Wang wrote:
>
> 在 2021/6/6 下午9:29, Gautam Dawar 写道:
> > From: Gautam Dawar <gdawar@xilinx.com>
> >
> > If some module invokes vdpa_device_unregister (usually in the module
> > unload function) when the userspace app (eg. QEMU) which had opened
> > the vhost-vdpa character device is still running, vhost_vdpa_remove()
> > function will block indefinitely in call to wait_for_completion().
> >
> > This causes the vdpa_device_unregister caller to hang and with a
> > usual side-effect of rmmod command not returning when this call
> > is in the module_exit function.
> >
> > This patch converts the wait_for_completion call to its timeout based
> > counterpart (wait_for_completion_timeout) and also adds a warning
> > message to alert the user/administrator about this hang situation.
> >
> > To eventually fix this problem, a mechanism will be required to let
> > vhost-vdpa module inform the userspace of this situation and
> > userspace will close the descriptor of vhost-vdpa char device.
> > This will enable vhost-vdpa to continue with graceful clean-up.
> >
> > Signed-off-by: Gautam Dawar <gdawar@xilinx.com>
> > ---
> > drivers/vhost/vdpa.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > index bfa4c6ef554e..572b64d09b06 100644
> > --- a/drivers/vhost/vdpa.c
> > +++ b/drivers/vhost/vdpa.c
> > @@ -1091,7 +1091,11 @@ static void vhost_vdpa_remove(struct vdpa_device *vdpa)
> > opened = atomic_cmpxchg(&v->opened, 0, 1);
> > if (!opened)
> > break;
> > - wait_for_completion(&v->completion);
> > + wait_for_completion_timeout(&v->completion,
> > + msecs_to_jiffies(1000));
> > + dev_warn_ratelimited(&v->dev,
> > + "%s waiting for /dev/%s to be closed\n",
> > + __func__, dev_name(&v->dev));
Can fill up the kernel log in this case ... dev_warn_once seems more
appropriate.
> > } while (1);
> > put_device(&v->dev);
>
>
> Acked-by: Jason Wang <jasowang@redhat.com>
>
next prev parent reply other threads:[~2021-07-03 8:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-06 13:29 [PATCH] vhost-vdpa: log warning message if vhost_vdpa_remove gets blocked Gautam Dawar
2021-06-06 13:29 ` Gautam Dawar
2021-06-15 14:33 ` Jason Wang
2021-06-15 14:33 ` Jason Wang
2021-07-03 8:11 ` Michael S. Tsirkin [this message]
2021-07-03 8:11 ` Michael S. Tsirkin
2021-07-03 19:08 ` Gautam Dawar
2021-07-03 19:01 ` gautam.dawar
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=20210703041124-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=gdawar.xilinx@gmail.com \
--cc=gdawar@xilinx.com \
--cc=hanand@xilinx.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martinh@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.