From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B52B8A0534; Tue, 4 Feb 2020 14:49:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1FD411C121; Tue, 4 Feb 2020 14:49:09 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 22D071BF9F for ; Tue, 4 Feb 2020 14:49:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580824146; 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:autocrypt:autocrypt; bh=FGGXESJELCP5FF/dEXpo2HYr/MUwOLf9bg+lql9EHrA=; b=CQKKq8d83/FRnoqJHfQoGI0P8Pl7WOpxibbqivqK0+owUQgFqvwiilC21udXfHiB4dY8dQ m0iaSPjllJIyi8jN5KnS+b5j5vfell16rz+W/bjLhH3Ih5gsB6tS7op+Wp+b5BfSiqvyKF dADGb6XAvp23RRDbHQ+Q7K6ctFd6Zac= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-25-h281AgNxPPm-Le8z90Z_4Q-1; Tue, 04 Feb 2020 08:49:03 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30B608010F1; Tue, 4 Feb 2020 13:49:02 +0000 (UTC) Received: from [10.33.36.105] (unknown [10.33.36.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58BF55DA83; Tue, 4 Feb 2020 13:48:55 +0000 (UTC) To: Eugenio Perez Martin Cc: dev@dpdk.org, "Liu, Yong" , Maxime Coquelin , Adrian Moreno Zapata , Jason Wang , "Michael S. Tsirkin" References: <20200129193310.9157-1-eperezma@redhat.com> <1bdb5d16-2a39-1a19-9c47-69b8cb4607a1@redhat.com> From: Kevin Traynor Autocrypt: addr=ktraynor@redhat.com; keydata= mQINBF2J2awBEADUEPNhgNI+nJNgiTAUcw4YIgVXEoHlsNPyyzG1BEXkWXALy0Y3fNTiw6+r ltWDkF9jzL9kfkecgQ67itGfk1OaBXgSGKuw1PUpxAwX2Bi76LAR6M5OsyGM9TSVVQwARalz hMwRBIZPzPc7or6Pw7jAOJ8SQGJ1Zlp1YJCjrvpe87V1tH/LY8Wnxn/EuoseFmWILAQZAtYS tGjcrAgYn3SPMLR1B0BP5bTBY06vWQjiufH8drenfDnMJAzuBdG1mqjnTqCjULZ3Hunv4xqZ aMnkvL/K5Tj1c12Oe4930EE53LrXIBUltRg5mBudSWHnC7twjH0082HH9f963Z/2UI63SFIT iUvRvAzJYytgy7XnWLQ0+goZBADKYfolOuC0H8VgCaux8u8KFF28Dy+N6TV2KI58jTlyg1Zu l7QwykZpnOkJFiy37Gfbu3YEOzO72cP/S7/A+zvuqkxi63jyEkd+FY99vLt/HN2MUZwRmKDw UPbLkmrs8WU01/POVsqDcfvz7vu2St8hqqTiSIdQGS2zyTKB2/DvPSM3jws3udkIYSuhn+X4 QBiV6lkVZ7DSE6a065gnAauAql+b32Eymy+xnG5jCt1tR+0Cp2VZYCR9OU2gmomUKBDoX/He pSgED01CqYPNjN+TddirwmQX7ep4DtXc8FWvv2g/pq9WZFQk2QARAQABtCNLZXZpbiBUcmF5 bm9yIDxrdHJheW5vckByZWRoYXQuY29tPokCTgQTAQgAOBYhBAoiOaH51tHF7VYtEI9CINER a+yJBQJdidmsAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEI9CINERa+yJoxIP/3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:48:54 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: h281AgNxPPm-Le8z90Z_4Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH] vhost: flush shadow tx if there is no more packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 04/02/2020 09:23, Eugenio Perez Martin wrote: > Hi Kevin! >=20 > Sorry, thanks for noticing it! It fixes commit ("31d6c6a5b vhost: optimiz= e > packed ring dequeue"), what was not present on 18.11 version (I've checke= d > that v19.08 does not contain the failure). >=20 Right, in that case the issue is present on 19.11 stable, so it's worth adding the tags to get it fixed in 19.11 stable. > Do I need to send another patch version with corrected commit message? >=20 Probably Maxime can do it on applying if you ask nicely :-) > Thanks! >=20 > On Fri, Jan 31, 2020 at 7:38 PM Kevin Traynor wrote= : >=20 >> Hi Eugenio, >> >> On 29/01/2020 19:33, Eugenio P=C3=A9rez wrote: >>> The current implementation of vhost_net in packed vring tries to fill >>> the shadow vector before send any actual changes to the guest. While >>> this can be beneficial for the throughput, it conflicts with some >>> bufferfloats methods like the linux kernel napi, that stops >>> transmitting packets if there are too much bytes/buffers in the >>> driver. >>> >>> To solve it, we flush the shadow packets at the end of >>> virtio_dev_tx_packed if we have starved the vring, i.e., the next >>> buffer is not available for the device. >>> >>> Since this last check can be expensive because of the atomic, we only >>> check it if we have not obtained the expected (count) packets. If it >>> happens to obtain "count" packets and there is no more available >>> packets the caller needs to keep call virtio_dev_tx_packed again. >>> >> >> It seems to be fixing an issue and should be considered for stable >> branches? You can add the tags needed in the commit message here: >> >> Fixes: >> Cc: stable@dpdk.org >> >>> Signed-off-by: Eugenio P=C3=A9rez >>> --- >>> lib/librte_vhost/virtio_net.c | 27 ++++++++++++++++++++++++++- >>> 1 file changed, 26 insertions(+), 1 deletion(-) >>> >>> diff --git a/lib/librte_vhost/virtio_net.c >> b/lib/librte_vhost/virtio_net.c >>> index 21c311732..ac2842b2d 100644 >>> --- a/lib/librte_vhost/virtio_net.c >>> +++ b/lib/librte_vhost/virtio_net.c >>> @@ -2133,6 +2133,20 @@ virtio_dev_tx_packed_zmbuf(struct virtio_net *de= v, >>> return pkt_idx; >>> } >>> >>> +static __rte_always_inline bool >>> +next_desc_is_avail(const struct vhost_virtqueue *vq) >>> +{ >>> + bool wrap_counter =3D vq->avail_wrap_counter; >>> + uint16_t next_used_idx =3D vq->last_used_idx + 1; >>> + >>> + if (next_used_idx >=3D vq->size) { >>> + next_used_idx -=3D vq->size; >>> + wrap_counter ^=3D 1; >>> + } >>> + >>> + return desc_is_avail(&vq->desc_packed[next_used_idx], >> wrap_counter); >>> +} >>> + >>> static __rte_noinline uint16_t >>> virtio_dev_tx_packed(struct virtio_net *dev, >>> struct vhost_virtqueue *vq, >>> @@ -2165,9 +2179,20 @@ virtio_dev_tx_packed(struct virtio_net *dev, >>> >>> } while (remained); >>> >>> - if (vq->shadow_used_idx) >>> + if (vq->shadow_used_idx) { >>> do_data_copy_dequeue(vq); >>> >>> + if (remained && !next_desc_is_avail(vq)) { >>> + /* >>> + * The guest may be waiting to TX some buffers to >>> + * enqueue more to avoid bufferfloat, so we try t= o >>> + * reduce latency here. >>> + */ >>> + vhost_flush_dequeue_shadow_packed(dev, vq); >>> + vhost_vring_call_packed(dev, vq); >>> + } >>> + } >>> + >>> return pkt_idx; >>> } >>> >>> >> >> >=20