Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1007686ybt; Fri, 19 Jun 2020 21:25:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwWLO2tU17ah9n/xNKIlImoym1ax2m3P/XLiU/2ugHwLRYoR7rshEeeWm3jFwysc/aNqPy X-Received: by 2002:aa7:c80c:: with SMTP id a12mr6667750edt.140.1592627125409; Fri, 19 Jun 2020 21:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592627125; cv=none; d=google.com; s=arc-20160816; b=07/nNc60Wo/reK08W1GfOdqJfEU1d3VuPpNgcEdeJEhAD6WLMa8oiYP1ea9CS1T1IN +/5X5oMA/eHNxV2/wjN/fDvluh/ByBC//+nhevhZnyLqwujqmkxgdG0BevuNHbp1cKOu GeMOiHNZNKCCvehB0XHJjrsZsRmf5mQNTm5/MvZ7Kp+okRG3qA+fpjojRD8j1yyLtuVe oUgsyuQs/l4iGNqvWGkwYvWCiEw4xAMlU8pi7KzLZO73Q1qid55NcBreh7+sTSlycRBu vEEs3X3e+cxKoqxhCP0TZEk0kQJfGOJWPTTwX81KUcozeB9+enjCUPGjTmq+76JpFcKS FepA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hizvuErrfe2IuRCAoJyyo6xCFe+4OpL2MM7w/xo1d5g=; b=gtIYw1d2qcuIq8C5UvlnoKu9p/l0JBNUh3oM7PsvXWItYUL1YRpcy4VGk0oUhzJ93l QUybVYI+0Ra6Q47LUbyEq4vVvclE7Y2IGWlyGxSS5djNPxH7Etd6d5Suo8fQ8W4qoEm/ r7vqvWzQZamQUT/qAbA8TbvzY4Xaf8VJoSWtAt3WRw/XkegweeNiT3n0PnPtCkyKoY8I ByalT5kOVVKGfaFc9QRKHaiwaOirl9o5XDAR4zyaBL22kCQOBM/b08MlNf03ifW3u7ys fHiMMREyKQ+wjAJpoKaEgaNRpyNY3PT4aTwTgapXciK2VMCzglsCTj0uVsnUh29GqvKK 683Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NFFWikqx; 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 mj14si5156601ejb.464.2020.06.19.21.25.03; Fri, 19 Jun 2020 21:25:25 -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=NFFWikqx; 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 S2405464AbgFSSXn (ORCPT + 99 others); Fri, 19 Jun 2020 14:23:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47447 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405381AbgFSSXj (ORCPT ); Fri, 19 Jun 2020 14:23:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592591018; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hizvuErrfe2IuRCAoJyyo6xCFe+4OpL2MM7w/xo1d5g=; b=NFFWikqxwoVHlXbGzwMMqrj7SIGT/HTLpqlCrMImpHngVLl5I5YfCCGr8sgG2r6oaNQz+x t4q5TeR7sHpLDjyphXp4NoE4YaGjYCbtqRBP8GW4Cex6PSxmtyWvaa/3aXaPo6PxaEvNy2 HSJdW4q/Y5FyJPRsIaqVyvEsn4LMR44= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-CYcofGs2NzCziALfYEt4aw-1; Fri, 19 Jun 2020 14:23:36 -0400 X-MC-Unique: CYcofGs2NzCziALfYEt4aw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5FD7107ACCA; Fri, 19 Jun 2020 18:23:34 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-14.ams2.redhat.com [10.36.113.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id E414C7C1E4; Fri, 19 Jun 2020 18:23:32 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: mst@redhat.com Cc: kvm list , Stefano Garzarella , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Stefan Hajnoczi , Jason Wang Subject: [RFC v9 07/11] vhost/net: avoid iov length math Date: Fri, 19 Jun 2020 20:22:58 +0200 Message-Id: <20200619182302.850-8-eperezma@redhat.com> In-Reply-To: <20200619182302.850-1-eperezma@redhat.com> References: <20200619182302.850-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Michael S. Tsirkin" Now that API exposes buffer length, we no longer need to scan IOVs to figure it out. Signed-off-by: Michael S. Tsirkin Signed-off-by: Eugenio PĂ©rez --- drivers/vhost/net.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 871214d8c64d..3356b249bf64 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -607,11 +607,9 @@ static bool vhost_exceeds_maxpend(struct vhost_net *net) } static size_t init_iov_iter(struct vhost_virtqueue *vq, struct iov_iter *iter, - size_t hdr_size, int out) + size_t len, size_t hdr_size, int out) { /* Skip header. TODO: support TSO. */ - size_t len = iov_length(vq->iov, out); - iov_iter_init(iter, WRITE, vq->iov, out, len); iov_iter_advance(iter, hdr_size); @@ -640,7 +638,7 @@ static int get_tx_bufs(struct vhost_net *net, } /* Sanity check */ - *len = init_iov_iter(vq, &msg->msg_iter, nvq->vhost_hlen, *out); + *len = init_iov_iter(vq, &msg->msg_iter, buf->out_len, nvq->vhost_hlen, *out); if (*len == 0) { vq_err(vq, "Unexpected header len for TX: %zd expected %zd\n", *len, nvq->vhost_hlen); @@ -1081,7 +1079,7 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, nlogs += *log_num; log += *log_num; } - len = iov_length(vq->iov + seg, in); + len = bufs[bufcount].in_len; datalen -= len; ++bufcount; seg += in; -- 2.18.1