From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Konstantin Ananyev" <konstantin.ananyev@huawei.com>,
"Ola Liljedahl" <Ola.Liljedahl@arm.com>,
"Wathsala Vithanage" <wathsala.vithanage@arm.com>,
"Honnappa Nagarahalli" <Honnappa.Nagarahalli@arm.com>
Cc: <dev@dpdk.org>, "Dhruv Tripathi" <Dhruv.Tripathi@arm.com>,
"Bruce Richardson" <bruce.richardson@intel.com>
Subject: RE: [PATCH 1/1] ring: safe partial ordering for head/tail update
Date: Thu, 25 Sep 2025 06:29:32 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F65465@smartserver.smartshare.dk> (raw)
In-Reply-To: <4cec8b9ca5114f90b8ce1047abdaa936@huawei.com>
I have been following this interesting discussion, and want to clarify:
For a generic ring, enqueue can fail if the ring doesn't have sufficient free space, and dequeue can fail if it doesn't have sufficient objects in queue.
However, when a ring is used as the backing store for a mempool, enqueue can never fail. (Dequeue can still fail if the mempool has been depleted.)
The reason enqueue into a mempool ring can never fail is:
On creation of the mempool ring, the objects held by the mempool (e.g. mbufs) are allocated in memory and enqueued into the ring. If the mempool ring has size SIZE, then SIZE objects are allocated in memory and enqueued into the mempool ring.
So, since only SIZE objects exist in the whole world, and the mempool ring has size SIZE, enqueue of those objects into the mempool ring cannot fail, and the mempool "put" API reflects this.
Note that this is a requirement for the mempool API, not the ring API.
So, if the ring API doesn't provide this guarantee (that if only SIZE objects exist, enqueue cannot fail), then this guarantee could be implemented in the mempool library where it interfaces to the ring "enqueue" API (instead of having the ring API provide this guarantee).
However, other libraries or applications might assume the same guarantee for a ring when no more than SIZE objects exist. (I don't know!) If this is the case, then it is a ring API requirement, not just a mempool API requirement.
One possible solution to this could be offering two ring enqueue APIs, a "fast" API without the guarantee and a "safe" API with the guarantee.
Somewhat like the iteration macros for linked lists: foreach() and foreach_safe().
next prev parent reply other threads:[~2025-09-25 4:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 18:54 [PATCH 0/1] ring: correct ordering issue in " Wathsala Vithanage
2025-09-15 18:54 ` [PATCH 1/1] ring: safe partial ordering for " Wathsala Vithanage
2025-09-16 15:42 ` Bruce Richardson
2025-09-16 18:19 ` Ola Liljedahl
2025-09-17 7:47 ` Bruce Richardson
2025-09-17 15:06 ` Stephen Hemminger
2025-09-18 17:40 ` Wathsala Vithanage
2025-09-16 22:57 ` Konstantin Ananyev
2025-09-16 23:08 ` Konstantin Ananyev
[not found] ` <2a611c3cf926d752a54b7655c27d6df874a2d0de.camel@arm.com>
2025-09-17 7:58 ` Konstantin Ananyev
2025-09-17 9:05 ` Ola Liljedahl
2025-09-20 12:01 ` Konstantin Ananyev
[not found] ` <cf7e14d4ba5e9d78fddf083b6c92d75942447931.camel@arm.com>
2025-09-22 7:12 ` Konstantin Ananyev
2025-09-23 21:57 ` Ola Liljedahl
2025-09-24 6:56 ` Konstantin Ananyev
2025-09-24 7:50 ` Konstantin Ananyev
2025-09-24 8:51 ` Ola Liljedahl
2025-09-24 10:08 ` Konstantin Ananyev
2025-09-24 11:27 ` Ola Liljedahl
2025-09-24 11:50 ` Konstantin Ananyev
2025-09-24 13:28 ` Ola Liljedahl
2025-09-24 15:03 ` Konstantin Ananyev
2025-09-25 4:29 ` Morten Brørup [this message]
2025-09-25 7:11 ` Konstantin Ananyev
2025-09-24 15:24 ` Stephen Hemminger
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=98CBD80474FA8B44BF855DF32C47DC35F65465@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=Dhruv.Tripathi@arm.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Ola.Liljedahl@arm.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@huawei.com \
--cc=wathsala.vithanage@arm.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).