From: Arseny Krasnov <arseny.krasnov@kaspersky.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jorgen Hansen <jhansen@vmware.com>,
Andra Paraschiv <andraprs@amazon.com>,
Colin Ian King <colin.king@canonical.com>,
Norbert Slusarek <nslusarek@gmx.net>, kvm <kvm@vger.kernel.org>,
Linux Virtualization <virtualization@lists.linux-foundation.org>,
netdev <netdev@vger.kernel.org>,
kernel list <linux-kernel@vger.kernel.org>,
Krasnov Arseniy <oxffffaa@gmail.com>
Subject: Re: [RFC PATCH v1 08/16] af_vsock: change SEQPACKET receive loop
Date: Wed, 30 Jun 2021 20:47:56 +0300 [thread overview]
Message-ID: <8769f306-1b95-6cda-828a-68c298093ad3@kaspersky.com> (raw)
In-Reply-To: <CAGxU2F5XtfKJ9cnK=J-gz4uW0AR9FsMc1Dq2jQx=dPGLRC+NTQ@mail.gmail.com>
On 30.06.2021 15:12, Stefano Garzarella wrote:
> On Mon, Jun 28, 2021 at 01:03:28PM +0300, Arseny Krasnov wrote:
>> Receive "loop" now really loop: it reads fragments one by
>> one, sleeping if queue is empty.
>>
>> NOTE: 'msg_ready' pointer is not passed to 'seqpacket_dequeue()'
>> here - it change callback interface, so it is moved to next patch.
>>
>> Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com>
>> ---
>> net/vmw_vsock/af_vsock.c | 31 ++++++++++++++++++++++---------
>> 1 file changed, 22 insertions(+), 9 deletions(-)
> I think you can merge patches 8, 9, and 10 together since we
> are touching the seqpacket_dequeue() behaviour.
>
> Then you can remove in separate patches the unneeded parts (e.g.
> seqpacket_has_data, msg_count, etc.).
>
> Thanks,
> Stefano
Ack
>
>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>> index 59ce35da2e5b..9552f05119f2 100644
>> --- a/net/vmw_vsock/af_vsock.c
>> +++ b/net/vmw_vsock/af_vsock.c
>> @@ -2003,6 +2003,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>> size_t len, int flags)
>> {
>> const struct vsock_transport *transport;
>> + bool msg_ready;
>> struct vsock_sock *vsk;
>> ssize_t record_len;
>> long timeout;
>> @@ -2013,23 +2014,36 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>> transport = vsk->transport;
>>
>> timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
>> + msg_ready = false;
>> + record_len = 0;
>>
>> - err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0);
>> - if (err <= 0)
>> - goto out;
>> + while (!msg_ready) {
>> + ssize_t fragment_len;
>> + int intr_err;
>>
>> - record_len = transport->seqpacket_dequeue(vsk, msg, flags);
>> + intr_err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0);
>> + if (intr_err <= 0) {
>> + err = intr_err;
>> + break;
>> + }
>>
>> - if (record_len < 0) {
>> - err = -ENOMEM;
>> - goto out;
>> + fragment_len = transport->seqpacket_dequeue(vsk, msg, flags);
>> +
>> + if (fragment_len < 0) {
>> + err = -ENOMEM;
>> + break;
>> + }
>> +
>> + record_len += fragment_len;
>> }
>>
>> if (sk->sk_err) {
>> err = -sk->sk_err;
>> } else if (sk->sk_shutdown & RCV_SHUTDOWN) {
>> err = 0;
>> - } else {
>> + }
>> +
>> + if (msg_ready && !err) {
>> /* User sets MSG_TRUNC, so return real length of
>> * packet.
>> */
>> @@ -2045,7 +2059,6 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
>> msg->msg_flags |= MSG_TRUNC;
>> }
>>
>> -out:
>> return err;
>> }
>>
>> --
>> 2.25.1
>>
>
next prev parent reply other threads:[~2021-06-30 17:48 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-28 9:59 [RFC PATCH v1 00/16] Improve SOCK_SEQPACKET receive logic Arseny Krasnov
2021-06-28 10:01 ` [RFC PATCH v1 01/16] vhost/vsock: don't set 'seqpacket_has_data()' callback Arseny Krasnov
2021-06-28 10:01 ` [RFC PATCH v1 02/16] vsock/loopback: " Arseny Krasnov
2021-06-28 10:02 ` [RFC PATCH v1 03/16] virtio/vsock: " Arseny Krasnov
2021-06-28 10:02 ` [RFC PATCH v1 04/16] virtio/vsock: remove 'virtio_transport_seqpacket_has_data' Arseny Krasnov
2021-06-28 10:02 ` [RFC PATCH v1 05/16] af_vsock: use SOCK_STREAM function to check data Arseny Krasnov
2021-06-30 12:10 ` Stefano Garzarella
2021-06-30 17:47 ` [MASSMAIL KLMS] " Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 06/16] vsock/virtio: remove record size limit for SEQPACKET Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 07/16] virtio/vsock: don't count EORs on receive Arseny Krasnov
2021-06-30 12:11 ` Stefano Garzarella
2021-06-30 17:47 ` Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 08/16] af_vsock: change SEQPACKET receive loop Arseny Krasnov
2021-06-30 12:12 ` Stefano Garzarella
2021-06-30 17:47 ` Arseny Krasnov [this message]
2021-06-28 10:03 ` [RFC PATCH v1 09/16] af_vsock/virtio: update dequeue callback interface Arseny Krasnov
2021-06-28 10:03 ` [RFC PATCH v1 10/16] virtio/vsock: update SEQPACKET dequeue logic Arseny Krasnov
2021-06-28 10:04 ` [RFC PATCH v1 11/16] afvsock: add 'seqpacket_drop()' Arseny Krasnov
2021-06-30 12:12 ` Stefano Garzarella
2021-06-30 17:48 ` Arseny Krasnov
2021-06-28 10:04 ` [RFC PATCH v1 12/16] virtio/vsock: add 'drop until EOR' logic Arseny Krasnov
2021-06-28 10:04 ` [RFC PATCH v1 13/16] vhost/vsock: enable 'seqpacket_drop' callback in transport Arseny Krasnov
2021-06-28 10:05 ` [RFC PATCH v1 14/16] virtio/vsock: " Arseny Krasnov
2021-06-28 10:05 ` [RFC PATCH v1 15/16] vsock/loopback: " Arseny Krasnov
2021-06-28 10:05 ` [RFC PATCH v1 16/16] vsock_test: SEQPACKET read to broken buffer Arseny Krasnov
2021-06-30 12:17 ` Stefano Garzarella
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=8769f306-1b95-6cda-828a-68c298093ad3@kaspersky.com \
--to=arseny.krasnov@kaspersky.com \
--cc=andraprs@amazon.com \
--cc=colin.king@canonical.com \
--cc=davem@davemloft.net \
--cc=jasowang@redhat.com \
--cc=jhansen@vmware.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=nslusarek@gmx.net \
--cc=oxffffaa@gmail.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®