Move EAL common functions
v9 cover Move EAL common functions
As per Thomas's suggestion dividing v8 patch into multiple smaller series. This patch contains changes to eal_lcore.c, eal_timer.c and eal_memory.c files.
Tested on Ubuntu x86_64 14.04 GCC and Clang
Tested on FreeBSD 10.0 x86_64 GCC and Clang
testpmd, make test were run successfully.
Ravi Kerur (3):
Move common functions in eal_lcore.c
Move common functions in eal_timer.c
Move common functions in eal_memory.c
lib/librte_eal/bsdapp/eal/Makefile | 2 + lib/librte_eal/bsdapp/eal/eal_lcore.c | 72 +++++--------------- lib/librte_eal/bsdapp/eal/eal_memory.c | 52 +++++++-------- lib/librte_eal/bsdapp/eal/eal_timer.c | 52 +++------------ lib/librte_eal/common/eal_common_lcore.c | 107 ++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_common_memory.c | 41 +++++++++++- lib/librte_eal/common/eal_common_timer.c | 102 ++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 63 ++++++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 3 + lib/librte_eal/linuxapp/eal/eal_lcore.c | 66 ++---------------- lib/librte_eal/linuxapp/eal/eal_memory.c | 52 +++------------ lib/librte_eal/linuxapp/eal/eal_timer.c | 55 ++------------- 12 files changed, 379 insertions(+), 288 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_lcore.c create mode 100644 lib/librte_eal/common/eal_common_timer.c
Signature · 1 line
1.9.1
PATCH v9 1/3 Move common functions in eal_lcore.c
Changes in v9
Rebase to latest code.
Changes in v8
Reorder eal_common_lcore.c compilation.
Changes in v7
None.
Changes in v6
None.
Changes in v5
Rebase to latest code.
Changes in v4
Implement cpu_detected() for BSD.
Have common RTE_LOG for Linux and BSD in rte_eal_cpu_init(). Remove RTE_EXEC_ENV_BSDAPP in common file.
Changes in v3
Changed subject to be more explicit on file name inclusion.
Changes in v2
None
Changes in v1
Move common function in eal_lcore.c to librte_eal/common/ eal_common_lcore.c file.
Following function is moved to eal_common_lcore.c file
int rte_eal_cpu_init(void);
Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in common function.Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.
--- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal_lcore.c | 72 +++++---------------- lib/librte_eal/common/eal_common_lcore.c | 107 +++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 14 ++++ lib/librte_eal/linuxapp/eal/Makefile | 2 + lib/librte_eal/linuxapp/eal/eal_lcore.c | 66 ++----------------- 6 files changed, 143 insertions(+), 119 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_lcore.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_timer.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c
lib/librte_eal/bsdapp/eal/eal_lcore.c +15 -57
89 lines not on this page · raw message
lib/librte_eal/common/eal_common_lcore.c new file +107 -0
107 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +14 -0
@@ -300,4 +300,18 @@ int rte_eal_dev_init(void);*/ int rte_eal_check_module (const char *module_name); +/** +* This function gets cpu core_id +* +* This function is private to the EAL. +*/ +unsigned eal_cpu_core_id (unsigned lcore_id); + +/** +* This function check if cpu is present +* +* This function is private to the EAL. +*/ +int eal_cpu_detected (unsigned lcore_id); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +2 -0
@@ -67,6 +67,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_vfio.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_pci_vfio_mp_sync.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_debug.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_lcore.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_timer.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_interrupts.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_alarm.c
@@ -107,6 +108,7 @@ CFLAGS_eal_pci_vfio.o := -D_GNU_SOURCE CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE CFLAGS_eal_common_options.o := -D_GNU_SOURCE CFLAGS_eal_common_thread.o := -D_GNU_SOURCE +CFLAGS_eal_common_lcore.o := -D_GNU_SOURCE # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
lib/librte_eal/linuxapp/eal/eal_lcore.c +4 -62
81 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v9 2/3 Move common functions in eal_timer.c
Changes in v9
Rebase to latest code.
Changes in v8
Reorder eal_common_timer.c compilation.
Changes in v7
None
Changes in v6
Added new line between Copyright and header file inclusion in eal_common_timer.c.
Changes in v5
Rebase to latest code.
Changes in v4
Removed extern declaration of eal_tsc_resolution_hz, instead provided _set_ API.
Make set_tsc_freq_from_clock as wrapper function for BSD.
Changes in v3
Changed subject to be more explicit on file name inclusion.
Changes in v2
Use common function name set_tsc_freq_from_sysctl for BSD and Linux. Update comments about its actuality in function declaration.
Changes in v1
Move common functions in eal_timer.c to librte_eal/common/ eal_common_timer.c file.
Following functions are moved to eal_common_timer.c file
void rte_delay_us(unsigned us);uint64_t rte_get_tsc_hz(void);
static void set_tsc_freq_fallback(void);
void set_tsc_freq(void);
Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.
--- lib/librte_eal/bsdapp/eal/Makefile | 1 + lib/librte_eal/bsdapp/eal/eal_timer.c | 52 +++------------- lib/librte_eal/common/eal_common_timer.c | 102 +++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 24 ++++++++ lib/librte_eal/linuxapp/eal/Makefile | 1 + lib/librte_eal/linuxapp/eal/eal_timer.c | 55 ++--------------- 6 files changed, 140 insertions(+), 95 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_timer.c
lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_timer.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c
lib/librte_eal/bsdapp/eal/eal_timer.c +8 -44
79 lines not on this page · raw message
lib/librte_eal/common/eal_common_timer.c new file +102 -0
102 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +24 -0
@@ -314,4 +314,28 @@ unsigned eal_cpu_core_id(unsigned lcore_id);*/ int eal_cpu_detected (unsigned lcore_id); +/** +* This function measures TSC frequency +* +* This function is private to the EAL. +*/ +void set_tsc_freq (void ); + +/** +* This function sets TSC frequency from sysctl +* for BSD and from clock for Linux. +* Is a wrapper function for BSD which will +* internally call set_tsc_freq_from_sysctl. +* +* This function is private to the EAL. +*/ +int set_tsc_freq_from_clock (void ); + +/** +* This function sets TSC frequency +* +* This function is private to the EAL. +*/ +void rte_set_tsc_hz (uint64_t tsc_hz); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -69,6 +69,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_debug.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_timer.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_interrupts.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_alarm.c ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
lib/librte_eal/linuxapp/eal/eal_timer.c +4 -51
91 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v9 2/3] Move common functions in eal_timer.c
2015-07-25 12:36, Ravi Kerur:
lib/librte_eal/common/eal_common_timer.c line 78
Quoted 5 lines
lib/librte_eal/common/eal_common_timer.c new file +5
-0+static void +set_tsc_freq_fallback (void ) +{ +RTE_LOG (WARNING ,EAL ,"WARNING: clock_gettime cannot use " + "CLOCK_MONOTONIC_RAW and HPET is not available"
Not generic enough for BSD.
We can say "TSC frequency estimated roughly"
Quoted 2 lines
lib/librte_eal/common/eal_common_timer.c new file +2
-0+ " - clock timings may be less accurate.\n"); +/* assume that the sleep(1) will sleep for 1 second */
[...]
Quoted 2 lines
+/**
+ * This function sets TSC frequency from sysctl
It is not the style of the file to start with "This function..."
Quoted 3 lines
+ * for BSD and from clock for Linux.
+ * Is a wrapper function for BSD which will
+ * internally callset_tsc_freq_from_sysctl.
This sentence is an implementation detail.
Re: [PATCH v9 2/3] Move common functions in eal_timer.c
In reply to Ravi Kerur2015-07-25 12:36, Ravi Kerur
Quoted 24 lines
static int
set_tsc_freq_from_sysctl(void)
{lib/librte_eal/bsdapp/eal/eal_timer.c +4
-2size_t sz;int tmp; +uint64_t tsc_hz; sz =sizeof (tmp); tmp =0 ;@@ -94,42 +77,23 @@ set_tsc_freq_from_sysctl(void)else if (tmp !=1 )RTE_LOG (WARNING ,EAL ,"TSC is not invariant\n" ); - sz =sizeof (eal_tsc_resolution_hz); -if (sysctlbyname ("machdep.tsc_freq" , &eal_tsc_resolution_hz, &sz,NULL ,0 )) { + sz =sizeof (tsc_hz); +if (sysctlbyname ("machdep.tsc_freq" , &tsc_hz, &sz,NULL ,0 )) {RTE_LOG (WARNING ,EAL ,"%s\n" ,strerror (errno));return -1 ; } +rte_set_tsc_hz (tsc_hz);return 0 ; }
[...]
Quoted 7 lines
lib/librte_eal/common/eal_common_timer.c new file +5
-0+void +rte_set_tsc_hz (uint64_t tsc_hz) +{ + eal_tsc_resolution_hz = tsc_hz; +}
[...]
lib/librte_eal/common/eal_common_timer.c line 98
Quoted 5 lines
lib/librte_eal/common/eal_common_timer.c new file +5
-0+void +set_tsc_freq (void ) +{ +if (set_tsc_freq_from_clock () <0 ) +set_tsc_freq_fallback ();
It would be simpler to get value from return of these functions and store it in eal_tsc_resolution_hz here.
PATCH v9 3/3 Move common functions in eal_memory.c
In reply to Ravi KerurChanges in v9
Rebase to latest code.
Changes in v8
None
Changes in v7
None
Changes in v6
Removed unnecessary comments in function declaration.
Changes in v5
Rebase to latest code.
Changes in v4
Make rte_eal_hugepage_init and rte_eal_hugepage_attach as wrapper functions for BSD.
Changes in v3
Changed subject to be more explicit on file name inclusion.
Changes in v2
Use common function names rte_eal_hugepage_init and rte_eal_hugepage_attach for BSD and Linux. Update comments about its actuality in function declaration.
Changes in v1
Move common functions in eal_memory.c to librte_eal/common/ eal_common_memory.c file.
Following functions are moved to eal_common_memory.c file
static int rte_eal_memdevice_init(void); int rte_eal_memory_init(void); Fix checkpatch warnings and errors.
--- lib/librte_eal/bsdapp/eal/eal_memory.c | 52 ++++++++++++++----------------- lib/librte_eal/common/eal_common_memory.c | 41 ++++++++++++++++++++++-- lib/librte_eal/common/eal_private.h | 29 +++++++++++++++-- lib/librte_eal/linuxapp/eal/eal_memory.c | 52 ++++++------------------------- 4 files changed, 98 insertions(+), 76 deletions(-)
lib/librte_eal/bsdapp/eal/eal_memory.c +23 -29
@@ -59,7 +59,7 @@ rte_mem_virt2phy(const void *virtaddr)return RTE_BAD_PHYS_ADDR ; } -static int +static inline int rte_eal_contigmem_init (void ) {struct rte_mem_config *mcfg;
@@ -132,7 +132,16 @@ rte_eal_contigmem_init(void)return 0 ; } -static int +/* +* Wrapper function to initialize contigmem. +*/ +int +rte_eal_hugepage_init (void ) +{ +return rte_eal_contigmem_init (); +} + +static inline int rte_eal_contigmem_attach (void ) {const struct hugepage_info *hpi;
@@ -193,35 +202,20 @@ error:return -1 ; } - -static int -rte_eal_memdevice_init (void ) +/* +* Wrapper function to attach contigmem. +*/ +int +rte_eal_hugepage_attach (void ) { -struct rte_config *config; - -if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) -return 0 ; - - config =rte_eal_get_configuration (); - config->mem_config->nchannel = internal_config.force_nchannel; - config->mem_config->nrank = internal_config.force_nrank; - -return 0 ; +return rte_eal_contigmem_attach (); } -/* init memory subsystem */ -int -rte_eal_memory_init (void ) +/* +* Wrapper function, no-op here. +*/ +void +test_proc_pagemap_readable (void ) { -RTE_LOG (INFO ,EAL ,"Setting up physically contiguous memory...\n" ); -const int retval =rte_eal_process_type () ==RTE_PROC_PRIMARY ? -rte_eal_contigmem_init () : -rte_eal_contigmem_attach (); -if (retval <0 ) -return -1 ; - -if (internal_config.no_shconf ==0 &&rte_eal_memdevice_init () <0 ) -return -1 ; - -return 0 ; +return ; }
lib/librte_eal/common/eal_common_memory.c +39 -2
62 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +27 -2
@@ -324,8 +324,6 @@ void set_tsc_freq(void);/** * This function sets TSC frequency from sysctl * for BSD and from clock for Linux. -* Is a wrapper function for BSD which will -* internally call set_tsc_freq_from_sysctl. * * This function is private to the EAL. */
@@ -338,4 +336,31 @@ int set_tsc_freq_from_clock(void);*/ void rte_set_tsc_hz (uint64_t tsc_hz); +/** +* This function prepares physical memory mapping +* i.e. hugepages on Linux and +* contigmem on BSD. +* +* This function is private to the EAL. +*/ +int rte_eal_hugepage_init (void ); + +/** +* This function creates memory mapping in secondary +* i.e. hugepages on Linux and +* contigmem on BSD. +* +* This function is private to the EAL. +*/ +int rte_eal_hugepage_attach (void ); + +/** +* This function checks /proc filesystem +* on Linux. +* +* This function is private to the EAL. +*/ +void +test_proc_pagemap_readable (void ); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/eal_memory.c +9 -43
78 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v9 3/3] Move common functions in eal_memory.c
2015-07-25 12:36, Ravi Kerur:
Quoted 2 lines
lib/librte_eal/bsdapp/eal/eal_memory.c +0
-0
[...]
lib/librte_eal/bsdapp/eal/eal_memory.c rte_eal_contigmem_init(void) · line 142
Quoted 8 lines
lib/librte_eal/bsdapp/eal/eal_memory.c +8
-0+/* +* Wrapper function to initialize contigmem. +*/ +int +rte_eal_hugepage_init (void ) +{ +return rte_eal_contigmem_init (); +}
The useless wrapper can be avoid by renaming the function: contigmem_init to hugepage_init.
Quoted 8 lines
lib/librte_eal/bsdapp/eal/eal_memory.c +6
-0+/* +* Wrapper function, no-op here. +*/ +void +test_proc_pagemap_readable (void ) { +return ; }
[...]
Quoted 2 lines
lib/librte_eal/common/eal_private.h +0
-0
[...]
lib/librte_eal/common/eal_private.h int set_tsc_freq_from_clock(void); · line 364
Quoted 8 lines
lib/librte_eal/common/eal_private.h +8
-0+/** +* This function checks /proc filesystem +* on Linux. +* +* This function is private to the EAL. +*/ +void +test_proc_pagemap_readable (void );
This check is specific to Linux. So it should not be in the common file.
v9 cover Move EAL common functions
In reply to Ravi KerurAs per Thomas's suggestion dividing v8 patch into multiple smaller series. This patch contains changes to eal_lcore.c, eal_timer.c and eal_memory.c files.
Tested on Ubuntu x86_64 14.04 GCC and Clang
Tested on FreeBSD 10.0 x86_64 GCC and Clang
testpmd, make test were run successfully.
Ravi Kerur (3):
Move common functions in eal_lcore.c
Move common functions in eal_timer.c
Move common functions in eal_memory.c
lib/librte_eal/bsdapp/eal/Makefile | 2 + lib/librte_eal/bsdapp/eal/eal_lcore.c | 72 +++++--------------- lib/librte_eal/bsdapp/eal/eal_memory.c | 52 +++++++-------- lib/librte_eal/bsdapp/eal/eal_timer.c | 52 +++------------ lib/librte_eal/common/eal_common_lcore.c | 107 ++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_common_memory.c | 41 +++++++++++- lib/librte_eal/common/eal_common_timer.c | 102 ++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 63 ++++++++++++++++++ lib/librte_eal/linuxapp/eal/Makefile | 3 + lib/librte_eal/linuxapp/eal/eal_lcore.c | 66 ++---------------- lib/librte_eal/linuxapp/eal/eal_memory.c | 52 +++------------ lib/librte_eal/linuxapp/eal/eal_timer.c | 55 ++------------- 12 files changed, 379 insertions(+), 288 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_lcore.c create mode 100644 lib/librte_eal/common/eal_common_timer.c
Signature · 1 line
1.9.1
v10 cover deduplicate EAL common functions
In reply to Ravi Kerurv9 was a subset of previous deduplications by Ravi Kerur. This v10 address the comments I've done on v9.
Ravi Kerur (3):
eal: deduplicate lcore initialization
eal: deduplicate timer functions
eal: deduplicate memory initialization
lib/librte_eal/bsdapp/eal/Makefile | 2 +
lib/librte_eal/bsdapp/eal/eal_lcore.c | 72 ++++---------------
lib/librte_eal/bsdapp/eal/eal_memory.c | 39 +----------
lib/librte_eal/bsdapp/eal/eal_timer.c | 58 ++--------------
.../eal/eal_lcore.c => common/eal_common_lcore.c} | 52 +++++---------
lib/librte_eal/common/eal_common_memory.c | 38 +++++++++-
.../eal/eal_timer.c => common/eal_common_timer.c} | 79 +++------------------
lib/librte_eal/common/eal_private.h | 46 +++++++++++++
lib/librte_eal/linuxapp/eal/Makefile | 3 +
lib/librte_eal/linuxapp/eal/eal_lcore.c | 66 ++----------------
lib/librte_eal/linuxapp/eal/eal_memory.c | 80 +++++++---------------
lib/librte_eal/linuxapp/eal/eal_timer.c | 60 ++--------------
12 files changed, 175 insertions(+), 420 deletions(-)
copy lib/librte_eal/{bsdapp/eal/eal_lcore.c => common/eal_common_lcore.c} (75%)
copy lib/librte_eal/{bsdapp/eal/eal_timer.c => common/eal_common_timer.c} (57%)Signature · 1 line
2.4.2
PATCH v10 1/3 eal: deduplicate lcore initialization
From: Ravi Kerur <[email protected]>
Implement cpu_detected() for BSD.
Move common function in eal_lcore.c to eal_common_lcore.c file.
---
lib/librte_eal/bsdapp/eal/Makefile | 1 +
lib/librte_eal/bsdapp/eal/eal_lcore.c | 72 +++++-----------------
.../eal/eal_lcore.c => common/eal_common_lcore.c} | 52 ++++++----------
lib/librte_eal/common/eal_private.h | 14 +++++
lib/librte_eal/linuxapp/eal/Makefile | 2 +
lib/librte_eal/linuxapp/eal/eal_lcore.c | 66 ++------------------
6 files changed, 55 insertions(+), 152 deletions(-)
copy lib/librte_eal/{bsdapp/eal/eal_lcore.c => common/eal_common_lcore.c} (75%)lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c # from common dir +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_launch.c
lib/librte_eal/bsdapp/eal/eal_lcore.c +15 -57
89 lines not on this page · raw message
lib/librte_eal/common/eal_common_lcore.c renamed from lib/librte_eal/bsdapp/eal/eal_lcore.c +19 -33
96 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +14 -0
@@ -300,4 +300,18 @@ int rte_eal_dev_init(void);*/ int rte_eal_check_module (const char *module_name); +/** +* Get cpu core_id. +* +* This function is private to the EAL. +*/ +unsigned eal_cpu_core_id (unsigned lcore_id); + +/** +* Check if cpu is present. +* +* This function is private to the EAL. +*/ +int eal_cpu_detected (unsigned lcore_id); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +2 -0
@@ -70,6 +70,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_ivshmem.c endif # from common dir +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_launch.c
@@ -102,6 +103,7 @@ CFLAGS_eal_pci_vfio.o := -D_GNU_SOURCE CFLAGS_eal_common_whitelist.o := -D_GNU_SOURCE CFLAGS_eal_common_options.o := -D_GNU_SOURCE CFLAGS_eal_common_thread.o := -D_GNU_SOURCE +CFLAGS_eal_common_lcore.o := -D_GNU_SOURCE # workaround for a gcc bug with noreturn attribute # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
lib/librte_eal/linuxapp/eal/eal_lcore.c +4 -62
81 lines not on this page · raw message
Signature · 1 line
2.4.2
PATCH v10 2/3 eal: deduplicate timer functions
In reply to Thomas MonjalonFrom: Ravi Kerur <[email protected]>
Move common functions from BSD/Linux to eal_common_timer.c. BSD uses sysctl and Linux uses CLOCK_MONOTIC_RAW to calibrate TSC. HPET is specific to Linux and not integrated in the common init.
---
lib/librte_eal/bsdapp/eal/Makefile | 1 +
lib/librte_eal/bsdapp/eal/eal_timer.c | 58 ++--------------
.../eal/eal_timer.c => common/eal_common_timer.c} | 79 +++-------------------
lib/librte_eal/common/eal_private.h | 14 ++++
lib/librte_eal/linuxapp/eal/Makefile | 1 +
lib/librte_eal/linuxapp/eal/eal_timer.c | 60 ++--------------
6 files changed, 39 insertions(+), 174 deletions(-)
copy lib/librte_eal/{bsdapp/eal/eal_timer.c => common/eal_common_timer.c} (57%)lib/librte_eal/bsdapp/eal/Makefile +1 -0
@@ -61,6 +61,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c # from common dir SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_launch.c
lib/librte_eal/bsdapp/eal/eal_timer.c +6 -52
77 lines not on this page · raw message
lib/librte_eal/common/eal_common_timer.c renamed from lib/librte_eal/bsdapp/eal/eal_timer.c +11 -68
107 lines not on this page · raw message
lib/librte_eal/common/eal_private.h +14 -0
@@ -314,4 +314,18 @@ unsigned eal_cpu_core_id(unsigned lcore_id);*/ int eal_cpu_detected (unsigned lcore_id); +/** +* Set TSC frequency from precise value or estimation +* +* This function is private to the EAL. +*/ +void set_tsc_freq (void ); + +/** +* Get precise TSC frequency from system +* +* This function is private to the EAL. +*/ +uint64_t get_tsc_freq (void ); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/Makefile +1 -0
@@ -71,6 +71,7 @@ endif # from common dir SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_lcore.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_timer.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_memzone.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_log.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_launch.c
lib/librte_eal/linuxapp/eal/eal_timer.c +6 -54
92 lines not on this page · raw message
Signature · 1 line
2.4.2
PATCH v10 3/3 eal: deduplicate memory initialization
In reply to Thomas MonjalonFrom: Ravi Kerur <[email protected]>
Move common functions from BSD/Linux to eal_common_memory.c file. BSD uses contigmem kernel module and Linux uses /proc/self/pagemap file.
--- lib/librte_eal/bsdapp/eal/eal_memory.c | 39 ++------------- lib/librte_eal/common/eal_common_memory.c | 38 ++++++++++++++- lib/librte_eal/common/eal_private.h | 18 +++++++ lib/librte_eal/linuxapp/eal/eal_memory.c | 80 ++++++++++--------------------- 4 files changed, 81 insertions(+), 94 deletions(-)
lib/librte_eal/bsdapp/eal/eal_memory.c +3 -36
@@ -59,7 +59,7 @@ rte_mem_virt2phy(const void *virtaddr)return RTE_BAD_PHYS_ADDR ; } -static int +int rte_eal_contigmem_init (void ) {struct rte_mem_config *mcfg;
@@ -132,8 +132,8 @@ rte_eal_contigmem_init(void)return 0 ; } -static int -rte_eal_contigmem_attach (void ) +int +rte_eal_hugepage_attach (void ) {const struct hugepage_info *hpi;int fd_hugepage_info, fd_hugepage =-1 ;
@@ -192,36 +192,3 @@ error:close (fd_hugepage);return -1 ; } - - -static int -rte_eal_memdevice_init (void ) -{ -struct rte_config *config; - -if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) -return 0 ; - - config =rte_eal_get_configuration (); - config->mem_config->nchannel = internal_config.force_nchannel; - config->mem_config->nrank = internal_config.force_nrank; - -return 0 ; -} - -/* init memory subsystem */ -int -rte_eal_memory_init (void ) -{ -RTE_LOG (INFO ,EAL ,"Setting up physically contiguous memory...\n" ); -const int retval =rte_eal_process_type () ==RTE_PROC_PRIMARY ? -rte_eal_contigmem_init () : -rte_eal_contigmem_attach (); -if (retval <0 ) -return -1 ; - -if (internal_config.no_shconf ==0 &&rte_eal_memdevice_init () <0 ) -return -1 ; - -return 0 ; -}
lib/librte_eal/common/eal_common_memory.c +36 -2
@@ -45,6 +45,7 @@#include <rte_log.h> #include "eal_private.h" +#include "eal_internal_cfg.h" /* * Return a pointer to a read-only table of struct rte_physmem_desc
@@ -69,7 +70,7 @@ rte_eal_get_physmem_size(void)/* get pointer to global configuration */ mcfg =rte_eal_get_configuration ()->mem_config; -for (i=0 ; i<RTE_MAX_MEMSEG ; i++) { +for (i =0 ; i <RTE_MAX_MEMSEG ; i++) {if (mcfg->memseg[i].addr ==NULL )break ;
@@ -89,7 +90,7 @@ rte_dump_physmem_layout(FILE *f)/* get pointer to global configuration */ mcfg =rte_eal_get_configuration ()->mem_config; -for (i=0 ; i<RTE_MAX_MEMSEG ; i++) { +for (i =0 ; i <RTE_MAX_MEMSEG ; i++) {if (mcfg->memseg[i].addr ==NULL )break ;
@@ -118,3 +119,36 @@ unsigned rte_memory_get_nrank(void) {return rte_eal_get_configuration ()->mem_config->nrank; } + +static int +rte_eal_memdevice_init (void ) +{ +struct rte_config *config; + +if (rte_eal_process_type () ==RTE_PROC_SECONDARY ) +return 0 ; + + config =rte_eal_get_configuration (); + config->mem_config->nchannel = internal_config.force_nchannel; + config->mem_config->nrank = internal_config.force_nrank; + +return 0 ; +} + +/* init memory subsystem */ +int +rte_eal_memory_init (void ) +{ +RTE_LOG (INFO ,EAL ,"Setting up physically contiguous memory...\n" ); + +const int retval =rte_eal_process_type () ==RTE_PROC_PRIMARY ? +rte_eal_hugepage_init () : +rte_eal_hugepage_attach (); +if (retval <0 ) +return -1 ; + +if (internal_config.no_shconf ==0 &&rte_eal_memdevice_init () <0 ) +return -1 ; + +return 0 ; +}
lib/librte_eal/common/eal_private.h +18 -0
@@ -328,4 +328,22 @@ void set_tsc_freq(void);*/ uint64_t get_tsc_freq (void ); +/** +* Prepare physical memory mapping +* i.e. hugepages on Linux and +* contigmem on BSD. +* +* This function is private to the EAL. +*/ +int rte_eal_hugepage_init (void ); + +/** +* Creates memory mapping in secondary process +* i.e. hugepages on Linux and +* contigmem on BSD. +* +* This function is private to the EAL. +*/ +int rte_eal_hugepage_attach (void ); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/eal_memory.c +24 -56
119 lines not on this page · raw message
Signature · 1 line
2.4.2
Re: [PATCH v10 0/3] deduplicate EAL common functions
In reply to Thomas Monjalon2015-07-27 02:56, Thomas Monjalon:
Quoted 7 lines
v9 was a subset of previous deduplications by Ravi Kerur. This v10 address the comments I've done on v9.
Ravi Kerur (3):
eal: deduplicate lcore initialization
eal: deduplicate timer functions
eal: deduplicate memory initialization
Applied shortly to integrate this old pending cleanup in RC2.
Re: [PATCH v10 0/3] deduplicate EAL common functions
Hi Thomas & Ravi,
Quoted 11 lines · Thomas Monjalon
2015-07-27 02:56, Thomas Monjalon:
Quoted 7 lines
v9 was a subset of previous deduplications by Ravi Kerur. This v10 address the comments I've done on v9.
Ravi Kerur (3):
eal: deduplicate lcore initialization
eal: deduplicate timer functions
eal: deduplicate memory initializationApplied shortly to integrate this old pending cleanup in RC2.
When I try to compile the dpdk for x86_x32-native-linuxapp-gcc , I get the following compilation error:
CC eal_common_timer.o
In file included from /usr/include/sys/sysctl.h:63:0,
from/home/matz/dpdk-pkg-cron/dpdk.org/lib/librte_eal/common/eal_common_timer.c:39:/usr/include/bits/sysctl.h:19:3: error: #error "sysctl system call is unsupported in x32 kernel"
# error "sysctl system call is unsupported in x32 kernel" ^
Removing the "#include <sys/sysctl.h>" line fixes the issue without impacting the compilation. I think this include is not needed and could be removed.
I can provide a patch if it's ok for you.
Regards,
Olivier
Re: [PATCH v10 0/3] deduplicate EAL common functions
Hi Olivier,
Quoted 28 lines · Olivier MATZ
Hi Thomas & Ravi,
Quoted 5 lines · Thomas Monjalon
2015-07-27 02:56, Thomas Monjalon:
Quoted 3 lines
v9 was a subset of previous deduplications by Ravi Kerur. This v10 address the comments I've done on v9.
Quoted 9 lines
Quoted 5 lines
Ravi Kerur (3):
eal: deduplicate lcore initialization
eal: deduplicate timer functions
eal: deduplicate memory initializationApplied shortly to integrate this old pending cleanup in RC2.
When I try to compile the dpdk for x86_x32-native-linuxapp-gcc , I get the following compilation error:
CC eal_common_timer.o
In file included from/usr/include/sys/sysctl.h:63:0,
from/home/matz/dpdk-pkg-cron/dpdk.org/lib/librte_eal/common/eal_common_timer.c:39:/usr/include/bits/sysctl.h:19:3: error: #error "sysctl system call is unsupported in x32 kernel"
Quoted 9 lines
# error "sysctl system call is unsupported in x32 kernel" ^Removing the "#include <
sys/sysctl.h>" line fixes the issue without impacting the compilation. I think this include is not needed and could be removed.
I can provide a patch if it's ok for you.
If it compiles fine on FreeBSD then it should be fine. It primarily needed for eal_timer.c in FreeBSD environment, during code movement it slipped through my mind. Sorry for the inconvenience.
Thanks,
Ravi
Quoted 4 lines
Regards,
Olivier
Re: [PATCH v10 0/3] deduplicate EAL common functions
In reply to Olivier MATZ2015-07-30 10:12, Olivier MATZ:
Quoted 24 lines
Hi Thomas & Ravi,
Quoted 11 lines · Thomas Monjalon
2015-07-27 02:56, Thomas Monjalon:
Quoted 7 lines
v9 was a subset of previous deduplications by Ravi Kerur. This v10 address the comments I've done on v9.
Ravi Kerur (3):
eal: deduplicate lcore initialization
eal: deduplicate timer functions
eal: deduplicate memory initializationApplied shortly to integrate this old pending cleanup in RC2.
When I try to compile the dpdk for x86_x32-native-linuxapp-gcc , I get the following compilation error:
CC eal_common_timer.o
In file included from/usr/include/sys/sysctl.h:63:0,
from/home/matz/dpdk-pkg-cron/dpdk.org/lib/librte_eal/common/eal_common_timer.c:39:/usr/include/bits/sysctl.h:19:3: error: #error "sysctl system call is unsupported in x32 kernel"
Quoted 7 lines
# error "sysctl system call is unsupported in x32 kernel" ^Removing the "#include <
sys/sysctl.h>" line fixes the issue without impacting the compilation. I think this include is not needed and could be removed.
I can provide a patch if it's ok for you.
After fixing another build issue on FreeBSD (patch sent), it builds well without sys/sysctl.h.
So it seems to be an useless inclusion.