From: Stefano Garzarella <sgarzare@redhat.com>
To: "Jiang Wang ." <jiang.wang@bytedance.com>
Cc: cong.wang@bytedance.com,
Xiongchun Duan <duanxiongchun@bytedance.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
cohuck@redhat.com, virtualization@lists.linux-foundation.org,
Yongji Xie <xieyongji@bytedance.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Arseny Krasnov <arseny.krasnov@kaspersky.com>
Subject: Re: [RFC v2] virtio-vsock: add description for datagram type
Date: Wed, 9 Jun 2021 09:40:11 +0200 [thread overview]
Message-ID: <20210609074011.at7wx2jxkquy7ykk@steredhat> (raw)
In-Reply-To: <CAP_N_Z9hKXKyf28Ve9U1O2DPACvbc4YdjNARL7brT01TuFtdBA@mail.gmail.com>
On Tue, Jun 08, 2021 at 09:31:28PM -0700, Jiang Wang . wrote:
>On Tue, May 18, 2021 at 9:59 PM Jiang Wang . <jiang.wang@bytedance.com> wrote:
>>
>> On Tue, May 18, 2021 at 6:02 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>> >
>> > On Mon, May 17, 2021 at 11:33:06PM -0700, Jiang Wang . wrote:
>> > >On Mon, May 17, 2021 at 4:02 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>> > >>
>> > >> On Fri, May 14, 2021 at 11:55:29AM -0700, Jiang Wang . wrote:
>> > >> >On Fri, May 14, 2021 at 8:17 AM Stefano Garzarella <sgarzare@redhat.com> wrote:
>> > >> >> On Thu, May 13, 2021 at 04:26:03PM -0700, Jiang Wang . wrote:
>> > >>
>> > >> [...]
>> > >>
>> > >> >> >I see. I will add some limit to dgram packets. Also, when the
>> > >> >> >virtqueues
>> > >> >> >are shared between stream and dgram, both of them need to grab a lock
>> > >> >> >before using the virtqueue, so one will not completely block another one.
>> > >> >>
>> > >> >> I'm not worried about the concurrent access that we definitely need to
>> > >> >> handle with a lock, but more about the uncontrolled packet sending that
>> > >> >> dgram might have, flooding the queues and preventing others from
>> > >> >> communicating.
>> > >> >
>> > >> >That is a valid concern. Let me explain how I would handle that if we
>> > >> >don't add two new virtqueues. For dgram, I also add a dgram_send_pkt_list,
>> > >> >which is similar to send_pkt_list for stream (and seqpacket). But there
>> > >> >is one difference. The dgram_send_pkt_list has a maximum size setting,
>> > >> >and keep tracking how many pkts are in the list. The track number
>> > >> >(dgram_send_pkt_list_size) is increased when a packet is added
>> > >> >to the list and is decreased when a packet
>> > >> >is removed from the list and added to the virtqueue. In
>> > >> >virtio_transport_send_pkt, if the current
>> > >> >dgram_send_pkt_list_size is equal
>> > >> >to the maximum ( let's say 128), then it will not add to the
>> > >> >dgram_send_pkt_list and return an error to the application.
>> > >>
>> > >> For stream socket, we have the send_pkt_list and the send worker because
>> > >> the virtqueue can be full and the transmitter needs to wait available
>> > >> slots, because we can't discard packets.
>> > >> For dgram I think we don't need this, so we can avoid the
>> > >> dgram_send_pkt_list and directly enqueue packets in the virtqueue.
>> > >>
>
>For the question of whether we need dgram_send_pkt_list, I tried to remove
>it and that has no problem with virtio vsock in the guest. But on the host, we
>still need to keep the dgram_send_pkt_list. The reason is that we cannot
>access virtqueue memory reliably in the syscall handling of an
>arbitrary process.
>The virtqueue memory is in the QEMU process virtual memory and may be
>paged out.
I see, I think in that case we can use the virtqueue size as limit for
the dgram_send_pkt_list.
I mean for example if the virtqueue has 128 elements, we can queue at
least 128 packets in the dgram_send_pkt_list.
If you have a better idea go ahead, we can discuss this implementation
detail in the RFC linux series :-)
Thanks,
Stefano
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2021-06-09 7:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 4:36 [RFC v2] virtio-vsock: add description for datagram type jiang.wang
2021-04-12 13:50 ` Stefan Hajnoczi
2021-04-12 14:21 ` Stefano Garzarella
2021-04-12 22:42 ` Jiang Wang .
2021-04-13 12:58 ` Stefano Garzarella
2021-04-13 13:16 ` Michael S. Tsirkin
2021-04-13 13:38 ` Stefano Garzarella
2021-04-13 13:50 ` Michael S. Tsirkin
2021-04-13 14:03 ` Stefano Garzarella
2021-04-13 19:58 ` Michael S. Tsirkin
2021-04-13 22:00 ` Jiang Wang .
2021-04-14 7:07 ` Stefano Garzarella
2021-04-14 6:57 ` Stefano Garzarella
2021-04-14 7:20 ` Michael S. Tsirkin
2021-04-14 9:38 ` Stefano Garzarella
2021-04-15 3:15 ` Jiang Wang .
2021-05-04 3:40 ` Jiang Wang .
2021-05-04 16:16 ` Stefano Garzarella
2021-05-04 17:06 ` Jiang Wang .
2021-05-05 10:49 ` Stefano Garzarella
2021-05-05 16:58 ` Jiang Wang .
2021-05-07 16:53 ` Jiang Wang .
2021-05-10 14:50 ` Stefano Garzarella
2021-05-13 23:26 ` Jiang Wang .
2021-05-14 15:17 ` Stefano Garzarella
2021-05-14 18:55 ` Jiang Wang .
2021-05-17 11:02 ` Stefano Garzarella
2021-05-18 6:33 ` Jiang Wang .
2021-05-18 13:02 ` Stefano Garzarella
2021-05-19 4:59 ` Jiang Wang .
2021-06-09 4:31 ` Jiang Wang .
2021-06-09 7:40 ` Stefano Garzarella [this message]
2021-04-12 22:39 ` [External] " Jiang Wang .
2021-05-13 14:57 ` Stefan Hajnoczi
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=20210609074011.at7wx2jxkquy7ykk@steredhat \
--to=sgarzare@redhat.com \
--cc=arseny.krasnov@kaspersky.com \
--cc=cohuck@redhat.com \
--cc=cong.wang@bytedance.com \
--cc=duanxiongchun@bytedance.com \
--cc=jiang.wang@bytedance.com \
--cc=mst@redhat.com \
--cc=stefanha@redhat.com \
--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