From patchwork Thu Sep 23 09:59:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feifei Wang X-Patchwork-Id: 99479 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D64FFA0C43; Thu, 23 Sep 2021 11:59:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D673441279; Thu, 23 Sep 2021 11:59:25 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 8ED4441250; Thu, 23 Sep 2021 11:59:20 +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 10BDA106F; Thu, 23 Sep 2021 02:59:20 -0700 (PDT) Received: from net-x86-dell-8268.shanghai.arm.com (net-x86-dell-8268.shanghai.arm.com [10.169.210.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B37103F59C; Thu, 23 Sep 2021 02:59:17 -0700 (PDT) From: Feifei Wang To: Konstantin Ananyev , Ferruh Yigit Cc: dev@dpdk.org, nd@arm.com, Feifei Wang , stable@dpdk.org, Ruifeng Wang Date: Thu, 23 Sep 2021 17:59:01 +0800 Message-Id: <20210923095902.301762-5-feifei.wang2@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210923095902.301762-1-feifei.wang2@arm.com> References: <20210902053253.3017858-1-feifei.wang2@arm.com> <20210923095902.301762-1-feifei.wang2@arm.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH v2 4/5] lib/bpf: use wait event scheme for Rx/Tx iteration 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" First, fix the bug that keyword const of func arg should be after "*". This is because const before "*" means the value of "cbi" should not be changed. But we should monitor that cbi->use changed and then we can jump out of loop. Second, instead of polling for cbi->use to be updated, use wait event scheme. Fixes: a93ff62a8938 ("bpf: introduce basic Rx/Tx filters") Cc: konstantin.ananyev@intel.com Cc: stable@dpdk.org Signed-off-by: Feifei Wang Reviewed-by: Ruifeng Wang --- lib/bpf/bpf_pkt.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/bpf/bpf_pkt.c b/lib/bpf/bpf_pkt.c index 6e8248f0d6..08ed8ff68c 100644 --- a/lib/bpf/bpf_pkt.c +++ b/lib/bpf/bpf_pkt.c @@ -111,9 +111,9 @@ bpf_eth_cbi_unuse(struct bpf_eth_cbi *cbi) * Waits till datapath finished using given callback. */ static void -bpf_eth_cbi_wait(const struct bpf_eth_cbi *cbi) +bpf_eth_cbi_wait(struct bpf_eth_cbi *const cbi) { - uint32_t nuse, puse; + uint32_t puse; /* make sure all previous loads and stores are completed */ rte_smp_mb(); @@ -122,11 +122,8 @@ bpf_eth_cbi_wait(const struct bpf_eth_cbi *cbi) /* in use, busy wait till current RX/TX iteration is finished */ if ((puse & BPF_ETH_CBI_INUSE) != 0) { - do { - rte_pause(); - rte_compiler_barrier(); - nuse = cbi->use; - } while (nuse == puse); + rte_compiler_barrier(); + rte_wait_event_32(&cbi->use, UINT_MAX, puse, ==, __ATOMIC_RELAXED); } }