Skip to contentSkip to conversation

don't inline rte_string_fns

PATCH In review Stephen Hemminger 2 participants 3 messages Feb 27, 2014 – Apr 17, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 don't inline rte_string_fns

The function rte_snprintf() can never be inlined by Gcc.
If compiled with -Winline it generates an error:
function ‘rte_snprintf’ can never be inlined because it uses variable argument lists [-Werror=inline]

Therefore since both rte_snprintf and rte_strsplit are not performance sensitive just move them to being real functions.

---
 app/test/test_eal_fs.c                         |    1 +
 lib/librte_eal/common/eal_common_string_fns.c  |   95 ++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_string_fns.h |   58 +--------------
 lib/librte_eal/linuxapp/eal/Makefile           |    1 +
 4 files changed, 101 insertions(+), 54 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_string_fns.c
app/test/test_eal_fs.c +1 -0
index 0a7524d..2c4bdc6 100644
@@ -36,6 +36,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 
 /* eal_filesystem.h is not a public header file, so use relative path */
 #include "../../lib/librte_eal/linuxapp/eal/include/eal_filesystem.h"
lib/librte_eal/common/eal_common_string_fns.c new file +95 -0

95 lines not on this page · raw message

lib/librte_eal/common/include/rte_string_fns.h +4 -54

77 lines not on this page · raw message

lib/librte_eal/linuxapp/eal/Makefile +1 -0
index b525130..b25a093 100644
@@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_cpuflags.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_whitelist.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_nonpci_devs.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_string_fns.c
 
 CFLAGS_eal.o := -D_GNU_SOURCE
 CFLAGS_eal_thread.o := -D_GNU_SOURCE
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to a message not in the archive

Hi,

I have some minor comments below.

27/02/2014 09:18, Stephen Hemminger :

Quoted 13 lines

The function rte_snprintf() can never be inlined by Gcc.
If compiled with -Winline it generates an error:
function ‘rte_snprintf’ can never be inlined because it uses variable
argument lists [-Werror=inline]

Therefore since both rte_snprintf and rte_strsplit are not performance sensitive just move them to being real functions.

lib/librte_eal/common/eal_common_string_fns.c line 4

Quoted 4 lines
lib/librte_eal/common/eal_common_string_fns.c new file +4 -0
@@ -0,0 +1,95 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.

It is now 2014 in version 1.6.0.

[...]

lib/librte_eal/common/eal_common_string_fns.c line 37

Quoted 4 lines
lib/librte_eal/common/eal_common_string_fns.c new file +4 -0
+#include <stdio.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <errno.h>

I think stddef.h is not needed.

[...]

lib/librte_eal/common/include/rte_string_fns.h extern "C" { · line 50

Quoted 7 lines
lib/librte_eal/common/include/rte_string_fns.h +0 -1
@@ -47,7 +47,6 @@ extern "C" {
 #include <stdio.h>
 #include <stdarg.h>
 #include <stddef.h>
-#include <errno.h>

stdarg and stddef are not needed.

[...]

lib/librte_eal/common/include/rte_string_fns.h extern "C" { · line 76

Quoted 4 lines
lib/librte_eal/common/include/rte_string_fns.h +2 -0
+int
+rte_snprintf(char *buffer, int buflen, const char *format, ...);
 

One blank line should be sufficient.

Quoted 2 lines

+int
rte_strsplit(char *string, int stringlen,

Thank you

Signature · 1 line
Thomas
#3 lore raw

Hi Stephen,
This patch is still pending.
Please send a v2.

2014-03-20 17:30, Thomas Monjalon:

Quoted 62 lines

Hi,

I have some minor comments below.

27/02/2014 09:18, Stephen Hemminger :

Quoted 15 lines

The function rte_snprintf() can never be inlined by Gcc.

If compiled with -Winline it generates an error:
function ‘rte_snprintf’ can never be inlined because it uses variable

argument lists [-Werror=inline]

Therefore since both rte_snprintf and rte_strsplit are not performance sensitive just move them to being real functions.

lib/librte_eal/common/eal_common_string_fns.c line 4

Quoted 4 lines
lib/librte_eal/common/eal_common_string_fns.c new file +4 -0
@@ -0,0 +1,95 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.

It is now 2014 in version 1.6.0.

[...]

lib/librte_eal/common/eal_common_string_fns.c line 37

Quoted 4 lines
lib/librte_eal/common/eal_common_string_fns.c new file +4 -0
+#include <stdio.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <errno.h>

I think stddef.h is not needed.

[...]

lib/librte_eal/common/include/rte_string_fns.h extern "C" { · line 52

Quoted 9 lines
lib/librte_eal/common/include/rte_string_fns.h +0 -1
@@ -47,7 +47,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <stdarg.h>
 #include <stddef.h>
 
-#include <errno.h>

stdarg and stddef are not needed.

[...]

lib/librte_eal/common/include/rte_string_fns.h extern "C" { · line 75

Quoted 2 lines
lib/librte_eal/common/include/rte_string_fns.h +2 -0
+int
+rte_snprintf(char *buffer, int buflen, const char *format, ...);

One blank line should be sufficient.

Quoted 3 lines

+int

rte_strsplit(char *string, int stringlen,

Thank you