Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4182630rwo; Tue, 25 Jul 2023 01:48:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlHn/sdZuJGkhRrQsbrJH6VkE2XxhDcHCPvd0jFNjQD7t1UPvxDhU/4QzQ6z7BUiRj3f9hPe X-Received: by 2002:a17:907:7625:b0:99b:4d3c:d7e4 with SMTP id jy5-20020a170907762500b0099b4d3cd7e4mr11988863ejc.63.1690274888882; Tue, 25 Jul 2023 01:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690274888; cv=none; d=google.com; s=arc-20160816; b=zxlQS94kP9dW5M1G2HD9kX5JD8z37mjUhS89hFuvGXhIhBX4hSOC+eOlOtMBXlYSpt 804nGv7TRA3c/zmqrcRz7LYpXIqiXfxiTFKQGuODI8JHa5ai2q5zcjYaAQir51tV/cb2 czHNFs7Ugb/oL85Cf//l1tSCEkHsbzrh/WtHMf93GxrQ/CSJDwZ+Q9Ism5nwHgpPv7Cr 6SrmabI1eaE8uXxEyEdEBngwhxYH79SnMHlR72zTvGh3SOr+L20sqLkJTN4HIFmeVbTF HIc/NrXSKW7HWlz9toWLM+h5/65gj6V8uglfN9ioAjBX0RB/Dv0Ux1f8jNBruNRSB09S uqRA== 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=3yzqiXhC1UF6kcx0o3Qs1VmhKMD7xafUTqbIR8LZgYk=; fh=LmSvGF8mKyhe+4SfmYOr3uCnhF0XAFkKvuoevTchCp0=; b=B8vRDhydbzJqa+Lb0fTI0H/Lko2V93JZmw91SWYLuXzq0mCBuTtAO1Kjbm72vCzs/2 rcMyF6k3Wiaw83SiA2K0lqx5RrLVgLAecxV2zA8dAQypB8eANF8CJRnF6ubS4/QMPt1P s7smSIWZhGWJj/72MMhjIWYtXsf69cWFkW48PUzNQ7+fbL2XrECFGNZPiCRafTv3LkYA AUvnVWMdm6/4EkjhFRYqa/pO41PGwSPVBxt42h8hXqpNASf6CWXq9QJtX6N9GuBzaLse rRtoDhvIEgK8gjvo8UqeDBl8nfhtlMWX4Arzj2mkrGgXI3kSAvqzl0uK2eYoPtgfvGmO qQ4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HySbZRws; 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 mc13-20020a170906eb4d00b00991ddce682esi7406107ejb.305.2023.07.25.01.47.45; Tue, 25 Jul 2023 01:48:08 -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=HySbZRws; 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 S231292AbjGYISy (ORCPT + 99 others); Tue, 25 Jul 2023 04:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbjGYISv (ORCPT ); Tue, 25 Jul 2023 04:18:51 -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 508C9E7B for ; Tue, 25 Jul 2023 01:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690273083; 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=3yzqiXhC1UF6kcx0o3Qs1VmhKMD7xafUTqbIR8LZgYk=; b=HySbZRwszuaN2E1+A3ae8Ra/sk0h8tlmrHDv7TWPB5IxaFbTU/3qSHLO5fqi2CMI8liDvF fK0gM0YjKbpuo2HqQq7WY1pE+UIWmA6/vhw6xR6Z9clRxQJ8zzgou8SP7QVgp3q4RZvUHs HqiS9Ue2fpEi1QYLJlr6ub0BkqwPscg= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-nV040Y2vNoSP_5sJUWEaRw-1; Tue, 25 Jul 2023 04:18:01 -0400 X-MC-Unique: nV040Y2vNoSP_5sJUWEaRw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3176ace3f58so237608f8f.0 for ; Tue, 25 Jul 2023 01:18:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690273080; x=1690877880; 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=3yzqiXhC1UF6kcx0o3Qs1VmhKMD7xafUTqbIR8LZgYk=; b=U2XbI5AHyYvl4VHZYeP4nyB1cASI4VB2mgErNUBqaWH5N4C72JJU+iuYATmxP+OB1t nWxk4hSjGDcclnqMYCo+Aq9z8o45BYmJixQmyRuahq3HfJpGk8R3dahVPahnOrQJREVa d0wDvVNQwtL4+lWYmAvc+smiGyE5zZ0PkH9EJo9X6talQGK0FroQCmLqvY0MFG9nzQ/V g+Dnr6Hm1DiKgfNV75xovCumwyORermpoc5ZhZgInxmqFchYrCCq4v50EmXews6jZStK iTbJifVxKews9/2ekDjj3JW5C7PC/YAZOcOgQk6+gY3Dhhs67C7bzmaYwSPq6VmaC1xA A+qw== X-Gm-Message-State: ABy/qLYex0t6JVS9sJIOz7EXGYKybm49/QYMiss8qPx3ntnGYDu7j3u3 HUv6MTtaThH/abjQw/V5UHU+UnBB0BV64dsQRlmIxDmniZ5BGXaeWPGyCWaO505L+iZwpmrz+3O rYVDFFNrU3ixXvKiRrf7T6/jm X-Received: by 2002:a5d:6507:0:b0:313:ef96:84c8 with SMTP id x7-20020a5d6507000000b00313ef9684c8mr8687886wru.67.1690273080448; Tue, 25 Jul 2023 01:18:00 -0700 (PDT) X-Received: by 2002:a5d:6507:0:b0:313:ef96:84c8 with SMTP id x7-20020a5d6507000000b00313ef9684c8mr8687872wru.67.1690273080102; Tue, 25 Jul 2023 01:18:00 -0700 (PDT) Received: from sgarzare-redhat ([193.207.217.123]) by smtp.gmail.com with ESMTPSA id j6-20020adfff86000000b0031274a184d5sm15506412wrr.109.2023.07.25.01.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:17:59 -0700 (PDT) Date: Tue, 25 Jul 2023 10:17:55 +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: [PATCH net-next v3 2/4] vsock/virtio: support to send non-linear skb Message-ID: <5lemb27slnjt3hieixwa744ghzu6zj5fc3eimfng7a2ba7y2as@ueve2vn2cxpl> References: <20230720214245.457298-1-AVKrasnov@sberdevices.ru> <20230720214245.457298-3-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20230720214245.457298-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 Fri, Jul 21, 2023 at 12:42:43AM +0300, Arseniy Krasnov wrote: >For non-linear skb use its pages from fragment array as buffers in >virtio tx queue. These pages are already pinned by 'get_user_pages()' >during such skb creation. > >Signed-off-by: Arseniy Krasnov >Reviewed-by: Stefano Garzarella >--- > Changelog: > v2 -> v3: > * Comment about 'page_to_virt()' is updated. I don't remove R-b, > as this change is quiet small I guess. Ack! Thanks, Stefano > > net/vmw_vsock/virtio_transport.c | 41 +++++++++++++++++++++++++++----- > 1 file changed, 35 insertions(+), 6 deletions(-) > >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c >index e95df847176b..7bbcc8093e51 100644 >--- a/net/vmw_vsock/virtio_transport.c >+++ b/net/vmw_vsock/virtio_transport.c >@@ -100,7 +100,9 @@ virtio_transport_send_pkt_work(struct work_struct *work) > vq = vsock->vqs[VSOCK_VQ_TX]; > > for (;;) { >- struct scatterlist hdr, buf, *sgs[2]; >+ /* +1 is for packet header. */ >+ struct scatterlist *sgs[MAX_SKB_FRAGS + 1]; >+ struct scatterlist bufs[MAX_SKB_FRAGS + 1]; > int ret, in_sg = 0, out_sg = 0; > struct sk_buff *skb; > bool reply; >@@ -111,12 +113,39 @@ virtio_transport_send_pkt_work(struct work_struct *work) > > virtio_transport_deliver_tap_pkt(skb); > reply = virtio_vsock_skb_reply(skb); >+ sg_init_one(&bufs[out_sg], virtio_vsock_hdr(skb), >+ sizeof(*virtio_vsock_hdr(skb))); >+ sgs[out_sg] = &bufs[out_sg]; >+ out_sg++; >+ >+ if (!skb_is_nonlinear(skb)) { >+ if (skb->len > 0) { >+ sg_init_one(&bufs[out_sg], skb->data, skb->len); >+ sgs[out_sg] = &bufs[out_sg]; >+ out_sg++; >+ } >+ } else { >+ struct skb_shared_info *si; >+ int i; >+ >+ si = skb_shinfo(skb); >+ >+ for (i = 0; i < si->nr_frags; i++) { >+ skb_frag_t *skb_frag = &si->frags[i]; >+ void *va; > >- sg_init_one(&hdr, virtio_vsock_hdr(skb), sizeof(*virtio_vsock_hdr(skb))); >- sgs[out_sg++] = &hdr; >- if (skb->len > 0) { >- sg_init_one(&buf, skb->data, skb->len); >- sgs[out_sg++] = &buf; >+ /* We will use 'page_to_virt()' for the userspace page >+ * here, because virtio or dma-mapping layers will call >+ * 'virt_to_phys()' later to fill the buffer descriptor. >+ * We don't touch memory at "virtual" address of this page. >+ */ >+ va = page_to_virt(skb_frag->bv_page); >+ sg_init_one(&bufs[out_sg], >+ va + skb_frag->bv_offset, >+ skb_frag->bv_len); >+ sgs[out_sg] = &bufs[out_sg]; >+ out_sg++; >+ } > } > > ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, GFP_KERNEL); >-- >2.25.1 >