[dpdk-dev] [PATCH] add one option memory-only for those secondary PRBs
Bruce Richardson
bruce.richardson at intel.com
Tue Dec 2 11:20:57 CET 2014
On Tue, Dec 02, 2014 at 05:41:08PM +0800, chixiaobo wrote:
> ---
> lib/librte_eal/common/eal_common_options.c | 18 +++-
> lib/librte_eal/common/eal_internal_cfg.h | 1 +
> lib/librte_eal/common/eal_options.h | 4 +-
> lib/librte_eal/linuxapp/eal/eal.c | 137 +++++++++++++++--------------
> 4 files changed, 89 insertions(+), 71 deletions(-)
> mode change 100644 => 100755 lib/librte_eal/common/eal_common_options.c
> mode change 100644 => 100755 lib/librte_eal/common/eal_internal_cfg.h
> mode change 100644 => 100755 lib/librte_eal/common/eal_options.h
> mode change 100644 => 100755 lib/librte_eal/linuxapp/eal/eal.c
>
> diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
> old mode 100644
> new mode 100755
> index e2810ab..5ab4b87
<snip>
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> old mode 100644
> new mode 100755
> index 89f3b5e..a03e511
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -752,14 +752,16 @@ rte_eal_init(int argc, char **argv)
>
> rte_config_init();
>
> - if (rte_eal_pci_init() < 0)
> - rte_panic("Cannot init PCI\n");
> + /*with memory-only option, we need not cpu affinity, pci device, alarm, external devices, interrupt, etc. */
> + if( !internal_config.memory_only ){
> + if (rte_eal_pci_init() < 0)
> + rte_panic("Cannot init PCI\n");
>
> #ifdef RTE_LIBRTE_IVSHMEM
> if (rte_eal_ivshmem_init() < 0)
> rte_panic("Cannot init IVSHMEM\n");
> #endif
> -
> + }
> if (rte_eal_memory_init() < 0)
> rte_panic("Cannot init memory\n");
>
> @@ -772,73 +774,73 @@ rte_eal_init(int argc, char **argv)
> if (rte_eal_tailqs_init() < 0)
> rte_panic("Cannot init tail queues for objects\n");
>
At this point, I believe you are finished the initialization for the
memory only case, so instead of adding all the rest of the content below to
an "if" statement and indenting it further, I think it would be better to have
a single short "if" statement here for "if (internal_config.memory_only) return"
leaving the rest of the existing function unmodified.
> -#ifdef RTE_LIBRTE_IVSHMEM
> - if (rte_eal_ivshmem_obj_init() < 0)
> - rte_panic("Cannot init IVSHMEM objects\n");
> -#endif
> -
> if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)
> rte_panic("Cannot init logs\n");
>
> - if (rte_eal_alarm_init() < 0)
> - rte_panic("Cannot init interrupt-handling thread\n");
> -
> - if (rte_eal_intr_init() < 0)
> - rte_panic("Cannot init interrupt-handling thread\n");
> -
> - if (rte_eal_timer_init() < 0)
> - rte_panic("Cannot init HPET or TSC timers\n");
> -
> - eal_check_mem_on_local_socket();
> -
> - rte_eal_mcfg_complete();
> -
> - TAILQ_FOREACH(solib, &solib_list, next) {
> - RTE_LOG(INFO, EAL, "open shared lib %s\n", solib->name);
> - solib->lib_handle = dlopen(solib->name, RTLD_NOW);
> - if (solib->lib_handle == NULL)
> - RTE_LOG(WARNING, EAL, "%s\n", dlerror());
> - }
> -
> - eal_thread_init_master(rte_config.master_lcore);
> -
> - RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n",
> - rte_config.master_lcore, (int)thread_id);
> -
> - if (rte_eal_dev_init() < 0)
> - rte_panic("Cannot init pmd devices\n");
> -
> - RTE_LCORE_FOREACH_SLAVE(i) {
> -
> - /*
> - * create communication pipes between master thread
> - * and children
> - */
> - if (pipe(lcore_config[i].pipe_master2slave) < 0)
> - rte_panic("Cannot create pipe\n");
> - if (pipe(lcore_config[i].pipe_slave2master) < 0)
> - rte_panic("Cannot create pipe\n");
> -
> - lcore_config[i].state = WAIT;
> -
> - /* create a thread for each lcore */
> - ret = pthread_create(&lcore_config[i].thread_id, NULL,
> - eal_thread_loop, NULL);
> - if (ret != 0)
> - rte_panic("Cannot create thread\n");
> - }
> -
> - /*
> - * Launch a dummy function on all slave lcores, so that master lcore
> - * knows they are all ready when this function returns.
> - */
> - rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
> - rte_eal_mp_wait_lcore();
> -
> - /* Probe & Initialize PCI devices */
> - if (rte_eal_pci_probe())
> - rte_panic("Cannot probe PCI\n");
> -
> + if( !internal_config.memory_only ){
> +#ifdef RTE_LIBRTE_IVSHMEM
> + if (rte_eal_ivshmem_obj_init() < 0)
> + rte_panic("Cannot init IVSHMEM objects\n");
> +#endif
> + if (rte_eal_alarm_init() < 0)
> + rte_panic("Cannot init interrupt-handling thread\n");
> +
> + if (rte_eal_intr_init() < 0)
> + rte_panic("Cannot init interrupt-handling thread\n");
> +
> + if (rte_eal_timer_init() < 0)
> + rte_panic("Cannot init HPET or TSC timers\n");
> +
> + eal_check_mem_on_local_socket();
> +
> + rte_eal_mcfg_complete();
> +
> + TAILQ_FOREACH(solib, &solib_list, next) {
> + RTE_LOG(INFO, EAL, "open shared lib %s\n", solib->name);
> + solib->lib_handle = dlopen(solib->name, RTLD_NOW);
> + if (solib->lib_handle == NULL)
> + RTE_LOG(WARNING, EAL, "%s\n", dlerror());
> + }
> +
> + eal_thread_init_master(rte_config.master_lcore);
> +
> + RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n",
> + rte_config.master_lcore, (int)thread_id);
> +
> + if (rte_eal_dev_init() < 0)
> + rte_panic("Cannot init pmd devices\n");
> +
> + RTE_LCORE_FOREACH_SLAVE(i) {
> +
> + /*
> + * create communication pipes between master thread
> + * and children
> + */
> + if (pipe(lcore_config[i].pipe_master2slave) < 0)
> + rte_panic("Cannot create pipe\n");
> + if (pipe(lcore_config[i].pipe_slave2master) < 0)
> + rte_panic("Cannot create pipe\n");
> +
> + lcore_config[i].state = WAIT;
> +
> + /* create a thread for each lcore */
> + ret = pthread_create(&lcore_config[i].thread_id, NULL,
> + eal_thread_loop, NULL);
> + if (ret != 0)
> + rte_panic("Cannot create thread\n");
> + }
> +
> + /*
> + * Launch a dummy function on all slave lcores, so that master lcore
> + * knows they are all ready when this function returns.
> + */
> + rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
> + rte_eal_mp_wait_lcore();
> +
> + /* Probe & Initialize PCI devices */
> + if (rte_eal_pci_probe())
> + rte_panic("Cannot probe PCI\n");
> + }
> return fctret;
> }
>
> @@ -859,3 +861,4 @@ int rte_eal_has_hugepages(void)
> {
> return ! internal_config.no_hugetlbfs;
> }
> +
Extra blank line added - probably not intended.
> --
> 1.9.4.msysgit.2
>
More information about the dev
mailing list