From: Stefano Garzarella <sgarzare@redhat.com>
To: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
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>,
Krasnov Arseniy <oxffffaa@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
kernel <kernel@sberdevices.ru>
Subject: Re: [RFC PATCH v1 3/3] vsock_test: POLLIN + SO_RCVLOWAT test.
Date: Wed, 20 Jul 2022 10:56:49 +0200 [thread overview]
Message-ID: <20220720085649.6pqj55hmkxlamxjq@sgarzare-redhat> (raw)
In-Reply-To: <ea414c31-741f-6994-651a-a686cba3d25e@sberdevices.ru>
On Wed, Jul 20, 2022 at 05:46:01AM +0000, Arseniy Krasnov wrote:
>On 19.07.2022 15:52, Stefano Garzarella wrote:
>> On Mon, Jul 18, 2022 at 08:19:06AM +0000, Arseniy Krasnov wrote:
>>> This adds test to check, that when poll() returns POLLIN and
>>> POLLRDNORM bits, next read call won't block.
>>>
>>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>>> ---
>>> tools/testing/vsock/vsock_test.c | 90 ++++++++++++++++++++++++++++++++
>>> 1 file changed, 90 insertions(+)
>>>
>>> diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
>>> index dc577461afc2..8e394443eaf6 100644
>>> --- a/tools/testing/vsock/vsock_test.c
>>> +++ b/tools/testing/vsock/vsock_test.c
>>> @@ -18,6 +18,7 @@
>>> #include <sys/socket.h>
>>> #include <time.h>
>>> #include <sys/mman.h>
>>> +#include <poll.h>
>>>
>>> #include "timeout.h"
>>> #include "control.h"
>>> @@ -596,6 +597,90 @@ static void test_seqpacket_invalid_rec_buffer_server(const struct test_opts *opt
>>> close(fd);
>>> }
>>>
>>> +static void test_stream_poll_rcvlowat_server(const struct test_opts *opts)
>>> +{
>>> +#define RCVLOWAT_BUF_SIZE 128
>>> + int fd;
>>> + int i;
>>> +
>>> + fd = vsock_stream_accept(VMADDR_CID_ANY, 1234, NULL);
>>> + if (fd < 0) {
>>> + perror("accept");
>>> + exit(EXIT_FAILURE);
>>> + }
>>> +
>>> + /* Send 1 byte. */
>>> + send_byte(fd, 1, 0);
>>> +
>>> + control_writeln("SRVSENT");
>>> +
>>> + /* Just empirically delay value. */
>>> + sleep(4);
>>
>> Why we need this sleep()?
>Purpose of sleep() is to move client in state, when it has 1 byte of rx data
>and poll() won't wake. For example:
>client: server:
>waits for "SRVSENT"
> send 1 byte
> send "SRVSENT"
>poll()
> sleep
>...
>poll sleeps
>...
> send rest of data
>poll wake up
>
>I think, without sleep there is chance, that client enters poll() when whole
>data from server is already received, thus test will be useless(it just tests
Right, I see (maybe add a comment in the test).
>poll()). May be i can remove "SRVSENT" as sleep is enough.
I think it's fine.
An alternative could be to use the `timeout` of poll():
client: server:
waits for "SRVSENT"
send 1 byte
send "SRVSENT"
poll(, timeout = 1 * 1000)
wait for "CLNSENT"
poll should return 0
send "CLNSENT"
poll(, timeout = 10 * 1000)
...
poll sleeps
...
send rest of data
poll wake up
I don't have a strong opinion, also your version seems fine, just an
alternative ;-)
Maybe in your version you can add a 10 sec timeout to poll, to avoid
that the test stuck for some reason (failing if the timeout is reached).
Thanks,
Stefano
next prev parent reply other threads:[~2022-07-20 8:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 8:12 [RFC PATCH v1 0/3] virtio/vsock: use SO_RCVLOWAT to set POLLIN/POLLRDNORM Arseniy Krasnov
2022-07-18 8:15 ` [RFC PATCH v1 1/3] vsock: use sk_skrcvlowat to set POLLIN,POLLRDNORM, bits Arseniy Krasnov
2022-07-19 12:44 ` Stefano Garzarella
2022-07-20 5:35 ` Arseniy Krasnov
2022-07-18 8:17 ` [RFC PATCH v1 2/3] virtio/vsock: use 'target' in notify_poll_in, callback Arseniy Krasnov
2022-07-19 12:48 ` Stefano Garzarella
2022-07-20 5:38 ` Arseniy Krasnov
2022-07-20 8:23 ` Stefano Garzarella
2022-07-20 18:54 ` Dexuan Cui
2022-07-21 6:02 ` Arseniy Krasnov
2022-07-18 8:19 ` [RFC PATCH v1 3/3] vsock_test: POLLIN + SO_RCVLOWAT test Arseniy Krasnov
2022-07-19 12:52 ` Stefano Garzarella
2022-07-20 5:46 ` Arseniy Krasnov
2022-07-20 8:56 ` Stefano Garzarella [this message]
2022-07-19 12:58 ` [RFC PATCH v1 0/3] virtio/vsock: use SO_RCVLOWAT to set POLLIN/POLLRDNORM Stefano Garzarella
2022-07-20 6:07 ` Arseniy Krasnov
2022-07-20 9:30 ` Stefano Garzarella
2022-07-20 10:52 ` Arseniy Krasnov
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=20220720085649.6pqj55hmkxlamxjq@sgarzare-redhat \
--to=sgarzare@redhat.com \
--cc=AVKrasnov@sberdevices.ru \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel@sberdevices.ru \
--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=oxffffaa@gmail.com \
--cc=pabeni@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;
as well as URLs for NNTP newsgroup(s).