Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4618909rwb; Mon, 8 Aug 2022 04:28:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7g7IXejAw9NpEqXnUDbghhPTRRTVLbEyzdtysyJ4vOM4ZlQgNhuM2D0lhJhhij0qU9C5xU X-Received: by 2002:a62:79c4:0:b0:52d:cd3d:2027 with SMTP id u187-20020a6279c4000000b0052dcd3d2027mr18524263pfc.71.1659958124261; Mon, 08 Aug 2022 04:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659958124; cv=none; d=google.com; s=arc-20160816; b=huCR7ddneE7iZ9eW3X92v9fehmGERyrH2Ip/mwn/501IjMNZdRu2YtQBmSSmpZyBhG VDMPffCpOA0pXJUzfOqGDSzS71l91n3mZJZtZOw9k485BHDEl/Y+lPn120QARFYYXoJw 1lzoaIBQRzEeS8mDH6K5sZxG0AkbvMYe4o6wKrX7uND8pkutmuE93X/aqm0SfuSO/Hy0 L1VZSmJZL4ZmS3D2Jlnh0A1Q9Yl82EKo/qvRTpcUBTStwWb1AbWasX/HWXN2M9L4E+9u n7mDU7krr+2aA+iDfw1ibj2j4B0t073l6T5r/9zyVIVhLggc3OHxolxkWFQv4p30+JDF 2Alg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yY0JFPsIeaqtqI4iFArqAoOxJZBsLvWKUrWCsvYe/Bc=; b=xPj/WuX4xqFIWnW/n399dRgqOPNGNNp2oOy7SY+1ipxhbH7y5IoTsqAAsHh/69IwLg qJvGhOiKeT2/Q/utEFE5mQbiCcJk+6lbXxS/2RmKJTfcSO1dl2BexJkZHWE8jxE/bJUh HdtA1F+f+ldpFjLsAxssft1B20b+SSJjD0GXSb4qgr+wLJZMEYdmWjNniKpwTNS5DvC9 U68JjR2VTn0UNH+PuMS32vCr/nwxKQHkmD2oRc6pNDyqcj4rjrJBUQswM0aJGcGpJFlj ffeGT0JR6n89dDO9iGjG2rnrjWgHEPxeAatxELk2DMcLBpQuY0/I6yeVPGhePMyGXX8p AKyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g5INBvX+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a056a00080600b0052ab2efeec4si11625861pfk.280.2022.08.08.04.28.28; Mon, 08 Aug 2022 04:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g5INBvX+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236317AbiHHLOa (ORCPT + 99 others); Mon, 8 Aug 2022 07:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242754AbiHHLO1 (ORCPT ); Mon, 8 Aug 2022 07:14:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6107C6449 for ; Mon, 8 Aug 2022 04:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659957265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yY0JFPsIeaqtqI4iFArqAoOxJZBsLvWKUrWCsvYe/Bc=; b=g5INBvX+6CvKAqjWw2DupmWSeLQhrfClfnREWRG+f5r64a4dVFAIFqEeJ71jRvItmTqlWz 6ZI1n/LaDmtHQij4QY0n6vdF46VILNDzhHeAaDasqvJtHMkfbh/va1a+2c2A9gNBgPwG8n vQ7HYvUsRJIvtubc2cunhBPo7YpCmr4= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-279-81rcekkcPTGXxYg0unhmTg-1; Mon, 08 Aug 2022 07:14:24 -0400 X-MC-Unique: 81rcekkcPTGXxYg0unhmTg-1 Received: by mail-qk1-f199.google.com with SMTP id bs41-20020a05620a472900b006b8e84d6cddso7629035qkb.19 for ; Mon, 08 Aug 2022 04:14:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=yY0JFPsIeaqtqI4iFArqAoOxJZBsLvWKUrWCsvYe/Bc=; b=Sa6Y1hNfhfn23JSACwcJgQ+KUCBrfiVVC8/1JPeT26uqNjlghnJCcugsUrNGO0LRWj J1pvHFIAZhxdxTsrXr9C0KJaj6dD72+KyGmOn8lEF1TWwXrjWTJCnFWhIDnMN1EtyVDC TQWHkqreRxfykjYFzKVVUoRSDh8cQu6IkNygI8rlub3XoxdGk83lb2Y7ds6eYn+ED+IA 2NQmWzGyX2Dkr3iphDpxJ2If/k5OhATH8xmBvo0uH7cL+fSIvDFnE/RmfvrUVaOcWI5c G8XDruE3Gbqz1Bfq+c+XrL15Xq1Txmx0aGZpxVAnKX1v6i6k/2XTK4PPNWGGMILaRoS2 I4gA== X-Gm-Message-State: ACgBeo0MKZCRqzXjVQEt5z9P0L4EJTXb4HdK4h/Jf3sO9CJDdwvJlcYT ptwJh5rzjkTEAF+ORHUYEX++EhaWqDjdWmdajjzFcqa9mKqlEk5890WYnTvAcO0MhX74li1fXN3 7gpUZYYd4lqGlYtFjtx/C23mw X-Received: by 2002:a37:9602:0:b0:6b8:753c:729d with SMTP id y2-20020a379602000000b006b8753c729dmr13647127qkd.83.1659957263905; Mon, 08 Aug 2022 04:14:23 -0700 (PDT) X-Received: by 2002:a37:9602:0:b0:6b8:753c:729d with SMTP id y2-20020a379602000000b006b8753c729dmr13647106qkd.83.1659957263654; Mon, 08 Aug 2022 04:14:23 -0700 (PDT) Received: from sgarzare-redhat (host-79-46-200-178.retail.telecomitalia.it. [79.46.200.178]) by smtp.gmail.com with ESMTPSA id n1-20020ac86741000000b00342f932c47csm1906952qtp.46.2022.08.08.04.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Aug 2022 04:14:22 -0700 (PDT) Date: Mon, 8 Aug 2022 13:14:12 +0200 From: Stefano Garzarella To: Arseniy Krasnov Cc: "David S. Miller" , "edumazet@google.com" , Jakub Kicinski , Paolo Abeni , "kys@microsoft.com" , "haiyangz@microsoft.com" , "sthemmin@microsoft.com" , "wei.liu@kernel.org" , Dexuan Cui , Stefan Hajnoczi , Bryan Tan , Vishnu Dasa , VMware PV-Drivers Reviewers , Krasnov Arseniy , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "kvm@vger.kernel.org" , kernel Subject: Re: [RFC PATCH v3 9/9] vsock_test: POLLIN + SO_RCVLOWAT test Message-ID: <20220808111412.iywihoyszvswomlb@sgarzare-redhat> References: <2ac35e2c-26a8-6f6d-2236-c4692600db9e@sberdevices.ru> <1f50d595-cd37-ad61-f165-5632162dc682@sberdevices.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1f50d595-cd37-ad61-f165-5632162dc682@sberdevices.ru> X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 03, 2022 at 02:07:58PM +0000, Arseniy Krasnov wrote: >This adds test to check,that when poll() returns POLLIN,POLLRDNORM bits, >next read call won't block. > >Signed-off-by: Arseniy Krasnov >--- > tools/testing/vsock/vsock_test.c | 107 +++++++++++++++++++++++++++++++ > 1 file changed, 107 insertions(+) > >diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c >index dc577461afc2..920dc5d5d979 100644 >--- a/tools/testing/vsock/vsock_test.c >+++ b/tools/testing/vsock/vsock_test.c >@@ -18,6 +18,7 @@ > #include > #include > #include >+#include > > #include "timeout.h" > #include "control.h" >@@ -596,6 +597,107 @@ 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"); >+ >+ /* Wait until client is ready to receive rest of data. */ >+ control_expectln("CLNSENT"); >+ >+ for (i = 0; i < RCVLOWAT_BUF_SIZE - 1; i++) >+ send_byte(fd, 1, 0); >+ >+ /* Keep socket in active state. */ >+ control_expectln("POLLDONE"); >+ >+ close(fd); >+} >+ >+static void test_stream_poll_rcvlowat_client(const struct test_opts *opts) >+{ >+ unsigned long lowat_val = RCVLOWAT_BUF_SIZE; >+ char buf[RCVLOWAT_BUF_SIZE]; >+ struct pollfd fds; >+ ssize_t read_res; >+ short poll_flags; >+ int fd; >+ >+ fd = vsock_stream_connect(opts->peer_cid, 1234); >+ if (fd < 0) { >+ perror("connect"); >+ exit(EXIT_FAILURE); >+ } >+ >+ if (setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT, >+ &lowat_val, sizeof(lowat_val))) { A small checkpatch warning that you can fix since you have to resend: CHECK: Alignment should match open parenthesis #76: FILE: tools/testing/vsock/vsock_test.c:645: + if (setsockopt(fd, SOL_SOCKET, SO_RCVLOWAT, + &lowat_val, sizeof(lowat_val))) { total: 0 errors, 0 warnings, 1 checks, 125 lines checked Thanks, Stefano