Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp227152imu; Thu, 8 Nov 2018 18:26:27 -0800 (PST) X-Google-Smtp-Source: AJdET5fRhSGUk8NENJYwQykz6S1mbE/ze3yk9MVp15UfzUdOIO6jn5Vh0i6vl52Q6w8bMM/B/Mp0 X-Received: by 2002:a65:4ccb:: with SMTP id n11mr2108754pgt.257.1541730387389; Thu, 08 Nov 2018 18:26:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541730387; cv=none; d=google.com; s=arc-20160816; b=D4ipxJhveJr4SjGGycvZ7KiUWCCczHT4M85hB53pMY8LP8hN5OTlZavin1dfATw1X9 OF34fmIFfvN1ZtkI/ION7PogngCboecotsks/we+HjgilbKJk6juif3jUH0WjLQLJSoI Zf1dvTolFF5oMDgu8TjIubaGjTrxDgG6gGrpwK2o+tRoReFhVcc97IA6mE+YkgziG35+ kGtsrEAW8Wi2gpzd0pZPzNOMu+C6DVJcTPSzoBn+WBw/KPQ6nWhH4PxL0SPNsLwpbTAm NsjhQdeegdhC8xHAxiT3H6Rnet8/MGHX/SAqNQ0pLDWF1qw4l5VKhjMSO/dJvEBu4ako Q3yA== 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; bh=z7JAmXVlgUTqNS09oIN/m5hVv/ItQlI2R1mAu7MQ6hE=; b=kzic36nu2HXzQSbo+C6yMWHm7dSdDYah20YRtgJX7vxYjUasBtVQTvFqPLVtCVuqWB 39JRG2ufDduW4KSo9uK9t6/CdLUIybH9mlG9kNKgvabUTRd16mZP3P7SagyfnzJ8tRXE nfZ16kan71b+gg/BuSWMlpybQxFeqKUJqPYptKR3YwKb4zpZhgDB8ICFn21iJzUhvieq B7iQ0quKpiJvT7UoKgsM54YA3XP0NQtxfIZkyhIByFbtKqlkWU4SppEmJW6g3zvZK2dU KkYze832jqqYaed1PEbotVjdumJcE4cff8VeGHeqwhltYba+EtqZRTyHz3SBPN4VH/9S pnNw== 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 69-v6si6540998pft.177.2018.11.08.18.26.11; Thu, 08 Nov 2018 18:26:27 -0800 (PST) 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 S1727828AbeKIMEG (ORCPT + 99 others); Fri, 9 Nov 2018 07:04:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40960 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727390AbeKIMEG (ORCPT ); Fri, 9 Nov 2018 07:04:06 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47DB8308FBA4; Fri, 9 Nov 2018 02:25:38 +0000 (UTC) Received: from [10.72.12.19] (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0657DBAA6; Fri, 9 Nov 2018 02:25:30 +0000 (UTC) Subject: Re: [PATCH net-next v2 3/5] virtio_ring: add packed ring support To: "Michael S. Tsirkin" Cc: Tiwei Bie , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, virtio-dev@lists.oasis-open.org, wexu@redhat.com, jfreimann@redhat.com References: <20180711022711.7090-1-tiwei.bie@intel.com> <20180711022711.7090-4-tiwei.bie@intel.com> <20181107123933-mutt-send-email-mst@kernel.org> <20181108013759.GA20591@debian> <2d46a41e-bc00-276a-e19a-105c9dffc75a@redhat.com> <20181108091337-mutt-send-email-mst@kernel.org> From: Jason Wang Message-ID: <21d6dbd9-8f78-6939-0e80-27b470aeb00a@redhat.com> Date: Fri, 9 Nov 2018 10:25:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181108091337-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 09 Nov 2018 02:25:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/11/8 下午10:14, Michael S. Tsirkin wrote: > On Thu, Nov 08, 2018 at 04:18:25PM +0800, Jason Wang wrote: >> On 2018/11/8 上午9:38, Tiwei Bie wrote: >>>>> + >>>>> + if (vq->vq.num_free < descs_used) { >>>>> + pr_debug("Can't add buf len %i - avail = %i\n", >>>>> + descs_used, vq->vq.num_free); >>>>> + /* FIXME: for historical reasons, we force a notify here if >>>>> + * there are outgoing parts to the buffer. Presumably the >>>>> + * host should service the ring ASAP. */ >>>> I don't think we have a reason to do this for packed ring. >>>> No historical baggage there, right? >>> Based on the original commit log, it seems that the notify here >>> is just an "optimization". But I don't quite understand what does >>> the "the heuristics which KVM uses" refer to. If it's safe to drop >>> this in packed ring, I'd like to do it. >> >> According to the commit log, it seems like a workaround of lguest networking >> backend. I agree to drop it, we should not have such burden. >> >> But we should notice that, with this removed, the compare between packed vs >> split is kind of unfair. > I don't think this ever triggers to be frank. When would it? I think it can happen e.g in the path of XDP transmission in __virtnet_xdp_xmit_one():         err = virtqueue_add_outbuf(sq->vq, sq->sg, 1, xdpf, GFP_ATOMIC);         if (unlikely(err))                 return -ENOSPC; /* Caller handle free/refcnt */ > >> Consider the removal of lguest support recently, >> maybe we can drop this for split ring as well? >> >> Thanks > If it's helpful, then for sure we can drop it for virtio 1. > Can you see any perf differences at all? With which device? I don't test but consider the case of XDP_TX in guest plus vhost_net in host. Since vhost_net is half duplex, it's pretty easier to trigger this condition. Thanks > >>> commit 44653eae1407f79dff6f52fcf594ae84cb165ec4 >>> Author: Rusty Russell >>> Date: Fri Jul 25 12:06:04 2008 -0500 >>> >>> virtio: don't always force a notification when ring is full >>> We force notification when the ring is full, even if the host has >>> indicated it doesn't want to know. This seemed like a good idea at >>> the time: if we fill the transmit ring, we should tell the host >>> immediately. >>> Unfortunately this logic also applies to the receiving ring, which is >>> refilled constantly. We should introduce real notification thesholds >>> to replace this logic. Meanwhile, removing the logic altogether breaks >>> the heuristics which KVM uses, so we use a hack: only notify if there are >>> outgoing parts of the new buffer. >>> Here are the number of exits with lguest's crappy network implementation: >>> Before: >>> network xmit 7859051 recv 236420 >>> After: >>> network xmit 7858610 recv 118136 >>> Signed-off-by: Rusty Russell >>> >>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c >>> index 72bf8bc09014..21d9a62767af 100644 >>> --- a/drivers/virtio/virtio_ring.c >>> +++ b/drivers/virtio/virtio_ring.c >>> @@ -87,8 +87,11 @@ static int vring_add_buf(struct virtqueue *_vq, >>> if (vq->num_free < out + in) { >>> pr_debug("Can't add buf len %i - avail = %i\n", >>> out + in, vq->num_free); >>> - /* We notify*even if* VRING_USED_F_NO_NOTIFY is set here. */ >>> - vq->notify(&vq->vq); >>> + /* FIXME: for historical reasons, we force a notify here if >>> + * there are outgoing parts to the buffer. Presumably the >>> + * host should service the ring ASAP. */ >>> + if (out) >>> + vq->notify(&vq->vq); >>> END_USE(vq); >>> return -ENOSPC; >>> } >>> >>>