DPDK patches and discussions
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	Rami Neiman <rami.neiman@solace.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Duane Pauls <Duane.Pauls@solace.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: RE: Question: Why doesn’t rte_ring use double-mapped VMA to eliminate wraparound logic?
Date: Mon, 10 Nov 2025 12:07:48 +0000	[thread overview]
Message-ID: <30360617ea8e48589b6490eb5b6f7388@huawei.com> (raw)
In-Reply-To: <20251108091408.584962e8@phoenix>



> > Hi all,
> > I have a design question regarding rte_ring that I didn’t find a historical rationale
> for in the archives.
> > Most modern high-perf ring buffers (e.g. some NIC drivers, some DB queue
> implementations, etc.) eliminate wrap-around branches by taking the ring’s element
> array and mapping two consecutive VA ranges to the same physical backing pages.
> > i.e. you allocate N elements, commit enough pages to cover N, then call mmap (or
> equivalent) again immediately following it, pointing to the same physical pages. So
> from the CPU’s POV the element array is logically [0 .. N*2) but physically it’s the
> same backing. Therefore a batch read/write can always be done as a single
> contiguous memcpy/CLD/STOS without conditionals, even if (head+bulk) exceeds N.
> > Pseudo illustration:
> >
> > [phys buffer of N slots]
> > VA: [0 .. N) -> phys
> > VA: [N .. 2N) -> same phys
> >
> >
> > For multi-element enqueue/dequeue it eliminates the “if wrap → split” case
> entirely — you can always memcpy in one contiguous op.
> > Question:
> > Is there an explicit reason DPDK doesn’t use this technique for rte_ring?
> > e.g.
> 
> Manipulating process mapping in user space is often non-portable, it is possible on
> Linux to use mmap
> to do this but would require deep changes to the API.

TBH, I didn't even consider such opportunity....
But yes, I Stephen already pointed, one potential problem:
DPDK memory allocation framework (rte_malloc)
doesn't support such double mappings for now.
Would it be a good thing to add or not - I suppose it depends on what
performance boost we will get in return and what would be a required code-changes complexity.
Konstantin



      reply	other threads:[~2025-11-10 12:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07 16:57 Rami Neiman
2025-11-08 17:14 ` Stephen Hemminger
2025-11-10 12:07   ` Konstantin Ananyev [this message]

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=30360617ea8e48589b6490eb5b6f7388@huawei.com \
    --to=konstantin.ananyev@huawei.com \
    --cc=Duane.Pauls@solace.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=rami.neiman@solace.com \
    --cc=stephen@networkplumber.org \
    /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).