[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ea414c31-741f-6994-651a-a686cba3d25e@sberdevices.ru>
Date: Wed, 20 Jul 2022 05:46:01 +0000
From: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
To: Stefano Garzarella <sgarzare@...hat.com>
CC: "David S. Miller" <davem@...emloft.net>,
"edumazet@...gle.com" <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Stefan Hajnoczi <stefanha@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Krasnov Arseniy <oxffffaa@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"virtualization@...ts.linux-foundation.org"
<virtualization@...ts.linux-foundation.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
kernel <kernel@...rdevices.ru>
Subject: Re: [RFC PATCH v1 3/3] vsock_test: POLLIN + SO_RCVLOWAT test.
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@...rdevices.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
poll()). May be i can remove "SRVSENT" as sleep is enough.
>
Powered by blists - more mailing lists