From patchwork Wed Aug 3 14:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12935537 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 2B344C3F6B0 for ; Wed, 3 Aug 2022 14:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238546AbiHCOCP (ORCPT ); Wed, 3 Aug 2022 10:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236785AbiHCOCO (ORCPT ); Wed, 3 Aug 2022 10:02:14 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56ADC2CE1C; Wed, 3 Aug 2022 07:02:12 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id A28B15FD2E; Wed, 3 Aug 2022 17:02:10 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1659535330; bh=B7MnM9LlcIMliFAHXLeyzEfSXIZ8NB66nwrKZJSvDgc=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=dubY+hTMsFMWN19jwfE4rvvJP42QM4Q1Rlayal/qamG5DnPV1O6AZrOmFdfK+MLlh yH2241C6lJ0DegbnqYsKDBn0rs7Q3l0xU04J7gNW0IhfbdIhZ3Qw/uDYE0gcc2faN3 xGllPhWGN2OeRcK1s+cTaiXGjbI/x/EDLfwZqUL+gQXjXrxGpkdJ+M37vtkA45HH43 6uz/RXK6ghh3QAukfqDSx5Yb5Ep5dKLmp+RF4hwblnB9coftL3GR8m488A2T+xD0+b 5qc/aT4TyBS+Obq0WEH6Xmq/h7JnaXKCDdTkqhj7HA62bTPobp9LUgYFaOiGwsrQXY cZYSj59OemWeg== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mail.sberdevices.ru (Postfix) with ESMTP; Wed, 3 Aug 2022 17:02:10 +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 , Bryan Tan , Vishnu Dasa , VMware PV-Drivers Reviewers , Krasnov Arseniy , "Arseniy Krasnov" 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 v3 6/9] vsock: add API call for data ready Thread-Topic: [RFC PATCH v3 6/9] vsock: add API call for data ready Thread-Index: AQHYp0GXMIwj7aEDFUyU7Z65eKQpMg== Date: Wed, 3 Aug 2022 14:01:57 +0000 Message-ID: In-Reply-To: <2ac35e2c-26a8-6f6d-2236-c4692600db9e@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: <85A4929A98C0C144AB0C8DA1959BA189@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/08/03 07:41:00 #20041172 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 Reviewed-by: Stefano Garzarella --- 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 3a1426eb8baa..47e80a7cbbdf 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);