[dpdk-dev,v3,4/4] eal: fix end character check in --lcores argument

Message ID 1469618870-144592-1-git-send-email-wei.dai@intel.com (mailing list archive)
State Rejected, archived
Headers

Commit Message

Wei Dai July 27, 2016, 11:27 a.m. UTC
  With --lcores 'a-b@c-d', eal_parse_cores() fails because
eal_parse_set() fails due to the next character after
lcore set a-b, which is '@'and not ',' or '\0'.
There is also a right check immediately
after this incorrect check.

Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 lib/librte_eal/common/eal_common_options.c | 2 --
 1 file changed, 2 deletions(-)
  

Comments

Ferruh Yigit July 28, 2016, 3:26 p.m. UTC | #1
On 7/27/2016 12:27 PM, Wei Dai wrote:
> With --lcores 'a-b@c-d', eal_parse_cores() fails because
> eal_parse_set() fails due to the next character after
> lcore set a-b, which is '@'and not ',' or '\0'.
> There is also a right check immediately
> after this incorrect check.
> 
> Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>

I am not sure if a-b@c-d syntax should be supported. (a-b)@(c-d) is
supported and already working.

It looks like a-b is only planned to use without @

and the usage a-b@c-d, like 1-2@4-5 implies to me:
1 -> 4
2 -> 5

but it doesn't work that way, it is always grouped after @, like it has
parenthesis, what it does is:
1 -> 4,5
2 -> 4,5

Even a-b@c is not working, but as I said if @ will be used, using
grouping seems more proper to me, like:
(a-b)@(c-d)
(a-b)@c

So this is mainly about defining the syntax, more than implementing it.
Somebody know more about syntax can comment better.

Regards,
ferruh
  
Thomas Monjalon July 28, 2016, 4:05 p.m. UTC | #2
2016-07-28 16:26, Ferruh Yigit:
> On 7/27/2016 12:27 PM, Wei Dai wrote:
> > With --lcores 'a-b@c-d', eal_parse_cores() fails because
> > eal_parse_set() fails due to the next character after
> > lcore set a-b, which is '@'and not ',' or '\0'.
> > There is also a right check immediately
> > after this incorrect check.
> > 
> > Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")
> > 
> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> 
> I am not sure if a-b@c-d syntax should be supported. (a-b)@(c-d) is
> supported and already working.

Agreed.

Series applied, except this last patch 4, thanks
  
Wei Dai Aug. 2, 2016, 8:22 a.m. UTC | #3
Hi, Thomas, Yigit

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, July 29, 2016 12:06 AM
> To: Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v3 4/4] eal: fix end character check in --lcores
> argument
> 
> 2016-07-28 16:26, Ferruh Yigit:
> > On 7/27/2016 12:27 PM, Wei Dai wrote:
> > > With --lcores 'a-b@c-d', eal_parse_cores() fails because
> > > eal_parse_set() fails due to the next character after lcore set a-b,
> > > which is '@'and not ',' or '\0'.
> > > There is also a right check immediately after this incorrect check.
> > >
> > > Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")
> > >
> > > Signed-off-by: Wei Dai <wei.dai@intel.com>
> >
> > I am not sure if a-b@c-d syntax should be supported. (a-b)@(c-d) is
> > supported and already working.
> 
> Agreed.
> 
> Series applied, except this last patch 4, thanks

Sorry, I can't find any document to clarify whether a-b@c-d shoule be supported.
So I design following case to verify all kinds of combination of - and @. 
I tested my patch with --lcores '0-3@12-15, 4-7@(8-11),  (8-11)@4-7, (12-15)@(0-3), 16-19, (20-23) ',
After calling eal_parse_args(argc, argv),  I observed lcore_config[i].cpuset to check cpuset of each lcore.
I added following codes immediately after calling fctret = eal_parse_args(argc, argv); in function rte_eal_init( )
in eal.c to check this patch.

	{
		struct rte_config *p;
		const char *rte_role_str[2] = {"ROLE_RTE", "ROLE_OFF"};
		p = rte_eal_get_configuration();
		for (i=0; i<28; i++) {
			printf("lcore %2d status = %s,  runs on cpuset = 0x%08lX\n", 
					i, rte_role_str[p->lcore_role[i]], lcore_config[i].cpuset.__bits[0]);
		}
	}

The result is as follow:
lcore  0 status = ROLE_RTE,  runs on cpuset = 0x0000F000
lcore  1 status = ROLE_RTE,  runs on cpuset = 0x0000F000
lcore  2 status = ROLE_RTE,  runs on cpuset = 0x0000F000
lcore  3 status = ROLE_RTE,  runs on cpuset = 0x0000F000
lcore  4 status = ROLE_RTE,  runs on cpuset = 0x00000F00
lcore  5 status = ROLE_RTE,  runs on cpuset = 0x00000F00
lcore  6 status = ROLE_RTE,  runs on cpuset = 0x00000F00
lcore  7 status = ROLE_RTE,  runs on cpuset = 0x00000F00
lcore  8 status = ROLE_RTE,  runs on cpuset = 0x000000F0
lcore  9 status = ROLE_RTE,  runs on cpuset = 0x000000F0
lcore 10 status = ROLE_RTE,  runs on cpuset = 0x000000F0
lcore 11 status = ROLE_RTE,  runs on cpuset = 0x000000F0
lcore 12 status = ROLE_RTE,  runs on cpuset = 0x0000000F
lcore 13 status = ROLE_RTE,  runs on cpuset = 0x0000000F
lcore 14 status = ROLE_RTE,  runs on cpuset = 0x0000000F
lcore 15 status = ROLE_RTE,  runs on cpuset = 0x0000000F
lcore 16 status = ROLE_RTE,  runs on cpuset = 0x00010000
lcore 17 status = ROLE_RTE,  runs on cpuset = 0x00020000
lcore 18 status = ROLE_RTE,  runs on cpuset = 0x00040000
lcore 19 status = ROLE_RTE,  runs on cpuset = 0x00080000
lcore 20 status = ROLE_RTE,  runs on cpuset = 0x00F00000
lcore 21 status = ROLE_RTE,  runs on cpuset = 0x00F00000
lcore 22 status = ROLE_RTE,  runs on cpuset = 0x00F00000
lcore 23 status = ROLE_RTE,  runs on cpuset = 0x00F00000
lcore 24 status = ROLE_OFF,  runs on cpuset = 0x00000000
lcore 25 status = ROLE_OFF,  runs on cpuset = 0x00000000
lcore 26 status = ROLE_OFF,  runs on cpuset = 0x00000000
lcore 27 status = ROLE_OFF,  runs on cpuset = 0x00000000
  
Thomas Monjalon Aug. 2, 2016, 10:45 a.m. UTC | #4
2016-08-02 08:22, Dai, Wei:
> Hi, Thomas, Yigit
> 
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2016-07-28 16:26, Ferruh Yigit:
> > > On 7/27/2016 12:27 PM, Wei Dai wrote:
> > > > With --lcores 'a-b@c-d', eal_parse_cores() fails because
> > > > eal_parse_set() fails due to the next character after lcore set a-b,
> > > > which is '@'and not ',' or '\0'.
> > > > There is also a right check immediately after this incorrect check.
> > > >
> > > > Fixes: 53e54bf81700 ("eal: new option --lcores for cpu assignment")
> > > >
> > > > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > >
> > > I am not sure if a-b@c-d syntax should be supported. (a-b)@(c-d) is
> > > supported and already working.
> > 
> > Agreed.
> > 
> > Series applied, except this last patch 4, thanks
> 
> Sorry, I can't find any document to clarify whether a-b@c-d shoule be supported.
> So I design following case to verify all kinds of combination of - and @. 
> I tested my patch with --lcores '0-3@12-15, 4-7@(8-11),  (8-11)@4-7, (12-15)@(0-3), 16-19, (20-23) ',

OK. So do you agree we can discard this patch and forget this syntax?
  

Patch

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 1a1bab3..f443a61 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -469,8 +469,6 @@  eal_parse_set(const char *input, uint16_t set[], unsigned num)
 				max = idx;
 				while (isblank(*end))
 					end++;
-				if (*end != ',' && *end != '\0')
-					return -1;
 			}
 
 			if (*end != ',' && *end != '\0' &&