DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>
Cc: <dev@dpdk.org>, "Bruce Richardson" <bruce.richardson@intel.com>,
	"Konstantin Ananyev" <konstantin.ananyev@huawei.com>
Subject: RE: [PATCH v3 1/2] stack: introduce pile
Date: Mon, 31 Aug 2026 18:37:03 +0200	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F65A28@smartserver.smartshare.dk> (raw)
In-Reply-To: <20260831081522.16ffb8b2@phoenix.local>

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Monday, 31 August 2026 18.06
> 
> On Thu, 27 Aug 2026 13:55:55 +0000
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
> > +__rte_stack_pile_pop(struct rte_stack *s,
> > +		void **obj_table,
> 
> NAK to using always_inline on a function this big
> It generates worse code in a lot of cases because of register spill.

OK, I will change it to "inline", and let the compiler decide.
Then we don't have to discuss which is better. :-)

I'll change the pull function too.

BTW, it's not quite as big as it looks.
Here's the function without comments, assertions and empty lines:

static __rte_always_inline unsigned int
__rte_stack_pile_pop(struct rte_stack *s,
		void **obj_table,
		unsigned int n)
{
	struct rte_stack_pile *pile = &s->stack_pile;
	struct rte_stack_pile_bulk_elem *bulk_first = NULL, *bulk_last = NULL;
	struct rte_stack_lf_elem *solo_first = NULL, *solo_last = NULL;
	unsigned int n_bulk = n / RTE_STACK_PILE_BULK_SIZE;
	unsigned int n_solo = n & (RTE_STACK_PILE_BULK_SIZE - 1);
	if (unlikely(n_bulk == 0)) {
		if (unlikely(n_solo == 0))
			return 0;
		goto solo;
	}
bulk:
	bulk_first = __rte_stack_pile_bulk_pop_elems(&pile->bulk, n_bulk, obj_table, &bulk_last);
	if (unlikely(bulk_first == NULL)) {
		unsigned int delta_bulk = n_bulk - __rte_stack_lf_elems_count(&pile->bulk);
		if (unlikely((int)delta_bulk <= 0))
			delta_bulk = 1;
		n_bulk -= delta_bulk;
		n_solo += RTE_STACK_PILE_BULK_SIZE * delta_bulk;
		if (n_bulk == 0)
			goto solo;
		goto bulk;
	}
	obj_table += n_bulk * RTE_STACK_PILE_BULK_SIZE;
	if (likely(n_solo == 0))
		goto done;
solo:
	solo_first = __rte_stack_lf_pop_elems(&pile->solo, n_solo,
			obj_table, &solo_last);
	if (solo_first != NULL)
		goto done;
	if (unlikely(n_solo >= RTE_STACK_PILE_BULK_SIZE))
		goto fail;
	if (unlikely(__rte_stack_pile_pop_frag(pile, obj_table, n_solo) == 0))
		goto fail;
done:
	if (bulk_first != NULL)
		__rte_stack_pile_bulk_push_elems(&pile->free_bulk, bulk_first, bulk_last, n_bulk);
	if (solo_first != NULL)
		__rte_stack_lf_push_elems(&pile->free_solo, solo_first, solo_last, n_solo);
	return n;
fail:
	if (bulk_first != NULL)
		__rte_stack_pile_bulk_push_elems(&pile->bulk, bulk_first, bulk_last, n_bulk);
	return 0;
}


  reply	other threads:[~2026-08-31 16:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 13:47 [PATCH] stack: introduce pile Morten Brørup
2026-08-12 14:34 ` Bruce Richardson
2026-08-12 16:01   ` Morten Brørup
2026-08-12 16:15     ` Bruce Richardson
2026-08-12 16:28       ` Morten Brørup
2026-08-13 11:50         ` Bruce Richardson
2026-08-17 13:10 ` Bruce Richardson
2026-08-18  8:11   ` Konstantin Ananyev
2026-08-18  8:50     ` Morten Brørup
2026-08-25  7:05 ` Konstantin Ananyev
2026-08-25  9:21   ` Morten Brørup
2026-08-25 11:29     ` Konstantin Ananyev
2026-08-26  8:13 ` Konstantin Ananyev
2026-08-27 13:55 ` [PATCH v3 0/2] introduce pile stack and mempool driver Morten Brørup
2026-08-27 13:55   ` [PATCH v3 1/2] stack: introduce pile Morten Brørup
2026-08-31  8:50     ` Konstantin Ananyev
2026-08-31  9:05       ` Morten Brørup
2026-08-31  9:38         ` Konstantin Ananyev
2026-08-31 10:09           ` Morten Brørup
2026-08-31 16:06     ` Stephen Hemminger
2026-08-31 16:37       ` Morten Brørup [this message]
2026-08-27 13:55   ` [PATCH v3 2/2] mempool: introduce pile driver Morten Brørup
2026-09-01  6:43 ` [PATCH v4 0/2] introduce pile stack and mempool driver Morten Brørup
2026-09-01  6:43   ` [PATCH v4 1/2] stack: introduce pile Morten Brørup
2026-09-01  6:43   ` [PATCH v4 2/2] mempool: introduce pile driver Morten Brørup
2026-09-02 16:00     ` 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=98CBD80474FA8B44BF855DF32C47DC35F65A28@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.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