From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 75E31A0032; Tue, 28 Sep 2021 11:18:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E015740E3C; Tue, 28 Sep 2021 11:17:59 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id C777040DF6 for ; Tue, 28 Sep 2021 11:17:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632820678; 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=eX2GVscZ7SmOfXYGnE8aCE7yPONFywqKXNBH6mZVQZ8=; b=I1yVqrpIW2rhrzTtoJV1wHTOiph2enzkpLpwHWcHodH7PjrH7VEtT9yffVFEsthP+Kapy6 2GJTM5W9bApnrbggNNnws9RBYldBJiBQvEMIn6KMupLR1noai06aqStsuQOmg3qnUWX94k nMZg4i1HRMEhlGS+321IDdIbA5pQveI= 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-89-IwgHu3AePWqWoJxxZ4vkzw-1; Tue, 28 Sep 2021 05:17:56 -0400 X-MC-Unique: IwgHu3AePWqWoJxxZ4vkzw-1 Received: by mail-wr1-f72.google.com with SMTP id j16-20020adfa550000000b0016012acc443so14897876wrb.14 for ; Tue, 28 Sep 2021 02:17:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:subject:in-reply-to :content-transfer-encoding; bh=eX2GVscZ7SmOfXYGnE8aCE7yPONFywqKXNBH6mZVQZ8=; b=rUfJVayR/BFO3CAX+h4svAygD6L8oVw6oVcFmeFzd1zuvT4ki7vQg2CrFgzWPSombZ 9peIlHd6usywfHd3zEWHQjyV3MZIgMbSQPk2pqACAb0gakma3/oae3Cz9O8VI0SMeLVV TOMDWPE5dFDJxTPklcDtX0+CQvcDqqdCLSSO9315dtsDX/RcRnZwMZiCw+vzxOkc2eVt 2bSC8oTiBcOoLmI1vLDCWeiFihfLMmAhVunOvNcwuamxx3mrlX0Y73G3lymffnZC9PvI YvQzGG+qGFHDOq1c4AywUJf0Z5ZRo067mCf8MdfrKhPZpp3qG8id8Ce5ty6UpzTh6r2R O5oA== X-Gm-Message-State: AOAM530kmFGNl92Yo6JYY8X70LM0eWEa5JlPVfVjz0rhPIPP2jhDLSiu JyDDlH2Z7+IDBZ6zT+qY5rGRpJ/gHzrooh2MVxQYreRdiPKXXU7XkiGPozm+Zf8ypxIJoLyNfcd wUq4= X-Received: by 2002:a7b:c350:: with SMTP id l16mr3462197wmj.151.1632820675683; Tue, 28 Sep 2021 02:17:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX3S5WaSnx12m/kOWXbljtlo198NadAFVl9CxMGn29SvSLNt1r3i9UrGNSB3SPlHjXDhxTjg== X-Received: by 2002:a7b:c350:: with SMTP id l16mr3462173wmj.151.1632820675493; Tue, 28 Sep 2021 02:17:55 -0700 (PDT) Received: from [192.168.0.36] ([78.18.26.217]) by smtp.gmail.com with ESMTPSA id d5sm19571405wra.38.2021.09.28.02.17.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Sep 2021 02:17:54 -0700 (PDT) Message-ID: <94502d72-979f-c5fc-4445-a5a1c51eb6ba@redhat.com> Date: Tue, 28 Sep 2021 10:17:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 To: Xuan Ding , dev@dpdk.org, maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: jiayu.hu@intel.com, cheng1.jiang@intel.com, bruce.richardson@intel.com, sunil.pai.g@intel.com, yinan.wang@intel.com, YvonneX.Yang@intel.com References: <20210909055758.106588-1-xuan.ding@intel.com> <20210928062446.101264-1-xuan.ding@intel.com> <20210928062446.101264-3-xuan.ding@intel.com> From: Kevin Traynor In-Reply-To: <20210928062446.101264-3-xuan.ding@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v5 2/2] examples/vhost: use API to check inflight packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 28/09/2021 07:24, Xuan Ding wrote: > In async data path, call rte_vhost_async_get_inflight_thread_unsafe() > API to directly return the number of inflight packets instead of > maintaining a local variable. > > Signed-off-by: Xuan Ding > --- > examples/vhost/main.c | 25 +++++++++++-------------- > examples/vhost/main.h | 1 - > 2 files changed, 11 insertions(+), 15 deletions(-) > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index d0bf1f31e3..3faac6d053 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -842,11 +842,8 @@ complete_async_pkts(struct vhost_dev *vdev) > > complete_count = rte_vhost_poll_enqueue_completed(vdev->vid, > VIRTIO_RXQ, p_cpl, MAX_PKT_BURST); > - if (complete_count) { > + if (complete_count) > free_pkts(p_cpl, complete_count); > - __atomic_sub_fetch(&vdev->pkts_inflight, complete_count, __ATOMIC_SEQ_CST); > - } > - > } > > static __rte_always_inline void > @@ -886,7 +883,6 @@ drain_vhost(struct vhost_dev *vdev) > > complete_async_pkts(vdev); > ret = rte_vhost_submit_enqueue_burst(vdev->vid, VIRTIO_RXQ, m, nr_xmit); > - __atomic_add_fetch(&vdev->pkts_inflight, ret, __ATOMIC_SEQ_CST); > > enqueue_fail = nr_xmit - ret; > if (enqueue_fail) > @@ -1212,7 +1208,6 @@ drain_eth_rx(struct vhost_dev *vdev) > complete_async_pkts(vdev); > enqueue_count = rte_vhost_submit_enqueue_burst(vdev->vid, > VIRTIO_RXQ, pkts, rx_count); > - __atomic_add_fetch(&vdev->pkts_inflight, enqueue_count, __ATOMIC_SEQ_CST); > > enqueue_fail = rx_count - enqueue_count; > if (enqueue_fail) > @@ -1338,6 +1333,7 @@ destroy_device(int vid) > struct vhost_dev *vdev = NULL; > int lcore; > uint16_t i; > + int pkts_inflight; You can move this down to the block it is used in > > TAILQ_FOREACH(vdev, &vhost_dev_list, global_vdev_entry) { > if (vdev->vid == vid) > @@ -1384,13 +1380,13 @@ destroy_device(int vid) > > if (async_vhost_driver) { > uint16_t n_pkt = 0; > - struct rte_mbuf *m_cpl[vdev->pkts_inflight]; > + pkts_inflight = rte_vhost_async_get_inflight_thread_unsafe(vid, VIRTIO_RXQ); > + struct rte_mbuf *m_cpl[pkts_inflight]; > > - while (vdev->pkts_inflight) { > + while (pkts_inflight) { > n_pkt = rte_vhost_clear_queue_thread_unsafe(vid, VIRTIO_RXQ, > - m_cpl, vdev->pkts_inflight); > + m_cpl, pkts_inflight); > free_pkts(m_cpl, n_pkt); > - __atomic_sub_fetch(&vdev->pkts_inflight, n_pkt, __ATOMIC_SEQ_CST); This is an infinite loop if there are pkts_inflight, need to recheck pkts_inflight in the loop. > } > > rte_vhost_async_channel_unregister(vid, VIRTIO_RXQ); > @@ -1486,6 +1482,7 @@ static int > vring_state_changed(int vid, uint16_t queue_id, int enable) > { > struct vhost_dev *vdev = NULL; > + int pkts_inflight; > > TAILQ_FOREACH(vdev, &vhost_dev_list, global_vdev_entry) { > if (vdev->vid == vid) > @@ -1500,13 +1497,13 @@ vring_state_changed(int vid, uint16_t queue_id, int enable) > if (async_vhost_driver) { > if (!enable) { > uint16_t n_pkt = 0; > - struct rte_mbuf *m_cpl[vdev->pkts_inflight]; > + pkts_inflight = rte_vhost_async_get_inflight_thread_unsafe(vid, queue_id); > + struct rte_mbuf *m_cpl[pkts_inflight]; > > - while (vdev->pkts_inflight) { > + while (pkts_inflight) { > n_pkt = rte_vhost_clear_queue_thread_unsafe(vid, queue_id, > - m_cpl, vdev->pkts_inflight); > + m_cpl, pkts_inflight); > free_pkts(m_cpl, n_pkt); > - __atomic_sub_fetch(&vdev->pkts_inflight, n_pkt, __ATOMIC_SEQ_CST); Same comments as destroy_device > } > } > } > diff --git a/examples/vhost/main.h b/examples/vhost/main.h > index e7b1ac60a6..0ccdce4b4a 100644 > --- a/examples/vhost/main.h > +++ b/examples/vhost/main.h > @@ -51,7 +51,6 @@ struct vhost_dev { > uint64_t features; > size_t hdr_len; > uint16_t nr_vrings; > - uint16_t pkts_inflight; > struct rte_vhost_memory *mem; > struct device_statistics stats; > TAILQ_ENTRY(vhost_dev) global_vdev_entry; >