From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Morten Brørup" <mb@smartsharesystems.com>,
"olivier.matz@6wind.com" <olivier.matz@6wind.com>,
"Honnappa.Nagarahalli@arm.com" <Honnappa.Nagarahalli@arm.com>,
"nd@arm.com" <nd@arm.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 2/2] ring: empty optimization
Date: Fri, 22 May 2020 12:32:14 +0000 [thread overview]
Message-ID: <BYAPR11MB33016E51083080F3F30C04A69AB40@BYAPR11MB3301.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200519152725.63486-3-mb@smartsharesystems.com>
>
> Testing if the ring is empty is as simple as comparing the producer and
> consumer pointers.
>
> In theory, this optimization reduces the number of potential cache misses
> from 3 to 2 by not having to read r->mask in rte_ring_count().
>
> The modification of this function were also discussed in the RFC here:
> https://mails.dpdk.org/archives/dev/2020-April/165752.html
>
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
> lib/librte_ring/rte_ring.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> index 9078e7c24..f67141482 100644
> --- a/lib/librte_ring/rte_ring.h
> +++ b/lib/librte_ring/rte_ring.h
> @@ -733,7 +733,9 @@ rte_ring_full(const struct rte_ring *r)
> static inline int
> rte_ring_empty(const struct rte_ring *r)
> {
> - return rte_ring_count(r) == 0;
> + uint32_t prod_tail = r->prod.tail;
> + uint32_t cons_tail = r->cons.tail;
> + return cons_tail == prod_tail;
> }
>
> /**
> --
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 2.17.1
next prev parent reply other threads:[~2020-05-22 12:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-13 15:31 [dpdk-dev] [PATCH] ring: empty and count optimizations Morten Brørup
2020-05-13 15:35 ` Morten Brørup
2020-05-13 17:08 ` Morten Brørup
2020-05-14 12:23 ` Ananyev, Konstantin
2020-05-14 13:45 ` Morten Brørup
2020-05-14 16:46 ` Ananyev, Konstantin
2020-05-14 18:00 ` Morten Brørup
2020-05-19 15:27 ` [dpdk-dev] [PATCH 0/2] ring: empty optimization Morten Brørup
2020-05-19 15:27 ` [dpdk-dev] [PATCH 1/2] ring: coding style cleanup Morten Brørup
2020-05-22 12:34 ` Ananyev, Konstantin
2020-05-19 15:27 ` [dpdk-dev] [PATCH 2/2] ring: empty optimization Morten Brørup
2020-05-19 15:52 ` Stephen Hemminger
2020-05-19 16:02 ` Morten Brørup
2020-07-01 9:19 ` David Marchand
2020-05-22 12:32 ` Ananyev, Konstantin [this message]
2020-07-01 9:20 ` [dpdk-dev] [PATCH 0/2] " David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BYAPR11MB33016E51083080F3F30C04A69AB40@BYAPR11MB3301.namprd11.prod.outlook.com \
--to=konstantin.ananyev@intel.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=nd@arm.com \
--cc=olivier.matz@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).