eal: apply thread affinity by assigned cpuset
[dpdk.git] / lib / librte_eal / bsdapp / eal / eal.c
index 69f3c03..44f9d42 100644 (file)
@@ -326,8 +326,10 @@ eal_parse_args(int argc, char **argv)
                int ret;
 
                /* getopt is not happy, stop right now */
-               if (opt == '?')
+               if (opt == '?') {
+                       eal_usage(prgname);
                        return -1;
+               }
 
                ret = eal_parse_common_option(opt, optarg, &internal_config);
                /* common parser is not happy */
@@ -340,6 +342,9 @@ eal_parse_args(int argc, char **argv)
                        continue;
 
                switch (opt) {
+               case 'h':
+                       eal_usage(prgname);
+                       exit(EXIT_SUCCESS);
                default:
                        if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
                                RTE_LOG(ERR, EAL, "Option %c is not supported "
@@ -432,6 +437,7 @@ rte_eal_init(int argc, char **argv)
        int i, fctret, ret;
        pthread_t thread_id;
        static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
+       char cpuset[RTE_CPU_AFFINITY_STR_LEN];
 
        if (!rte_atomic32_test_and_set(&run_once))
                return -1;
@@ -502,13 +508,18 @@ rte_eal_init(int argc, char **argv)
        if (rte_eal_pci_init() < 0)
                rte_panic("Cannot init PCI\n");
 
-       RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%p)\n",
-               rte_config.master_lcore, thread_id);
-
        eal_check_mem_on_local_socket();
 
        rte_eal_mcfg_complete();
 
+       eal_thread_init_master(rte_config.master_lcore);
+
+       ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+
+       RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+               rte_config.master_lcore, thread_id, cpuset,
+               ret == 0 ? "" : "...");
+
        if (rte_eal_dev_init() < 0)
                rte_panic("Cannot init pmd devices\n");
 
@@ -532,8 +543,6 @@ rte_eal_init(int argc, char **argv)
                        rte_panic("Cannot create thread\n");
        }
 
-       eal_thread_init_master(rte_config.master_lcore);
-
        /*
         * Launch a dummy function on all slave lcores, so that master lcore
         * knows they are all ready when this function returns.