Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp73860rwb; Mon, 26 Sep 2022 09:27:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yDwws/Ib4pB1vVd0A9p+ufPGiZQLKOyY+fl8SjXoR2e/JiAG/nPPATfADk/S2G947uhk4 X-Received: by 2002:a17:90b:4a8a:b0:202:8eec:b87a with SMTP id lp10-20020a17090b4a8a00b002028eecb87amr37493722pjb.48.1664209620798; Mon, 26 Sep 2022 09:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664209620; cv=none; d=google.com; s=arc-20160816; b=T0T/v9mWfwRcOlKtwZMzCeY7P/9bw6cA9g1yQ1bXQ3xb1FrNKJ1Krs7Jq0GLbZeAxA XwGdYNnstTWQsfoZvA+IKcIlM0FkaxvDqiX3TLCWgyhaLpGbtebiXALosxMFQtHOt8xp zE667YQ1SnRrJZY3aV6+rQ1jhydMxtPt1K2yF2XBLLbjMeWh4pEo4I8tPaEGRlrLwQ83 sLSDiwIU9srNUEJfs9Uupb1vz0zOEGyh5Gj3ckRii6cFGMD4g9dVD6A45553jjxaIaZd o8sab3vAU4vpPMAlWIiLkWbIb3zgxf65VaZWWUFnaqkVjM1Jv3mqUO65q7+Iuf2asC4v RNVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=i7qiiLpBZNt2KOcykqgJFQ/WQh3oxgQ6inHkaKhb85Y=; b=ddPtKYzzm/irqlxBxEFEqnoJUjqIa0TgktoRVyxFOl0KII3SMtV8tyMt0Otsx+21jE nEb09ZnzxOi0sFjUW/UFv5q1AiagITcMifFu5yUp7VW6H3Ft1k5NYMhT+r+WTB6enhos uz9cgDz9s1STmglEWjZ2UcyvWncrAWhyfUCXX8KhG4yu0eG8tKyCH3FIif2oyO3qeJO9 lAVg3ofIiOL6SB/GRIL9A+Bnpt0aJY7VkPtqphLbWkwW5HpW8/tThyHc1a8GMjOlFje5 L5wVCoH/WUcdgNnTnIgwO0Y8bpMsl4sqGTEcK6gvaL9f8PvVqTHZ31uaPwhaYPlIq0pj zm7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sib5IscL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np9-20020a17090b4c4900b001f31f339134si12834145pjb.152.2022.09.26.09.26.47; Mon, 26 Sep 2022 09:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sib5IscL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235200AbiIZOzZ (ORCPT + 99 others); Mon, 26 Sep 2022 10:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235260AbiIZOyd (ORCPT ); Mon, 26 Sep 2022 10:54:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D5DD564F3 for ; Mon, 26 Sep 2022 06:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664198517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=i7qiiLpBZNt2KOcykqgJFQ/WQh3oxgQ6inHkaKhb85Y=; b=Sib5IscLwkCJpCzcQaahJfuUkB+6APQqt7D9cK3QqMhKpRvl9R0sd2E7Vr32vnF54Y6Mqs NRsh1h0qhngx7v85HvPJvlk78oWntcR9BUlf5JofTuS6g/6SPwhMztaV/z4rB94eNtXErY w+xF1y9lcBIFY9wTR68yon9xlbaS+Yw= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-274-LPiAXkqcNqKE_URClrdOLQ-1; Mon, 26 Sep 2022 09:21:56 -0400 X-MC-Unique: LPiAXkqcNqKE_URClrdOLQ-1 Received: by mail-qt1-f199.google.com with SMTP id i12-20020ac871cc000000b0035ba1b1ba9cso4750845qtp.22 for ; Mon, 26 Sep 2022 06:21:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=i7qiiLpBZNt2KOcykqgJFQ/WQh3oxgQ6inHkaKhb85Y=; b=cjAVugNP6obEdiKakxp3PChgDA7wx1KkOT2eBwTG3nd85ihJVDxjafjqezMmnDAS3l A0ktWcj3H0RpEsLzg7zv7A+Zl3KZFlda6fuvTJwuuI3bL2dys0mqLCcnEeFZAh4MoE3i lFkNhC+BJ8OpCeotmgBOrnfEus2bPBigFxdQGe8cA3IwDrDvjBB3g9gEp/LKM8zpyA5b tkABGwjsOX8lzwHR6YiBaNl+vwdnhWvejOZzWGH9DW748oyTCCWE8Rj24zKuMPCqkqfa KhzbGSMTmnobIr5baLu/0qRrXSMsJbkoYoEpu1Sy7c00+u3hIIWkWoR8s4M0Vwe/PAju +lqg== X-Gm-Message-State: ACrzQf2S7y29xqF3p1nvie0Wk2vGmkW78GPqwD+b27UYRM7tk3gWkkPY cQJ+4IBmdBdt4qXrIhODV5VOl/VJeDOrkolDEtkwx20IwLBb1hwFbGBxEZs/kKvFU9lzEKeSqDb JVX4V67YkN6eQJRZLB9hfkrKw X-Received: by 2002:a05:620a:424c:b0:6be:78d5:ec73 with SMTP id w12-20020a05620a424c00b006be78d5ec73mr13912697qko.579.1664198516076; Mon, 26 Sep 2022 06:21:56 -0700 (PDT) X-Received: by 2002:a05:620a:424c:b0:6be:78d5:ec73 with SMTP id w12-20020a05620a424c00b006be78d5ec73mr13912666qko.579.1664198515834; Mon, 26 Sep 2022 06:21:55 -0700 (PDT) Received: from sgarzare-redhat (host-79-46-200-222.retail.telecomitalia.it. [79.46.200.222]) by smtp.gmail.com with ESMTPSA id t14-20020a05620a450e00b006cbcdc6efedsm11986040qkp.41.2022.09.26.06.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:21:55 -0700 (PDT) Date: Mon, 26 Sep 2022 15:21:45 +0200 From: Stefano Garzarella To: Bobby Eshleman Cc: Bobby Eshleman , Bobby Eshleman , Cong Wang , Jiang Wang , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: Re: [PATCH 2/6] vsock: return errors other than -ENOMEM to socket Message-ID: <20220926132145.utv2rzswhejhxrvb@sgarzare-redhat> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 15, 2022 at 10:56:05AM -0700, Bobby Eshleman wrote: >This commit allows vsock implementations to return errors >to the socket layer other than -ENOMEM. One immediate effect >of this is that upon the sk_sndbuf threshold being reached -EAGAIN >will be returned and userspace may throttle appropriately. > >Resultingly, a known issue with uperf is resolved[1]. > >Additionally, to preserve legacy behavior for non-virtio >implementations, hyperv/vmci force errors to be -ENOMEM so that behavior >is unchanged. > >[1]: https://gitlab.com/vsock/vsock/-/issues/1 > >Signed-off-by: Bobby Eshleman >--- > include/linux/virtio_vsock.h | 3 +++ > net/vmw_vsock/af_vsock.c | 3 ++- > net/vmw_vsock/hyperv_transport.c | 2 +- > net/vmw_vsock/virtio_transport_common.c | 3 --- > net/vmw_vsock/vmci_transport.c | 9 ++++++++- > 5 files changed, 14 insertions(+), 6 deletions(-) > >diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h >index 17ed01466875..9a37eddbb87a 100644 >--- a/include/linux/virtio_vsock.h >+++ b/include/linux/virtio_vsock.h >@@ -8,6 +8,9 @@ > #include > #include > >+/* Threshold for detecting small packets to copy */ >+#define GOOD_COPY_LEN 128 >+ This change seems unrelated. Please move it in the patch where you need this. Maybe it's better to add a prefix if we move it in an header file (e.g. VIRTIO_VSOCK_...). Thanks, Stefano > enum virtio_vsock_metadata_flags { > VIRTIO_VSOCK_METADATA_FLAGS_REPLY = BIT(0), > VIRTIO_VSOCK_METADATA_FLAGS_TAP_DELIVERED = BIT(1), >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index e348b2d09eac..1893f8aafa48 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -1844,8 +1844,9 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, > written = transport->stream_enqueue(vsk, > msg, len - total_written); > } >+ > if (written < 0) { >- err = -ENOMEM; >+ err = written; > goto out_err; > } > >diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c >index fd98229e3db3..e99aea571f6f 100644 >--- a/net/vmw_vsock/hyperv_transport.c >+++ b/net/vmw_vsock/hyperv_transport.c >@@ -687,7 +687,7 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg, > if (bytes_written) > ret = bytes_written; > kfree(send_buf); >- return ret; >+ return ret < 0 ? -ENOMEM : ret; > } > > static s64 hvs_stream_has_data(struct vsock_sock *vsk) >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index 920578597bb9..d5780599fe93 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -23,9 +23,6 @@ > /* How long to wait for graceful shutdown of a connection */ > #define VSOCK_CLOSE_TIMEOUT (8 * HZ) > >-/* Threshold for detecting small packets to copy */ >-#define GOOD_COPY_LEN 128 >- > static const struct virtio_transport * > virtio_transport_get_ops(struct vsock_sock *vsk) > { >diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c >index b14f0ed7427b..c927a90dc859 100644 >--- a/net/vmw_vsock/vmci_transport.c >+++ b/net/vmw_vsock/vmci_transport.c >@@ -1838,7 +1838,14 @@ static ssize_t vmci_transport_stream_enqueue( > struct msghdr *msg, > size_t len) > { >- return vmci_qpair_enquev(vmci_trans(vsk)->qpair, msg, len, 0); >+ int err; >+ >+ err = vmci_qpair_enquev(vmci_trans(vsk)->qpair, msg, len, 0); >+ >+ if (err < 0) >+ err = -ENOMEM; >+ >+ return err; > } > > static s64 vmci_transport_stream_has_data(struct vsock_sock *vsk) >-- >2.35.1 >