[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230421030345-mutt-send-email-mst@kernel.org>
Date: Fri, 21 Apr 2023 03:04:12 -0400
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Jason Wang <jasowang@...hat.com>
Cc: Andrey Smetanin <asmetanin@...dex-team.ru>, kvm@...r.kernel.org,
virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, yc-core@...dex-team.ru
Subject: Re: [PATCH] vhost_net: revert upend_idx only on retriable error
On Thu, Dec 01, 2022 at 05:01:58PM +0800, Jason Wang wrote:
> On Wed, Nov 23, 2022 at 6:24 PM Andrey Smetanin
> <asmetanin@...dex-team.ru> wrote:
> >
> > Fix possible virtqueue used buffers leak and corresponding stuck
> > in case of temporary -EIO from sendmsg() which is produced by
> > tun driver while backend device is not up.
> >
> > In case of no-retriable error and zcopy do not revert upend_idx
> > to pass packet data (that is update used_idx in corresponding
> > vhost_zerocopy_signal_used()) as if packet data has been
> > transferred successfully.
>
> Should we mark head.len as VHOST_DMA_DONE_LEN in this case?
>
> Thanks
Jason do you want to take over this work? It's been stuck
in my inbox for a while.
> >
> > Signed-off-by: Andrey Smetanin <asmetanin@...dex-team.ru>
> > ---
> > drivers/vhost/net.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> > index 20265393aee7..93e9166039b9 100644
> > --- a/drivers/vhost/net.c
> > +++ b/drivers/vhost/net.c
> > @@ -934,13 +934,16 @@ static void handle_tx_zerocopy(struct vhost_net *net, struct socket *sock)
> >
> > err = sock->ops->sendmsg(sock, &msg, len);
> > if (unlikely(err < 0)) {
> > + bool retry = err == -EAGAIN || err == -ENOMEM || err == -ENOBUFS;
> > +
> > if (zcopy_used) {
> > if (vq->heads[ubuf->desc].len == VHOST_DMA_IN_PROGRESS)
> > vhost_net_ubuf_put(ubufs);
> > - nvq->upend_idx = ((unsigned)nvq->upend_idx - 1)
> > - % UIO_MAXIOV;
> > + if (retry)
> > + nvq->upend_idx = ((unsigned)nvq->upend_idx - 1)
> > + % UIO_MAXIOV;
> > }
> > - if (err == -EAGAIN || err == -ENOMEM || err == -ENOBUFS) {
> > + if (retry) {
> > vhost_discard_vq_desc(vq, 1);
> > vhost_net_enable_vq(net, vq);
> > break;
> > --
> > 2.25.1
> >
Powered by blists - more mailing lists