From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: "Morten Brørup" <mb@smartsharesystems.com>,
"dev@dpdk.org" <dev@dpdk.org>
Cc: "wathsala.vithanage@arm.com" <wathsala.vithanage@arm.com>
Subject: RE: [PATCH v4 2/2] ring: introduce peek API for soring
Date: Tue, 5 May 2026 15:45:37 +0000 [thread overview]
Message-ID: <9cd42a60e340484da836f14bafe275fd@huawei.com> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35F65828@smartserver.smartshare.dk>
> > +static inline uint32_t
> > +soring_enqueue_start(struct rte_soring *r, uint32_t num,
> > + enum rte_ring_queue_behavior behavior, uint32_t *free_space)
> > +{
> > + enum rte_ring_sync_type st;
> > + uint32_t free, head, n, next;
> > +
> > + RTE_ASSERT(r != NULL && r->nb_stage > 0);
> > +
> > + st = r->prod.ht.sync_type;
> > +
> > + switch (st) {
> > + case RTE_RING_SYNC_ST:
> > + n = __rte_ring_headtail_move_head(&r->prod.ht, &r->cons.ht,
> > + r->capacity, RTE_RING_SYNC_ST, num, behavior,
> > + &head, &next, &free);
> > + break;
> > + case RTE_RING_SYNC_MT_HTS:
> > + n = __rte_ring_hts_move_head(&r->prod.hts, &r->cons.ht,
> > + r->capacity, num, behavior, &head, &free);
> > + break;
> > + default:
> > + /* unsupported mode, shouldn't be here */
> > + RTE_ASSERT(0);
>
> Is RTE_ASSERT(0) the right choice for failure here?
> Unless built with assertions enabled, RTE_ASSERT(0) does nothing, and this
> function also does nothing but returns 0 as free_space, which may not be
> correct.
>
> Maybe rte_panic() instead.
> It's an application bug to call this with the wrong SORING sync type.
> We cannot handle it gracefully, so better to fail early.
Yep, it is a bug in application in such case, but as rule of thumb we avoid panics in
the libs, even when user provided incorrect input.
At least, all lib/ring API function work like that - if given sync type is not supported,
then function doesn't touch the ring contents and fills 'free/available'
parameter with zero. So ring is sort-of unusable to the caller.
> Just an idea; I have no strong preference.
Ok, then I leave it like that.
Thanks for the review.
Konstantin
> > + free = 0;
> > + n = 0;
> > + }
> > +
> > + if (free_space != NULL)
> > + *free_space = free - n;
> > + return n;
> > +}
> > +
next prev parent reply other threads:[~2026-05-05 15:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 17:16 [PATCH v1 0/2] few improvemnts for SORING lib Konstantin Ananyev
2026-04-15 17:16 ` [PATCH v1 1/2] ring: make soring to finalize its own stage only Konstantin Ananyev
2026-04-15 17:16 ` [PATCH v1 2/2] ring: introduce peek API for soring Konstantin Ananyev
2026-04-16 19:14 ` [PATCH v2 0/2] few improvemnts for SORING lib Konstantin Ananyev
2026-04-16 19:14 ` [PATCH v2 1/2] ring: make soring to finalize its own stage only Konstantin Ananyev
2026-04-16 19:14 ` [PATCH v2 2/2] ring: introduce peek API for soring Konstantin Ananyev
2026-04-17 21:23 ` [PATCH v3 0/2] few improvemnts for SORING lib Konstantin Ananyev
2026-04-17 21:23 ` [PATCH v3 1/2] ring: make soring to finalize its own stage only Konstantin Ananyev
2026-04-17 21:23 ` [PATCH v3 2/2] ring: introduce peek API for soring Konstantin Ananyev
2026-04-18 3:28 ` [PATCH v3 0/2] few improvemnts for SORING lib Stephen Hemminger
2026-04-23 9:16 ` [PATCH v4 " Konstantin Ananyev
2026-04-23 9:16 ` [PATCH v4 1/2] ring: make soring to always finalize its own stage Konstantin Ananyev
2026-04-28 11:54 ` Morten Brørup
2026-04-23 9:16 ` [PATCH v4 2/2] ring: introduce peek API for soring Konstantin Ananyev
2026-04-28 12:56 ` Morten Brørup
2026-05-05 15:45 ` Konstantin Ananyev [this message]
2026-04-29 15:57 ` [PATCH v4 0/2] few improvemnts for SORING lib Stephen Hemminger
2026-05-05 15:47 ` [PATCH v5 " Konstantin Ananyev
2026-05-05 15:47 ` [PATCH v5 1/2] ring: make soring to always finalize its own stage Konstantin Ananyev
2026-05-05 15:47 ` [PATCH v5 2/2] ring: introduce peek API for soring Konstantin Ananyev
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=9cd42a60e340484da836f14bafe275fd@huawei.com \
--to=konstantin.ananyev@huawei.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.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