From patchwork Mon Sep 28 19:03:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313685 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3546825ilg; Mon, 28 Sep 2020 12:06:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB+qNemdPvFmG4bxgQIyVuBuCAhn8Pb/G889R0AepSrVAZ0b4KIeEiCGezLlTDkEmCWD2w X-Received: by 2002:a17:906:850:: with SMTP id f16mr193624ejd.447.1601319988900; Mon, 28 Sep 2020 12:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319988; cv=none; d=google.com; s=arc-20160816; b=cmHWJVkeiWToi22Cf+6gPldMoMd+2YoO3cSf6GylMWLdRfs+zxaRCvN7fUyR1WkCnI EF7mRdmUdyJxDpWmiMSJAfa5ycH6Y/FwshVo9mSC5F1b7+qf0wQ8bJtLdWE4GCFRt40N RiOv4YBInVovibmwN5xKenThDAgiaielSE62P+QqfEuhIwU4L16YxYLYE1vk6mUmMgMH eANKP0kWZiBwzVcfDgBnuTjYh3Z9hDs82W1+4k2UXBeWmI+JP3ZHjgMOgDE9Ey2v8PU6 E99nq1WbbVQzzyL6tPKeSZ0cnxSj4i8MYV2Lx1hrKLik9Ipdte7CjDIW7QdqTNa4A3H4 szeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=wtPJsTEUS8TV2vJnUGxVFC7gXL6BkN4gaYGCRSPSglk=; b=bg1dOgDlxqet3p3SHwseg1SblhAfBxGDSqaZwz9pT6ppD+BZ8myxk4QDMjN5nX1hpO yDOy9IfAvY2E1qqpu5qUJLjxxfprOw1sQeFrAq2m0ztxj0R+EfVnzpkllaVGJkth1+gM ZTF0Mh1fyp95wstQHNowmCEU7RhZ+rY+c9P+efZuj5hafvPRki1IfB38pQdjTJZRw8IN h63KOV0+v8GcWfAA16svadwK37ztu4Ymn6NE0TUlYklUPnRaJ0/+uK912TmlRcU5Luuu KVqhzjBjJoIl70jKzoqSXKL9zjC0W5NeSEfgYCF3a5grBlYMbu9eKKSsS1R4ECIERCxF Hcgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id d22si1299870edx.11.2020.09.28.12.06.28; Mon, 28 Sep 2020 12:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D8741D66B; Mon, 28 Sep 2020 21:04:20 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 072D31D5D8 for ; Mon, 28 Sep 2020 21:04:10 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 770E5113E; Mon, 28 Sep 2020 12:04:08 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 670073F70D; Mon, 28 Sep 2020 12:04:08 -0700 (PDT) From: Honnappa Nagarahalli To: dev@dpdk.org, honnappa.nagarahalli@arm.com, phil.yang@arm.com, jgrajcia@cisco.com, ferruh.yigit@intel.com Cc: nd@arm.com Date: Mon, 28 Sep 2020 14:03:34 -0500 Message-Id: <20200928190334.40624-8-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928190334.40624-1-honnappa.nagarahalli@arm.com> References: <20200921192254.20560-1-honnappa.nagarahalli@arm.com> <20200928190334.40624-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v2 8/8] net/memif: move the barrier outside the loop 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" load-acquire memory order has a barrier. Loading it inside the loop will result in a barrier in every iteration. Hence, load the variable once outside the loop. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 704350022..c73cde8fd 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -249,16 +249,17 @@ memif_get_buffer(struct pmd_process_private *proc_private, memif_desc_t *d) static void memif_free_stored_mbufs(struct pmd_process_private *proc_private, struct memif_queue *mq) { + uint16_t cur_tail; uint16_t mask = (1 << mq->log2_ring_size) - 1; memif_ring_t *ring = memif_get_ring_from_queue(proc_private, mq); /* FIXME: improve performance */ /* The ring->tail acts as a guard variable between Tx and Rx * threads, so using load-acquire pairs with store-release - * to synchronize it between threads. + * in function eth_memif_rx for S2M queues. */ - while (mq->last_tail != __atomic_load_n(&ring->tail, - __ATOMIC_ACQUIRE)) { + cur_tail = __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE); + while (mq->last_tail != cur_tail) { RTE_MBUF_PREFETCH_TO_FREE(mq->buffers[(mq->last_tail + 1) & mask]); /* Decrement refcnt and free mbuf. (current segment) */ rte_mbuf_refcnt_update(mq->buffers[mq->last_tail & mask], -1);