DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Euan Bourke <euan.bourke@intel.com>, <dev@dpdk.org>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: Re: [PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing
Date: Thu, 30 Nov 2023 08:59:33 +0000	[thread overview]
Message-ID: <ZWhO9Tgm77UoeuXf@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <20231129141413.73faa6c8@hermes.local>

On Wed, Nov 29, 2023 at 02:14:13PM -0800, Stephen Hemminger wrote:
> On Tue, 28 Nov 2023 14:07:41 +0000
> Euan Bourke <euan.bourke@intel.com> wrote:
> 
> > +int
> > +rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len)
> > +{
> > +	int32_t min = -1;
> > +	char *end = NULL;
> > +
> > +	struct core_bits *mask = malloc(sizeof(struct core_bits));
> > +	if (mask == NULL)
> > +		return -1;
> > +	memset(mask, 0, sizeof(struct core_bits));
> > +
> 
> The structure is not variable size, and small, why bother using malloc().
> Just use on stack structure.

Well, it's just over 4k in size, and we hit problems in the past with
alpine linux where the stack size wasn't as big as expected, leading to
issues with telemetry string manipulation. In that case I think it was due
to nested calls as well as large stack structs, though. For this core
parsing, having this struct on stack is unlikely to cause issues, but for a
non-datapath API I suggests to Euan to use malloc as a lower-risk
alternative, since performance of an arg parsing API is unlikely to be a
major concern.

However, if you feel that it should be on the stack and won't cause any
issues, it does make the code shorter and easier to work with!

/Bruce

  reply	other threads:[~2023-11-30  8:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22 16:45 [PATCH 24.03 0/4] add new command line argument parsing library Euan Bourke
2023-11-22 16:45 ` [PATCH 24.03 1/4] arg_parser: new library for command line parsing Euan Bourke
2023-11-23 15:50   ` Bruce Richardson
2023-11-22 16:45 ` [PATCH 24.03 2/4] arg_parser: add new coremask parsing API Euan Bourke
2023-11-23 15:55   ` Bruce Richardson
2023-11-22 16:45 ` [PATCH 24.03 3/4] eal: add support for new arg parsing library Euan Bourke
2023-11-22 16:45 ` [PATCH 24.03 4/4] dlb2: add new arg parsing library API support Euan Bourke
2023-11-28 14:07 ` [PATCH 24.03 v2 0/5] add new command line argument parsing library Euan Bourke
2023-11-28 14:07   ` [PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing Euan Bourke
2023-11-29 22:12     ` Stephen Hemminger
2023-11-29 22:12     ` Stephen Hemminger
2023-11-29 22:14     ` Stephen Hemminger
2023-11-30  8:59       ` Bruce Richardson [this message]
2023-11-28 14:07   ` [PATCH 24.03 v2 2/5] arg_parser: add new coremask parsing API Euan Bourke
2023-11-28 14:07   ` [PATCH 24.03 v2 3/5] eal: add support for new arg parsing library Euan Bourke
2023-11-28 14:07   ` [PATCH 24.03 v2 4/5] eal: update to service core related parsers Euan Bourke
2023-11-28 14:07   ` [PATCH 24.03 v2 5/5] event/dlb2: add new arg parsing library API support Euan Bourke

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=ZWhO9Tgm77UoeuXf@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=euan.bourke@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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).