DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bao-Long Tran <tranbaolong@niometrics.com>
To: dev@dpdk.org
Subject: [dpdk-dev] rte_eal_init() behavior
Date: Fri, 15 Nov 2019 17:28:58 +0800	[thread overview]
Message-ID: <CC54B817-E492-48A4-AE54-9C8330B2A5D3@niometrics.com> (raw)

Hi,

In most of the examples, the argc and argv from main are passed directly
to rte_eal_init(). This has the implication that argv[0] is the program
name. When a user crafts his own argv, he must submit a placeholder at
argv[0] as well, or else the EAL parameters won't be parsed correctly.

Below is a minimal demonstration. It requests 1 lcore, but EAL
initializes all available lcores instead. If I put in some placeholder,
then it's working as expected.

#include <stdio.h> 
#include <string.h> 
#include <rte_eal.h>
#include <rte_lcore.h>

int main(void) 
{
        int argc = 0;
        char *argv[4];

        // if we don't add "foo", EAL won't initialize correctly
        //argv[argc++] = strdup("foo"); 
        argv[argc++] = strdup("-l 0");

        if (rte_eal_init(argc, argv) < 0)
                rte_exit(EXIT_FAILURE, "EAL initialization error\n");

        printf("%s: lcore count specificed: 1, got: %u\n", 
                1 == rte_lcore_count() ? "PASS" : "FAIL", 
                rte_lcore_count());

        return 0; 
}

If I'm not mistaken, this behavior is not documented anywhere, including
the source code or API. It is also totally silent, no warning
whatsoever. I guess one way to make sure that rte_eal_init() was
correctly executed is to compare its return value to the number of args
passed in, but this is too cumbersome and in fact most of the examples
don't do it.

I suggest we should document this behavior, and maybe fix it so that
users won't need to pass in a placeholder.

--BL

                 reply	other threads:[~2019-11-15  9:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CC54B817-E492-48A4-AE54-9C8330B2A5D3@niometrics.com \
    --to=tranbaolong@niometrics.com \
    --cc=dev@dpdk.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;
as well as URLs for NNTP newsgroup(s).