Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp237481pxb; Fri, 3 Sep 2021 00:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNRE0OIzIOP4bjh69/GXbfc1Zm5dxTsweZ1lqyyeehJFU9IcmTicc9lZh6ueot4+NE+AYf X-Received: by 2002:a6b:ce17:: with SMTP id p23mr2028886iob.90.1630654942408; Fri, 03 Sep 2021 00:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630654942; cv=none; d=google.com; s=arc-20160816; b=iXVzNgXZpr7HBj+Z1mLjmvbTpnQRE47FEGjTBl/nh6LCT003CIv3/9D9IFPg46mZLB Asc195NBpYa/pkanLAuxVfa9Ht7P+utyesCycdQnBclueYoxlyVxJdFuv4N+EonDHDq1 HeV75mYVIcyTliWQ+zGSbHT6mPY6J+OeILXCxtydG/5FWUQkX5tVCbamZ24sUoxDPZZL i2JCMTkODSojgzOikMwFZn4YXb/7PcAsVsreoTcR4I3ls4GdU/88E7zX13LMPPwbStJP CQi/6HAMljf+NqBExj6BC4cHHtVafn+In4Q/bqz3EIZhIq5xj15ToUDzWM1z+crrL6sB 3RZg== 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=EeO/1ruPx/J3HagGwQQq0jPFzGgymZG7mS2oDGjCub4=; b=M3URxnzQYfKbImiIEz7/Vn88mKkt5XiLpkvY/kbEuS1ir8ntVg/zUsDT0LWuxyA6ug 56z6V6ydhm40x9eY6j6Y1D/qRsK9XxDI4JwiSfJShltgWCsy0hW+tVSDh2vlvLsHxE/R 2+hqwf23hxdddSspk82gaDJ/Hiydhtor5SE9bYfdmV5FvdrPboJsFjVz6UjB+cb7r/By m2xKpIA87MCNDtLcrCRh+n3ozlsVF9cFwG1D0WxsVFUsFhzpki+j+gDIORoJv56QDCtl lHh3GIosru59zn5Up4uxZ0d81o2LF2qwvJgTPZazVCVupfMhBVPQzg4fZRwksghneWyL j3Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AEC5tqOy; 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 y15si4239248ily.49.2021.09.03.00.42.10; Fri, 03 Sep 2021 00:42:22 -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=AEC5tqOy; 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 S1347419AbhICG4p (ORCPT + 99 others); Fri, 3 Sep 2021 02:56:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55670 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347254AbhICG4o (ORCPT ); Fri, 3 Sep 2021 02:56:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630652144; 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=EeO/1ruPx/J3HagGwQQq0jPFzGgymZG7mS2oDGjCub4=; b=AEC5tqOyojbpH3X8GZVtqdsU1HIfKgKTL+SdhIdqmKQQpW8bOc/WVsYi5OOVTFmUXQMifq L4wAJRULZix6bDKBOuNlyLM9v7/xMf6R6xJ7vM0nfZ7RJrVtw5IXr7MdfRqoQ13vFNcatK Rl+W8rixVIZpx6Ve3/WN8PQuCI0o/BA= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-mX8xWzP1Nua97E8Oqwflmw-1; Fri, 03 Sep 2021 02:55:43 -0400 X-MC-Unique: mX8xWzP1Nua97E8Oqwflmw-1 Received: by mail-ej1-f70.google.com with SMTP id cf17-20020a170906b2d100b005d42490f86bso2258260ejb.3 for ; Thu, 02 Sep 2021 23:55:43 -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=EeO/1ruPx/J3HagGwQQq0jPFzGgymZG7mS2oDGjCub4=; b=uV8Qvdi78EWsOpmc7Ztxh6zkflcDO/bPsUu8UJqK8imcS65aSMvn4NrLPRuCcTUw8W spSVyc0WgTqxJ+cfV3P6kEu5xbCrGoucoHE3J0M0R9nuQqFF2bDdLkFHs65XIEcIE9H6 85RiCNI5na9LrkqPEjQu7GoPq2A04Dtl0H99UVLc6c0long3pldjlHdLH+skzGDs/NAq UmezKnCv+LqIlP47mZwmUdEl+FaG3Efulq+JKRS1YIfZ5IXMf7p4p/bGMo5VvWsnNKxP Qo8xyHN1ubQKMpzCs5pO8LBhdcs1L9tMhUiZTG8sKQFxpgTKpNXkLOeRiaaXjzTKRCAu 7+NQ== X-Gm-Message-State: AOAM531ey0AdFffAU79bFFIfmBiTYvcKAkyitTirh8bvoTEG/yvqUeeB gzQdwM6148Lzw21lWK96TS6NBvuqQiuzBYNrYoTOdbObo6UANOFdrEhMhMA1KM77BpRPlJds0c5 T0E7OxM62cpoK8FqSINOWGOs8 X-Received: by 2002:a05:6402:2909:: with SMTP id ee9mr2379470edb.377.1630652142358; Thu, 02 Sep 2021 23:55:42 -0700 (PDT) X-Received: by 2002:a05:6402:2909:: with SMTP id ee9mr2379457edb.377.1630652142126; Thu, 02 Sep 2021 23:55:42 -0700 (PDT) Received: from steredhat (host-79-51-2-59.retail.telecomitalia.it. [79.51.2.59]) by smtp.gmail.com with ESMTPSA id k12sm2391179edq.59.2021.09.02.23.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 23:55:41 -0700 (PDT) Date: Fri, 3 Sep 2021 08:55:39 +0200 From: Stefano Garzarella To: Arseny Krasnov Cc: Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Norbert Slusarek , Colin Ian King , Andra Paraschiv , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stsp2@yandex.ru, oxffffaa@gmail.com Subject: Re: [PATCH net-next v4 3/6] vhost/vsock: support MSG_EOR bit processing Message-ID: <20210903065539.nb2hk4sszdtlqfmb@steredhat> References: <20210903061353.3187150-1-arseny.krasnov@kaspersky.com> <20210903061541.3187840-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210903061541.3187840-1-arseny.krasnov@kaspersky.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 03, 2021 at 09:15:38AM +0300, Arseny Krasnov wrote: >'MSG_EOR' handling has similar logic as 'MSG_EOM' - if bit present >in packet's header, reset it to 0. Then restore it back if packet >processing wasn't completed. Instead of bool variable for each >flag, bit mask variable was added: it has logical OR of 'MSG_EOR' >and 'MSG_EOM' if needed, to restore flags, this variable is ORed >with flags field of packet. > >Signed-off-by: Arseny Krasnov >--- > drivers/vhost/vsock.c | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > >diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c >index feaf650affbe..93e8d635e18f 100644 >--- a/drivers/vhost/vsock.c >+++ b/drivers/vhost/vsock.c >@@ -114,7 +114,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, > size_t nbytes; > size_t iov_len, payload_len; > int head; >- bool restore_flag = false; >+ u32 flags_to_restore = 0; > > spin_lock_bh(&vsock->send_pkt_list_lock); > if (list_empty(&vsock->send_pkt_list)) { >@@ -179,15 +179,20 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, > * created dynamically and are initialized with header > * of current packet(except length). But in case of > * SOCK_SEQPACKET, we also must clear message delimeter >- * bit(VIRTIO_VSOCK_SEQ_EOM). Otherwise, instead of one >- * packet with delimeter(which marks end of message), >- * there will be sequence of packets with delimeter >- * bit set. After initialized header will be copied to >- * rx buffer, this bit will be restored. >+ * bit (VIRTIO_VSOCK_SEQ_EOM) and MSG_EOR bit >+ * (VIRTIO_VSOCK_SEQ_EOR) if set. Otherwise, >+ * there will be sequence of packets with these >+ * bits set. After initialized header will be copied to >+ * rx buffer, these required bits will be restored. > */ > if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SEQ_EOM) { > pkt->hdr.flags &= ~cpu_to_le32(VIRTIO_VSOCK_SEQ_EOM); >- restore_flag = true; >+ flags_to_restore |= VIRTIO_VSOCK_SEQ_EOM; >+ >+ if (le32_to_cpu(pkt->hdr.flags & VIRTIO_VSOCK_SEQ_EOR)) { >+ pkt->hdr.flags &= ~cpu_to_le32(VIRTIO_VSOCK_SEQ_EOR); >+ flags_to_restore |= VIRTIO_VSOCK_SEQ_EOR; >+ } > } > } > >@@ -224,8 +229,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, > * to send it with the next available buffer. > */ > if (pkt->off < pkt->len) { >- if (restore_flag) >- pkt->hdr.flags |= cpu_to_le32(VIRTIO_VSOCK_SEQ_EOM); >+ pkt->hdr.flags |= cpu_to_le32(flags_to_restore); > > /* We are queueing the same virtio_vsock_pkt to handle > * the remaining bytes, and we want to deliver it >-- >2.25.1 > Reviewed-by: Stefano Garzarella