Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp665210ybg; Wed, 10 Jun 2020 10:21:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrQ93RIeLlJ0H00MZi1Tmp5YOT2iyj1UUBzUMOOMM/SY80I0DTt4fAnHkj/MdX4PnU1b/I X-Received: by 2002:aa7:d0cb:: with SMTP id u11mr3222319edo.381.1591809703992; Wed, 10 Jun 2020 10:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591809703; cv=none; d=google.com; s=arc-20160816; b=j0QmGCD6f1dQazNMFMDbWwSTttNWRPUSWRimFc4zhfrMSxhwqYdUwZ0RLu1jy3jj6q /w/Z1OTKibJpQFEJF/iRnsvZxcskyQOR9ouJjMEjIhThwsjZTx22mGKUjes9Hg7hcXxl Sjdo8snEdiW3XQDHfU0Kn6ENQN4Yuj3OBpAb/KbWF/ZrDdI1tdH6DGCUM1M7OamuK/a3 CzetFikbgW63zSHCpVvWeFGmzup56kR9ywErDd0qXNYiEcLgmHkBupyTDc5PrdveEeg2 vPTvnFAKJ/7em3Ly1TsWuXL9KL3ne8/g64xhN/Lt2oI3iKCUezualk/c5h2eDoVNb5to Zy+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=anaWHR8ODh6bT+XuFE0Xz0+EuRSEm+J1BoLhgrw84d0=; b=HpScL3rmMaVusapYaD3m3aawkZPW3WSTW4PV2gZ4xLknYaUhT1ZqSnxFQyI69wAQYt etYcjzAInIA/8jOFXgRD5PqZvL61o2h441bT+nYsjvVqvhFygFTPHE2jFf3UqwDxT0a7 vpDWsy7TUmOFhqV7qguvhASFHuMwSqZiBSUkshSmRhM6bk6NLxAvrg8SGYsuWgUSrfR+ oTx+9EFg+08UAiMlkPVSCT9aNtX/krIuryT2elKKmJCMHlECtq6xyVHY13TcJqWNRdwX Xu/i9Lon8qJBhH2jnQvZ/hadsKtaTSZW4RPh2G/XRvglk5fzI9HNE0bbk4qdJH0a33zX knCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PqwsPm3+; 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 p11si141823edq.151.2020.06.10.10.21.19; Wed, 10 Jun 2020 10:21:43 -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=PqwsPm3+; 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 S1730612AbgFJQTP (ORCPT + 99 others); Wed, 10 Jun 2020 12:19:15 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:21587 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728491AbgFJQTO (ORCPT ); Wed, 10 Jun 2020 12:19:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591805951; 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: in-reply-to:in-reply-to:references:references; bh=anaWHR8ODh6bT+XuFE0Xz0+EuRSEm+J1BoLhgrw84d0=; b=PqwsPm3+wCtoi/v/uszAfAEjXalzKuvEu4AWipiAtWKzz1GnfaNnGLnOPmjOyIWdhWxO2b DFL3m6P4s0A3ucDHFEe8Y2nMEoEOvu6tdBe1jKqVclnpj7P9WUtWn6AyXF6LrPBjjfaBQI imBTP9sJb3LhvSUArEFFpRYYzpE+2As= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-E_bzrkwnMMOz0T16rcULLw-1; Wed, 10 Jun 2020 12:19:09 -0400 X-MC-Unique: E_bzrkwnMMOz0T16rcULLw-1 Received: by mail-qk1-f197.google.com with SMTP id l184so2568091qkb.2 for ; Wed, 10 Jun 2020 09:19:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=anaWHR8ODh6bT+XuFE0Xz0+EuRSEm+J1BoLhgrw84d0=; b=HCy/zcF4xjAiTX6JZG/Wh8p6KQ272m+aJAXSqIsJkESYGXB7tWpDWsewKHB5yz9SeC 9YgVc8EA1TRNu8bOTzKboGVCqcFNaXg9b+NuyylSdX9UAg1pAh4JUTrt9H/W4rpdY57Z vlQunvgGq5v/6G6IC5bgzs6O6o758OWdoB/p0JdJIrjFtyK10ix4ux5laRN1EJz3tPDU mWGN9UfUHVdsqIZMLr13bEVNgboe19Q4njaCWR36IRPPPjTdkbi5WimJdYNzkJZqSmR9 6cTSEKfgEKBXEtY7mQgfSuH/ZC/HFmsI2LuO1A+ynAsC3motPvetmKR24I6+d6YKaiSZ YOVg== X-Gm-Message-State: AOAM533BIqUdrmTaDiu+S8ppiK2zy57FzPXJXAO1JmhtIAQZyIvBtlhW wH3cqfngVyBV69cQWlgcKfN3S8pfoXb251ul7THA0FYsa0a58OMnQAkIaCcjcxsf8is66OYyAB6 PgNtsnJYy/82sECSqVzemgUfrfLPsPNYj0W73Scqw X-Received: by 2002:a37:2702:: with SMTP id n2mr3862398qkn.497.1591805949116; Wed, 10 Jun 2020 09:19:09 -0700 (PDT) X-Received: by 2002:a37:2702:: with SMTP id n2mr3862363qkn.497.1591805948686; Wed, 10 Jun 2020 09:19:08 -0700 (PDT) MIME-Version: 1.0 References: <20200610113515.1497099-1-mst@redhat.com> <20200610113515.1497099-4-mst@redhat.com> <20200610111147-mutt-send-email-mst@kernel.org> In-Reply-To: <20200610111147-mutt-send-email-mst@kernel.org> From: Eugenio Perez Martin Date: Wed, 10 Jun 2020 18:18:32 +0200 Message-ID: Subject: Re: [PATCH RFC v7 03/14] vhost: use batched get_vq_desc version To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, kvm list , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Jason Wang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 10, 2020 at 5:13 PM Michael S. Tsirkin wrote: > > On Wed, Jun 10, 2020 at 02:37:50PM +0200, Eugenio Perez Martin wrote: > > > +/* This function returns a value > 0 if a descriptor was found, or 0 if none were found. > > > + * A negative code is returned on error. */ > > > +static int fetch_descs(struct vhost_virtqueue *vq) > > > +{ > > > + int ret; > > > + > > > + if (unlikely(vq->first_desc >= vq->ndescs)) { > > > + vq->first_desc = 0; > > > + vq->ndescs = 0; > > > + } > > > + > > > + if (vq->ndescs) > > > + return 1; > > > + > > > + for (ret = 1; > > > + ret > 0 && vq->ndescs <= vhost_vq_num_batch_descs(vq); > > > + ret = fetch_buf(vq)) > > > + ; > > > > (Expanding comment in V6): > > > > We get an infinite loop this way: > > * vq->ndescs == 0, so we call fetch_buf() here > > * fetch_buf gets less than vhost_vq_num_batch_descs(vq); descriptors. ret = 1 > > * This loop calls again fetch_buf, but vq->ndescs > 0 (and avail_vq == > > last_avail_vq), so it just return 1 > > That's what > [PATCH RFC v7 08/14] fixup! vhost: use batched get_vq_desc version > is supposed to fix. > Sorry, I forgot to include that fixup. With it I don't see CPU stalls, but with that version latency has increased a lot and I see packet lost: + ping -c 5 10.200.0.1 PING 10.200.0.1 (10.200.0.1) 56(84) bytes of data. From 10.200.0.2 icmp_seq=1 Destination Host Unreachable From 10.200.0.2 icmp_seq=2 Destination Host Unreachable From 10.200.0.2 icmp_seq=3 Destination Host Unreachable 64 bytes from 10.200.0.1: icmp_seq=5 ttl=64 time=6848 ms --- 10.200.0.1 ping statistics --- 5 packets transmitted, 1 received, +3 errors, 80% packet loss, time 76ms rtt min/avg/max/mdev = 6848.316/6848.316/6848.316/0.000 ms, pipe 4 -- I cannot even use netperf. If I modify with my proposed version: + ping -c 5 10.200.0.1 PING 10.200.0.1 (10.200.0.1) 56(84) bytes of data. 64 bytes from 10.200.0.1: icmp_seq=1 ttl=64 time=7.07 ms 64 bytes from 10.200.0.1: icmp_seq=2 ttl=64 time=0.358 ms 64 bytes from 10.200.0.1: icmp_seq=3 ttl=64 time=5.35 ms 64 bytes from 10.200.0.1: icmp_seq=4 ttl=64 time=2.27 ms 64 bytes from 10.200.0.1: icmp_seq=5 ttl=64 time=0.426 ms [root@localhost ~]# netperf -H 10.200.0.1 -p 12865 -l 10 -t TCP_STREAM MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.200.0.1 () port 0 AF_INET Recv Send Send Socket Socket Message Elapsed Size Size Size Time Throughput bytes bytes bytes secs. 10^6bits/sec 131072 16384 16384 10.01 4742.36 [root@localhost ~]# netperf -H 10.200.0.1 -p 12865 -l 10 -t UDP_STREAM MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.200.0.1 () port 0 AF_INET Socket Message Elapsed Messages Size Size Time Okay Errors Throughput bytes bytes secs # # 10^6bits/sec 212992 65507 10.00 9214 0 482.83 212992 10.00 9214 482.83 I will compare with the non-batch version for reference, but the difference between the two is noticeable. Maybe it's worth finding a good value for the if() inside fetch_buf? Thanks! > -- > MST >