From patchwork Fri Aug 19 05:36:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 12948347 X-Patchwork-Delegate: kuba@kernel.org 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 9C604C32771 for ; Fri, 19 Aug 2022 05:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242217AbiHSFhX (ORCPT ); Fri, 19 Aug 2022 01:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236150AbiHSFhW (ORCPT ); Fri, 19 Aug 2022 01:37:22 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55180CACBE; Thu, 18 Aug 2022 22:37:20 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id A92515FD07; Fri, 19 Aug 2022 08:37:18 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1660887438; bh=M8QbwpizhBqEUoqruWQEZu9WRSDqgcrIIvziju9qy/c=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=K9W78BuRr9a/+6G2w1+n0PGd/0X6YGcijrN4bIPZRDEK94KzIBmxnHJuoAkA4+qpy 3Z76+sNf0pWpCbvIOVHNoS+yTPhl9p6Dmgm1juI0TrQ1x/wv0NHnpLdQ4H5iLN4BDx 4Xq8l+zcILkdMB1cW41oMuo5lNbL44WATqcmVFDTV1D2D7rNatrcrc3Mu7Zn8Tfo+B eEKtdBzI4UvmEg2lRpFRrujqiCC+X/53yfYAAMNic6ytUm2v1io+i8eJ8nb6eGWNn4 OVHt3Ed6tymJDI72IRerKIOIZVePFcdp3IP/cesMUqTeYyHUjjf4Fh5pyoqK0VKq0j ei9AfP5qVlLqA== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mail.sberdevices.ru (Postfix) with ESMTP; Fri, 19 Aug 2022 08:37: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 , Bryan Tan , Vishnu Dasa , Krasnov Arseniy , "Michael S. Tsirkin" 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 , VMware PV-Drivers Reviewers Subject: [PATCH net-next v4 6/9] vsock: add API call for data ready Thread-Topic: [PATCH net-next v4 6/9] vsock: add API call for data ready Thread-Index: AQHYs42v4z1AREcY90CCwR1c1P12XQ== Date: Fri, 19 Aug 2022 05:36:52 +0000 Message-ID: <60fe5506-eb2e-99f0-08ec-27ab611920d0@sberdevices.ru> In-Reply-To: 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: <61E37C54AE8DE541AF8C776A1124B686@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/19 00:26:00 #20118704 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 d609a088cb27..568a87c5e0d0 100644 --- a/include/net/af_vsock.h +++ b/include/net/af_vsock.h @@ -78,6 +78,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 b5cbc849844b..85a665253e84 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);