DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: chixiaobo <xiaobo.chi@nsn.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] add one option memory-only for those secondary PRBs
Date: Tue, 2 Dec 2014 10:20:57 +0000	[thread overview]
Message-ID: <20141202102057.GA9888@bricha3-MOBL3> (raw)
In-Reply-To: <1417513268-6040-1-git-send-email-xiaobo.chi@nsn.com>

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
> 

      parent reply	other threads:[~2014-12-02 10:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02  9:41 chixiaobo
2014-12-02  9:55 ` Chi, Xiaobo (NSN - CN/Hangzhou)
2014-12-02 10:01   ` Thomas Monjalon
2014-12-02 10:20 ` Bruce Richardson [this message]

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=20141202102057.GA9888@bricha3-MOBL3 \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=xiaobo.chi@nsn.com \
    /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).