Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3858042rwb; Tue, 16 Aug 2022 09:53:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7hL3mErOAvHtoIwl0wjx9LSfgH2rsqjF3KRZM+Hdz0hBSae+05z4bYX9FrYkPICj1lJRyY X-Received: by 2002:a62:d418:0:b0:52d:9322:b285 with SMTP id a24-20020a62d418000000b0052d9322b285mr22379186pfh.66.1660668819546; Tue, 16 Aug 2022 09:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660668819; cv=none; d=google.com; s=arc-20160816; b=SIvD8/aFo/wIbTWH/p907WhdwyiinHXNjPwGm6vOacEO+1Zp/SR9/H8wYsSJsDVLHl T/sYAbg2V7UiK1j9sZIcRVogGsFQPIZdNKGv70+HjUNV271935unJRbT44+gwDInY9pP iBElQBdhBxMcU0wkNbVYPr0GhU489K62/sndxWJKH2yoj5fe2C4KgAN310YvjyWW2z1O uq/OkWMVOYbzyfXQiQbSiPjEZYe61MZU4Pp5+9RD8eHKlUjWBJ276JFlBL+LhCa12kHe Tg26Qr3MVF8NrV9z+whMS0BLnCOJxSw9G5ex5Mb7msbMFEBY9FuXmEu9ODl58P1B6MUk 3QZw== 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=Iy+lcK0z1Pv9kZZ/l2ldtDAdFaOohY4aditAQU865N8=; b=m4QXFUCfxbYf7dISMGEL7pBdTdpp2SPIuqiBsJ7jMr0Va4VCZ4Ni4JZ6Kbopc/IurK rfMiTBtqscORwFerqiNsOslfteLI0aJvJlCdQqwFQ30846j9cPVcuNrlNPs4TS6hL8eN vshqWO6GTMW1jhjEy6ZVI0LE8Jnr0ZefvEqGcQKpjjSedUJ8heyyBpn+9EmDFHLLHqgw Lv6HtlApOazNDpkh51NJcn3T3d1DNQoQSjYP29tKgEtdNZiJtKxwzFl6gm2GtW73M/so D8t37rZZjgYX5+KpWtz57jYnSExCvDPiTwVZbXP1B60FVPiO/uEbMvUk3s0ya6F//TIc kuBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UgUacS84; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o26-20020a635a1a000000b0041291b52146si13941638pgb.256.2022.08.16.09.53.28; Tue, 16 Aug 2022 09:53:39 -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=@gmail.com header.s=20210112 header.b=UgUacS84; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236417AbiHPQ1S (ORCPT + 99 others); Tue, 16 Aug 2022 12:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236397AbiHPQ1J (ORCPT ); Tue, 16 Aug 2022 12:27:09 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DFDE7B7A0; Tue, 16 Aug 2022 09:27:07 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id s36-20020a17090a69a700b001faad0a7a34so515137pjj.4; Tue, 16 Aug 2022 09:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=Iy+lcK0z1Pv9kZZ/l2ldtDAdFaOohY4aditAQU865N8=; b=UgUacS841BUW2A0gjmS9P2fm8xwyFNWB/NxCwLTu1FYyCYwPFtYeiqShlGy1cbXULy LzL6O/HWYDV06qsabtIVgsJ1n9yfdDmY+MxKGhNb1eZd8eBibmvxHw2ehtXO5oce18Dl bZYDpJ8dKBl1kIEim6z/ky+TOHRVkwxsne9Do7KeetA6qjQisUHzVNfgjqIWpjL/C+2H aVqWR0in+NFHlIk3w0qAZt/ldCYLH2xJGVm0Td2TtA1EgfBTpgcBDrDlYfp+AQN2w9LD CgURhAkDbGkeJqf1AyL6pLaUcaELfYXqDUJB66jAQa/MG2LzoZchnuASqEDvAVHugDHn spMw== 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; bh=Iy+lcK0z1Pv9kZZ/l2ldtDAdFaOohY4aditAQU865N8=; b=nluwZnXwVH6TyxJdm0gGHTZSotBn4UvFvoVnzoN6rx/0EsBbGGuO6QxFjrXkpAjysz FWnQOFfurQk4VT2rPmv0qJsvCNI3BlkKWWd8EtrvAvDbOodqLzkbxS5rCyEE8BSQ9R/9 yD1oGWqJagaDvBRGDBOeLBuiHp9y8WIq73bAZiyx3M69RqrWoBAgEX9pmMXZvVYzatJ9 Ll9u1LkG+y/VCl0+WZ75/hsNq3opsb/1Tg8KBnW3qxfW6jHmewxSwI8p2Ps+AprhJin/ wytHo6cELFjgRV+9mOGvOPryuBXuus3Dc6/WYDLUcYyW+BbBDzVt5b6qdx4sOPOTjXOm hZWA== X-Gm-Message-State: ACgBeo0U0tRGunMEdCSKhZf0ZmTJUMH3sLdd/XnOncIy3dFEeYaCjzdB 1XwcpO9t0mfD6ix+fcbr1rw= X-Received: by 2002:a17:90b:3141:b0:1f7:75cf:a449 with SMTP id ip1-20020a17090b314100b001f775cfa449mr24069838pjb.18.1660667226565; Tue, 16 Aug 2022 09:27:06 -0700 (PDT) Received: from localhost (c-73-164-155-12.hsd1.wa.comcast.net. [73.164.155.12]) by smtp.gmail.com with ESMTPSA id n12-20020a17090a394c00b001f2ef3c7956sm6544549pjf.25.2022.08.16.09.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 09:27:05 -0700 (PDT) Date: Tue, 16 Aug 2022 02:30:59 +0000 From: Bobby Eshleman To: Bobby Eshleman Cc: virtio-dev@lists.oasis-open.org, Bobby Eshleman , Cong Wang , Jiang Wang , Stefan Hajnoczi , Stefano Garzarella , "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: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DATE_IN_PAST_12_24, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 CC'ing virtio-dev@lists.oasis-open.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 > + > 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 >