Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp749522ybg; Wed, 10 Jun 2020 12:42:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuEbC80x1/nKko1yf8X1wGN50Vh3WS1gSy43uI37+IU8AOpXdpoVXXTYgkBLBpFbu/VR2w X-Received: by 2002:a05:6402:a4d:: with SMTP id bt13mr3924083edb.338.1591818128336; Wed, 10 Jun 2020 12:42:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591818128; cv=none; d=google.com; s=arc-20160816; b=Aru1K4KuUVKJvoVood0CYxy2gHpLulhz0WCOJNLedr1xE57Pc9DC+e4Ocw/mq/mDrV qidBO64mmEcVH7cR/m3WC2oDolkabTCTDokObFz/9MisOg5lcss+4LehsC2hP1vAKZ78 XgVOATZIzYX75GnR2+MyK9TwV5szqRYfPjKMEbzwjXQu27S9I7lE0lycTKE9x25GKeEp VX092WQj3QwjKT/AwiHotRxlgLDzxyVfcw0b1YFyTAEbLpnlnEJFV4YYE1vxJwcGypFX /BkOrp/hnr8cspDDyr7Q5F4/j2lbmS71PfmpPbW+kKf40ezLv6AWNa3WnCjPglpGKqb7 +tgg== 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:date:cc:to:from:subject:message-id :dkim-signature; bh=UCaS5B0zDLBWnfrEXUqdrW0d6LJpY2CfoA/LuwizqL4=; b=Kh7ldR9esyLxQNOt1LO7Hcro4nuWp1Ec8uKmerLDJX0LMPb38ykuE5oeObGafCYqob zQQ0xbqQlEaw/aJHQNIIsVdwjUMgr4G82GsIhKv+Fkr2L/3nYWTQFv4Io5ZSZh3Q8d9y pimjiWZUCqRxe6Z8/CRb99RVR/qqodVyoLbqUSGOA5Ivbz4cbVXwhyV2GBcuR2xTersQ Uwh32uhW3mkoSXkIjJmZki2ZDYgbKIPdIdQQj0kxjwXS9EUP5QnpY1SySQOZLWkU8U65 atVgd0Pa07SIasRTK/Bx5sfIiSh7uOkg9fbNV6CoCShpB14H/MGTLjwlK8NGy4V8HKCw xCcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ls1xk/qf"; 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 n4si612680eje.267.2020.06.10.12.41.45; Wed, 10 Jun 2020 12:42:08 -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="Ls1xk/qf"; 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 S1730063AbgFJPN5 (ORCPT + 99 others); Wed, 10 Jun 2020 11:13:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50083 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730056AbgFJPN4 (ORCPT ); Wed, 10 Jun 2020 11:13:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591802034; 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=UCaS5B0zDLBWnfrEXUqdrW0d6LJpY2CfoA/LuwizqL4=; b=Ls1xk/qfaKZVEoeux1dbDR6coWYqxOoriNXYK2Uxko9Kr8MQr3FRnvxQgjVUn795gIPqYQ u9aafpuDwW3ZU4u81xi86TRts6JckGEaLUNOPQSq0qdWWQ4FxGtj2kUQ6tXlvYfnGpdLXI GSt1JKC2J0o2YqzewFIzMZna7je5qM4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-360-SH615xblPOe7e8efm2W-3g-1; Wed, 10 Jun 2020 11:13:52 -0400 X-MC-Unique: SH615xblPOe7e8efm2W-3g-1 Received: by mail-wr1-f72.google.com with SMTP id r5so1219807wrt.9 for ; Wed, 10 Jun 2020 08:13:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=UCaS5B0zDLBWnfrEXUqdrW0d6LJpY2CfoA/LuwizqL4=; b=HtzzDO/Lp5g8fsM6bNW+O0DFcdC6cVYFj1X7tqic+N2/qKnwHkr598dcMnc5hfbSnf fcsjZI3L1q3RhyOBZCNvDjq+FqRJNlhbfDj9YF1fWAj8un/CdtI8DzQlDRysFDlW2Ab8 v+uYPrnJ23W/pinB0bNcMv99ezrGFbPZXjJQKzIjNrw9QID/0JAxowSDU6FhKwxiLBPo i5rQa5OPtwPKZy360mjqzFKyA7R5S685PEBrZcmo8U6zRkeL0BpOgK3HUuRTfArZjB/2 WMPnOoyPv70ehIFpNA/m/uag3/tyCVnlx9VtOd5u6eXwLkD44k6cO4RVEMAMg8FxN2YH vMhw== X-Gm-Message-State: AOAM532bUWZjEbbeDR0gXqiAObtQVnjMVFltjwYP9fOw4+K3o0hEvvbm rNuCCJ17akYLJA+OCc9sx/lTPKKiTQ7tbLz1FX742gLll5n4lYg02Zlq+/Qj5tWrk4dNw/Dgymf 14HVdZBoAAktaqX7WLIpOZySq X-Received: by 2002:adf:e285:: with SMTP id v5mr4183929wri.129.1591802031334; Wed, 10 Jun 2020 08:13:51 -0700 (PDT) X-Received: by 2002:adf:e285:: with SMTP id v5mr4183909wri.129.1591802031104; Wed, 10 Jun 2020 08:13:51 -0700 (PDT) Received: from eperezma.remote.csb (109.141.78.188.dynamic.jazztel.es. [188.78.141.109]) by smtp.gmail.com with ESMTPSA id u12sm102944wrq.90.2020.06.10.08.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 08:13:50 -0700 (PDT) Message-ID: Subject: Re: [PATCH RFC v7 04/14] vhost/net: pass net specific struct pointer From: Eugenio =?ISO-8859-1?Q?P=E9rez?= To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Jason Wang Date: Wed, 10 Jun 2020 17:13:48 +0200 In-Reply-To: <20200610113515.1497099-5-mst@redhat.com> References: <20200610113515.1497099-1-mst@redhat.com> <20200610113515.1497099-5-mst@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-6.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-06-10 at 07:36 -0400, Michael S. Tsirkin wrote: > In preparation for further cleanup, pass net specific pointer > to ubuf callbacks so we can move net specific fields > out to net structures. > > Signed-off-by: Michael S. Tsirkin > --- > drivers/vhost/net.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c > index bf5e1d81ae25..ff594eec8ae3 100644 > --- a/drivers/vhost/net.c > +++ b/drivers/vhost/net.c > @@ -94,7 +94,7 @@ struct vhost_net_ubuf_ref { > */ > atomic_t refcount; > wait_queue_head_t wait; > - struct vhost_virtqueue *vq; > + struct vhost_net_virtqueue *nvq; > }; > > #define VHOST_NET_BATCH 64 > @@ -231,7 +231,7 @@ static void vhost_net_enable_zcopy(int vq) > } > > static struct vhost_net_ubuf_ref * > -vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy) > +vhost_net_ubuf_alloc(struct vhost_net_virtqueue *nvq, bool zcopy) > { > struct vhost_net_ubuf_ref *ubufs; > /* No zero copy backend? Nothing to count. */ > @@ -242,7 +242,7 @@ vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy) > return ERR_PTR(-ENOMEM); > atomic_set(&ubufs->refcount, 1); > init_waitqueue_head(&ubufs->wait); > - ubufs->vq = vq; > + ubufs->nvq = nvq; > return ubufs; > } > > @@ -384,13 +384,13 @@ static void vhost_zerocopy_signal_used(struct vhost_net *net, > static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success) > { > struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; > - struct vhost_virtqueue *vq = ubufs->vq; > + struct vhost_net_virtqueue *nvq = ubufs->nvq; > int cnt; > > rcu_read_lock_bh(); > > /* set len to mark this desc buffers done DMA */ > - vq->heads[ubuf->desc].len = success ? > + nvq->vq.heads[ubuf->desc].in_len = success ? Not like this matter a lot, because it will be override in next patches of the series, but `.len` has been replaced by `.in_len`, making compiler complain. This fixes it: diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index ff594eec8ae3..fdecf39c9ac9 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -390,7 +390,7 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success) rcu_read_lock_bh(); /* set len to mark this desc buffers done DMA */ - nvq->vq.heads[ubuf->desc].in_len = success ? + nvq->vq.heads[ubuf->desc].len = success ? VHOST_DMA_DONE_LEN : VHOST_DMA_FAILED_LEN; cnt = vhost_net_ubuf_put(ubufs); > VHOST_DMA_DONE_LEN : VHOST_DMA_FAILED_LEN; > cnt = vhost_net_ubuf_put(ubufs); > > @@ -402,7 +402,7 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success) > * less than 10% of times). > */ > if (cnt <= 1 || !(cnt % 16)) > - vhost_poll_queue(&vq->poll); > + vhost_poll_queue(&nvq->vq.poll); > > rcu_read_unlock_bh(); > } > @@ -1525,7 +1525,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) > /* start polling new socket */ > oldsock = vhost_vq_get_backend(vq); > if (sock != oldsock) { > - ubufs = vhost_net_ubuf_alloc(vq, > + ubufs = vhost_net_ubuf_alloc(nvq, > sock && vhost_sock_zcopy(sock)); > if (IS_ERR(ubufs)) { > r = PTR_ERR(ubufs);