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);