Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp262669pxv; Wed, 30 Jun 2021 05:13:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6vqtrN8PVZhTn3TWWtMsOu+tmxeRmPk06V2XCMVJV/+xAVKsxVeuRqkCegQrA8Z5zjrjp X-Received: by 2002:a02:7126:: with SMTP id n38mr8793694jac.75.1625055185501; Wed, 30 Jun 2021 05:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625055185; cv=none; d=google.com; s=arc-20160816; b=mTUi8YcqkiVGIySUs85HC+8vDM4vnPvGO7Vp35+bWKRNIEABh3mi0VwBEjluoRh+/h BdtH34e46wLwsf9VdGhDaU+wMvMLL3xlIM5LtdCQaQrV1NCoIAhqH9l4vhtrv0L2w0G9 urWqRCBr817tVb0wUPndndZ6/x/FpZ84ilrGYrYXBQ3vxsPtETq5B9siYYRTDq3lYYw3 G+DJcbgJyNUL1/5rP2pCuxa5s6mRbwLPK65Wgr+h3M8sE5TNmaNa3RzBjjl0/YWfh6Gn Vz3OOdITYMddD/VnO2c/gZCWsbX7tRoijJWMQdET3t88uxydhCzS2yNp6MFbCa4Wmu1/ tHGA== 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=IgkWdNwml5AbnxYQNYHxxHeoFVm9yVfptJ5ZSxaAHBs=; b=iBrpThU7TjaB2MOJTETEeHoGpaI0X/bAtNZtUw5r5GNcCfNNTQpGmQWNftNAUEQpxc QUk4cyMFwRKtdzqmN1uWBvYAhYYwYX25RtFr9fUMlHpAp/H+vGwhYblVCN9QEWQp/bom Iv+2jgXIxcVShPPqfZKMh+al/VuCiEW5U0q3GJpk5reWf/5sYy3DPndnbMrNWKmki1nJ Pp4d6rDvFmjczJR/L6cYVWmb8hAd0cfsogyxvO3ZAGXzm4hw5tOXH4i/9j/4MEBdDifX JNLiGrJ9Xk9Qr1HLzlxh/vKOADDWNhcwlG9c2DReDk7lvkEaVWnBV+fZEwW1OqVJVxbv AnCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cOE9N8F3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si9765069iow.4.2021.06.30.05.12.51; Wed, 30 Jun 2021 05:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cOE9N8F3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234480AbhF3MOq (ORCPT + 99 others); Wed, 30 Jun 2021 08:14:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28282 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234405AbhF3MOo (ORCPT ); Wed, 30 Jun 2021 08:14:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625055135; 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=IgkWdNwml5AbnxYQNYHxxHeoFVm9yVfptJ5ZSxaAHBs=; b=cOE9N8F3wf7wu6EUG0j1c6FrvsiiugCu90iFKmWgoxRe+QtvahOB4ZNe7eZMnqRbBYXleD XHz0KqROPV4yFVYnOqANK6mfUzRFwElglu226lYfmKr9iH34KcaYXHvGu/UFV3ehIYyVWt h14B6tLjY69ocXjCu5u8EPlXtJTcmOU= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-b62XH-WGOR-hPOIxOIXJWw-1; Wed, 30 Jun 2021 08:12:14 -0400 X-MC-Unique: b62XH-WGOR-hPOIxOIXJWw-1 Received: by mail-ej1-f69.google.com with SMTP id de48-20020a1709069bf0b029048ae3ebecabso673868ejc.16 for ; Wed, 30 Jun 2021 05:12:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IgkWdNwml5AbnxYQNYHxxHeoFVm9yVfptJ5ZSxaAHBs=; b=b0IQ3O2YKO5Jr+T2YI8BaLjxWKLdiMjrZpVyey+JmL75+Hs/1xSVjKy3GTho/lHdbw Z8Oxt6k/ZrSabEQjnuWIVqsqBP5X7ddUMbjhflrVojrxA6kKrSHxCp75VrHC3ZwJzy3C ZjcPjL1meMySwX8N5SIkKlb0e0bylWwngJ+T1OBNOn7yKdqPekKnaVgegjM/BoOSh9kv sckGqtHhZ7qlKwFLpYV1nD7W5zC8tdt0iRXVFnE8pZ5YGMGS7B0yOr0Pr1Vw+qnzNN4a RnFmOHnKUBS56yHmeu430ilG6X+siGUxBr3Cx/Y0iFUxUalznrduC66GdPblR5i5Ut2C SLhw== X-Gm-Message-State: AOAM531QjJSjVXyDklWvnI5HIQbvpcQVJtUu9S/nEZa3JDIGpl3FB6/7 1hF7LztaLOT8HSsOcIW4I0XI6Nd+BcVbusvcGV8HeoMBohZPtbQoiCSG+fS5A8fSty/xo1yhzdM foAP4oBc8HMH4DlJ+WsI1GBIL X-Received: by 2002:a17:906:9516:: with SMTP id u22mr35503406ejx.442.1625055133032; Wed, 30 Jun 2021 05:12:13 -0700 (PDT) X-Received: by 2002:a17:906:9516:: with SMTP id u22mr35503385ejx.442.1625055132807; Wed, 30 Jun 2021 05:12:12 -0700 (PDT) Received: from steredhat (host-79-18-148-79.retail.telecomitalia.it. [79.18.148.79]) by smtp.gmail.com with ESMTPSA id b17sm3361405edd.58.2021.06.30.05.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 05:12:12 -0700 (PDT) Date: Wed, 30 Jun 2021 14:12:09 +0200 From: Stefano Garzarella To: Arseny Krasnov Cc: Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Jorgen Hansen , Andra Paraschiv , Colin Ian King , Norbert Slusarek , kvm , Linux Virtualization , netdev , kernel list , Krasnov Arseniy Subject: Re: [RFC PATCH v1 08/16] af_vsock: change SEQPACKET receive loop Message-ID: References: <20210628095959.569772-1-arseny.krasnov@kaspersky.com> <20210628100331.571056-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210628100331.571056-1-arseny.krasnov@kaspersky.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 28, 2021 at 01:03:28PM +0300, Arseny Krasnov wrote: >Receive "loop" now really loop: it reads fragments one by >one, sleeping if queue is empty. > >NOTE: 'msg_ready' pointer is not passed to 'seqpacket_dequeue()' >here - it change callback interface, so it is moved to next patch. > >Signed-off-by: Arseny Krasnov >--- > net/vmw_vsock/af_vsock.c | 31 ++++++++++++++++++++++--------- > 1 file changed, 22 insertions(+), 9 deletions(-) I think you can merge patches 8, 9, and 10 together since we are touching the seqpacket_dequeue() behaviour. Then you can remove in separate patches the unneeded parts (e.g. seqpacket_has_data, msg_count, etc.). Thanks, Stefano > >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index 59ce35da2e5b..9552f05119f2 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -2003,6 +2003,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg, > size_t len, int flags) > { > const struct vsock_transport *transport; >+ bool msg_ready; > struct vsock_sock *vsk; > ssize_t record_len; > long timeout; >@@ -2013,23 +2014,36 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg, > transport = vsk->transport; > > timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); >+ msg_ready = false; >+ record_len = 0; > >- err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0); >- if (err <= 0) >- goto out; >+ while (!msg_ready) { >+ ssize_t fragment_len; >+ int intr_err; > >- record_len = transport->seqpacket_dequeue(vsk, msg, flags); >+ intr_err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0); >+ if (intr_err <= 0) { >+ err = intr_err; >+ break; >+ } > >- if (record_len < 0) { >- err = -ENOMEM; >- goto out; >+ fragment_len = transport->seqpacket_dequeue(vsk, msg, flags); >+ >+ if (fragment_len < 0) { >+ err = -ENOMEM; >+ break; >+ } >+ >+ record_len += fragment_len; > } > > if (sk->sk_err) { > err = -sk->sk_err; > } else if (sk->sk_shutdown & RCV_SHUTDOWN) { > err = 0; >- } else { >+ } >+ >+ if (msg_ready && !err) { > /* User sets MSG_TRUNC, so return real length of > * packet. > */ >@@ -2045,7 +2059,6 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg, > msg->msg_flags |= MSG_TRUNC; > } > >-out: > return err; > } > >-- >2.25.1 >