DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] rte_eal_init() behavior
@ 2019-11-15  9:28 Bao-Long Tran
  0 siblings, 0 replies; only message in thread
From: Bao-Long Tran @ 2019-11-15  9:28 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-15  9:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-15  9:28 [dpdk-dev] rte_eal_init() behavior Bao-Long Tran

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).