[v7,9/9] eal: add minimum viable code to support parsing

Message ID 20200201000406.11060-10-pallavi.kadam@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Windows patchset with additional EAL functionalities |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/Intel-compilation fail apply issues

Commit Message

Kadam, Pallavi Feb. 1, 2020, 12:04 a.m. UTC
  Adding specific logic for eal.c to support parsing on
Windows.

Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
Reviewed-by: Keith Wiles <keith.wiles@intel.com>
---
 lib/librte_eal/windows/eal/eal.c | 133 ++++++++++++++++++++++++++++++-
 1 file changed, 130 insertions(+), 3 deletions(-)
  

Comments

Dmitry Kozlyuk Feb. 5, 2020, 7:54 p.m. UTC | #1
Crashes at argument parsing, WinDbg log attached.
  
Kadam, Pallavi Feb. 6, 2020, 12:39 a.m. UTC | #2
On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:
> Crashes at argument parsing, WinDbg log attached.

This patch works fine with meson=0.49.
I was able to execute the 'helloworld' app.

When I tried to build with meson=0.52 it failed with the error:
[9/25] Linking target lib/librte_kvargs-20.0.dll.
FAILED: lib/librte_kvargs-20.0.dll
clang @lib/librte_kvargs-20.0.dll.rsp
clang: error: no such file or directory: '/OPT:REF'

Not completely sure, if this could be the reason for the crash.

>
  
Kadam, Pallavi Feb. 6, 2020, 1:39 a.m. UTC | #3
On 2/5/2020 4:39 PM, Pallavi Kadam wrote:
>
>
> On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:
>> Crashes at argument parsing, WinDbg log attached.
> This patch works fine with meson=0.49.
> I was able to execute the 'helloworld' app.
>
> When I tried to build with meson=0.52 it failed with the error:
> [9/25] Linking target lib/librte_kvargs-20.0.dll.
> FAILED: lib/librte_kvargs-20.0.dll
> clang @lib/librte_kvargs-20.0.dll.rsp
> clang: error: no such file or directory: '/OPT:REF'

Fixed this error with the patch you sent before.
were able to execute parsing:

$ ./build/examples/dpdk-helloworld.exe -l 4-8
EAL: Detected 20 lcore(s)
EAL: Detected 2 NUMA nodes
hello from core 5
hello from core 6
hello from core 7
hello from core 8
hello from core 4

>
> Not completely sure, if this could be the reason for the crash.
  
Thomas Monjalon Feb. 6, 2020, 2:11 a.m. UTC | #4
06/02/2020 02:39, Pallavi Kadam:
> On 2/5/2020 4:39 PM, Pallavi Kadam wrote:
> > On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:
> >> Crashes at argument parsing, WinDbg log attached.
> > This patch works fine with meson=0.49.
> > I was able to execute the 'helloworld' app.
> >
> > When I tried to build with meson=0.52 it failed with the error:
> > [9/25] Linking target lib/librte_kvargs-20.0.dll.
> > FAILED: lib/librte_kvargs-20.0.dll
> > clang @lib/librte_kvargs-20.0.dll.rsp
> > clang: error: no such file or directory: '/OPT:REF'
> 
> Fixed this error with the patch you sent before.

Which patch?
Please ack the patch so I can merge it.
  
Kadam, Pallavi Feb. 6, 2020, 3:18 a.m. UTC | #5
On 2/5/2020 6:11 PM, Thomas Monjalon wrote:
> 06/02/2020 02:39, Pallavi Kadam:
>> On 2/5/2020 4:39 PM, Pallavi Kadam wrote:
>>> On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:
>>>> Crashes at argument parsing, WinDbg log attached.
>>> This patch works fine with meson=0.49.
>>> I was able to execute the 'helloworld' app.
>>>
>>> When I tried to build with meson=0.52 it failed with the error:
>>> [9/25] Linking target lib/librte_kvargs-20.0.dll.
>>> FAILED: lib/librte_kvargs-20.0.dll
>>> clang @lib/librte_kvargs-20.0.dll.rsp
>>> clang: error: no such file or directory: '/OPT:REF'
>> Fixed this error with the patch you sent before.
> Which patch?
> Please ack the patch so I can merge it.

The patch below fixes the meson error:
clang: error: no such file or directory: '/OPT:REF'

https://github.com/mesonbuild/meson/pull/6483 @Dmitry, Can you please 
confirm if you can still see the crash?

>
>
>
  
Dmitry Kozlyuk Feb. 6, 2020, 6:41 a.m. UTC | #6
> On 2/5/2020 4:39 PM, Pallavi Kadam wrote:
> >
> >
> > On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:  
> >> Crashes at argument parsing, WinDbg log attached.  
> > This patch works fine with meson=0.49.
> > I was able to execute the 'helloworld' app.
> >
> > When I tried to build with meson=0.52 it failed with the error:
> > [9/25] Linking target lib/librte_kvargs-20.0.dll.
> > FAILED: lib/librte_kvargs-20.0.dll
> > clang @lib/librte_kvargs-20.0.dll.rsp
> > clang: error: no such file or directory: '/OPT:REF'  
> 
> Fixed this error with the patch you sent before.
> were able to execute parsing:
> 
> $ ./build/examples/dpdk-helloworld.exe -l 4-8
> EAL: Detected 20 lcore(s)
> EAL: Detected 2 NUMA nodes
> hello from core 5
> hello from core 6
> hello from core 7
> hello from core 8
> hello from core 4
> 
> >
> > Not completely sure, if this could be the reason for the crash.  

The crash does not happen with any arguments, "-l 4-8" works fine as do
"-cf" and "-v", but "--log-level=eal:8" crashes reproducibly. I assume
application should not crash on invalid options, but report an error and exit.
For the reference, I applied your patchset to the latest dpdk:master.

Z:\>build\native\clang\examples\dpdk-helloworld.exe
EAL: Detected 4 lcore(s)
EAL: Detected 1 NUMA nodes

	OK, no lcores specified.

Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf
EAL: Detected 4 lcore(s)
EAL: Detected 1 NUMA nodes
hello from core 1
hello from core 2
hello from core 3
hello from core 0

	OK, 4 lcores enabled.

Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf --log-level=eal:8

	Crash, WinDbg log attached to bug report.

Z:\>echo %errorlevel%
-1073741819

Z:\>

Attaching the build log, but I don't think it matters, it's something with
getopt implementation or it's use, judging by stack trace.

P.S. I can also see "--syslog" option in the help message, you should
probably hide it via #ifndef, as you did with said option handling.
  
Thomas Monjalon Feb. 6, 2020, 9:26 a.m. UTC | #7
As discussed in community meeting, the goal was to have core parsing
in Windows EAL 20.02.
Given that there is a crash and a doubt on the imported getopt library,
I think it's better to postpone this series to 20.05.


06/02/2020 07:41, Dmitry Kozlyuk:
> > On 2/5/2020 4:39 PM, Pallavi Kadam wrote:
> > > On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:  
> > >> Crashes at argument parsing, WinDbg log attached.  
> > > This patch works fine with meson=0.49.
> > > I was able to execute the 'helloworld' app.
> > >
> > > When I tried to build with meson=0.52 it failed with the error:
> > > [9/25] Linking target lib/librte_kvargs-20.0.dll.
> > > FAILED: lib/librte_kvargs-20.0.dll
> > > clang @lib/librte_kvargs-20.0.dll.rsp
> > > clang: error: no such file or directory: '/OPT:REF'  
> > 
> > Fixed this error with the patch you sent before.
> > were able to execute parsing:
> > 
> > $ ./build/examples/dpdk-helloworld.exe -l 4-8
> > EAL: Detected 20 lcore(s)
> > EAL: Detected 2 NUMA nodes
> > hello from core 5
> > hello from core 6
> > hello from core 7
> > hello from core 8
> > hello from core 4
> > 
> > >
> > > Not completely sure, if this could be the reason for the crash.  
> 
> The crash does not happen with any arguments, "-l 4-8" works fine as do
> "-cf" and "-v", but "--log-level=eal:8" crashes reproducibly. I assume
> application should not crash on invalid options, but report an error and exit.
> For the reference, I applied your patchset to the latest dpdk:master.
> 
> Z:\>build\native\clang\examples\dpdk-helloworld.exe
> EAL: Detected 4 lcore(s)
> EAL: Detected 1 NUMA nodes
> 
> 	OK, no lcores specified.
> 
> Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf
> EAL: Detected 4 lcore(s)
> EAL: Detected 1 NUMA nodes
> hello from core 1
> hello from core 2
> hello from core 3
> hello from core 0
> 
> 	OK, 4 lcores enabled.
> 
> Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf --log-level=eal:8
> 
> 	Crash, WinDbg log attached to bug report.
> 
> Z:\>echo %errorlevel%
> -1073741819
> 
> Z:\>
> 
> Attaching the build log, but I don't think it matters, it's something with
> getopt implementation or it's use, judging by stack trace.
> 
> P.S. I can also see "--syslog" option in the help message, you should
> probably hide it via #ifndef, as you did with said option handling.
  
Kadam, Pallavi Feb. 7, 2020, 3:45 a.m. UTC | #8
Hi Dmitry,

On 2/5/2020 10:41 PM, Dmitry Kozlyuk wrote:
>
>> On 2/5/2020 4:39 PM, Pallavi Kadam wrote:
>>>
>>> On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:
>>>> Crashes at argument parsing, WinDbg log attached.
>>> This patch works fine with meson=0.49.
>>> I was able to execute the 'helloworld' app.
>>>
>>> When I tried to build with meson=0.52 it failed with the error:
>>> [9/25] Linking target lib/librte_kvargs-20.0.dll.
>>> FAILED: lib/librte_kvargs-20.0.dll
>>> clang @lib/librte_kvargs-20.0.dll.rsp
>>> clang: error: no such file or directory: '/OPT:REF'
>> Fixed this error with the patch you sent before.
>> were able to execute parsing:
>>
>> $ ./build/examples/dpdk-helloworld.exe -l 4-8
>> EAL: Detected 20 lcore(s)
>> EAL: Detected 2 NUMA nodes
>> hello from core 5
>> hello from core 6
>> hello from core 7
>> hello from core 8
>> hello from core 4
>>
>>> Not completely sure, if this could be the reason for the crash.
> The crash does not happen with any arguments, "-l 4-8" works fine as do
> "-cf" and "-v", but "--log-level=eal:8" crashes reproducibly. I assume
> application should not crash on invalid options, but report an error and exit.
> For the reference, I applied your patchset to the latest dpdk:master.
>
> Z:\>build\native\clang\examples\dpdk-helloworld.exe
> EAL: Detected 4 lcore(s)
> EAL: Detected 1 NUMA nodes
>
> 	OK, no lcores specified.
>
> Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf
> EAL: Detected 4 lcore(s)
> EAL: Detected 1 NUMA nodes
> hello from core 1
> hello from core 2
> hello from core 3
> hello from core 0
>
> 	OK, 4 lcores enabled.
>
> Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf --log-level=eal:8
>
> 	Crash, WinDbg log attached to bug report.
>
> Z:\>echo %errorlevel%
> -1073741819
>
> Z:\>
>
> Attaching the build log, but I don't think it matters, it's something with
> getopt implementation or it's use, judging by stack trace.

Thanks for the detailed log.
There was bit size issue in getopt file. We fixed the issue.
Please try v8 and let us know.

>
> P.S. I can also see "--syslog" option in the help message, you should
> probably hide it via #ifndef, as you did with said option handling.

Incorporated in v8. Thanks

>
  
Menon, Ranjit Feb. 7, 2020, 4:46 p.m. UTC | #9
On 2/6/2020 1:26 AM, Thomas Monjalon wrote:
> As discussed in community meeting, the goal was to have core parsing
> in Windows EAL 20.02.
> Given that there is a crash and a doubt on the imported getopt library,
> I think it's better to postpone this series to 20.05.
> 
> 

Thomas...
We have fixed the crash in the v8 series of this patch - Pallavi sent it 
out for review last night. (It was a simple fix)

Can we please get this merged into 20.02? It would be great to progress 
Windows support in this release. (The initial Windows support was merged 
in 19.02, so it's been a year since we moved it forward! :-))

thanks,

Ranjit
  
Menon, Ranjit Feb. 7, 2020, 5:17 p.m. UTC | #10
On 2/7/2020 8:46 AM, Ranjit Menon wrote:
> On 2/6/2020 1:26 AM, Thomas Monjalon wrote:
> > As discussed in community meeting, the goal was to have core parsing
> > in Windows EAL 20.02.
> > Given that there is a crash and a doubt on the imported getopt library,
> > I think it's better to postpone this series to 20.05.
> >
> >
>
> Thomas...
> We have fixed the crash in the v8 series of this patch - Pallavi sent it
> out for review last night. (It was a simple fix)
>
> Can we please get this merged into 20.02? It would be great to progress
> Windows support in this release. (The initial Windows support was merged
> in 19.02, so it's been a year since we moved it forward! :-))
>
> thanks,
>
> Ranjit
Sorry, I believe the initial patches were merged in 19.05, still a long time!

@Dmitry: If you could do some rudimentary tests and ACK the v8 series of this patch, it would be very helpful.
thanks,

Ranjit
  
Narcisa Ana Maria Vasile Feb. 8, 2020, 12:43 a.m. UTC | #11
On 2/6/2020 1:26 AM, Thomas Monjalon wrote:
> As discussed in community meeting, the goal was to have core parsing
> in Windows EAL 20.02.
> Given that there is a crash and a doubt on the imported getopt library,
> I think it's better to postpone this series to 20.05.

The crash is now fixed in the last patchset version.

I tested and observed no crashes.

>
> 06/02/2020 07:41, Dmitry Kozlyuk:
>>> On 2/5/2020 4:39 PM, Pallavi Kadam wrote:
>>>> On 2/5/2020 11:54 AM, Dmitry Kozlyuk wrote:  
>>>>> Crashes at argument parsing, WinDbg log attached.  
>>>> This patch works fine with meson=0.49.
>>>> I was able to execute the 'helloworld' app.
>>>>
>>>> When I tried to build with meson=0.52 it failed with the error:
>>>> [9/25] Linking target lib/librte_kvargs-20.0.dll.
>>>> FAILED: lib/librte_kvargs-20.0.dll
>>>> clang @lib/librte_kvargs-20.0.dll.rsp
>>>> clang: error: no such file or directory: '/OPT:REF'  
>>> Fixed this error with the patch you sent before.
>>> were able to execute parsing:
>>>
>>> $ ./build/examples/dpdk-helloworld.exe -l 4-8
>>> EAL: Detected 20 lcore(s)
>>> EAL: Detected 2 NUMA nodes
>>> hello from core 5
>>> hello from core 6
>>> hello from core 7
>>> hello from core 8
>>> hello from core 4
>>>
>>>> Not completely sure, if this could be the reason for the crash.  
>> The crash does not happen with any arguments, "-l 4-8" works fine as do
>> "-cf" and "-v", but "--log-level=eal:8" crashes reproducibly. I assume
>> application should not crash on invalid options, but report an error and exit.
>> For the reference, I applied your patchset to the latest dpdk:master.
>>
>> Z:\>build\native\clang\examples\dpdk-helloworld.exe
>> EAL: Detected 4 lcore(s)
>> EAL: Detected 1 NUMA nodes
>>
>> 	OK, no lcores specified.
>>
>> Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf
>> EAL: Detected 4 lcore(s)
>> EAL: Detected 1 NUMA nodes
>> hello from core 1
>> hello from core 2
>> hello from core 3
>> hello from core 0
>>
>> 	OK, 4 lcores enabled.
>>
>> Z:\>build\native\clang\examples\dpdk-helloworld.exe -cf --log-level=eal:8
>>
>> 	Crash, WinDbg log attached to bug report.
>>
>> Z:\>echo %errorlevel%
>> -1073741819
>>
>> Z:\>
>>
>> Attaching the build log, but I don't think it matters, it's something with
>> getopt implementation or it's use, judging by stack trace.
>>
>> P.S. I can also see "--syslog" option in the help message, you should
>> probably hide it via #ifndef, as you did with said option handling.
>
>
>
>
  

Patch

diff --git a/lib/librte_eal/windows/eal/eal.c b/lib/librte_eal/windows/eal/eal.c
index 931a5860c..6a4778954 100644
--- a/lib/librte_eal/windows/eal/eal.c
+++ b/lib/librte_eal/windows/eal/eal.c
@@ -16,6 +16,9 @@ 
 #include <eal_options.h>
 #include <eal_private.h>
 
+ /* Allow the application to print its usage message too if set */
+static rte_usage_hook_t	rte_application_usage_hook;
+
 /* define fd variable here, because file needs to be kept open for the
  * duration of the program, as we hold a write lock on it in the primary proc
  */
@@ -83,6 +86,124 @@  eal_proc_type_detect(void)
 	return ptype;
 }
 
+/* display usage */
+static void
+eal_usage(const char *prgname)
+{
+	printf("\nUsage: %s ", prgname);
+	eal_common_usage();
+	/* Allow the application to print its usage message too
+	 *if hook is set
+	 */
+	if (rte_application_usage_hook) {
+		printf("===== Application Usage =====\n\n");
+		rte_application_usage_hook(prgname);
+	}
+}
+
+/* Parse the arguments for --log-level only */
+static void
+eal_log_level_parse(int argc, char **argv)
+{
+	int opt;
+	char **argvopt;
+	int option_index;
+
+	argvopt = argv;
+
+	eal_reset_internal_config(&internal_config);
+
+	while ((opt = getopt_long(argc, argvopt, eal_short_options,
+		eal_long_options, &option_index)) != EOF) {
+
+		int ret;
+
+		/* getopt is not happy, stop right now */
+		if (opt == '?')
+			break;
+
+		ret = (opt == OPT_LOG_LEVEL_NUM) ?
+			eal_parse_common_option(opt, optarg,
+				&internal_config) : 0;
+
+		/* common parser is not happy */
+		if (ret < 0)
+			break;
+	}
+
+	optind = 0; /* reset getopt lib */
+}
+
+/* Parse the argument given in the command line of the application */
+__attribute__((optnone)) static int
+eal_parse_args(int argc, char **argv)
+{
+	int opt, ret;
+	char **argvopt;
+	int option_index;
+	char *prgname = argv[0];
+
+	argvopt = argv;
+
+	while ((opt = getopt_long(argc, argvopt, eal_short_options,
+		eal_long_options, &option_index)) != EOF) {
+
+		int ret;
+
+		/* getopt is not happy, stop right now */
+		if (opt == '?') {
+			eal_usage(prgname);
+			return -1;
+		}
+
+		ret = eal_parse_common_option(opt, optarg, &internal_config);
+		/* common parser is not happy */
+		if (ret < 0) {
+			eal_usage(prgname);
+			return -1;
+		}
+		/* common parser handled this option */
+		if (ret == 0)
+			continue;
+
+		switch (opt) {
+		case 'h':
+			eal_usage(prgname);
+			exit(EXIT_SUCCESS);
+		default:
+			if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
+				RTE_LOG(ERR, EAL, "Option %c is not supported "
+					"on Windows\n", opt);
+			} else if (opt >= OPT_LONG_MIN_NUM &&
+				opt < OPT_LONG_MAX_NUM) {
+				RTE_LOG(ERR, EAL, "Option %s is not supported "
+					"on Windows\n",
+					eal_long_options[option_index].name);
+			} else {
+				RTE_LOG(ERR, EAL, "Option %d is not supported "
+					"on Windows\n", opt);
+			}
+			eal_usage(prgname);
+			return -1;
+		}
+	}
+
+	if (eal_adjust_config(&internal_config) != 0)
+		return -1;
+
+	/* sanity checks */
+	if (eal_check_common_options(&internal_config) != 0) {
+		eal_usage(prgname);
+		return -1;
+	}
+
+	if (optind >= 0)
+		argv[optind - 1] = prgname;
+	ret = optind - 1;
+	optind = 0; /* reset getopt lib */
+	return ret;
+}
+
 static int
 sync_func(void *arg __rte_unused)
 {
@@ -98,9 +219,11 @@  rte_eal_init_alert(const char *msg)
 
  /* Launch threads, called at application init(). */
 int
-rte_eal_init(int argc __rte_unused, char **argv __rte_unused)
+rte_eal_init(int argc, char **argv)
 {
-	int i;
+	int i, fctret;
+
+	eal_log_level_parse(argc, argv);
 
 	/* create a map of all processors in the system */
 	eal_create_cpu_map();
@@ -111,6 +234,10 @@  rte_eal_init(int argc __rte_unused, char **argv __rte_unused)
 		return -1;
 	}
 
+	fctret = eal_parse_args(argc, argv);
+	if (fctret < 0)
+		exit(1);
+
 	eal_thread_init_master(rte_config.master_lcore);
 
 	RTE_LCORE_FOREACH_SLAVE(i) {
@@ -139,5 +266,5 @@  rte_eal_init(int argc __rte_unused, char **argv __rte_unused)
 	 */
 	rte_eal_mp_remote_launch(sync_func, NULL, SKIP_MASTER);
 	rte_eal_mp_wait_lcore();
-	return 0;
+	return fctret;
 }