From patchwork Mon Jul 25 07:56:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80189C433EF for ; Mon, 25 Jul 2022 07:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232492AbiGYH5X (ORCPT ); Mon, 25 Jul 2022 03:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiGYH5W (ORCPT ); Mon, 25 Jul 2022 03:57:22 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3305FD135; Mon, 25 Jul 2022 00:57:20 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 7EEF45FD0B; Mon, 25 Jul 2022 10:57:18 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658735838; bh=3yFDKShsdzLtXczy78DAfWUgL5KDQChLK4zk2QgRds0=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=EGu2Dbrm/JzyVU9s17oiJ4dY2K+UGlqrAuSJazSarGzav5+kEnjvT9NLhiO3MAtzY B4hY3uiJuy4ewR9VYVJXcWjwWTg6AfDWEZ0g8AGlQuE/P5ZcNThMwenBSLnpt1oK7r /zV/5iPkuwnITY+xbjl5T5j21MrKqfi69r7bM33ZHZh/X2CDTOSLhfykFOs7glH47Z gH6wryAX5DRKyndQQUSkZuooBhlv4akGpTjyoCVIxRHmRxPXBHNLFFqCGQ0dYEoW4c wT7xlN4kG8QUZNIgyWvYvbffFoKMuh1FYgZjxMmzfgGupPCvE7U1yE2AieaC4kweBj ODTc/xd9LblQQ== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 10:57:18 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , "Michael S. Tsirkin" , Arseniy Krasnov , Krasnov Arseniy CC: "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: [RFC PATCH v2 1/9] vsock: use sk_rcvlowat to set POLLIN/POLLRDNORM Thread-Topic: [RFC PATCH v2 1/9] vsock: use sk_rcvlowat to set POLLIN/POLLRDNORM Thread-Index: AQHYn/weV9iJ1kN02k+zjfwbZg+ycw== Date: Mon, 25 Jul 2022 07:56:59 +0000 Message-ID: In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: <8ED96AEDE2917D419B416B6B7150A4C0@sberdevices.ru> MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC Both bits indicate, that next data read call won't be blocked, but when sk_rcvlowat is not 1, these bits will be set by poll anyway, thus when user tries to dequeue data,it will wait until sk_rcvlowat bytes of data will be available. Signed-off-by: Arseniy Krasnov --- net/vmw_vsock/af_vsock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index f04abf662ec6..63a13fa2686a 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1066,8 +1066,9 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock, if (transport && transport->stream_is_active(vsk) && !(sk->sk_shutdown & RCV_SHUTDOWN)) { bool data_ready_now = false; + int target = sock_rcvlowat(sk, 0, INT_MAX); int ret = transport->notify_poll_in( - vsk, 1, &data_ready_now); + vsk, target, &data_ready_now); if (ret < 0) { mask |= EPOLLERR; } else { From patchwork Mon Jul 25 07:59:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3DD5C43334 for ; Mon, 25 Jul 2022 07:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbiGYH71 (ORCPT ); Mon, 25 Jul 2022 03:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiGYH7Z (ORCPT ); Mon, 25 Jul 2022 03:59:25 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44368D135; Mon, 25 Jul 2022 00:59:24 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id A53335FD0B; Mon, 25 Jul 2022 10:59:22 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658735962; bh=Ktbbd9hXNDd86/yoPDR8TGlX/txvLJI7Vez6o0MPzn4=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=gFDyn5lzlgkq+1RPQOn85zVANkvBlwyYpykkMIJY6UypfMMHCTtgI3V261SMRQmoM OEaiMZRkJBeIgBP0TBhaVDfXr2rgbxXJup8k5IHzw0e+Z1sOLk/O9hTkW/R/vdSeJw Cm+EUAhhdUkv/BBELOryaT+XCGy2TJvvUEbwh6ON79jddLMI9oWAvTuqk0s0kuNFoO TV5r+6XUM12EO+/dPIZdQ9wqEDpIwHU0IZs2viw5e2+HtibjdgElKHPiyWEDDzShwp 4GSt4btMauaGAt0WgK1BQeoIxmbNrScyFihaaEzKtDtnz/1XQjiWCbwDY1rwAntkUR wiAWTT4GD/e/g== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 10:59:21 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "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: [RFC PATCH v2 2/9] virtio/vsock: use 'target' in notify_poll_in, callback Thread-Topic: [RFC PATCH v2 2/9] virtio/vsock: use 'target' in notify_poll_in, callback Thread-Index: AQHYn/xnBQBRPJKwbEuxzxqKhyN7Rw== Date: Mon, 25 Jul 2022 07:59:02 +0000 Message-ID: In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This callback controls setting of POLLIN,POLLRDNORM output bits of poll() syscall,but in some cases,it is incorrectly to set it, when socket has at least 1 bytes of available data. Use 'target' which is already exists and equal to sk_rcvlowat in this case. Signed-off-by: Arseniy Krasnov --- net/vmw_vsock/virtio_transport_common.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index ec2c2afbf0d0..8f6356ebcdd1 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -634,10 +634,7 @@ virtio_transport_notify_poll_in(struct vsock_sock *vsk, size_t target, bool *data_ready_now) { - if (vsock_stream_has_data(vsk)) - *data_ready_now = true; - else - *data_ready_now = false; + *data_ready_now = vsock_stream_has_data(vsk) >= target; return 0; } From patchwork Mon Jul 25 08:01:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927826 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA329C43334 for ; Mon, 25 Jul 2022 08:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233408AbiGYICI (ORCPT ); Mon, 25 Jul 2022 04:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233254AbiGYIBn (ORCPT ); Mon, 25 Jul 2022 04:01:43 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F8F0C4D; Mon, 25 Jul 2022 01:01:23 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 6D3C55FD0D; Mon, 25 Jul 2022 11:01:21 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658736081; bh=clwHLJbaAdIOxlNPZw2nq1Q/tNfbQXWFX/0A1JAfY1A=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=JSJb3jvdz27xbfWwjpzAyXwjiBz1t+R9hEP6DBSuP/icxq/lSxSJpirmts2mZVpHc 3sdJE6TbMr69rpJFKvE+rdlw1eQ6tjrf4PPKRCGKl39BoTWWrMXSpp5mLwudktu36m NQ0eBeIASqh8WIh5xWzseHOSLEMqczHpYXoPIbdC5cPqICzXM7mIhG5hcozWHLFxeI bxZmU9JOIbqWDz3bCLomb44FZtw1rHyRp7ISFILWyps08JXbY04ljpQqiJDsn1Du8f kPnsBctDmZTNDPktCzgohpBjTIC/qbZ5d9emSDvICqowJeUH9xnHfXl8ISdALO4hBm 1uTzFKHlJWZTA== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 11:01:20 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "kvm@vger.kernel.org" , kernel Subject: [RFC PATCH v2 3/9] vmci/vsock: use 'target' in notify_poll_in, callback Thread-Topic: [RFC PATCH v2 3/9] vmci/vsock: use 'target' in notify_poll_in, callback Thread-Index: AQHYn/yuG7nDISN+mkeT5PR9a2L0xw== Date: Mon, 25 Jul 2022 08:01:01 +0000 Message-ID: <355f4bb6-82e7-2400-83e9-c704a7ef92f3@sberdevices.ru> In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This callback controls setting of POLLIN,POLLRDNORM output bits of poll() syscall,but in some cases,it is incorrectly to set it, when socket has at least 1 bytes of available data. Use 'target' which is already exists and equal to sk_rcvlowat in this case. Signed-off-by: Arseniy Krasnov --- net/vmw_vsock/vmci_transport_notify.c | 2 +- net/vmw_vsock/vmci_transport_notify_qstate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/vmw_vsock/vmci_transport_notify.c b/net/vmw_vsock/vmci_transport_notify.c index d69fc4b595ad..1684b85b0660 100644 --- a/net/vmw_vsock/vmci_transport_notify.c +++ b/net/vmw_vsock/vmci_transport_notify.c @@ -340,7 +340,7 @@ vmci_transport_notify_pkt_poll_in(struct sock *sk, { struct vsock_sock *vsk = vsock_sk(sk); - if (vsock_stream_has_data(vsk)) { + if (vsock_stream_has_data(vsk) >= target) { *data_ready_now = true; } else { /* We can't read right now because there is nothing in the diff --git a/net/vmw_vsock/vmci_transport_notify_qstate.c b/net/vmw_vsock/vmci_transport_notify_qstate.c index 0f36d7c45db3..a40407872b53 100644 --- a/net/vmw_vsock/vmci_transport_notify_qstate.c +++ b/net/vmw_vsock/vmci_transport_notify_qstate.c @@ -161,7 +161,7 @@ vmci_transport_notify_pkt_poll_in(struct sock *sk, { struct vsock_sock *vsk = vsock_sk(sk); - if (vsock_stream_has_data(vsk)) { + if (vsock_stream_has_data(vsk) >= target) { *data_ready_now = true; } else { /* We can't read right now because there is nothing in the From patchwork Mon Jul 25 08:03:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02B4ECCA48A for ; Mon, 25 Jul 2022 08:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233212AbiGYIDk (ORCPT ); Mon, 25 Jul 2022 04:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233079AbiGYIDj (ORCPT ); Mon, 25 Jul 2022 04:03:39 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A77EEDD5; Mon, 25 Jul 2022 01:03:37 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 023055FD0B; Mon, 25 Jul 2022 11:03:36 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658736216; bh=ResIOTy9DtBCfFDcIrfJCTjPADSZ5tQYImGjTsxUyvo=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=lM8Nl4Fbc/6vWHJhcXeHIxt3ITjWEOS8Onm/13zRj7S9F4ZkGxJZQ2lKjbkZrqwqp 6lLbHbgTguiShFfnfks3PKJ3nKeKgTEe/6LNPzgAxY1jvUPWGSRahgewHslfyPc+kU KGSg7TDhFz2dSBK2jNA4Y0B5K4ItSFYzkRO9dZh4Kl/oeQGxmLbFkOGukhmviv9rJD PipSBoEbqGpvcLXSbEJOcA4miUhEBCwWVBnJkfxGWJbLwrxhm1cPOMZ0WJWaJi8Qgm OxVxAxrMF+jz9Hy/b1M7d4A3g4nl2IPFGuI0EbTlsHroVI8sON55iwElzju4Yatb5b Bv3P2n2wcBQFw== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 11:03:35 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "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: [RFC PATCH v2 4/9] vsock_test: POLLIN + SO_RCVLOWAT test Thread-Topic: [RFC PATCH v2 4/9] vsock_test: POLLIN + SO_RCVLOWAT test Thread-Index: AQHYn/z+AQM5dz7N4k2SsXDpTP7kGA== Date: Mon, 25 Jul 2022 08:03:16 +0000 Message-ID: <84bf0761-0bd5-d93e-b192-6ef209da498f@sberdevices.ru> In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC 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))) { + perror("setsockopt"); + exit(EXIT_FAILURE); + } + + control_expectln("SRVSENT"); + + /* At this point, server sent 1 byte. */ + fds.fd = fd; + poll_flags = POLLIN | POLLRDNORM; + fds.events = poll_flags; + + /* Try to wait for 1 sec. */ + if (poll(&fds, 1, 1000) < 0) { + perror("poll"); + exit(EXIT_FAILURE); + } + + /* poll() must return nothing. */ + if (fds.revents) { + fprintf(stderr, "Unexpected poll result %hx\n", + fds.revents); + exit(EXIT_FAILURE); + } + + /* Tell server to send rest of data. */ + control_writeln("CLNSENT"); + + /* Poll for data. */ + if (poll(&fds, 1, 10000) < 0) { + perror("poll"); + exit(EXIT_FAILURE); + } + + /* Only these two bits are expected. */ + if (fds.revents != poll_flags) { + fprintf(stderr, "Unexpected poll result %hx\n", + fds.revents); + exit(EXIT_FAILURE); + } + + /* Use MSG_DONTWAIT, if call is going to wait, EAGAIN + * will be returned. + */ + read_res = recv(fd, buf, sizeof(buf), MSG_DONTWAIT); + if (read_res != RCVLOWAT_BUF_SIZE) { + fprintf(stderr, "Unexpected recv result %zi\n", + read_res); + exit(EXIT_FAILURE); + } + + control_writeln("POLLDONE"); + + close(fd); +} + static struct test_case test_cases[] = { { .name = "SOCK_STREAM connection reset", @@ -646,6 +748,11 @@ static struct test_case test_cases[] = { .run_client = test_seqpacket_invalid_rec_buffer_client, .run_server = test_seqpacket_invalid_rec_buffer_server, }, + { + .name = "SOCK_STREAM poll() + SO_RCVLOWAT", + .run_client = test_stream_poll_rcvlowat_client, + .run_server = test_stream_poll_rcvlowat_server, + }, {}, }; From patchwork Mon Jul 25 08:05:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC11C433EF for ; Mon, 25 Jul 2022 08:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233386AbiGYIFw (ORCPT ); Mon, 25 Jul 2022 04:05:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbiGYIFv (ORCPT ); Mon, 25 Jul 2022 04:05:51 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 292CA13CD8; Mon, 25 Jul 2022 01:05:50 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 47AE05FD0B; Mon, 25 Jul 2022 11:05:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658736348; bh=pCw9/kVOeCE/CCajlNyM8QpfiZna4eRW1EqZxJu2eJg=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=NipdLVEYo9awZ8x/aNxrBaWkKUZJULScNVDO/L5BjJu9VPXvNLJB5etTtlKSRTbRN QuHINHSY9o2W8nKRwPGrA7KXTUR5psVb0bg4D+PzLPmNqxhvd3FuiU7/FBdg+k221p O2MMfgjHndPhBKb1R/3pS/6XF5TWqpsaeBUztix0L0dSzx5YpbmjwnIH5+eY8kVvM6 kzoMZ+LK/uTBpJnaMi11fo8I36+AxR9KeaSRIS3xwqv5gfLKE4DPqfHKvOi76a8ZIF xDghmsCDdnLue7SaicVx1XVoQdTcbkBG6QwWXb6+MahRZ9l/37O7KRsOojWrekhhLO a/DAmCRqqVnfw== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 11:05:47 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "kvm@vger.kernel.org" , kernel Subject: [RFC PATCH v2 5/9] vsock: SO_RCVLOWAT transport set callback Thread-Topic: [RFC PATCH v2 5/9] vsock: SO_RCVLOWAT transport set callback Thread-Index: AQHYn/1NoPOM/Um+pUC5XxeDqd2x/w== Date: Mon, 25 Jul 2022 08:05:28 +0000 Message-ID: <8baa2e3a-af6b-c0fe-9bfb-7cf89506474a@sberdevices.ru> In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: <40D3115A2D73A340AB96E70176059B63@sberdevices.ru> MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This adds transport specific callback for SO_RCVLOWAT, because in some transports it may be difficult to know current available number of bytes ready to read. Thus, when SO_RCVLOWAT is set, transport may reject it. Signed-off-by: Arseniy Krasnov --- include/net/af_vsock.h | 1 + net/vmw_vsock/af_vsock.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h index f742e50207fb..eae5874bae35 100644 --- a/include/net/af_vsock.h +++ b/include/net/af_vsock.h @@ -134,6 +134,7 @@ struct vsock_transport { u64 (*stream_rcvhiwat)(struct vsock_sock *); bool (*stream_is_active)(struct vsock_sock *); bool (*stream_allow)(u32 cid, u32 port); + int (*set_rcvlowat)(struct vsock_sock *, int); /* SEQ_PACKET. */ ssize_t (*seqpacket_dequeue)(struct vsock_sock *vsk, struct msghdr *msg, diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 63a13fa2686a..b7a286db4af1 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -2130,6 +2130,24 @@ vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, return err; } +static int vsock_set_rcvlowat(struct sock *sk, int val) +{ + const struct vsock_transport *transport; + struct vsock_sock *vsk; + int err = 0; + + vsk = vsock_sk(sk); + transport = vsk->transport; + + if (transport->set_rcvlowat) + err = transport->set_rcvlowat(vsk, val); + + if (!err) + WRITE_ONCE(sk->sk_rcvlowat, val ? : 1); + + return err; +} + static const struct proto_ops vsock_stream_ops = { .family = PF_VSOCK, .owner = THIS_MODULE, @@ -2149,6 +2167,7 @@ static const struct proto_ops vsock_stream_ops = { .recvmsg = vsock_connectible_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, + .set_rcvlowat = vsock_set_rcvlowat, }; static const struct proto_ops vsock_seqpacket_ops = { From patchwork Mon Jul 25 08:07:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A7EFC43334 for ; Mon, 25 Jul 2022 08:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233558AbiGYIHn (ORCPT ); Mon, 25 Jul 2022 04:07:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiGYIHm (ORCPT ); Mon, 25 Jul 2022 04:07:42 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D21BC13CD2; Mon, 25 Jul 2022 01:07:40 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 3804D5FD0B; Mon, 25 Jul 2022 11:07:39 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658736459; bh=sObFnqMOAqUFZ0if5Z6xdt9QYQocsNhmpGqLuSvEmg0=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=ZSC+dgKzMe5KQOX2bHAFy9k1fbo6e4VPd+sP1+eVqADRou6+zZzNJ6VhcMGjrqS2O 5Lsv2cP1tdj3yS106hiwsdyYImOVdzfPQlmjW6ZSM8td35SZKUv+wcQIgedQndfDkY vl4bc3aR0gCvDJuY1aFzQ7zsfvZzgMsvVySHd9lJ/6SmbllceHWJJacRVciHcxhZpU k7ZT9Shga1rI+R9xGe2YS8xzye/k4uSxvMmX3DsePSp6NBQL6C3Z7wH4FxIKM5e2yS 5yYpSRDNj/GgrmiKD2jPp42rIHLNK9mHvxa3Yp16akDmFOyDuGuMzVdgRFgu9n/EtR W/l2T3ax8vweA== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 11:07:38 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "kvm@vger.kernel.org" , kernel Subject: [RFC PATCH v2 6/9] hv_sock: disable SO_RCVLOWAT support Thread-Topic: [RFC PATCH v2 6/9] hv_sock: disable SO_RCVLOWAT support Thread-Index: AQHYn/2PdDRRTeWJ4EqSAxbUzqz6wg== Date: Mon, 25 Jul 2022 08:07:19 +0000 Message-ID: <6ee85279-df24-7de1-d62d-7a8249fc8fc3@sberdevices.ru> In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: <0E7C70C150A9C040BEFBAFD04BAAB181@sberdevices.ru> MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC For Hyper-V it is quiet difficult to support this socket option,due to transport internals, so disable it. Signed-off-by: Arseniy Krasnov Reviewed-by: Dexuan Cui --- net/vmw_vsock/hyperv_transport.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c index e111e13b6660..5fab8f356a86 100644 --- a/net/vmw_vsock/hyperv_transport.c +++ b/net/vmw_vsock/hyperv_transport.c @@ -802,6 +802,12 @@ int hvs_notify_send_post_enqueue(struct vsock_sock *vsk, ssize_t written, return 0; } +static +int hvs_set_rcvlowat(struct vsock_sock *vsk, int val) +{ + return -EOPNOTSUPP; +} + static struct vsock_transport hvs_transport = { .module = THIS_MODULE, @@ -837,6 +843,7 @@ static struct vsock_transport hvs_transport = { .notify_send_pre_enqueue = hvs_notify_send_pre_enqueue, .notify_send_post_enqueue = hvs_notify_send_post_enqueue, + .set_rcvlowat = hvs_set_rcvlowat }; static bool hvs_check_transport(struct vsock_sock *vsk) From patchwork Mon Jul 25 08:09:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 694E6C433EF for ; Mon, 25 Jul 2022 08:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233589AbiGYIJi (ORCPT ); Mon, 25 Jul 2022 04:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbiGYIJh (ORCPT ); Mon, 25 Jul 2022 04:09:37 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6AFA13CF1; Mon, 25 Jul 2022 01:09:35 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 2FEB15FD0B; Mon, 25 Jul 2022 11:09:34 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658736574; bh=8Ivq+HaIhab5sDZRwlp1YxHLjfjPLxbgUFjb3B5LEag=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=miO2/SbY2I/aFgai9tTMeYxTqrqOESBDM5W50xeYgwrfl/w3iOi18mjdI2/wjPIgc 1iJhq9I/ck69I6/JUBJL6oc05XLjYduRzyHEfRVtlwq5eui/8qmfrEo/NUJlbFR5AS aRWF4DlvG44nnQqzXX6i1HZq/4EeuMLUhXTubQJghJZufe5KDBGkzj3RLGMHgiV7dq H3osn6G6llMi/fj3oIIsTdLqS+dkZtBML2IA4kOWGNtGAkkmxJTFrTPavob9FxGOKn ZevFhdRWZCTrHciwGk4LRVUy9/p6TPK81UBvTyBIbiFLM7wg7tj2MCi3fssRvIR46A MGoVN7hJ84teA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 11:09:32 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "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: [RFC PATCH v2 7/9] vsock: add API call for data ready Thread-Topic: [RFC PATCH v2 7/9] vsock: add API call for data ready Thread-Index: AQHYn/3THBoZAnkEuk6UJ/SrjY0PHA== Date: Mon, 25 Jul 2022 08:09:13 +0000 Message-ID: <56c7f26b-2996-9a0c-c5fa-0941d6f01542@sberdevices.ru> In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: <7EEE6F4618DD0C4DB88CB2235D12D41E@sberdevices.ru> MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This adds 'vsock_data_ready()' which must be called by transport to kick sleeping data readers. It checks for SO_RCVLOWAT value before waking user,thus preventing spurious wake ups.Based on 'tcp_data_ready()' logic. Signed-off-by: Arseniy Krasnov --- include/net/af_vsock.h | 1 + net/vmw_vsock/af_vsock.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h index eae5874bae35..7b79fc5164cc 100644 --- a/include/net/af_vsock.h +++ b/include/net/af_vsock.h @@ -77,6 +77,7 @@ struct vsock_sock { s64 vsock_stream_has_data(struct vsock_sock *vsk); s64 vsock_stream_has_space(struct vsock_sock *vsk); struct sock *vsock_create_connected(struct sock *parent); +void vsock_data_ready(struct sock *sk); /**** TRANSPORT ****/ diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index b7a286db4af1..4b3ec3f9383f 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -882,6 +882,16 @@ s64 vsock_stream_has_space(struct vsock_sock *vsk) } EXPORT_SYMBOL_GPL(vsock_stream_has_space); +void vsock_data_ready(struct sock *sk) +{ + struct vsock_sock *vsk = vsock_sk(sk); + + if (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat || + sock_flag(sk, SOCK_DONE)) + sk->sk_data_ready(sk); +} +EXPORT_SYMBOL_GPL(vsock_data_ready); + static int vsock_release(struct socket *sock) { __vsock_release(sock->sk, 0); From patchwork Mon Jul 25 08:11:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAE3ACCA473 for ; Mon, 25 Jul 2022 08:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233710AbiGYIL4 (ORCPT ); Mon, 25 Jul 2022 04:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbiGYILz (ORCPT ); Mon, 25 Jul 2022 04:11:55 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B56FB13CE5; Mon, 25 Jul 2022 01:11:53 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 031455FD0B; Mon, 25 Jul 2022 11:11:52 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658736712; bh=6XZQtWxl9pDfCffcJW86vuM5/TgZ8YvSCAXMREbLKGk=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=eYz29V8S80mjj6Cu3OXN/JPf+FO5amHW3qjlJXQnM1fB7txMjH/sIdNnoTMm68HTK SVprIGXmR+/grmDp/MmjWirkAnciVVILfoG34W2XtG3BlHMFJlEPPOLqBX97mu4w6k Ieqz//IqdKPi/0vjlqDnyetGnixehtAzwccq0sG4an0GbNGDg//nb8N10ocowWohoR GirePWBGl9lgBiro/jEOM4sCiCyEiOXNaD8YmhkJPqcSv36Tia4LN5M9BtpZZaAY5h d0cF2EP02CP8+rVFVGMTSE5rkr9KUX+N/GMHoSvnugjjZehQ9fraGe1M3koK8JdCnQ prqlLVwOlgmGQ== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 11:11:51 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "kvm@vger.kernel.org" , kernel Subject: [RFC PATCH v2 8/9] virtio/vsock: check SO_RCVLOWAT before wake up reader Thread-Topic: [RFC PATCH v2 8/9] virtio/vsock: check SO_RCVLOWAT before wake up reader Thread-Index: AQHYn/4msdZhsnhzrEat7NUwhk8xxA== Date: Mon, 25 Jul 2022 08:11:32 +0000 Message-ID: <821eea3a-f449-c889-4c43-6665e9421d95@sberdevices.ru> In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: <12F1E4F7463A144DB443C3811EAC5452@sberdevices.ru> MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This adds extra condition to wake up data reader: do it only when number of readable bytes >= SO_RCVLOWAT. Otherwise, there is no sense to kick user,because it will wait until SO_RCVLOWAT bytes will be dequeued. Signed-off-by: Arseniy Krasnov --- net/vmw_vsock/virtio_transport_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 8f6356ebcdd1..35863132f4f1 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1081,7 +1081,7 @@ virtio_transport_recv_connected(struct sock *sk, switch (le16_to_cpu(pkt->hdr.op)) { case VIRTIO_VSOCK_OP_RW: virtio_transport_recv_enqueue(vsk, pkt); - sk->sk_data_ready(sk); + vsock_data_ready(sk); return err; case VIRTIO_VSOCK_OP_CREDIT_REQUEST: virtio_transport_send_credit_update(vsk); From patchwork Mon Jul 25 08:13:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12927857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C9FCC433EF for ; Mon, 25 Jul 2022 08:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233825AbiGYIN4 (ORCPT ); Mon, 25 Jul 2022 04:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233764AbiGYINw (ORCPT ); Mon, 25 Jul 2022 04:13:52 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A530C13DD2; Mon, 25 Jul 2022 01:13:45 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id 190835FD0B; Mon, 25 Jul 2022 11:13:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1658736824; bh=0VolYYzByKFenHk7cNZW+B/GD/dVG5AI5iMaU934WLI=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=pl/k/J4dr5/K2zhWjDqsI3QB4a9FNrML10R9GEmttN+XJjuttiEBF7ZMyhqPbFTP7 T3wvE53MGKHiFk8A8n+VdPOdRT+HH8hkJKz1cJGNxM1xgEZkgA2N18fqkT0lhJJa6R 5ofF5p6KrQxgDMabyrgHjD+AUDQRY4b7kWuw7G9NhObGiXkW/HZ/mnLJEhwZOT1NJA u789hjNHVfSntbLj7RIAOI5RyP5F2psxIpA2HUY5ylq0cPMPdo0WMwC1ytffQH0YVJ Mv/tAicXkZ813BF655eNtgdGCFn9Cq/xBdDWB5PFxZgk3F9f3aWyPhFRQ8GYMsmk3X k3OxeFJPcx5ug== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 25 Jul 2022 11:13:42 +0300 (MSK) From: Arseniy Krasnov To: Stefano Garzarella , "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 , Arseniy Krasnov , Krasnov Arseniy CC: "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "kvm@vger.kernel.org" , kernel Subject: [RFC PATCH v2 9/9] vmci/vsock: check SO_RCVLOWAT before wake up reader Thread-Topic: [RFC PATCH v2 9/9] vmci/vsock: check SO_RCVLOWAT before wake up reader Thread-Index: AQHYn/5oY29w5nBisUCpLo7sMc0FdQ== Date: Mon, 25 Jul 2022 08:13:23 +0000 Message-ID: <664ce269-ba46-926e-9c34-070079a7ae3e@sberdevices.ru> In-Reply-To: <19e25833-5f5c-f9b9-ac0f-1945ea17638d@sberdevices.ru> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-ID: <1F5A3AF0531B954A9BA3E54B91976C95@sberdevices.ru> MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/07/25 03:52:00 #19956163 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC This adds extra condition to wake up data reader: do it only when number of readable bytes >= SO_RCVLOWAT. Otherwise, there is no sense to kick user,because it will wait until SO_RCVLOWAT bytes will be dequeued. Signed-off-by: Arseniy Krasnov --- net/vmw_vsock/vmci_transport_notify.c | 2 +- net/vmw_vsock/vmci_transport_notify_qstate.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/vmw_vsock/vmci_transport_notify.c b/net/vmw_vsock/vmci_transport_notify.c index 1684b85b0660..ab42d73ab3da 100644 --- a/net/vmw_vsock/vmci_transport_notify.c +++ b/net/vmw_vsock/vmci_transport_notify.c @@ -307,7 +307,7 @@ vmci_transport_handle_wrote(struct sock *sk, struct vsock_sock *vsk = vsock_sk(sk); PKT_FIELD(vsk, sent_waiting_read) = false; #endif - sk->sk_data_ready(sk); + vsock_data_ready(sk); } static void vmci_transport_notify_pkt_socket_init(struct sock *sk) diff --git a/net/vmw_vsock/vmci_transport_notify_qstate.c b/net/vmw_vsock/vmci_transport_notify_qstate.c index a40407872b53..41dca5fbea5e 100644 --- a/net/vmw_vsock/vmci_transport_notify_qstate.c +++ b/net/vmw_vsock/vmci_transport_notify_qstate.c @@ -84,7 +84,7 @@ vmci_transport_handle_wrote(struct sock *sk, bool bottom_half, struct sockaddr_vm *dst, struct sockaddr_vm *src) { - sk->sk_data_ready(sk); + vsock_data_ready(sk); } static void vsock_block_update_write_window(struct sock *sk) @@ -282,7 +282,7 @@ vmci_transport_notify_pkt_recv_post_dequeue( /* See the comment in * vmci_transport_notify_pkt_send_post_enqueue(). */ - sk->sk_data_ready(sk); + vsock_data_ready(sk); } return err;