DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 09/10] eal: get relative core index
Date: Tue, 25 Nov 2014 10:51:41 +0000	[thread overview]
Message-ID: <20141125105141.GI5260@bricha3-MOBL3> (raw)
In-Reply-To: <1416692622-28886-10-git-send-email-thomas.monjalon@6wind.com>

On Sat, Nov 22, 2014 at 10:43:41PM +0100, Thomas Monjalon wrote:
> From: Patrick Lu <Patrick.Lu@intel.com>
> 
> EAL -c option allows the user to enable any lcore in the system.
> Often times, the user app wants to know 1st enabled core, 2nd
> enabled core, etc, rather than phyical core ID (rte_lcore_id().)
> 
> The new API rte_lcore_index() will return an index from enabled lcores
> starting from zero.
> 
> Signed-off-by: Patrick Lu <patrick.lu@intel.com>
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>

I think this is good as far as it goes, but I think an extra API to get the
lcore with the given index would be a great extension to this. That would
allow you to do:

rte_eal_remote_launch(func0, arg0, rte_lcore_with_index(0));
rte_eal_remote_launch(func1, arg1, rte_lcore_with_index(1));
...

However, as a good start, I think this should be applied for now, so...

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

> ---
>  lib/librte_eal/common/eal_common_options.c | 13 ++++++++++---
>  lib/librte_eal/common/include/rte_lcore.h  | 20 ++++++++++++++++++++
>  2 files changed, 30 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
> index 18d03e3..c9df8f5 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -185,19 +185,23 @@ eal_parse_coremask(const char *coremask)
>  					return -1;
>  				}
>  				cfg->lcore_role[idx] = ROLE_RTE;
> +				lcore_config[idx].core_index = count;
>  				if (count == 0)
>  					cfg->master_lcore = idx;
>  				count++;
>  			} else {
>  				cfg->lcore_role[idx] = ROLE_OFF;
> +				lcore_config[idx].core_index = -1;
>  			}
>  		}
>  	}
>  	for (; i >= 0; i--)
>  		if (coremask[i] != '0')
>  			return -1;
> -	for (; idx < RTE_MAX_LCORE; idx++)
> +	for (; idx < RTE_MAX_LCORE; idx++) {
>  		cfg->lcore_role[idx] = ROLE_OFF;
> +		lcore_config[idx].core_index = -1;
> +	}
>  	if (count == 0)
>  		return -1;
>  	/* Update the count of enabled logical cores of the EAL configuration */
> @@ -225,9 +229,11 @@ eal_parse_corelist(const char *corelist)
>  	while ((i > 0) && isblank(corelist[i - 1]))
>  		i--;
>  
> -	/* Reset core roles */
> -	for (idx = 0; idx < RTE_MAX_LCORE; idx++)
> +	/* Reset config */
> +	for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
>  		cfg->lcore_role[idx] = ROLE_OFF;
> +		lcore_config[idx].core_index = -1;
> +	}
>  
>  	/* Get list of cores */
>  	min = RTE_MAX_LCORE;
> @@ -250,6 +256,7 @@ eal_parse_corelist(const char *corelist)
>  				min = idx;
>  			for (idx = min; idx <= max; idx++) {
>  				cfg->lcore_role[idx] = ROLE_RTE;
> +				lcore_config[idx].core_index = count;
>  				if (count == 0)
>  					cfg->master_lcore = idx;
>  				count++;
> diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h
> index a0b4356..49b2c03 100644
> --- a/lib/librte_eal/common/include/rte_lcore.h
> +++ b/lib/librte_eal/common/include/rte_lcore.h
> @@ -64,6 +64,7 @@ struct lcore_config {
>  	volatile enum rte_lcore_state_t state; /**< lcore state */
>  	unsigned socket_id;        /**< physical socket id for this lcore */
>  	unsigned core_id;          /**< core number on socket for this lcore */
> +	int core_index;            /**< relative index, starting from 0 */
>  };
>  
>  /**
> @@ -110,6 +111,25 @@ rte_lcore_count(void)
>  }
>  
>  /**
> + * Return the index of the lcore starting from zero.
> + * The order is physical or given by command line (-l option).
> + *
> + * @param lcore_id
> + *   The targeted lcore, or -1 for the current one.
> + * @return
> + *   The relative index, or -1 if not enabled.
> + */
> +static inline int
> +rte_lcore_index(int lcore_id)
> +{
> +	if (lcore_id >= RTE_MAX_LCORE)
> +		return -1;
> +	if (lcore_id < 0)
> +		lcore_id = rte_lcore_id();
> +	return lcore_config[lcore_id].core_index;
> +}
> +
> +/**
>   * Return the ID of the physical socket of the logical core we are
>   * running on.
>   * @return
> -- 
> 2.1.3
> 

  reply	other threads:[~2014-11-25 10:40 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-22 21:43 [dpdk-dev] [PATCH 00/10] eal cleanup and new options Thomas Monjalon
2014-11-22 21:43 ` [dpdk-dev] [PATCH 01/10] eal: move internal headers in source directory Thomas Monjalon
2014-11-25 10:21   ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 02/10] eal: factorize common headers Thomas Monjalon
2014-11-25 10:23   ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 03/10] eal: fix header guards Thomas Monjalon
2014-11-25 10:28   ` Bruce Richardson
2014-11-25 12:23     ` Thomas Monjalon
2014-11-25 13:37       ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 04/10] eal: factorize internal config reset Thomas Monjalon
2014-11-25 10:30   ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 05/10] eal: factorize options sanity check Thomas Monjalon
2014-11-25 10:42   ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 06/10] eal: factorize configuration adjustment Thomas Monjalon
2014-11-25 10:44   ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 07/10] eal: add core list input format Thomas Monjalon
2014-11-23  1:35   ` Neil Horman
2014-11-24 11:28     ` Bruce Richardson
2014-11-24 13:19       ` Thomas Monjalon
2014-11-24 13:28         ` Bruce Richardson
2014-11-24 13:37           ` Burakov, Anatoly
2014-11-24 14:01             ` Neil Horman
2014-11-24 14:52           ` Venkatesan, Venky
2014-11-24 16:12             ` Roger Keith Wiles
2014-11-24 17:04               ` Neil Horman
2014-11-24 17:09                 ` Roger Keith Wiles
2014-11-24 17:11                 ` Burakov, Anatoly
2014-11-24 17:17                   ` Neil Horman
2014-11-25 10:45   ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 08/10] config: support 128 cores Thomas Monjalon
2014-11-25 10:46   ` Bruce Richardson
2014-11-22 21:43 ` [dpdk-dev] [PATCH 09/10] eal: get relative core index Thomas Monjalon
2014-11-25 10:51   ` Bruce Richardson [this message]
2014-11-22 21:43 ` [dpdk-dev] [PATCH 10/10] eal: add option --master-lcore Thomas Monjalon
2014-11-25  9:09   ` Simon Kuenzer
2014-11-25 12:45     ` Thomas Monjalon
2014-11-25 13:39       ` Bruce Richardson
2014-11-26 10:34         ` Simon Kuenzer
2014-11-25 14:55 ` [dpdk-dev] [PATCH 00/10] eal cleanup and new options Thomas Monjalon
2014-11-25 15:06   ` Bruce Richardson

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=20141125105141.GI5260@bricha3-MOBL3 \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.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).