Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4882623rdh; Wed, 29 Nov 2023 13:34:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFrdTk82NeRPlVGoqvcZlpoyvqG80ooOTLiKthiw52DPKbi+Vqx8h6VX4JAJajzEFRHdjKW X-Received: by 2002:a05:6a00:430f:b0:6cd:df27:9519 with SMTP id cb15-20020a056a00430f00b006cddf279519mr2061983pfb.34.1701293653169; Wed, 29 Nov 2023 13:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701293653; cv=none; d=google.com; s=arc-20160816; b=EjMLDS4O1y5L6sD+MkPSvyHMgBvpzSoKTJ9lCqu6BHoZtnFvAs5m4qVUipmJOV4KIN X7i2Vqqaaa7iedjqy4whY9pHiHFQsCR9g9YIGHLJGkG0HjHq+7shvubnr8x8kLI2pCva +fwMDm5P2XAcv54TNw8Kpymor8+DA9qWQvh681MWLaGqaKJRov1KmkrKo0z4NfXOeJkP tQc3BvH81VE0jz0Ck5hBu8Oe1QMH/05TPKh77/NXRgRTl+PAHcyLH61uFMb4Wx5grBWF qDOvxDrgO8onORTaYtE1hklFpWehZmsQz2bW8ZzieffqpxwWxtFdnOhJKIHjJZbDId3Q pWXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=QmSY2pGQxU6w1k15KLPfxFzFL1f+liuJFRwQZE7zOc8=; fh=wIHqZpOIuzcidDZ82yQbOZuyHJty7uvaWDEh/efoVzA=; b=0sTLQJ3IL/XgFwL6MWTcVxqCwziZF1kZMlA/aSC/2ddhTylW2996651E/cYnOQn/Ro Qadf9l5C552DPjlTBFFj8ZIF4YsOYuB59Jb8OIqpqQcSCglbLdEcs7mUWr9VKKyT+My9 ++tQrXlgV5XU3ma+vL/V6jO8YiqUyXl2W1wcNILZ1fH72eERpGBPlfelxEFf5fg6LRUU DZebevMaOiSyC3kejT6KnGwhGw/QKLe4JCWGYiRdglJdgTs8aLsnxn/qe+L9oFXF07+m gWWFGI8BMMIzZdQrtLWpobc2kkTwn4gpJekYhYoTx9tXV8QId9Slm04XkyR55vG2r6Xk E1NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=W1rIug4u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k7-20020a63f007000000b005a073e0cc9asi14859395pgh.803.2023.11.29.13.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:34:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=W1rIug4u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E19C680B8F3F; Wed, 29 Nov 2023 13:33:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234456AbjK2Vda (ORCPT + 99 others); Wed, 29 Nov 2023 16:33:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234391AbjK2Vd1 (ORCPT ); Wed, 29 Nov 2023 16:33:27 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 994EB10C8; Wed, 29 Nov 2023 13:33:30 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 6CE79120005; Thu, 30 Nov 2023 00:33:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 6CE79120005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701293608; bh=QmSY2pGQxU6w1k15KLPfxFzFL1f+liuJFRwQZE7zOc8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=W1rIug4uP/DmTlK06JboTA4kzwXh49hnZ2HA4OURAphPgk2EqZfSp4sHdjQSYLxVp XT6dZ5luuarNNloOKM8krcAo/O1KA05E9oBxOcFCr7jOiNsSlDmQwJBB+VkN/XZR0g 1a/YZDCSK5mPv5h+NPp7nC3yVr8/5rpQdmA27BnsagKtqG8KU2Yi3wpMjcshWpRtfM fWLCxWcAis/KxCVN6yuyIZd4NA5xEzxgmOPZF2D55aPb6GXWwJDow06yAtqXuy9Vdp KawCi1cpSDWwrtJl8A1Zdz31kbMcNEtYen8y4j68Dzxhmde/ZXgMeP5PJei2sDUkJe MQleIDksgAyig== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 30 Nov 2023 00:33:28 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 30 Nov 2023 00:33:27 +0300 From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , Subject: [RFC PATCH v4 0/3] send credit update during setting SO_RCVLOWAT Date: Thu, 30 Nov 2023 00:25:16 +0300 Message-ID: <20231129212519.2938875-1-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181714 [Nov 29 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: avkrasnov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;git.kernel.org:7.1.1;127.0.0.199:7.1.2;100.64.160.123:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1;lore.kernel.org:7.1.1;salutedevices.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2023/11/29 20:51:00 X-KSMG-LinksScanning: Clean, bases: 2023/11/29 20:51:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/11/29 19:17:00 #22574327 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 29 Nov 2023 13:33:57 -0800 (PST) Hello, DESCRIPTION This patchset fixes old problem with hungup of both rx/tx sides and adds test for it. This happens due to non-default SO_RCVLOWAT value and deferred credit update in virtio/vsock. Link to previous old patchset: https://lore.kernel.org/netdev/39b2e9fd-601b-189d-39a9-914e5574524c@sberdevices.ru/ Here is what happens step by step: TEST INITIAL CONDITIONS 1) Vsock buffer size is 128KB. 2) Maximum packet size is also 64KB as defined in header (yes it is hardcoded, just to remind about that value). 3) SO_RCVLOWAT is default, e.g. 1 byte. STEPS SENDER RECEIVER 1) sends 128KB + 1 byte in a single buffer. 128KB will be sent, but for 1 byte sender will wait for free space at peer. Sender goes to sleep. 2) reads 64KB, credit update not sent 3) sets SO_RCVLOWAT to 64KB + 1 4) poll() -> wait forever, there is only 64KB available to read. So in step 4) receiver also goes to sleep, waiting for enough data or connection shutdown message from the sender. Idea to fix it is that rx kicks tx side to continue transmission (and may be close connection) when rx changes number of bytes to be woken up (e.g. SO_RCVLOWAT) and this value is bigger than number of available bytes to read. I've added small test for this, but not sure as it uses hardcoded value for maximum packet length, this value is defined in kernel header and used to control deferred credit update. And as this is not available to userspace, I can't control test parameters correctly (if one day this define will be changed - test may become useless). Head for this patchset is: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=f1be1e04c76bb9c44789d3575bba4418cf0ea359 Link to v1: https://lore.kernel.org/netdev/20231108072004.1045669-1-avkrasnov@salutedevices.com/ Link to v2: https://lore.kernel.org/netdev/20231119204922.2251912-1-avkrasnov@salutedevices.com/ Link to v3: https://lore.kernel.org/netdev/20231122180510.2297075-1-avkrasnov@salutedevices.com/ Changelog: v1 -> v2: * Patchset rebased and tested on new HEAD of net-next (see hash above). * New patch is added as 0001 - it removes return from SO_RCVLOWAT set callback in 'af_vsock.c' when transport callback is set - with that we can set 'sk_rcvlowat' only once in 'af_vsock.c' and in future do not copy-paste it to every transport. It was discussed in v1. * See per-patch changelog after ---. v2 -> v3: * See changelog after --- in 0003 only (0001 and 0002 still same). v3 -> v4: * Patchset rebased and tested on new HEAD of net-next (see hash above). * See per-patch changelog after ---. Arseniy Krasnov (3): vsock: update SO_RCVLOWAT setting callback virtio/vsock: send credit update during setting SO_RCVLOWAT vsock/test: SO_RCVLOWAT + deferred credit update test drivers/vhost/vsock.c | 3 +- include/linux/virtio_vsock.h | 1 + include/net/af_vsock.h | 2 +- net/vmw_vsock/af_vsock.c | 9 +- net/vmw_vsock/hyperv_transport.c | 4 +- net/vmw_vsock/virtio_transport.c | 3 +- net/vmw_vsock/virtio_transport_common.c | 27 +++++ net/vmw_vsock/vsock_loopback.c | 3 +- tools/testing/vsock/vsock_test.c | 149 ++++++++++++++++++++++++ 9 files changed, 193 insertions(+), 8 deletions(-) -- 2.25.1