From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: virtualization@lists.linux.dev, jasowang@redhat.com,
xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
parav@nvidia.com, feliu@nvidia.com,
Heng Qi <hengqi@linux.alibaba.com>
Subject: Re: [PATCH virtio 7/8] virtio_pci_modern: use completion instead of busy loop to wait on admin cmd result
Date: Mon, 24 Jun 2024 07:30:54 -0400 [thread overview]
Message-ID: <20240624072340-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20240624090451.2683976-8-jiri@resnulli.us>
On Mon, Jun 24, 2024 at 11:04:50AM +0200, Jiri Pirko wrote:
> @@ -73,21 +91,30 @@ static int virtqueue_exec_admin_cmd(struct virtio_pci_device *vp_dev,
> !((1ULL << opcode) & admin_vq->supported_cmds))
> return -EOPNOTSUPP;
>
> - ret = virtqueue_add_sgs(vq, sgs, out_num, in_num, cmd, GFP_KERNEL);
> - if (ret < 0)
> - return -EIO;
> -
> - if (unlikely(!virtqueue_kick(vq)))
> - return -EIO;
> + init_completion(&cmd->completion);
>
> - while (!virtqueue_get_buf(vq, &len) &&
> - !virtqueue_is_broken(vq))
> - cpu_relax();
> +again:
> + spin_lock_irqsave(&admin_vq->lock, flags);
> + ret = virtqueue_add_sgs(vq, sgs, out_num, in_num, cmd, GFP_KERNEL);
> + if (ret < 0) {
> + if (ret == -ENOSPC) {
> + spin_unlock_irqrestore(&admin_vq->lock, flags);
> + cpu_relax();
> + goto again;
> + }
> + goto unlock_err;
> + }
> + if (WARN_ON_ONCE(!virtqueue_kick(vq)))
> + goto unlock_err;
> + spin_unlock_irqrestore(&admin_vq->lock, flags);
>
> - if (virtqueue_is_broken(vq))
> - return -EIO;
> + wait_for_completion(&cmd->completion);
>
> return 0;
> +
> +unlock_err:
> + spin_unlock_irqrestore(&admin_vq->lock, flags);
> + return -EIO;
> }
>
The reason we had the virtqueue_is_broken check previously,
is because this way surprise removal works: it happens to set
vq broken flag on all vqs.
So if you are changing that to a completion, I think surprise
removal needs to trigger a callback so the completion
can be signalled.
I think the cvq work also needs this, BTW.
--
MST
next prev parent reply other threads:[~2024-06-24 11:31 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 9:04 [PATCH virtio 0/8] virtio_pci_modern: allow parallel admin queue commands execution Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 1/8] virtio_pci: push out single vq find code to vp_find_one_vq_msix() Jiri Pirko
2024-06-24 10:52 ` Heng Qi
2024-06-24 13:11 ` Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 2/8] virtio_pci_modern: treat vp_dev->admin_vq.info.vq pointer as static Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 3/8] virtio: push out code to vp_avq_index() Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 4/8] virtio: create admin queues alongside other virtqueues Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 5/8] virtio_pci_modern: create admin queue of queried size Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 6/8] virtio_pci_modern: pass cmd as an identification token Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 7/8] virtio_pci_modern: use completion instead of busy loop to wait on admin cmd result Jiri Pirko
2024-06-24 11:30 ` Michael S. Tsirkin [this message]
2024-06-24 13:10 ` Jiri Pirko
2024-06-25 11:07 ` Jiri Pirko
2024-06-25 12:53 ` Parav Pandit
2024-06-25 14:29 ` Jiri Pirko
2024-06-24 11:34 ` Michael S. Tsirkin
2024-06-24 13:10 ` Jiri Pirko
2024-06-24 9:04 ` [PATCH virtio 8/8] virtio_pci_modern: remove admin queue serialization lock Jiri Pirko
2024-06-24 9:53 ` [PATCH virtio 0/8] virtio_pci_modern: allow parallel admin queue commands execution Heng Qi
2024-06-24 11:23 ` Michael S. Tsirkin
2024-06-24 13:46 ` Jiri Pirko
2024-06-24 13:55 ` Michael S. Tsirkin
2024-06-24 14:51 ` Jiri Pirko
2024-06-24 15:16 ` Michael S. Tsirkin
2024-06-25 2:11 ` Heng Qi
2024-06-25 6:38 ` Jiri Pirko
2024-06-25 6:41 ` Parav Pandit
2024-06-25 7:29 ` Michael S. Tsirkin
2024-06-25 8:01 ` Jiri Pirko
2024-06-25 7:20 ` Michael S. Tsirkin
2024-06-25 7:25 ` Parav Pandit
2024-06-24 15:10 ` Jiri Pirko
2024-06-24 15:23 ` Michael S. Tsirkin
2024-06-24 15:45 ` Jiri Pirko
2024-06-24 11:07 ` Michael S. Tsirkin
2024-06-24 13:09 ` Jiri Pirko
2024-06-24 13:16 ` Michael S. Tsirkin
2024-06-24 13:36 ` Jiri Pirko
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=20240624072340-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=feliu@nvidia.com \
--cc=hengqi@linux.alibaba.com \
--cc=jasowang@redhat.com \
--cc=jiri@resnulli.us \
--cc=parav@nvidia.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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).