Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30765589rwd; Thu, 6 Jul 2023 10:20:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlED9aqL+Hips8RhLpH/J3tIGAD4RV5Rrr8HtyB910ioR5v4UigKTPDCH76/GcWq3QmcsTL4 X-Received: by 2002:a05:6870:ac0c:b0:19f:1df3:ffce with SMTP id kw12-20020a056870ac0c00b0019f1df3ffcemr3331029oab.53.1688664025684; Thu, 06 Jul 2023 10:20:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688664025; cv=none; d=google.com; s=arc-20160816; b=FbTBGEn3ihMYWVmBNk3OfRc8vM1+90vcQ3o9IyJDl4GCIGBlgxPklxPji6SV3rhwnR 7Y6806frQtN0yne8rCEih0GM0nGY+ohB/h4q1cr0N2rfgP5fjrfPB+5ojlLkYYpE2Gnx /ZtjtakrKKQOgM7Saw/ZnJFQs5K3WvndWY+UWKhGjPikRRgmC4NXan0obwkAm/AQOeCF O2bdlWgFUD4ZVtPWbxg44pkVhTiaug08nlNlnI78IZJXUo3/3hlKzz39DeYIAK6szqW9 M3MHIn5S7A8JLjfWmZgryi2zmr6BSd95lAY1qkelQIAJ+JdVix/dFLIy6gFeM558OgOX LDlg== 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=gJektsoy0misgOoLPFYa4+3boQJ8dt+dK5kdqOR27mc=; fh=LmSvGF8mKyhe+4SfmYOr3uCnhF0XAFkKvuoevTchCp0=; b=vTB38lVS9cpXIzY8Vlewkg8xfF/NsA0wu1aw1ZiXQR+WhC7zvtGmqbKCG+rwTs1zg0 t0iqX27lGxji3hTK81CiCU256DedON3AWDss0FDeyB2pV36+XNReL5kl8/PFve/dqK+3 1NEA7yFtkcWCguyb6Vw5+XJW4/Mz29U8W9+O7dtVrI+xFQ9jnVvwQuKiMAq8Wj8HxjU9 3UgtsTvbHQuRdWEZVB3GgBivxAuclpkJGM+sCGzCn08VybaA+3yrj7rDT5iSoM+L1WRb DfeFGMi6GVewnkV+MKsfSPwZG6UoE3bzXJCK/RuHJEnJK4IDcFNjdrqUYFUkBuIFJBrv qZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aGYc0LVg; 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 t19-20020a17090a5d9300b0026308f709e6si76360pji.113.2023.07.06.10.20.11; Thu, 06 Jul 2023 10:20:25 -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=aGYc0LVg; 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 S230022AbjGFQu0 (ORCPT + 99 others); Thu, 6 Jul 2023 12:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbjGFQuY (ORCPT ); Thu, 6 Jul 2023 12:50:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA9A51FDB for ; Thu, 6 Jul 2023 09:49:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688662152; 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=gJektsoy0misgOoLPFYa4+3boQJ8dt+dK5kdqOR27mc=; b=aGYc0LVgnsTlZ3zLww9ck3SK0WI03d3LzohrpbpDVUWVDn1Jos06olBKK1OjHgqQhKWllR YpdxYJHOfZVQOw74NKSAakWsOW2J94AKPXYbWO+Sv8rgQWg96PxPOEIW5NWa0ymhLZ1OIL iL0ggFmQDuBe67+E4cOVK38m8Gi8y5Y= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-wB2HzEhcNNarnXTwNwnWxg-1; Thu, 06 Jul 2023 12:49:10 -0400 X-MC-Unique: wB2HzEhcNNarnXTwNwnWxg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-97542592eb9so62124466b.2 for ; Thu, 06 Jul 2023 09:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688662150; x=1691254150; 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 :message-id:reply-to; bh=gJektsoy0misgOoLPFYa4+3boQJ8dt+dK5kdqOR27mc=; b=ErRM9QKCNr6A86KpVV9FDtRAghqvsaxWjoke8uDCI59SK659G2ubDARl2Ow1bUXkkr 9Vic3FjlQ8kYQpzjjpRv06jZX8gon9E4t4TC4xsxmdJvrodiJl59dhYr3EtVdlBCG5lC nUc/utT6BiFSRHWTKwzsW5GR0evObu5grAN74Rlom1ILsRQtLDfymAd7+4Hs+LjdIKdB krYd8MA01DuZf75cHjxXjddaUObfKzjMcMclAoFj8kptXJBzPOkixVMjssDyZ1CUOQgT lQsKv89X/ObeGFNnmDTrRQOeBMhhSnavv9Dc8b3JN8YUBC8U80BfmRrBkMgWq6c/FCjI 9uig== X-Gm-Message-State: ABy/qLYoXz6qGT7+uiDfe04AfmjbNQAn1HihU5c0+Sqc5WOpo8tGYQjm KM+/9qOeh3n+8K9NTUQPQWPAotM2LuQF3WbVMp5g38mrxOYTNZqKTXrn9YxeW+QWHHOqOxhudtj C/ugaMhwjdwHQi7Jr5SQggWqH X-Received: by 2002:a17:907:a07c:b0:96a:2acf:61e1 with SMTP id ia28-20020a170907a07c00b0096a2acf61e1mr2160893ejc.64.1688662149877; Thu, 06 Jul 2023 09:49:09 -0700 (PDT) X-Received: by 2002:a17:907:a07c:b0:96a:2acf:61e1 with SMTP id ia28-20020a170907a07c00b0096a2acf61e1mr2160884ejc.64.1688662149602; Thu, 06 Jul 2023 09:49:09 -0700 (PDT) Received: from sgarzare-redhat (host-79-46-200-163.retail.telecomitalia.it. [79.46.200.163]) by smtp.gmail.com with ESMTPSA id s6-20020a170906454600b00992c92af6f4sm1039367ejq.144.2023.07.06.09.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jul 2023 09:49:09 -0700 (PDT) Date: Thu, 6 Jul 2023 18:49:06 +0200 From: Stefano Garzarella To: Arseniy Krasnov Cc: Stefan Hajnoczi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@sberdevices.ru, oxffffaa@gmail.com Subject: Re: [RFC PATCH v5 02/17] vhost/vsock: read data from non-linear skb Message-ID: References: <20230701063947.3422088-1-AVKrasnov@sberdevices.ru> <20230701063947.3422088-3-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20230701063947.3422088-3-AVKrasnov@sberdevices.ru> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Sat, Jul 01, 2023 at 09:39:32AM +0300, Arseniy Krasnov wrote: >This adds copying to guest's virtio buffers from non-linear skbs. Such >skbs are created by protocol layer when MSG_ZEROCOPY flags is used. It >replaces call of 'copy_to_iter()' to 'skb_copy_datagram_iter()'- second >function can read data from non-linear skb. Also this patch uses field >'frag_off' from skb control block. This field shows current offset to >read data from skb which could be both linear or not. > >Signed-off-by: Arseniy Krasnov >--- > Changelog: > v4 -> v5: > * Use local variable for 'frag_off'. > * Update commit message by adding some details about 'frag_off' field. > * R-b from Bobby Eshleman removed due to patch update. I think we should merge this patch with the previous one, since vhost-vsock for example uses virtio_transport_stream_do_dequeue() that we change in the previous commit, so we will break the bisection. The patch LGTM! Stefano > > drivers/vhost/vsock.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > >diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c >index 6578db78f0ae..cb00e0e059e4 100644 >--- a/drivers/vhost/vsock.c >+++ b/drivers/vhost/vsock.c >@@ -114,6 +114,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, > struct sk_buff *skb; > unsigned out, in; > size_t nbytes; >+ u32 frag_off; > int head; > > skb = virtio_vsock_skb_dequeue(&vsock->send_pkt_queue); >@@ -156,7 +157,8 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, > } > > iov_iter_init(&iov_iter, ITER_DEST, &vq->iov[out], in, iov_len); >- payload_len = skb->len; >+ frag_off = VIRTIO_VSOCK_SKB_CB(skb)->frag_off; >+ payload_len = skb->len - frag_off; > hdr = virtio_vsock_hdr(skb); > > /* If the packet is greater than the space available in the >@@ -197,8 +199,10 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, > break; > } > >- nbytes = copy_to_iter(skb->data, payload_len, &iov_iter); >- if (nbytes != payload_len) { >+ if (skb_copy_datagram_iter(skb, >+ frag_off, >+ &iov_iter, >+ payload_len)) { > kfree_skb(skb); > vq_err(vq, "Faulted on copying pkt buf\n"); > break; >@@ -212,13 +216,13 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, > vhost_add_used(vq, head, sizeof(*hdr) + payload_len); > added = true; > >- skb_pull(skb, payload_len); >+ VIRTIO_VSOCK_SKB_CB(skb)->frag_off += payload_len; > total_len += payload_len; > > /* If we didn't send all the payload we can requeue the packet > * to send it with the next available buffer. > */ >- if (skb->len > 0) { >+ if (VIRTIO_VSOCK_SKB_CB(skb)->frag_off < skb->len) { > hdr->flags |= cpu_to_le32(flags_to_restore); > > /* We are queueing the same skb to handle >-- >2.25.1 >