Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1519303imm; Tue, 22 May 2018 05:28:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqb9Fw9dGGtnR0lXT3rNLKD/rCEX/l+Wu0v400ZmJGIOZRqjeESYe4GqqCZn6IUTa82Pfm1 X-Received: by 2002:a65:6557:: with SMTP id a23-v6mr13586232pgw.319.1526992107852; Tue, 22 May 2018 05:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526992107; cv=none; d=google.com; s=arc-20160816; b=fws5wUvEcQngNuwCX+bgAJgI8iEVQ0+V+TMfRw1k1sncAlLi4UoWk1OXbXjeOhcKEa dHq/FlvrdieBN6O60FvQ7XCodRRUPFEhort5LwtHzM8tU7iZlhWdp/tF3looX8oUPNoP rjoAWKuvyMHW5pd/sF7Qox3ekj5fEnvkyHYVaL+xpK4ugIgp2b/gKduqpPYbtfPyzcsE YgJ6zWXjieG7B077RO7XiPP7/dOX7w9+2UBLKN/kb/+zEYgkl6RSSXTDPGsqSKCcPt9G euln2s2R8cTtit5i88x6PubwH3Zsn35OH3UujoyvYlN8RWwc5OmZaURlJ8eZVkAK94H2 EIww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=aGc3w+HtUDC95fDv27G/W2BVO87MQFOEcWOlewDSSyI=; b=y2jRZQ5WoC57bpIi4UuNiwypbfImbFtt7u/8SHr65v/5ddaZ5m89BKXVFzFHa6320Q /G6wcxJzUV9DrcJrppqGjvB5urNIHZ6XhvK1uI0dm1TLgZkQJBUni5J2C20xCm8ZCpPt T0p1PiG0eFXIBQqM+kede78E3rjn1kDKcnV4xfJBbdj1IQzqgTFYPxw9P/KA7mastmic DbDw816qnk34YvMSbUCZAA7qVhvj3T8XX9Fp0qokcr3y0Hp8H7Wc0+OLo5nIl35wccZx EV64fXduWVtk+Eu0EU8rBYJpeg02wbZFr+BNeyDwkCkzDzXSMJkeVbgfhsT5ZWF/cJF9 mJCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si16985211ple.372.2018.05.22.05.28.13; Tue, 22 May 2018 05:28:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbeEVM0s (ORCPT + 99 others); Tue, 22 May 2018 08:26:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60604 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751340AbeEVM0q (ORCPT ); Tue, 22 May 2018 08:26:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C135E81663FD; Tue, 22 May 2018 12:26:45 +0000 (UTC) Received: from [10.72.12.75] (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94DF81002954; Tue, 22 May 2018 12:26:40 +0000 (UTC) Subject: Re: [RFC PATCH net-next 01/12] vhost_net: introduce helper to initialize tx iov iter To: Jesse Brandeburg Cc: mst@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org References: <1526893473-20128-1-git-send-email-jasowang@redhat.com> <1526893473-20128-2-git-send-email-jasowang@redhat.com> <20180521092400.00004c68@intel.com> From: Jason Wang Message-ID: <2d54d4e2-c5fc-167b-9a8d-762aed2d1ba5@redhat.com> Date: Tue, 22 May 2018 20:26:37 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180521092400.00004c68@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 22 May 2018 12:26:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 22 May 2018 12:26:45 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年05月22日 00:24, Jesse Brandeburg wrote: > Hi Jason, a few nits. > > On Mon, 21 May 2018 17:04:22 +0800 Jason wrote: >> Signed-off-by: Jason Wang >> --- >> drivers/vhost/net.c | 34 +++++++++++++++++++++++----------- >> 1 file changed, 23 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c >> index c4b49fc..15d191a 100644 >> --- a/drivers/vhost/net.c >> +++ b/drivers/vhost/net.c >> @@ -459,6 +459,26 @@ static bool vhost_exceeds_maxpend(struct vhost_net *net) >> min_t(unsigned int, VHOST_MAX_PEND, vq->num >> 2); >> } >> >> +static size_t init_iov_iter(struct vhost_virtqueue *vq, struct iov_iter *iter, >> + 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); >> + /* Sanity check */ >> + if (!iov_iter_count(iter)) { >> + vq_err(vq, "Unexpected header len for TX: " >> + "%zd expected %zd\n", >> + len, hdr_size); > ok, it was like this before, but please unwrap the string in " ", there > should be no line breaks in string declarations and they are allowed to > go over 80 characters. Ok. > >> + return -EFAULT; >> + } >> + len = iov_iter_count(iter); >> + >> + return len; >> +} >> + >> /* Expects to be always run from workqueue - which acts as >> * read-size critical section for our kind of RCU. */ >> static void handle_tx(struct vhost_net *net) >> @@ -521,18 +541,10 @@ static void handle_tx(struct vhost_net *net) >> "out %d, int %d\n", out, in); >> break; >> } >> - /* Skip header. TODO: support TSO. */ >> - len = iov_length(vq->iov, out); >> - iov_iter_init(&msg.msg_iter, WRITE, vq->iov, out, len); >> - iov_iter_advance(&msg.msg_iter, hdr_size); >> - /* Sanity check */ >> - if (!msg_data_left(&msg)) { >> - vq_err(vq, "Unexpected header len for TX: " >> - "%zd expected %zd\n", >> - len, hdr_size); >> + >> + len = init_iov_iter(vq, &msg.msg_iter, hdr_size, out); >> + if (len < 0) > len is declared as size_t, which is unsigned, and can never be > negative. I'm pretty sure this is a bug. Yes, let me fix it in next version. Thanks > > >> break; >> - } >> - len = msg_data_left(&msg); >> >> zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN >> && !vhost_exceeds_maxpend(net)