From patchwork Mon Sep 28 19:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313678 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3545074ilg; Mon, 28 Sep 2020 12:04:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJkatQC3nZOkQkbfuB0DaHceLAti9wukAQvbqSq4pzLMr0AwKZBytgNkIYE9eFiqEg1kcz X-Received: by 2002:a50:9dc8:: with SMTP id l8mr3467146edk.58.1601319852792; Mon, 28 Sep 2020 12:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319852; cv=none; d=google.com; s=arc-20160816; b=BTMZ8s9fu5pOxCzKFOv+iMk2ZuDsPyinEX+obv6xMdRuSjTvuyB8TGDlVrcpGekT+Q R09kXOXJqnBqj1JPsbddR+fgtZpc2VPFlpZw/ybHDd6kvY2XtySUVWil1HuBVyFdiri/ Kgb4OTAufNoriPdgB65Kn0wdqOxifnp4oI8efTejiqnCWprtaXJIAV5Ou79gxI7xL4Iw /NS1ySEHOzQmh8BLYaLUMqCmtzMS9HgL/KF2KpVGOTBNEo3HeCGyQnpKSeJD0VOc5eFS NYv5C2iO5drlYACSY23RhvHsmjTzAemi8THdSw19+3k2m2MZ410TL2J1luc6s2TKVp/v Rq9g== 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=vOeJz8MfK06tflfpTWoaYWZkMyJOfJOy8ZSdAi+HTM0=; b=yREN2/F5W3S9VYn5JuCdENrTkFw7PW/dIt4siyprXp5vENLCtsakgxh/hcpb+wq4Ri wis1RV3ImQf+En6oX+m7WwdyR/tqN337D1mijOHsPr7bQPcNxkNtCG8Gy6f5rxnYp1LF G5dp6PrmjQRbswcTI6XWmWbqOZq0FsNYuG+0iB8lMa7MtUdU9UA7n62jNLVt9aod67xW J6lk+g+DuMR3vRZUyx5XGK7WIK2a9ChN+MOKPkaVNsl1HLOb1l+GKI8j4PF5APKL/SdN thN5F9l1DH1ZrGxlMKSpFDNJyGjUGWxM87gFLg7TxCK3MH/Ga4DYUKPHZJRhuGmyyMfi Bzww== 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 qn11si1182800ejb.303.2020.09.28.12.04.12; Mon, 28 Sep 2020 12:04:12 -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 529AE1D614; Mon, 28 Sep 2020 21:04:05 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 978201D553; Mon, 28 Sep 2020 21:04:02 +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 F0E371063; Mon, 28 Sep 2020 12:04:00 -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 DBADB3F70D; Mon, 28 Sep 2020 12:04:00 -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, stable@dpdk.org Date: Mon, 28 Sep 2020 14:03:27 -0500 Message-Id: <20200928190334.40624-1-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921192254.20560-1-honnappa.nagarahalli@arm.com> References: <20200921192254.20560-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v2 1/8] net/memif: do not update local copy of tail in tx function 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" In the case of S2M queues, the receiver synchronizes with the sender (i.e. informs of the packets it has received) using ring->tail. Hence, the sender does not need to update last_tail. In the case of M2S queues, the receiver uses last_tail to keep track of the descriptors it has received. The sender is not required to update the last_tail. Updating the last_tail makes it a shared variable between the transmitter and receiver affecting the performance. Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD") Cc: jgrajcia@cisco.com Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Jakub Grajciar diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index a19c0f3e6..130099f2e 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -580,12 +580,10 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) ring_size = 1 << mq->log2_ring_size; mask = ring_size - 1; - n_free = __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE) - mq->last_tail; - mq->last_tail += n_free; - if (type == MEMIF_RING_S2M) { slot = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE); - n_free = ring_size - slot + mq->last_tail; + n_free = ring_size - slot + + __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE); } else { slot = __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE); n_free = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE) - slot; From patchwork Mon Sep 28 19:03:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313679 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3545401ilg; Mon, 28 Sep 2020 12:04:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKOPzMZIMEkl7qCLIIQz10WKIOBTLBN0PGNeiByLsUsuvK0Z9EnQRwFAXTdkgF7iXD44J9 X-Received: by 2002:a17:906:c309:: with SMTP id s9mr219877ejz.167.1601319877525; Mon, 28 Sep 2020 12:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319877; cv=none; d=google.com; s=arc-20160816; b=j7IZMwF1oNtJOhJRnnTWvPaMphis9RnAJRrhCmwykbtvoBNvLSmWr4coWbTlHBy0ff U6zbZXGITDy6hcGdVPuec1gS4F+KaiuFJeieGZB/cH4lNDolfgriRVDNsEkSmCI+RBIn i3PbdVucoa/PGcwnKmnAVZilVTdMqDDwGHcZp/XxsvtjIv7Ti4GU7PZXAzKX5uRYhpph yFZ2K6lWaaAHxLpnSasjKJSttFd+NS69vQERCFzyRf1Uzs+Xs4B8vFfyaU69ulTLMdQV 08LOro84bc0knE+BKi/Mwy8/BHBQ8BQWYKe7HlgknMrslUltdXrAITLboL7tApBw8uYI d+5w== 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=klz5Tr4Y+lTVKXVxaokPVFGxjaVucOvYhhlWDXoJaGQ=; b=GDiEFvXPiqdv7GFHpB/JdGUT3sNQnMNR4u8sXp+Jb4/57umzpPIJFXOnEaESRRaeUz 3GTVBj7Q6fZZbXE40HV9GwQwv38mufLKPygd7bMNejOeNNYB+i7UpyHQ97Sc+yoSkpGl latatevWW7RI7HZDbYdmB+u2B1UhL1bNaElz5WP2AF4kC92uPUWh9c7OB1Y93wvMGO7o Q0+eaG1uXfIX7MF7Sm+nTt0Y7qvDfQ5I2YYBHB7c3DlyWhZuiOTYhnK6cOtNRGEvCVWo I7SohiRSYbaAF1FXWj1M3w8tP6ibym81M1egA83m5rOocudgZfY95rX/CxTlY4KjqNSa TyVg== 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 da1si1250614edb.102.2020.09.28.12.04.37; Mon, 28 Sep 2020 12:04:37 -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 80FFD1D69D; Mon, 28 Sep 2020 21:04:10 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id EBA1A1D66B; Mon, 28 Sep 2020 21:04:06 +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 45D51113E; Mon, 28 Sep 2020 12:04:05 -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 355963F70D; Mon, 28 Sep 2020 12:04:05 -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, stable@dpdk.org Date: Mon, 28 Sep 2020 14:03:28 -0500 Message-Id: <20200928190334.40624-2-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 2/8] net/memif: relax the load of ring tail pointer for M2S ring 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" For M2S rings, ring->tail is updated by the sender and eth_memif_tx function is called in the context of sending thread. The loads in the sender do not need to synchronize with its own stores. Fixes: a2aafb9aa651 ("net/memif: optimize with one-way barrier") Cc: phil.yang@arm.com Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 130099f2e..8bacacaa8 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -585,7 +585,13 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) n_free = ring_size - slot + __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE); } else { - slot = __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE); + /* For M2S queues ring->tail is updated by the sender and + * this function is called in the context of sending thread. + * The loads in the sender do not need to synchronize with + * its own stores. Hence, the following load can be a + * relaxed load. + */ + slot = __atomic_load_n(&ring->tail, __ATOMIC_RELAXED); n_free = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE) - slot; } From patchwork Mon Sep 28 19:03:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313680 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3545620ilg; Mon, 28 Sep 2020 12:04:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK+IHQKPtN4JCDYt/KWkcjirUVCjpNPIvYoQinZrY2lG9myDrbOw8QYFTloI79aahEeb6M X-Received: by 2002:a17:906:4993:: with SMTP id p19mr209903eju.277.1601319897860; Mon, 28 Sep 2020 12:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319897; cv=none; d=google.com; s=arc-20160816; b=w7nME/AILzIs4rqAzSLNJK7n3ReYvQMq8XN71NI0JA7QSJ4feej+cKlYxtOsS7CWAi NIjFKod59QXFYijtKJ4p2OSFG4NcGEfSbpiQwm4HDyQWquEhEYNZSOf8YHAL5Jes2cXX bBK7fLjtTqDwmCL9WRQ6u2olMJIK2qWttoE5xFZnJTKAsfgq9Y5FtP5EH/Y0EbFdRgD0 2OO7DoYON+cothyPrV2w8X7XpJLj5m69Rm7Kl+XDxXyihsy0YVwn3K4qot4UL5KGhWip VUoUHJWhJfcDNh86zhKL9PWjb+PmzqT2b5O6wK2dgFuYJ6X6kMbSoVGl9OTzcnmcEpRP PcFQ== 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=cMFap+loTMjX/P88jnpnAuiWZ2BJzXw2iWl3rYzclbE=; b=RMlKlBF3PG5advJtq278gNiq1q3L2B61w/2dCaihEy54hnwGEHd7Iv5R021SaauyF6 w3ecJ3wLc9Awxk2t7JfGk0utlSJUQ83xFAlYh+L0ZpoJ6McQTVlmcFeO7Ncu3NavZZU1 CWoKkqSZtJRo1ZLqCjuovNx6D2oIiAxQAlIRbWg6WN03zA3eSRaTvmJz2n+KDAeYzeP0 TVJ2pdZahVv91isoxs9VSSzKqYrPhZUPerLSW+B97ubrai5v3h74ThBaLimi1g0SYEqp Jx2ZEAf5akPPlfpMFWcq9ZSC/NqL8c2FxO+D2dF7DUhdvCQ1BmOUnfcqT9tzjeRxrJSW hHuw== 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 p7si1253971edq.28.2020.09.28.12.04.57; Mon, 28 Sep 2020 12:04:57 -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 63DED1D6B7; Mon, 28 Sep 2020 21:04:12 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id CB3811D681; Mon, 28 Sep 2020 21:04:07 +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 079541477; Mon, 28 Sep 2020 12:04:06 -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 DCDAE3F70D; Mon, 28 Sep 2020 12:04:05 -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, stable@dpdk.org Date: Mon, 28 Sep 2020 14:03:29 -0500 Message-Id: <20200928190334.40624-3-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 3/8] net/memif: relax the load of ring head pointer for M2S ring 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" For M2S rings, ring->head is updated by the receiver and eth_memif_rx function is called in the context of receiving thread. The loads in the receiver do not need to synchronize with its own stores. Fixes: a2aafb9aa651 ("net/memif: optimize with one-way barrier") Cc: phil.yang@arm.com Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 8bacacaa8..159b45180 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -410,7 +410,11 @@ eth_memif_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) refill: if (type == MEMIF_RING_M2S) { - head = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE); + /* ring->head is updated by the receiver and this function + * is called in the context of receiver thread. The loads in + * the receiver do not need to synchronize with its own stores. + */ + head = __atomic_load_n(&ring->head, __ATOMIC_RELAXED); n_slots = ring_size - head + mq->last_tail; while (n_slots--) { From patchwork Mon Sep 28 19:03:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313681 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3545910ilg; Mon, 28 Sep 2020 12:05:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpqs8wZCiN+ADyQS7JqmpoLfYVaZzIO2Fbbk0cP/QIQHdzmk7eENQqF3y+h0lzEuXtTKcS X-Received: by 2002:a17:906:e103:: with SMTP id gj3mr210883ejb.153.1601319917265; Mon, 28 Sep 2020 12:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319917; cv=none; d=google.com; s=arc-20160816; b=S4fbydzNZ4T/9MTCn5AD3g+DuTGi+D2sn8Mgk5teZ9C4lU+8TdTl1FTRH98u+9Ax/6 /kNBhWu4kV5xCvWQOCX1pAl6OMFZiFH9DArKNpENhJhskT95mldVQhGj+5Q46gMY9D45 geCxlWvrFw8WTbjmI3DjOKAXTzczTiBqZgfE1NTLRB10S687TBtICSk8JTDu3eykZOH8 jf7FmAtzhxj+Jgalt/AbrT7X3WIx+iupaV7aoXEjOx3rVDuZdZ3fz5jgO2zR4bMLLQMN LTGnTM5ZOnyDkyCrHeXlWFm+ZnE1+riYGiFyDf1F7LnAYMDRjbFSIcoQw2fRnMGDsue+ r2Eg== 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=Mz8eWWz+xpBFsQgArznYQwH3zLyx/HWjC9dukxdjtPc=; b=mEyPhc6IC/llJZsMlNMUMFlkKFISQb9gY1JrWRQJOMlfgss5wZdYu7ZARUd06L2u62 JfPrIIV91jDp2JqIm+E0bMDOJ+mruFxyGlPoP06QgkPh2svwIBS5smOewHpm5AtOZP0c aLjHwzLIIt4TU4XFHOc9W5rfa+G2VCLV+nQ0cxiO6UweXjammyVby+i+ml/bM8itlFae qxJ27ZwA0aHndsoOTSAqh0VbS3yQzKKLslAbwmLzJf0I7B+mjjGN3Ek0wvGAk/2XivE/ NvT+ZN42IMbMUhe8JdcLvbx+zfZGL1rjOzTKEerwBVDjH5h5/JJuzk4lFv5fVvM+3W4Y nPXA== 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 l10si1135861edr.220.2020.09.28.12.05.17; Mon, 28 Sep 2020 12:05:17 -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 08D481D6BE; Mon, 28 Sep 2020 21:04:14 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id F2EEA1D5D8; Mon, 28 Sep 2020 21:04:07 +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 6E53214BF; Mon, 28 Sep 2020 12:04:06 -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 5D7F13F70D; Mon, 28 Sep 2020 12:04:06 -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, stable@dpdk.org Date: Mon, 28 Sep 2020 14:03:30 -0500 Message-Id: <20200928190334.40624-4-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 4/8] net/memif: relax the load of ring head pointer for S2M ring 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" For S2M rings, ring->head is updated by the sender and eth_memif_tx function is called in the context of sending thread. The loads in the sender do not need to synchronize with its own stores. Fixes: a2aafb9aa651 ("net/memif: optimize with one-way barrier") Cc: phil.yang@arm.com Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 159b45180..96db76121 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -585,7 +585,13 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mask = ring_size - 1; if (type == MEMIF_RING_S2M) { - slot = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE); + /* For S2M queues ring->head is updated by the sender and + * this function is called in the context of sending thread. + * The loads in the sender do not need to synchronize with + * its own stores. Hence, the following load can be a + * relaxed load. + */ + slot = __atomic_load_n(&ring->head, __ATOMIC_RELAXED); n_free = ring_size - slot + __atomic_load_n(&ring->tail, __ATOMIC_ACQUIRE); } else { From patchwork Mon Sep 28 19:03:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313683 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3546304ilg; Mon, 28 Sep 2020 12:05:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkEKo4vrLPmc51ua5L/z8xY7H6yudIb5qMAtNJ74jdbIpygMhhW8LQT9lIJhMeOUwyW3hg X-Received: by 2002:a17:906:95cd:: with SMTP id n13mr199990ejy.297.1601319950102; Mon, 28 Sep 2020 12:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319950; cv=none; d=google.com; s=arc-20160816; b=tMxDqpgNuORgIupTLxifdWDVwCjDV73aWoJ1vxf78P0UlkrVmJIDwFoLv613/7uHJ7 3Jw4tVaEx/kZH+w5uRLi2e/GrkZa1xEiJk0ZI3/E9dwQUPA8Kp/RXU/OJr22T9X1hEtp ZkfjquMQ0tMho84m0j39tSmqG/0idJ0d7nRYZMJUm9ggHzOLBaOILHT276j8KgP+/J5a ap+eu8ppzjcZVgBfaj6zYNEKJc1iAAiLM5/iReFrkTmjYHHVKf4bUQCo9mZ35Q5d0mZ1 MX3o+WD16PR7k+Syh8337LvvM3JPGqUl/skeOBtYC8idm6uahYpZQFzvWUi7EOS6qESK qZmQ== 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=YogujJsej78DpRuEJcZp9SZF/RTDOyET7qHo0Ua0RLs=; b=S0nscV9KrXI659K5BVvDVTUJQtK8qyGEwvh+4EKgqVVQdqyMurAbdQxdDi4/OOfAOk xuSD7R6iS/ROawTQ8YnkEVzWCIFytmIjRQtTAquZKbs206Q53dhZqz1YTlkl3NFBTiI8 jPKgfkSrF1HXDGyQPwCP0p3+ybWQVsEJ49gRudQUvlkoP2dQJYTdbHDhXpw0OnbRVTJ2 zsSLLMOTg0dc1EGTjV0XDe48V0P7rsleF6q9FCvJRwr5Rrzq4VJ62997MSuWI3YqQFog /JHRFJCPyp6Bl1Ktdsqs1IdXM2s9nkYBJbuNZpynygg68/PcIitFpWdN7DyfadGeBtQX 2WvA== 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 c3si1133521ejk.666.2020.09.28.12.05.49; Mon, 28 Sep 2020 12:05:50 -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 1F03F1D6D0; Mon, 28 Sep 2020 21:04:17 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 870CC1D681 for ; Mon, 28 Sep 2020 21:04:09 +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 CE03D14F6; Mon, 28 Sep 2020 12:04:06 -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 BE40F3F70D; Mon, 28 Sep 2020 12:04:06 -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:31 -0500 Message-Id: <20200928190334.40624-5-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 5/8] net/memif: relax the load of ring head pointer for M2S zc ring 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" For zero-copy M2S rings, ring->head is updated by the receiver and eth_memif_rx_zc function is called in the context of receiving thread. The loads in the receiver do not need to synchronize with its own stores. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 96db76121..404c86ae8 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -514,11 +514,11 @@ eth_memif_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) /* Supply master with new buffers */ refill: - /* The ring->head acts as a guard variable between Tx and Rx - * threads, so using load-acquire pairs with store-release - * to synchronize it between threads. + /* ring->head is updated by the receiver and this function + * is called in the context of receiver thread. The loads in + * the receiver do not need to synchronize with its own stores. */ - head = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE); + head = __atomic_load_n(&ring->head, __ATOMIC_RELAXED); n_slots = ring_size - head + mq->last_tail; if (n_slots < 32) @@ -543,6 +543,10 @@ eth_memif_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) (uint8_t *)proc_private->regions[d0->region]->addr; } no_free_mbufs: + /* The ring->head acts as a guard variable between Tx and Rx + * threads, so using store-release pairs with load-acquire + * in function eth_memif_tx. + */ __atomic_store_n(&ring->head, head, __ATOMIC_RELEASE); mq->n_pkts += n_rx_pkts; From patchwork Mon Sep 28 19:03:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313682 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3546100ilg; Mon, 28 Sep 2020 12:05:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAP2qu0oyntT9HCJ2zqdUxjxegkYDkrcrx4bpHbrbnLpmlBqzEWvC4Or2/9QinyVbr1z0j X-Received: by 2002:a17:906:c1d7:: with SMTP id bw23mr222292ejb.171.1601319933566; Mon, 28 Sep 2020 12:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319933; cv=none; d=google.com; s=arc-20160816; b=AeNhf9PtQxQa1BPY4b8S/SF3loiYyZalTUt6AGgtbDu8x+R89/oydvwW4M9y0fm9e7 I2vDmSwetqUgqqGc5/1PH8Ef7JwqwlNw0E29D3szRr/ppvo7U6M7eTi2qvAZkyKtNNvu eKCtXmkdpYox6SCZuvHfKn+jwltZiDFo7E/OLL+XYxQ04HfIW6nbgiPCIG9nprjT9EGM hjWn2cNYs87NDDcdV9caK1BXt82jadihR4hla5N/0MDdznM/pHjVZPxALslko+yx5iMc gSjilh9SsvGzsJ8UQ8N5pukEGC4LgUjlC9/s/MmZ9HVS6Lm4TO093B3rlvbbb9EZ2pQD 2pUQ== 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=GU9dARXNt9sMTonaO/Rw04cQ7AOmn/Pox4JW04ehysU=; b=mHlFqvBNd7NXNhiwfqtVfrwfDZW/D2tRZQbC0f0q7jy7DSR+f0F9ueDut2X4OwD4Zq n1k+9NdekL0Z5geZqcRyzftvfV6GBqyszgoVjMN4t2nvulUIaa7daJMOb1Nsbi3HAdVU NjLNS231VZxtDRJKQsUkutjRiPOu/u8ZBWzjXg89XbhIf4R0tgjFHEAt3/u4bJoFt6VV vaLZh5zbEkW6aiw4KWve9ZIUjEks6LwcRoZ70M5nBCQgjvkPskzAF3oUuIoa2hOaAmqN IflagnyTkPQzZVspHOT/+MitAXdUYDKY/V1wEZu+WxZglRHgKak306tx4gQ4EtLL+2bf rjdQ== 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 o21si1118714ejg.255.2020.09.28.12.05.33; Mon, 28 Sep 2020 12:05:33 -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 9CF711D6C8; Mon, 28 Sep 2020 21:04:15 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 014431D68D for ; Mon, 28 Sep 2020 21:04:08 +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 52EA81063; Mon, 28 Sep 2020 12:04:07 -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 41AC43F70D; Mon, 28 Sep 2020 12:04:07 -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:32 -0500 Message-Id: <20200928190334.40624-6-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 6/8] net/memif: remove extra check 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" eth_memif_tx_zc function is called only for S2M rings. Remove additional code for M2S rings in this function. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 404c86ae8..9babd073a 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -735,7 +735,6 @@ eth_memif_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) rte_eth_devices[mq->in_port].process_private; memif_ring_t *ring = memif_get_ring_from_queue(proc_private, mq); uint16_t slot, n_free, ring_size, mask, n_tx_pkts = 0; - memif_ring_type_t type = mq->type; struct rte_eth_link link; if (unlikely((pmd->flags & ETH_MEMIF_FLAG_CONNECTED) == 0)) @@ -812,11 +811,8 @@ eth_memif_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } no_free_slots: - /* update ring pointers */ - if (type == MEMIF_RING_S2M) - __atomic_store_n(&ring->head, slot, __ATOMIC_RELEASE); - else - __atomic_store_n(&ring->tail, slot, __ATOMIC_RELEASE); + /* ring type always MEMIF_RING_S2M */ + __atomic_store_n(&ring->head, slot, __ATOMIC_RELEASE); /* Send interrupt, if enabled. */ if ((ring->flags & MEMIF_RING_FLAG_MASK_INT) == 0) { From patchwork Mon Sep 28 19:03:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 313684 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp3546572ilg; Mon, 28 Sep 2020 12:06:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXAKqtKOjppkNsC++ehsph6uvitF0oj4hBkhKy68mva26TuRC7Xjiq/wtxkhmQarW1Er1c X-Received: by 2002:a17:906:8508:: with SMTP id i8mr252528ejx.390.1601319970055; Mon, 28 Sep 2020 12:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601319970; cv=none; d=google.com; s=arc-20160816; b=pQgvjcpcgc9P9Uvk25tOZuHBW478sbfy2nhgjw3ZEHRm9YI7l+WmnbCi0h/lINaBzA ROegwXJiNCIGb+SN18NAG+5Si0H5QaWIOvo2ih5i+/tewtN66QFhsFxF7FNTv8GodtMS /5EHtJTHy6TYsNFBOtatKdRXTzfkDbxMEz1rGJGRA0VarWyYjZLkCqU1Cmpbq08/Hqy9 qbu59BMEPpsjiVng6XNbaVTIkh/8fTVn8+d3wgxYYrkd/4gF8wAJCmpJ53x47M42TQos EEV1PHDXNGtmSuzbAftZTtfG9CmG9341j36CkCvLzw3/qn6zp2uZqcpASIqFdvTMwxKz weTg== 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=B5eSf1+B5bz81Do4s2efPEUVD7dIGpfeh+AIqK3r4eo=; b=I8A3dkm1QwG4zzLfoVLC3FLA4Li5Ke8Wh3X5iIC7ATtJByT8be3mMNYH7hKqdbx37W AQ1CmDLjBC+HGImxkqHwcoC/0Z4kZ/p/RcqhICDAQwHT2/4YDUcBiioJgNYnmgPD5unu AOzbIEQN5L6N2QrZ4ME1k5FTiZl5Otp8r0zfzgqlK/Arg3zg32MUwkhUtWu6rCjGuxB3 AIRRcWHMQJtwzS9IAT4wOncHpKEdDi7IRDvNZtCsr6f4j9uY8/mnhgDYI0lC1Q0bbX00 RI5I9qPymxt6Bjda4VELiviPIubDGoTL9yYWR2qM18BImsrddMr3wa5VBDcnFITvNruh Y35Q== 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 c17si1240539ejx.205.2020.09.28.12.06.09; Mon, 28 Sep 2020 12:06:10 -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 973521D6DF; Mon, 28 Sep 2020 21:04:18 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id AC2931D5D8 for ; Mon, 28 Sep 2020 21:04:08 +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 E67371500; Mon, 28 Sep 2020 12:04:07 -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 D68493F70D; Mon, 28 Sep 2020 12:04:07 -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:33 -0500 Message-Id: <20200928190334.40624-7-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 7/8] net/memif: relax the load of ring head pointer for S2M zc ring 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" For zero-copy S2M rings, ring->head is updated by the sender and eth_memif_tx_zc function is called in the context of sending thread. The loads in the sender do not need to synchronize with its own stores. Signed-off-by: Honnappa Nagarahalli Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang --- drivers/net/memif/rte_eth_memif.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index 9babd073a..704350022 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -752,11 +752,13 @@ eth_memif_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) memif_free_stored_mbufs(proc_private, mq); /* ring type always MEMIF_RING_S2M */ - /* The ring->head acts as a guard variable between Tx and Rx - * threads, so using load-acquire pairs with store-release - * to synchronize it between threads. + /* For S2M queues ring->head is updated by the sender and + * this function is called in the context of sending thread. + * The loads in the sender do not need to synchronize with + * its own stores. Hence, the following load can be a + * relaxed load. */ - slot = __atomic_load_n(&ring->head, __ATOMIC_ACQUIRE); + slot = __atomic_load_n(&ring->head, __ATOMIC_RELAXED); n_free = ring_size - slot + mq->last_tail; int used_slots; @@ -812,6 +814,10 @@ eth_memif_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) no_free_slots: /* ring type always MEMIF_RING_S2M */ + /* The ring->head acts as a guard variable between Tx and Rx + * threads, so using store-release pairs with load-acquire + * in function eth_memif_rx for S2M rings. + */ __atomic_store_n(&ring->head, slot, __ATOMIC_RELEASE); /* Send interrupt, if enabled. */ 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);