Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp23370483rwd; Sat, 1 Jul 2023 00:13:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlHH5BXrTFlVgsAH77OajQz9443sRWhc9f38jXIOdWUWXpREw+rOtgIJaiFA5rPPDU7RsNAH X-Received: by 2002:a92:d390:0:b0:345:6e49:30d3 with SMTP id o16-20020a92d390000000b003456e4930d3mr4465353ilo.26.1688195628328; Sat, 01 Jul 2023 00:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688195628; cv=none; d=google.com; s=arc-20160816; b=ixsNU49R4yjsT7HwuA92ZOvhfR2C6Pe7zNHYWtymuMJYfHr+vXmtLzPdbNvs5h73U5 aoSsxdo7EqI3eOGw2aSsvzT+1sifybFu98kkHH/anVOw9MxyiAKgASzVQ9l/JyCczDBg zL8aP84G6/QJi5h/ydQEXowjtv2dWi6I4+n0lCdza06cjvVUMti9OARoq3K/RDq4ho5p r8ZzY38v/IK/EdaydoAFa7fjI3oLfxKW5lyQSDC3DSnm6/nToKy/x1bwrCyOKHSMFMBA x1/axH8MAv/2hKvZQEhfCG8oDf5ndsM3NtKIHDUb8WqBIBXFr2lwJxBJ5zN9N5RAvsmI 8fRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=C4H+wApJQrD5oBvAIFQn1rVYvXO7cAQ8ZFLo0nPthkM=; fh=PzWIi6JmlJNekYqVy23433fKO6OE4+V62ucRx731HUI=; b=k6n1pEswXCG2eitl0gc7r+ZjI0nWgh+LtqrxAbOXUviNkhbpxh6aTu9ohncbk517Uf iQmgO0w6HoYh+RdEY2QfOhvfQEo2M0b2WUUiAFSmDSvlAHZUnt4iuioUt0se0lp58KWY q6Mo/CvOehDbaiI6C8nSdZ655IzpUpY2PpTmNA53C0ZHlpxgWEIc+z/eyHYARVK1SOFg nOAfNncDONtSln1+W3lTkJq3ESVqCo6oIclkroh12qt2DKk/l1SNsXEGzoZDbjoAXSb7 f28KAv/2kypgqeN5V7ZWLl7ww6812hvYm3W8pLX45bivtCr9pZnzUMpeCk0Bu6A9Uffy I9hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=HvDlPf8q; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d30-20020a17090a6f2100b00262ea2f8539si11538478pjk.153.2023.07.01.00.13.34; Sat, 01 Jul 2023 00:13:48 -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=@sberdevices.ru header.s=mail header.b=HvDlPf8q; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231367AbjGAGwr (ORCPT + 99 others); Sat, 1 Jul 2023 02:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbjGAGvb (ORCPT ); Sat, 1 Jul 2023 02:51:31 -0400 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4323729D; Fri, 30 Jun 2023 23:45:21 -0700 (PDT) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 667C2120006; Sat, 1 Jul 2023 09:45:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 667C2120006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1688193904; bh=C4H+wApJQrD5oBvAIFQn1rVYvXO7cAQ8ZFLo0nPthkM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=HvDlPf8qU/gY2bSik5UniSMVdFesypxX6RV/Fq9pBOTjCdswFOLEyZ8YD0CmoMwNg 3ypQBD2VkJifNmQx2fcS2zAtlE7HYJJrSuBJmtEyHJaHs1AOSuW8qBOy3oRKdcfeWZ 85x9etBqjyjNgHJ7EZI/ywHEsEDqPaNgLPWvETARnWnBfl8TzvERv7ji3wctYBVG52 o1tjWZ2/iwtdF4WgpVEUVGFJP/3nhR9L0EKgF0vZzjX2OAYwm7i9IntS6BA7yRQNxu LbxB2ANH3Pm7FZgntIEar49ukYRSrv/d6486QAdsslBKpeOHCFMRJlOJbEbLxAoxVr CARWjzO8RfQSg== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Sat, 1 Jul 2023 09:45:03 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sat, 1 Jul 2023 09:44:43 +0300 From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , , Arseniy Krasnov Subject: [RFC PATCH v5 02/17] vhost/vsock: read data from non-linear skb Date: Sat, 1 Jul 2023 09:39:32 +0300 Message-ID: <20230701063947.3422088-3-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230701063947.3422088-1-AVKrasnov@sberdevices.ru> References: <20230701063947.3422088-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 178380 [Jun 30 2023] X-KSMG-AntiSpam-Version: 5.9.59.0 X-KSMG-AntiSpam-Envelope-From: AVKrasnov@sberdevices.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 517 517 b0056c19d8e10afbb16cb7aad7258dedb0179a79, {Tracking_from_domain_doesnt_match_to}, sberdevices.ru:7.1.1,5.0.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;100.64.160.123:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1, FromAlignment: s, {Tracking_white_helo}, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/07/01 04:02:00 #21597763 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 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. 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