DPDK patches and discussions
 help / color / mirror / Atom feed
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: Thomas Monjalon <thomas.monjalon@6wind.com>, <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 10/10] eal: add option --master-lcore
Date: Tue, 25 Nov 2014 10:09:42 +0100	[thread overview]
Message-ID: <54744756.4010207@neclab.eu> (raw)
In-Reply-To: <1416692622-28886-11-git-send-email-thomas.monjalon@6wind.com>

Hi Thomas,

thanks for your work. I have one (minor) comment for this patch that 
should be fixed in a later version.

Acknowledged.


Thanks,

Simon

On 22.11.2014 22:43, Thomas Monjalon wrote:
> From: Simon Kuenzer <simon.kuenzer@neclab.eu>
>
> Enable users to specify the lcore id that is used as master lcore.
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> ---
>   app/test/test.c                            |  1 +
>   app/test/test_eal_flags.c                  | 51 ++++++++++++++++++++++++++++++
>   lib/librte_eal/common/eal_common_options.c | 39 ++++++++++++++++++++---
>   lib/librte_eal/common/eal_options.h        |  2 ++
>   4 files changed, 89 insertions(+), 4 deletions(-)
>
> diff --git a/app/test/test.c b/app/test/test.c
> index 9bee6bb..2fecff5 100644
> --- a/app/test/test.c
> +++ b/app/test/test.c
> @@ -82,6 +82,7 @@ do_recursive_call(void)
>   	} actions[] =  {
>   			{ "run_secondary_instances", test_mp_secondary },
>   			{ "test_missing_c_flag", no_action },
> +			{ "test_master_lcore_flag", no_action },
>   			{ "test_missing_n_flag", no_action },
>   			{ "test_no_hpet_flag", no_action },
>   			{ "test_whitelist_flag", no_action },
> diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
> index 5ad89c5..6a6ef08 100644
> --- a/app/test/test_eal_flags.c
> +++ b/app/test/test_eal_flags.c
> @@ -549,6 +549,51 @@ test_missing_c_flag(void)
>   }
>
>   /*
> + * Test --master-lcore option with matching coremask
> + */
> +static int
> +test_master_lcore_flag(void)
> +{
> +#ifdef RTE_EXEC_ENV_BSDAPP
> +	/* BSD target doesn't support prefixes at this point */
> +	const char *prefix = "";
> +#else
> +	char prefix[PATH_MAX], tmp[PATH_MAX];
> +	if (get_current_prefix(tmp, sizeof(tmp)) == NULL) {
> +		printf("Error - unable to get current prefix!\n");
> +		return -1;
> +	}
> +	snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
> +#endif
> +
> +	/* --master-lcore flag but no value */
> +	const char *argv1[] = { prgname, prefix, mp_flag, "-n", "1", "-c", "3", "--master-lcore"};
> +	/* --master-lcore flag with invalid value */
> +	const char *argv2[] = { prgname, prefix, mp_flag, "-n", "1", "-c", "3", "--master-lcore", "-1"};
> +	const char *argv3[] = { prgname, prefix, mp_flag, "-n", "1", "-c", "3", "--master-lcore", "X"};
> +	/* master lcore not in coremask */
> +	const char *argv4[] = { prgname, prefix, mp_flag, "-n", "1", "-c", "3", "--master-lcore", "2"};
> +	/* valid value */
> +	const char *argv5[] = { prgname, prefix, mp_flag, "-n", "1", "-c", "3", "--master-lcore", "1"};
> +	/* valid value set before coremask */
> +	const char *argv6[] = { prgname, prefix, mp_flag, "-n", "1", "--master-lcore", "1", "-c", "3"};
> +
> +	if (launch_proc(argv1) == 0
> +			|| launch_proc(argv2) == 0
> +			|| launch_proc(argv3) == 0
> +			|| launch_proc(argv4) == 0) {
> +		printf("Error - process ran without error with wrong --master-lcore\n");
> +		return -1;
> +	}
> +	if (launch_proc(argv5) != 0
> +			|| launch_proc(argv6) != 0) {
> +		printf("Error - process did not run ok with valid --master-lcore\n");
> +		return -1;
> +	}
> +	return 0;
> +}
> +
> +/*
>    * Test that the app doesn't run without the -n flag. In all cases
>    * should give an error and fail to run.
>    * Since -n is not compulsory for MP, we instead use --no-huge and --no-shconf
> @@ -1237,6 +1282,12 @@ test_eal_flags(void)
>   		return ret;
>   	}
>
> +	ret = test_master_lcore_flag();
> +	if (ret < 0) {
> +		printf("Error in test_master_lcore_flag()\n");
> +		return ret;
> +	}
> +
>   	ret = test_missing_n_flag();
>   	if (ret < 0) {
>   		printf("Error in test_missing_n_flag()\n");
> diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
> index c9df8f5..54bd31d 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -67,6 +67,7 @@ eal_short_options[] =
>   const struct option
>   eal_long_options[] = {
>   	{OPT_HUGE_DIR, 1, 0, OPT_HUGE_DIR_NUM},
> +	{OPT_MASTER_LCORE, 1, 0, OPT_MASTER_LCORE_NUM},
>   	{OPT_PROC_TYPE, 1, 0, OPT_PROC_TYPE_NUM},
>   	{OPT_NO_SHCONF, 0, 0, OPT_NO_SHCONF_NUM},
>   	{OPT_NO_HPET, 0, 0, OPT_NO_HPET_NUM},
> @@ -186,8 +187,6 @@ eal_parse_coremask(const char *coremask)
>   				}
>   				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;
> @@ -257,8 +256,6 @@ eal_parse_corelist(const char *corelist)
>   			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++;
>   			}
>   			min = RTE_MAX_LCORE;
> @@ -274,6 +271,22 @@ eal_parse_corelist(const char *corelist)
>   	return 0;
>   }
>
> +/* Changes the lcore id of the master thread */
> +static int
> +eal_parse_master_lcore(const char *arg)
> +{
> +	char *parsing_end;
> +	struct rte_config *cfg = rte_eal_get_configuration();
> +
> +	errno = 0;
> +	cfg->master_lcore = (uint32_t) strtol(arg, &parsing_end, 0);
> +	if (errno || parsing_end[0] != 0)
> +		return -1;
> +	if (cfg->master_lcore >= RTE_MAX_LCORE)
> +		return -1;
> +	return 0;
> +}
> +
>   static int
>   eal_parse_syslog(const char *facility, struct internal_config *conf)
>   {
> @@ -439,6 +452,14 @@ eal_parse_common_option(int opt, const char *optarg,
>   		conf->process_type = eal_parse_proc_type(optarg);
>   		break;
>
> +	case OPT_MASTER_LCORE_NUM:
> +		if (eal_parse_master_lcore(optarg) < 0) {
> +			RTE_LOG(ERR, EAL, "invalid parameter for --"
> +					OPT_MASTER_LCORE "\n");
> +			return -1;
> +		}
> +		break;
> +
>   	case OPT_VDEV_NUM:
>   		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
>   				optarg) < 0) {
> @@ -480,10 +501,15 @@ int
>   eal_adjust_config(struct internal_config *internal_cfg)
>   {
>   	int i;
> +	struct rte_config *cfg = rte_eal_get_configuration();
>
>   	if (internal_config.process_type == RTE_PROC_AUTO)
>   		internal_config.process_type = eal_proc_type_detect();
>
> +	/* default master lcore is the first one */
> +	if (cfg->master_lcore == 0)
> +		cfg->master_lcore = rte_get_next_lcore(-1, 0, 0);
> +

Might be confusing if a user specifies --master-lcore 0 and uses a 
coremask/corelist where core id 0 is not specified.
What about setting cfg->master_lcore to (RTE_MAX_LCORE + 1) on 
initialization in order to distinguish if a master_lcore got specified 
by the user or not?

>   	/* if no memory amounts were requested, this will result in 0 and
>   	 * will be overridden later, right after eal_hugepage_info_init() */
>   	for (i = 0; i < RTE_MAX_NUMA_NODES; i++)
> @@ -502,6 +528,10 @@ eal_check_common_options(struct internal_config *internal_cfg)
>   			"-c or -l\n");
>   		return -1;
>   	}
> +	if (cfg->lcore_role[cfg->master_lcore] != ROLE_RTE) {
> +		RTE_LOG(ERR, EAL, "Master lcore is not enabled for DPDK\n");
> +		return -1;
> +	}
>
>   	if (internal_cfg->process_type == RTE_PROC_INVALID) {
>   		RTE_LOG(ERR, EAL, "Invalid process type specified\n");
> @@ -550,6 +580,7 @@ eal_common_usage(void)
>   	       "  -l CORELIST  : List of cores to run on\n"
>   	       "                 The argument format is <c1>[-c2][,c3[-c4],...]\n"
>   	       "                 where c1, c2, etc are core indexes between 0 and %d\n"
> +	       "  --"OPT_MASTER_LCORE" ID: Core ID that is used as master\n"
>   	       "  -n NUM       : Number of memory channels\n"
>   	       "  -v           : Display version information on startup\n"
>   	       "  -m MB        : memory to allocate (see also --"OPT_SOCKET_MEM")\n"
> diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
> index f58965c..e476f8d 100644
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -45,6 +45,8 @@ enum {
>   	OPT_LONG_MIN_NUM = 256,
>   #define OPT_HUGE_DIR    "huge-dir"
>   	OPT_HUGE_DIR_NUM = OPT_LONG_MIN_NUM,
> +#define OPT_MASTER_LCORE "master-lcore"
> +	OPT_MASTER_LCORE_NUM,
>   #define OPT_PROC_TYPE   "proc-type"
>   	OPT_PROC_TYPE_NUM,
>   #define OPT_NO_SHCONF   "no-shconf"
>

  reply	other threads:[~2014-11-25  8:59 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
2014-11-22 21:43 ` [dpdk-dev] [PATCH 10/10] eal: add option --master-lcore Thomas Monjalon
2014-11-25  9:09   ` Simon Kuenzer [this message]
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=54744756.4010207@neclab.eu \
    --to=simon.kuenzer@neclab.eu \
    --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).