* [dpdk-stable] [RFC PATCH v1 4/5] lib/bpf: use wait until scheme for Rx/Tx iteration [not found] <20210902053253.3017858-1-feifei.wang2@arm.com> @ 2021-09-02 5:32 ` Feifei Wang [not found] ` <20210923095902.301762-1-feifei.wang2@arm.com> 1 sibling, 0 replies; 4+ messages in thread From: Feifei Wang @ 2021-09-02 5:32 UTC (permalink / raw) To: Konstantin Ananyev, Ferruh Yigit Cc: dev, nd, Feifei Wang, stable, Ruifeng Wang 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_until_unequal api. Fixes: a93ff62a8938 ("bpf: introduce basic Rx/Tx filters") Cc: konstantin.ananyev@intel.com Cc: stable@dpdk.org Signed-off-by: Feifei Wang <feifei.wang2@arm.com> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> --- 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..ed63e00219 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_until_unequal_32(&cbi->use, puse, __ATOMIC_RELAXED); } } -- 2.25.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20210923095902.301762-1-feifei.wang2@arm.com>]
* [dpdk-stable] [RFC PATCH v2 4/5] lib/bpf: use wait event scheme for Rx/Tx iteration [not found] ` <20210923095902.301762-1-feifei.wang2@arm.com> @ 2021-09-23 9:59 ` Feifei Wang 2021-09-24 18:07 ` Ananyev, Konstantin 0 siblings, 1 reply; 4+ messages in thread From: Feifei Wang @ 2021-09-23 9:59 UTC (permalink / raw) To: Konstantin Ananyev, Ferruh Yigit Cc: dev, nd, Feifei Wang, stable, Ruifeng Wang 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 <feifei.wang2@arm.com> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> --- 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); } } -- 2.25.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-stable] [RFC PATCH v2 4/5] lib/bpf: use wait event scheme for Rx/Tx iteration 2021-09-23 9:59 ` [dpdk-stable] [RFC PATCH v2 4/5] lib/bpf: use wait event " Feifei Wang @ 2021-09-24 18:07 ` Ananyev, Konstantin 2021-09-26 2:19 ` [dpdk-stable] 回复: " Feifei Wang 0 siblings, 1 reply; 4+ messages in thread From: Ananyev, Konstantin @ 2021-09-24 18:07 UTC (permalink / raw) To: Feifei Wang, Yigit, Ferruh; +Cc: dev, nd, stable, Ruifeng Wang > > First, fix the bug that keyword const of func arg should be after "*". I believe there is no bug here. > This is because const before "*" means the value of "cbi" should not be > changed. Exactly, it says that the function itself will not change the value of "cbi". It just waits for the value to be changed by someone else. So please keep parameter list intact. > 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 <feifei.wang2@arm.com> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> > --- > 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); > } > } > > -- > 2.25.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-stable] 回复: [RFC PATCH v2 4/5] lib/bpf: use wait event scheme for Rx/Tx iteration 2021-09-24 18:07 ` Ananyev, Konstantin @ 2021-09-26 2:19 ` Feifei Wang 0 siblings, 0 replies; 4+ messages in thread From: Feifei Wang @ 2021-09-26 2:19 UTC (permalink / raw) To: Ananyev, Konstantin, Yigit, Ferruh; +Cc: dev, nd, stable, Ruifeng Wang, nd > -----邮件原件----- > 发件人: Ananyev, Konstantin <konstantin.ananyev@intel.com> > 发送时间: Saturday, September 25, 2021 2:08 AM > 收件人: Feifei Wang <Feifei.Wang2@arm.com>; Yigit, Ferruh > <ferruh.yigit@intel.com> > 抄送: dev@dpdk.org; nd <nd@arm.com>; stable@dpdk.org; Ruifeng Wang > <Ruifeng.Wang@arm.com> > 主题: RE: [RFC PATCH v2 4/5] lib/bpf: use wait event scheme for Rx/Tx > iteration > > > > > > First, fix the bug that keyword const of func arg should be after "*". > > I believe there is no bug here. > > > This is because const before "*" means the value of "cbi" should not > > be changed. > > Exactly, it says that the function itself will not change the value of "cbi". > It just waits for the value to be changed by someone else. > So please keep parameter list intact. Thanks for your explanation. The reason I changed is that I ever used rte_wait_until_xx(validate *addr) API here, And there is conflict between "const" and "validate", complier will report warning here. But now I think since I keep it as it is, there will be no warning due to new macro has no "validate". I will delete this unnecessary bug fix. > > > 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 <feifei.wang2@arm.com> > > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> > > --- > > 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); > > } > > } > > > > -- > > 2.25.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-26 2:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20210902053253.3017858-1-feifei.wang2@arm.com> 2021-09-02 5:32 ` [dpdk-stable] [RFC PATCH v1 4/5] lib/bpf: use wait until scheme for Rx/Tx iteration Feifei Wang [not found] ` <20210923095902.301762-1-feifei.wang2@arm.com> 2021-09-23 9:59 ` [dpdk-stable] [RFC PATCH v2 4/5] lib/bpf: use wait event " Feifei Wang 2021-09-24 18:07 ` Ananyev, Konstantin 2021-09-26 2:19 ` [dpdk-stable] 回复: " Feifei Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).