mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
To: Stefano Garzarella <sgarzare@redhat.com>,
	Bryan Tan <bryantan@vmware.com>, Vishnu Dasa <vdasa@vmware.com>,
	VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"kys@microsoft.com" <kys@microsoft.com>,
	"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"sthemmin@microsoft.com" <sthemmin@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"Dexuan Cui" <decui@microsoft.com>,
	Krasnov Arseniy <oxffffaa@gmail.com>,
	"virtualization@lists.linux-foundation.org" 
	<virtualization@lists.linux-foundation.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	kernel <kernel@sberdevices.ru>
Subject: Re: [RFC PATCH v2 0/9] vsock: updates for SO_RCVLOWAT handling
Date: Thu, 28 Jul 2022 06:08:38 +0000	[thread overview]
Message-ID: <d5166d4e-4892-4cdf-df01-4da43b8e269d@sberdevices.ru> (raw)
In-Reply-To: <20220727123710.pwzy6ag3gavotxda@sgarzare-redhat>

On 27.07.2022 15:37, Stefano Garzarella wrote:
> Hi Arseniy,
> 
> On Mon, Jul 25, 2022 at 07:54:05AM +0000, Arseniy Krasnov wrote:
>> Hello,
>>
>> This patchset includes some updates for SO_RCVLOWAT:
>>
>> 1) af_vsock:
>>   During my experiments with zerocopy receive, i found, that in some
>>   cases, poll() implementation violates POSIX: when socket has non-
>>   default SO_RCVLOWAT(e.g. not 1), poll() will always set POLLIN and
>>   POLLRDNORM bits in 'revents' even number of bytes available to read
>>   on socket is smaller than SO_RCVLOWAT value. In this case,user sees
>>   POLLIN flag and then tries to read data(for example using  'read()'
>>   call), but read call will be blocked, because  SO_RCVLOWAT logic is
>>   supported in dequeue loop in af_vsock.c. But the same time,  POSIX
>>   requires that:
>>
>>   "POLLIN     Data other than high-priority data may be read without
>>               blocking.
>>    POLLRDNORM Normal data may be read without blocking."
>>
>>   See https://www.open-std.org/jtc1/sc22/open/n4217.pdf, page 293.
>>
>>   So, we have, that poll() syscall returns POLLIN, but read call will
>>   be blocked.
>>
>>   Also in man page socket(7) i found that:
>>
>>   "Since Linux 2.6.28, select(2), poll(2), and epoll(7) indicate a
>>   socket as readable only if at least SO_RCVLOWAT bytes are available."
>>
>>   I checked TCP callback for poll()(net/ipv4/tcp.c, tcp_poll()), it
>>   uses SO_RCVLOWAT value to set POLLIN bit, also i've tested TCP with
>>   this case for TCP socket, it works as POSIX required.
>>
>>   I've added some fixes to af_vsock.c and virtio_transport_common.c,
>>   test is also implemented.
>>
>> 2) virtio/vsock:
>>   It adds some optimization to wake ups, when new data arrived. Now,
>>   SO_RCVLOWAT is considered before wake up sleepers who wait new data.
>>   There is no sense, to kick waiter, when number of available bytes
>>   in socket's queue < SO_RCVLOWAT, because if we wake up reader in
>>   this case, it will wait for SO_RCVLOWAT data anyway during dequeue,
>>   or in poll() case, POLLIN/POLLRDNORM bits won't be set, so such
>>   exit from poll() will be "spurious". This logic is also used in TCP
>>   sockets.
> 
> Nice, it looks good!
Thank You!
> 
>>
>> 3) vmci/vsock:
>>   Same as 2), but i'm not sure about this changes. Will be very good,
>>   to get comments from someone who knows this code.
> 
> I CCed VMCI maintainers to the patch and also to this cover, maybe better to keep them in the loop for next versions.
> 
> (Jorgen's and Rajesh's emails bounced back, so I'm CCing here only Bryan, Vishnu, and pv-drivers@vmware.com)
Ok, i'll CC them in the next version
> 
>>
>> 4) Hyper-V:
>>   As Dexuan Cui mentioned, for Hyper-V transport it is difficult to
>>   support SO_RCVLOWAT, so he suggested to disable this feature for
>>   Hyper-V.
> 
> I left a couple of comments in some patches, but it seems to me to be in a good state :-)
> 
> I would just suggest a bit of a re-organization of the series (the patches are fine, just the order):
>   - introduce vsock_set_rcvlowat()
>   - disabling it for hv_sock
>   - use 'target' in virtio transports
>   - use 'target' in vmci transports
>   - use sock_rcvlowat in vsock_poll()
>     I think is better to pass sock_rcvlowat() as 'target' when the
>     transports are already able to use it
>   - add vsock_data_ready()
>   - use vsock_data_ready() in virtio transports
>   - use vsock_data_ready() in vmci transports
>   - tests
> 
> What do you think?
No problem! I think i can wait for reply from VMWare guys before preparing v3
> 
> Thanks,
> Stefano
> 


  reply	other threads:[~2022-07-28  6:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25  7:54 Arseniy Krasnov
2022-07-25  7:56 ` [RFC PATCH v2 1/9] vsock: use sk_rcvlowat to set POLLIN/POLLRDNORM Arseniy Krasnov
2022-07-27 12:17   ` Stefano Garzarella
2022-07-28  6:04     ` Arseniy Krasnov
2022-07-25  7:59 ` [RFC PATCH v2 2/9] virtio/vsock: use 'target' in notify_poll_in, callback Arseniy Krasnov
2022-07-25  8:01 ` [RFC PATCH v2 3/9] vmci/vsock: " Arseniy Krasnov
2022-07-27 12:22   ` Stefano Garzarella
2022-07-27 12:29     ` Stefano Garzarella
2022-07-28  6:05     ` Arseniy Krasnov
2022-07-25  8:03 ` [RFC PATCH v2 4/9] vsock_test: POLLIN + SO_RCVLOWAT test Arseniy Krasnov
2022-07-25  8:05 ` [RFC PATCH v2 5/9] vsock: SO_RCVLOWAT transport set callback Arseniy Krasnov
2022-07-27 12:24   ` Stefano Garzarella
2022-07-28  6:06     ` Arseniy Krasnov
2022-07-25  8:07 ` [RFC PATCH v2 6/9] hv_sock: disable SO_RCVLOWAT support Arseniy Krasnov
2022-08-02  5:42   ` Dexuan Cui
2022-07-25  8:09 ` [RFC PATCH v2 7/9] vsock: add API call for data ready Arseniy Krasnov
2022-07-25  8:11 ` [RFC PATCH v2 8/9] virtio/vsock: check SO_RCVLOWAT before wake up reader Arseniy Krasnov
2022-07-25  8:13 ` [RFC PATCH v2 9/9] vmci/vsock: " Arseniy Krasnov
2022-07-27 12:37 ` [RFC PATCH v2 0/9] vsock: updates for SO_RCVLOWAT handling Stefano Garzarella
2022-07-28  6:08   ` Arseniy Krasnov [this message]
2022-08-02  5:31     ` Vishnu Dasa
2022-08-02  5:35       ` Arseniy Krasnov
2022-08-02  5:35   ` Vishnu Dasa
2022-08-02  8:04     ` 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=d5166d4e-4892-4cdf-df01-4da43b8e269d@sberdevices.ru \
    --to=avkrasnov@sberdevices.ru \
    --cc=bryantan@vmware.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=edumazet@google.com \
    --cc=haiyangz@microsoft.com \
    --cc=kernel@sberdevices.ru \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=oxffffaa@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pv-drivers@vmware.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=sthemmin@microsoft.com \
    --cc=vdasa@vmware.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wei.liu@kernel.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®