From: Stephen Hemminger <stephen@networkplumber.org>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: "Bruce Richardson" <bruce.richardson@intel.com>, <dev@dpdk.org>
Subject: Re: [PATCH v2 1/6] eal: add macros for local variable-length structure buffers
Date: Tue, 1 Dec 2026 11:36:54 -0800 [thread overview]
Message-ID: <20261201113654.7013a15c@phoenix.local> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35F65B4A@smartserver.smartshare.dk>
On Tue, 1 Dec 2026 20:29:46 +0100
Morten Brørup <mb@smartsharesystems.com> wrote:
> > From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> > Sent: Tuesday, 1 December 2026 19.23
> >
> > Many drivers allocate small control-path messages, which consist of a
> > header structure followed by a variable-length array, using malloc and
> > free, which adds error handling and the risk of leaks on error paths.
> >
> > Add RTE_DEFINE_FLEX and RTE_DEFINE_FLEX_BYTES macros to define such
> > buffers on the stack instead, (similar to equivalent macros in Linux
> > kernel). The buffer is a union of a byte array and the structure type,
> > giving correct alignment and type-safe access via a pointer, with the
> > byte array first so that zero-initialization covers the whole buffer.
> >
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
>
> I thought we wanted to get rid of variable length arrays...
> Could this be implemented using alloca() instead?
>
>
There is difference between Variable Length Array (VLA) which
is on stack buffer like:
void foo(size_t n)
{
int results[n];
...
And Flexible Array which is structure with variable amount of data
at the end:
struct foo {
int nflow;
struct flow flows[];
}
The Linux kernel also uses Gcc/clang counted by, can these macros do that?
next prev parent reply other threads:[~2026-12-01 19:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 16:09 [PATCH 27.03 0/6] eliminate unnecessary dynamic allocation Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 1/6] eal: add macros for local variable-length structure buffers Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 2/6] net/iavf: use stack storage for virtchnl messages Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 3/6] net/ice: use stack storage for function-local buffers Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 4/6] net/idpf: use stack storage for virtchnl messages Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 5/6] net/cpfl: use stack storage for function-local buffers Bruce Richardson
2026-11-16 16:09 ` [PATCH 27.03 6/6] net/i40e: " Bruce Richardson
2026-12-01 18:22 ` [PATCH v2 0/6] eliminate unnecessary dynamic allocation Bruce Richardson
2026-12-01 18:22 ` [PATCH v2 1/6] eal: add macros for local variable-length structure buffers Bruce Richardson
2026-12-01 19:29 ` Morten Brørup
2026-12-01 19:36 ` Stephen Hemminger [this message]
2026-12-01 19:37 ` Stephen Hemminger
2026-12-01 18:22 ` [PATCH v2 2/6] net/iavf: use stack storage for virtchnl messages Bruce Richardson
2026-12-01 18:22 ` [PATCH v2 3/6] net/ice: use stack storage for function-local buffers Bruce Richardson
2026-12-01 18:22 ` [PATCH v2 4/6] net/idpf: use stack storage for virtchnl messages Bruce Richardson
2026-12-01 18:22 ` [PATCH v2 5/6] net/cpfl: use stack storage for function-local buffers Bruce Richardson
2026-12-01 18:22 ` [PATCH v2 6/6] net/i40e: " Bruce Richardson
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=20261201113654.7013a15c@phoenix.local \
--to=stephen@networkplumber.org \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.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