[dpdk-dev] service: add corelist to EAL arguments
Checks
Commit Message
This commit allows the -S (captial 's') to be used to indicate
a corelist for Services. This is a "nice to have" patch, and does
not modify any of the service core functionality.
Suggested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
lib/librte_eal/common/eal_common_options.c | 74 ++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
Comments
Hi Harry,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren
> Sent: Monday, July 17, 2017 4:22 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com; Van Haaren, Harry <harry.van.haaren@intel.com>
> Subject: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
>
> This commit allows the -S (captial 's') to be used to indicate
> a corelist for Services. This is a "nice to have" patch, and does
> not modify any of the service core functionality.
>
> Suggested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> ---
> lib/librte_eal/common/eal_common_options.c | 74 ++++++++++++++++++++++++++++++
> 1 file changed, 74 insertions(+)
>
> diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
> index 00265d6..696a627 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -65,6 +65,7 @@ eal_short_options[] =
> "d:" /* driver */
> "h" /* help */
> "l:" /* corelist */
> + "S:" /* service corelist */
> "m:" /* memory size */
> "n:" /* memory channels */
> "r:" /* memory ranks */
> @@ -402,6 +403,72 @@ eal_parse_coremask(const char *coremask)
> }
>
Do we need a new parsing function here?
Can't we reuse at least part of '-l' parsing code?
Konstantin
> static int
> +eal_parse_service_corelist(const char *corelist)
> +{
> + struct rte_config *cfg = rte_eal_get_configuration();
> + int i, idx = 0;
> + unsigned count = 0;
> + char *end = NULL;
> + int min, max;
> +
> + if (corelist == NULL)
> + return -1;
> +
> + /* Remove all blank characters ahead and after */
> + while (isblank(*corelist))
> + corelist++;
> + i = strlen(corelist);
> + while ((i > 0) && isblank(corelist[i - 1]))
> + i--;
> +
> + /* Get list of cores */
> + min = RTE_MAX_LCORE;
> + do {
> + while (isblank(*corelist))
> + corelist++;
> + if (*corelist == '\0')
> + return -1;
> + errno = 0;
> + idx = strtoul(corelist, &end, 10);
> + if (errno || end == NULL)
> + return -1;
> + while (isblank(*end))
> + end++;
> + if (*end == '-') {
> + min = idx;
> + } else if ((*end == ',') || (*end == '\0')) {
> + max = idx;
> + if (min == RTE_MAX_LCORE)
> + min = idx;
> + for (idx = min; idx <= max; idx++) {
> + if (cfg->lcore_role[idx] != ROLE_SERVICE) {
> + /* handle master lcore already parsed */
> + uint32_t lcore = idx;
> + if (cfg->master_lcore == lcore &&
> + master_lcore_parsed) {
> + RTE_LOG(ERR, EAL,
> + "Error: lcore %u is master lcore, cannot use as service core\n",
> + idx);
> + return -1;
> + }
> + lcore_config[idx].core_role =
> + ROLE_SERVICE;
> + count++;
> + }
> + }
> + min = RTE_MAX_LCORE;
> + } else
> + return -1;
> + corelist = end + 1;
> + } while (*end != '\0');
> +
> + if (count == 0)
> + return -1;
> +
> + return 0;
> +}
> +
> +static int
> eal_parse_corelist(const char *corelist)
> {
> struct rte_config *cfg = rte_eal_get_configuration();
> @@ -912,6 +979,13 @@ eal_parse_common_option(int opt, const char *optarg,
> return -1;
> }
> break;
> + /* service corelist */
> + case 'S':
> + if (eal_parse_service_corelist(optarg) < 0) {
> + RTE_LOG(ERR, EAL, "invalid service core list\n");
> + return -1;
> + }
> + break;
> /* size of memory */
> case 'm':
> conf->memory = atoi(optarg);
> --
> 2.7.4
> From: Ananyev, Konstantin
> Sent: Monday, July 17, 2017 4:54 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>; dev@dpdk.org
> Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com; Van Haaren, Harry
> <harry.van.haaren@intel.com>
> Subject: RE: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
>
> Hi Harry,
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren
> > Sent: Monday, July 17, 2017 4:22 PM
> > To: dev@dpdk.org
> > Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com; Van Haaren, Harry
> <harry.van.haaren@intel.com>
> > Subject: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
> >
> > This commit allows the -S (captial 's') to be used to indicate
> > a corelist for Services. This is a "nice to have" patch, and does
> > not modify any of the service core functionality.
> >
> > Suggested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> > ---
> > lib/librte_eal/common/eal_common_options.c | 74 ++++++++++++++++++++++++++++++
> > 1 file changed, 74 insertions(+)
> >
> > diff --git a/lib/librte_eal/common/eal_common_options.c
> b/lib/librte_eal/common/eal_common_options.c
> > index 00265d6..696a627 100644
> > --- a/lib/librte_eal/common/eal_common_options.c
> > +++ b/lib/librte_eal/common/eal_common_options.c
> > @@ -65,6 +65,7 @@ eal_short_options[] =
> > "d:" /* driver */
> > "h" /* help */
> > "l:" /* corelist */
> > + "S:" /* service corelist */
> > "m:" /* memory size */
> > "n:" /* memory channels */
> > "r:" /* memory ranks */
> > @@ -402,6 +403,72 @@ eal_parse_coremask(const char *coremask)
> > }
> >
>
> Do we need a new parsing function here?
> Can't we reuse at least part of '-l' parsing code?
> Konstantin
Yep we should - in this instance (post-RC2..) I don't want to rock-the-boat and change any existing EAL functionality.
During review of eventdev-sample-app and service-cores, Jerin had noted that we are duplicating various functions for parsing strings, and really we should cleanup into a single function to call from all of them. That should be scheduled as post 17.08 rework.
> -----Original Message-----
> From: Van Haaren, Harry
> Sent: Monday, July 17, 2017 4:58 PM
> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; dev@dpdk.org
> Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com
> Subject: RE: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
>
> > From: Ananyev, Konstantin
> > Sent: Monday, July 17, 2017 4:54 PM
> > To: Van Haaren, Harry <harry.van.haaren@intel.com>; dev@dpdk.org
> > Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com; Van Haaren, Harry
> > <harry.van.haaren@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
> >
> > Hi Harry,
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren
> > > Sent: Monday, July 17, 2017 4:22 PM
> > > To: dev@dpdk.org
> > > Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com; Van Haaren, Harry
> > <harry.van.haaren@intel.com>
> > > Subject: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
> > >
> > > This commit allows the -S (captial 's') to be used to indicate
> > > a corelist for Services. This is a "nice to have" patch, and does
> > > not modify any of the service core functionality.
> > >
> > > Suggested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > > Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> > > ---
> > > lib/librte_eal/common/eal_common_options.c | 74 ++++++++++++++++++++++++++++++
> > > 1 file changed, 74 insertions(+)
> > >
> > > diff --git a/lib/librte_eal/common/eal_common_options.c
> > b/lib/librte_eal/common/eal_common_options.c
> > > index 00265d6..696a627 100644
> > > --- a/lib/librte_eal/common/eal_common_options.c
> > > +++ b/lib/librte_eal/common/eal_common_options.c
> > > @@ -65,6 +65,7 @@ eal_short_options[] =
> > > "d:" /* driver */
> > > "h" /* help */
> > > "l:" /* corelist */
> > > + "S:" /* service corelist */
> > > "m:" /* memory size */
> > > "n:" /* memory channels */
> > > "r:" /* memory ranks */
> > > @@ -402,6 +403,72 @@ eal_parse_coremask(const char *coremask)
> > > }
> > >
> >
> > Do we need a new parsing function here?
> > Can't we reuse at least part of '-l' parsing code?
> > Konstantin
>
>
> Yep we should - in this instance (post-RC2..) I don't want to rock-the-boat and change any existing EAL functionality.
>
> During review of eventdev-sample-app and service-cores, Jerin had noted that we are duplicating various functions for parsing strings, and
> really we should cleanup into a single function to call from all of them. That should be scheduled as post 17.08 rework.
Sound ok to me then.
Konstantin
> From: Ananyev, Konstantin
> Sent: Monday, July 17, 2017 5:11 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>; dev@dpdk.org
> Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com
> Subject: RE: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
>
>
>
> > -----Original Message-----
> > From: Van Haaren, Harry
> > Sent: Monday, July 17, 2017 4:58 PM
> > To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; dev@dpdk.org
> > Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com
> > Subject: RE: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
> >
> > > From: Ananyev, Konstantin
> > > Sent: Monday, July 17, 2017 4:54 PM
> > > To: Van Haaren, Harry <harry.van.haaren@intel.com>; dev@dpdk.org
> > > Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com; Van Haaren, Harry
> > > <harry.van.haaren@intel.com>
> > > Subject: RE: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
> > >
> > > Hi Harry,
> > >
> > > > -----Original Message-----
> > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren
> > > > Sent: Monday, July 17, 2017 4:22 PM
> > > > To: dev@dpdk.org
> > > > Cc: thomas@monjalon.net; jerin.jacob@caviumnetworks.com; Van Haaren, Harry
> > > <harry.van.haaren@intel.com>
> > > > Subject: [dpdk-dev] [PATCH] service: add corelist to EAL arguments
> > > >
> > > > This commit allows the -S (captial 's') to be used to indicate
> > > > a corelist for Services. This is a "nice to have" patch, and does
> > > > not modify any of the service core functionality.
> > > >
> > > > Suggested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > > > Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> > > > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> > > > ---
> > > > lib/librte_eal/common/eal_common_options.c | 74 ++++++++++++++++++++++++++++++
> > > > 1 file changed, 74 insertions(+)
> > > >
> > > > diff --git a/lib/librte_eal/common/eal_common_options.c
> > > b/lib/librte_eal/common/eal_common_options.c
> > > > index 00265d6..696a627 100644
> > > > --- a/lib/librte_eal/common/eal_common_options.c
> > > > +++ b/lib/librte_eal/common/eal_common_options.c
> > > > @@ -65,6 +65,7 @@ eal_short_options[] =
> > > > "d:" /* driver */
> > > > "h" /* help */
> > > > "l:" /* corelist */
> > > > + "S:" /* service corelist */
> > > > "m:" /* memory size */
> > > > "n:" /* memory channels */
> > > > "r:" /* memory ranks */
> > > > @@ -402,6 +403,72 @@ eal_parse_coremask(const char *coremask)
> > > > }
> > > >
> > >
> > > Do we need a new parsing function here?
> > > Can't we reuse at least part of '-l' parsing code?
> > > Konstantin
> >
> >
> > Yep we should - in this instance (post-RC2..) I don't want to rock-the-boat and change
> any existing EAL functionality.
> >
> > During review of eventdev-sample-app and service-cores, Jerin had noted that we are
> duplicating various functions for parsing strings, and
> > really we should cleanup into a single function to call from all of them. That should be
> scheduled as post 17.08 rework.
>
> Sound ok to me then.
Cool. I should note; good point, absolutely agree, and thanks for review :)
17/07/2017 18:21, Harry van Haaren:
> This commit allows the -S (captial 's') to be used to indicate
> a corelist for Services. This is a "nice to have" patch, and does
> not modify any of the service core functionality.
>
> Suggested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Applied, thanks
@@ -65,6 +65,7 @@ eal_short_options[] =
"d:" /* driver */
"h" /* help */
"l:" /* corelist */
+ "S:" /* service corelist */
"m:" /* memory size */
"n:" /* memory channels */
"r:" /* memory ranks */
@@ -402,6 +403,72 @@ eal_parse_coremask(const char *coremask)
}
static int
+eal_parse_service_corelist(const char *corelist)
+{
+ struct rte_config *cfg = rte_eal_get_configuration();
+ int i, idx = 0;
+ unsigned count = 0;
+ char *end = NULL;
+ int min, max;
+
+ if (corelist == NULL)
+ return -1;
+
+ /* Remove all blank characters ahead and after */
+ while (isblank(*corelist))
+ corelist++;
+ i = strlen(corelist);
+ while ((i > 0) && isblank(corelist[i - 1]))
+ i--;
+
+ /* Get list of cores */
+ min = RTE_MAX_LCORE;
+ do {
+ while (isblank(*corelist))
+ corelist++;
+ if (*corelist == '\0')
+ return -1;
+ errno = 0;
+ idx = strtoul(corelist, &end, 10);
+ if (errno || end == NULL)
+ return -1;
+ while (isblank(*end))
+ end++;
+ if (*end == '-') {
+ min = idx;
+ } else if ((*end == ',') || (*end == '\0')) {
+ max = idx;
+ if (min == RTE_MAX_LCORE)
+ min = idx;
+ for (idx = min; idx <= max; idx++) {
+ if (cfg->lcore_role[idx] != ROLE_SERVICE) {
+ /* handle master lcore already parsed */
+ uint32_t lcore = idx;
+ if (cfg->master_lcore == lcore &&
+ master_lcore_parsed) {
+ RTE_LOG(ERR, EAL,
+ "Error: lcore %u is master lcore, cannot use as service core\n",
+ idx);
+ return -1;
+ }
+ lcore_config[idx].core_role =
+ ROLE_SERVICE;
+ count++;
+ }
+ }
+ min = RTE_MAX_LCORE;
+ } else
+ return -1;
+ corelist = end + 1;
+ } while (*end != '\0');
+
+ if (count == 0)
+ return -1;
+
+ return 0;
+}
+
+static int
eal_parse_corelist(const char *corelist)
{
struct rte_config *cfg = rte_eal_get_configuration();
@@ -912,6 +979,13 @@ eal_parse_common_option(int opt, const char *optarg,
return -1;
}
break;
+ /* service corelist */
+ case 'S':
+ if (eal_parse_service_corelist(optarg) < 0) {
+ RTE_LOG(ERR, EAL, "invalid service core list\n");
+ return -1;
+ }
+ break;
/* size of memory */
case 'm':
conf->memory = atoi(optarg);