Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp501028imm; Mon, 21 May 2018 09:24:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqbByhwvmb6jcdFwjucACT/qLaHzKnVaWvqk9g1TVlz6f9tLW6Ab5rhYyQMtpO+bgXVW5AM X-Received: by 2002:a63:b44b:: with SMTP id n11-v6mr2149095pgu.254.1526919874541; Mon, 21 May 2018 09:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526919874; cv=none; d=google.com; s=arc-20160816; b=pNAHLsDTKpNj5+pfflp54xzhlOrm0bQQ3Tg7zCKXQspsHyMc9pkcm1jP7dp2uEO3p9 YJzuap72651qniXsiq09mx6QDOGIh8GfmFbbp2TewgWumxo5N7KcLSFvFMqD2UJXjsR0 YFfeIDtElkEsnR5wnza2SKVprY3dYVGmNHUZa+0BBzHCa2sjjR0coNZZqfepo58nJDtW PyGkSAOgbIRgACH2CNNChyiv77YRpHYCEm1aw3ERUAfH8Kzk/7pV3kYoRnIMU2t02e/w mKcAZ97OWT2qTK/5fvPmZYIPnbMQbTrARpA+kCSIIjpMyoh4Unf9YgafwZokqvvDj7GK iHHw== 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:subject:cc:to:from:date :arc-authentication-results; bh=Ig4xuwFPxuQzqEd/i+NX7btAoqxoZKIALRKi6R7nxgQ=; b=uCCSvmxj2/5oiRAbi1jBbglfsurW2sjSbjbuD310RWdFmy266EasRlrtLONy2S3WQA gnDxi7qdCcwe2QuGKiz7O5U+F80fktbz7BHUbHHyksNcXySzSJ++Ud9wfXyBwwuI3kAX ZMTv1aKUhrJ1/07n9xtZK0jC6pj3H31vIRU+1nS0xk1exNKOqEA+9tasfyKbIjkb+9YV ZqYoZkeGkA6Dai+A+YFflACfc+1D7ibNkX0D13fJ/ZmZz1BxUKeR5Pn8qLP3rhYFNy2A tLjQcCCmnNqQSdA7JRPOQNShrZ4li4Ee2RNaXOfOjwSTn6X3FWIp6+7LIkAu5pH0giy9 dsvw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n13-v6si11082230pgd.541.2018.05.21.09.24.19; Mon, 21 May 2018 09:24:34 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753203AbeEUQYD (ORCPT + 99 others); Mon, 21 May 2018 12:24:03 -0400 Received: from mga11.intel.com ([192.55.52.93]:64975 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753130AbeEUQYB (ORCPT ); Mon, 21 May 2018 12:24:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2018 09:24:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,426,1520924400"; d="scan'208";a="57747998" Received: from jesse-tab.amr.corp.intel.com (HELO localhost) ([10.166.244.182]) by orsmga001.jf.intel.com with ESMTP; 21 May 2018 09:24:00 -0700 Date: Mon, 21 May 2018 09:24:00 -0700 From: Jesse Brandeburg To: Jason Wang Cc: , , , , , jesse.brandeburg@intel.com Subject: Re: [RFC PATCH net-next 01/12] vhost_net: introduce helper to initialize tx iov iter Message-ID: <20180521092400.00004c68@intel.com> In-Reply-To: <1526893473-20128-2-git-send-email-jasowang@redhat.com> References: <1526893473-20128-1-git-send-email-jasowang@redhat.com> <1526893473-20128-2-git-send-email-jasowang@redhat.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.30; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + 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. > break; > - } > - len = msg_data_left(&msg); > > zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN > && !vhost_exceeds_maxpend(net)