make lcore_config internal
cover make lcore_config internal
This set of patches makes the lcore_config structure internal to EAL and not part of the ABI. It supersedes earlier RFC.
The first 4 would go into current release, and the last would go into later release to make it fully internal.
The same should be done for rte_config, but that
is more difficult.
Stephen Hemminger (5):
eal: add accessor functions for lcore_config
bus: use lcore accessor functions
examples/bond: use lcore accessor
app/test: use lcore accessor functions
eal: make lcore_config private
app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 ++--- app/test/test_ring_perf.c | 22 ++++--- app/test/test_stack_perf.c | 20 +++--- doc/guides/rel_notes/release_19_05.rst | 7 +++ drivers/bus/dpaa/dpaa_bus.c | 6 +- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +- examples/bond/main.c | 4 +- lib/librte_eal/common/eal_common_launch.c | 2 + lib/librte_eal/common/eal_common_lcore.c | 39 ++++++++++++ lib/librte_eal/common/eal_private.h | 22 +++++++ lib/librte_eal/common/include/rte_lcore.h | 76 +++++++++++------------ lib/librte_eal/common/rte_service.c | 2 + lib/librte_eal/rte_eal_version.map | 12 +++- 14 files changed, 159 insertions(+), 73 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/5 eal: add accessor functions for lcore_config
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples. Mark the state and return code functions as experimental since these values might change in the future and probably shouldn't have been used by non EAL code anyway.
Most of these functions are not marked as experimental since we want applications to convert over asap. The one exception is the return_code, which is only used by some tests now and not clear that it is even that useful.
--- doc/guides/rel_notes/release_19_05.rst | 7 +++ lib/librte_eal/common/eal_common_lcore.c | 39 +++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 52 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 4 files changed, 94 insertions(+), 15 deletions(-)
doc/guides/rel_notes/release_19_05.rst +7 -0
@@ -222,6 +222,13 @@ ABI Changes alignment for ``rte_crypto_asym_op`` to restore expected ``rte_crypto_op`` layout and alignment. +* eal: the lcore config structure ``struct lcore_config`` will be made + internal to the EAL in a future release. This will allow the structure to + change without impacting API or ABI. All accesses to fields of this + structure should be done by the corresponding accessor functions. + For example, instead of using ``lcore_config[lcore_id].socket_id`` + the function ``rte_lcore_socket_id(lcore_id)`` should be used instead. + Shared Library Versions -----------------------
lib/librte_eal/common/eal_common_lcore.c +39 -0
@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset (unsigned int lcore_id) +{ +return lcore_config[lcore_id].cpuset; +} + +unsigned +rte_lcore_to_socket_id (unsigned int lcore_id) +{ +return lcore_config[lcore_id].socket_id; +} + +int +rte_lcore_return_code (unsigned int lcore_id) +{ +return lcore_config[lcore_id].ret; +} +static int socket_id_cmp (const void *a,const void *b) {
lib/librte_eal/common/include/rte_lcore.h +37 -15
70 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +11 -0
@@ -268,6 +268,16 @@ DPDK_18.11 { } DPDK_18.08; +DPDK_19.05 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_18.08; + EXPERIMENTAL { global:
@@ -329,6 +339,7 @@ EXPERIMENTAL { rte_fbarray_set_free; rte_fbarray_set_used; rte_intr_callback_unregister_pending; + rte_lcore_return_code; rte_log_register_type_and_pick_level; rte_malloc_dump_heaps; rte_malloc_heap_create;
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 1/5] eal: add accessor functions for lcore_config
Quoted 9 lines · Stephen Hemminger
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples. Mark the state and return code functions as experimental since these values might change in the future and probably shouldn't have been used by non EAL code anyway.
You removed the state function, no need to mention it.
Since we already expose the state, exposing the ret code seems fair. Applications can wait themselves and check the return code the way they want.
Just want to point that the current test app could do without it, since it is quite simple, it waits for all, then checks all return codes.
Quoted 5 lines
Most of these functions are not marked as experimental since we want applications to convert over asap. The one exception is the
return_code, which is only used by some tests now and not clear that it is even that useful.
+1
(quoted diff) +0 -0
Quoted 27 lines
b/lib/librte_eal/common/eal_common_lcore.c
index1cbac42286ba..c3cf5a06269d100644lib/librte_eal/common/eal_common_lcore.c +19
-0@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); +
lib/librte_eal/common/eal_common_lcore.c line 47
Quoted 10 lines
lib/librte_eal/common/eal_common_lcore.c +9
-0+return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset (unsigned int lcore_id) +{ +return lcore_config[lcore_id].cpuset; +} + +unsigned
Ah, checkpatch does not complain for me, I would have expected a warning on "unsigned int".
Can you fix it so that it matches the declaration from the header ?
+rte_lcore_to_socket_id(unsigned int lcore_id)
lib/librte_eal/common/eal_common_lcore.c
Quoted 13 lines
lib/librte_eal/common/eal_common_lcore.c +10
-0+{ +return lcore_config[lcore_id].socket_id; +} + +int +rte_lcore_return_code (unsigned int lcore_id) +{ +return lcore_config[lcore_id].ret; +} +static int socket_id_cmp (const void *a,const void *b) {
The rest looks fine.
Signature · 1 line
David Marchand
PATCH 2/5 bus: use lcore accessor functions
In reply to Stephen HemmingerFix the bus logic in fslmc and dpaa drivers to use the new accessor functions.
--- drivers/bus/dpaa/dpaa_bus.c | 6 ++++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +4 -2
@@ -254,6 +254,7 @@ int rte_dpaa_portal_init(void *arg)unsigned int cpu, lcore =rte_lcore_id ();int ret;struct dpaa_portal *dpaa_io_portal; +rte_cpuset_t cpuset;BUS_INIT_FUNC_TRACE ();
@@ -263,12 +264,13 @@ int rte_dpaa_portal_init(void *arg)if (lcore >=RTE_MAX_LCORE )return -1 ; - cpu = lcore_config[lcore].core_id; + cpu =rte_lcore_to_cpu_id (lcore);/* Set CPU affinity for this thread.*/ id =pthread_self (); + cpuset =rte_lcore_cpuset (lcore); ret =pthread_setaffinity_np (id,sizeof (cpu_set_t), - &lcore_config[lcore].cpuset); + &cpuset);if (ret) {DPAA_BUS_LOG (ERR ,"pthread_setaffinity_np failed on core :%u" " (lcore=%u) with ret: %d" , cpu, lcore, ret);
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -1
@@ -366,7 +366,9 @@ dpaa2_check_lcore_cpuset(void)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (CPU_ISSET (i, &lcore_config[lcore_id].cpuset)) { +rte_cpuset_t cpuset =rte_lcore_cpuset (lcore_id); + +if (CPU_ISSET (i, &cpuset)) {RTE_LOG (DEBUG ,EAL ,"lcore id = %u cpu=%u\n" , lcore_id, i);if (dpaa2_cpu[lcore_id] !=0xffffffff ) {
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 2/5] bus: use lcore accessor functions
Quoted 55 lines · Stephen Hemminger
Fix the bus logic in fslmc and dpaa drivers to use the new accessor functions.
Signed-off-by Stephen Hemminger <[email protected]>--- drivers/bus/dpaa/dpaa_bus.c | 6 ++++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)drivers/bus/dpaa/dpaa_bus.c +4
-2@@ -254,6 +254,7 @@ int rte_dpaa_portal_init(void *arg)unsigned int cpu, lcore =rte_lcore_id ();int ret;struct dpaa_portal *dpaa_io_portal; +rte_cpuset_t cpuset;BUS_INIT_FUNC_TRACE ();@@ -263,12 +264,13 @@ int rte_dpaa_portal_init(void *arg)if (lcore >=RTE_MAX_LCORE )return -1 ; - cpu = lcore_config[lcore].core_id; + cpu =rte_lcore_to_cpu_id (lcore);/* Set CPU affinity for this thread.*/ id =pthread_self (); + cpuset =rte_lcore_cpuset (lcore); ret =pthread_setaffinity_np (id,sizeof (cpu_set_t), - &lcore_config[lcore].cpuset); + &cpuset);if (ret) { DPAA_BUS_LOG(ERR, "pthread_setaffinity_np failed on core:%u"
" (lcore=%u) with ret: %d", cpu, lcore, ret);drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3
-1@@ -366,7 +366,9 @@ dpaa2_check_lcore_cpuset(void)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (CPU_ISSET (i, &lcore_config[lcore_id].cpuset)) { +rte_cpuset_t cpuset =rte_lcore_cpuset (lcore_id); + +if (CPU_ISSET (i, &cpuset)) {RTE_LOG (DEBUG ,EAL ,"lcore id = %u cpu=%u\n", lcore_id, i);if (dpaa2_cpu[lcore_id] != 0xffffffff) {
Quoted 4 lines
--
2.17.1
Signature · 1 line
David Marchand
PATCH 3/5 examples/bond: use lcore accessor
In reply to Stephen HemmingerUse the accessor function to look at lcore state.
--- examples/bond/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
examples/bond/main.c +2 -2
@@ -526,8 +526,8 @@ static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,int slave_core_id =rte_lcore_id ();rte_spinlock_trylock (&global_flag_stru_p->lock); -if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { -if (lcore_config[global_flag_stru_p->LcoreMainCore].state !=WAIT ) { +if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { +if (rte_lcore_state (global_flag_stru_p->LcoreMainCore) !=WAIT ) {rte_spinlock_unlock (&global_flag_stru_p->lock);return ; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 3/5] examples/bond: use lcore accessor
Quoted 13 lines · Stephen Hemminger
Use the accessor function to look at lcore state.
Signed-off-by Stephen Hemminger <[email protected]>--- examples/bond/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)examples/bond/main.c +0
-0
examples/bond/main.c static void cmd_start_parsed(__attribute__((unused)) · line 533
Quoted 10 lines
examples/bond/main.c +2
-2@@ -526,8 +526,8 @@ static void cmd_start_parsed(__attribute__((unused))void *parsed_result, int slave_core_id = rte_lcore_id();rte_spinlock_trylock (&global_flag_stru_p->lock); -if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { -if (lcore_config[global_flag_stru_p->LcoreMainCore].state != WAIT) { +if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { +if (rte_lcore_state (global_flag_stru_p->LcoreMainCore) !=WAIT ) {
s/rte_lcore_state/rte_eal_get_lcore_state/
rte_spinlock_unlock(&global_flag_stru_p->lock);
Quoted 6 lines
return; }--
2.17.1
And you missed another reference in this file:
examples/bond/main.c +0 -0
@@ -527,7 +527,7 @@ static void cmd_start_parsed(__attribute__((unused))
void *parsed_result,
rte_spinlock_trylock(&global_flag_stru_p->lock);
if (global_flag_stru_p->LcoreMainIsRunning == 0) {
- if (rte_lcore_state(global_flag_stru_p->LcoreMainCore) !=
WAIT) {
+ if
(rte_eal_get_lcore_state(global_flag_stru_p->LcoreMainCore) != WAIT) {
rte_spinlock_unlock(&global_flag_stru_p->lock);
return;
}@@ -796,7 +796,7 @@ static void prompt(__attribute__((unused)) void *arg1)
/* check state of lcores */
RTE_LCORE_FOREACH_SLAVE(slave_core_id) {
- if (lcore_config[slave_core_id].state != WAIT)
+ if (rte_eal_get_lcore_state(slave_core_id) != WAIT)
return -EBUSY;
}
/* start lcore main on core != master_core - ARP response thread */Signature · 1 line
David Marchand
PATCH 4/5 app/test: use lcore accessor functions
In reply to Stephen HemmingerUse the new accessor functions. Don't refer to lcore_config directly.
--- app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++++++------- app/test/test_ring_perf.c | 22 ++++++++++++---------- app/test/test_stack_perf.c | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 28 deletions(-)
app/test/test_cryptodev.c +1 -1
@@ -378,7 +378,7 @@ testsuite_setup(void)strcpy (temp_str, vdev_args);strlcat (temp_str,";" ,sizeof (temp_str)); slave_core_count++; - socket_id = lcore_config[i].socket_id; + socket_id =rte_lcore_to_socket_id (i); }if (slave_core_count !=2 ) { RTE_LOG(ERR, USER1,
app/test/test_hash_readwrite_lf.c +7 -7
@@ -741,7 +741,7 @@ test_hash_add_no_ks_lookup_hit(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -813,7 +813,7 @@ test_hash_add_no_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -889,7 +889,7 @@ test_hash_add_ks_lookup_hit_non_sp(struct rwc_perf *rwc_perf_results,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -965,7 +965,7 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1040,7 +1040,7 @@ test_hash_add_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, intif (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1141,7 +1141,7 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1225,7 +1225,7 @@ test_hash_add_ks_lookup_hit_extbkt(struct rwc_perf *rwc_perf_results,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
app/test/test_ring_perf.c +12 -10
@@ -52,10 +52,11 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 == c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -75,10 +76,11 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 != c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -98,8 +100,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if (s1 != s2){ lcp->c1 = id1; lcp->c2 = id2;
app/test/test_stack_perf.c +10 -10
@@ -44,10 +44,10 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] == core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -70,10 +70,10 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] != core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -95,8 +95,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if (socket[0 ] != socket[1 ]) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v1 4/5] app/test: use lcore accessor functions
Quoted 193 lines · Stephen Hemminger
Use the new accessor functions. Don't refer to
lcore_configdirectly.Signed-off-by Stephen Hemminger <[email protected]>--- app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++++++------- app/test/test_ring_perf.c | 22 ++++++++++++---------- app/test/test_stack_perf.c | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 28 deletions(-)app/test/test_cryptodev.c +1
-1@@ -378,7 +378,7 @@ testsuite_setup(void)strcpy (temp_str, vdev_args);strlcat (temp_str,";" ,sizeof (temp_str)); slave_core_count++; - socket_id = lcore_config[i].socket_id; + socket_id =rte_lcore_to_socket_id (i); }if (slave_core_count !=2 ) { RTE_LOG(ERR, USER1,app/test/test_hash_readwrite_lf.c +1
-1@@ -741,7 +741,7 @@ test_hash_add_no_ks_lookup_hit(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err;unsigned long long
cycles_per_lookup=app/test/test_hash_readwrite_lf.c +1
-1@@ -813,7 +813,7 @@ test_hash_add_no_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, if (ret < 0) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err;unsigned long long
cycles_per_lookup=app/test/test_hash_readwrite_lf.c +1
-1@@ -889,7 +889,7 @@ test_hash_add_ks_lookup_hit_non_sp(struct rwc_perf *rwc_perf_results, if (ret < 0) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err;unsigned long long
cycles_per_lookup=app/test/test_hash_readwrite_lf.c +1
-1@@ -965,7 +965,7 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf, if (ret < 0) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err;unsigned long long
cycles_per_lookup=app/test/test_hash_readwrite_lf.c +1
-1@@ -1040,7 +1040,7 @@ test_hash_add_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, intif (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err;unsigned long long
cycles_per_lookup=app/test/test_hash_readwrite_lf.c +1
-1@@ -1141,7 +1141,7 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err;unsigned long long
cycles_per_lookup=app/test/test_hash_readwrite_lf.c +1
-1@@ -1225,7 +1225,7 @@ test_hash_add_ks_lookup_hit_extbkt(struct rwc_perf *rwc_perf_results,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err;unsigned long long
cycles_per_lookup=app/test/test_ring_perf.c +12
-10@@ -52,10 +52,11 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 == c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;@@ -75,10 +76,11 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 != c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;@@ -98,8 +100,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if (s1 != s2){ lcp->c1 = id1; lcp->c2 = id2;app/test/test_stack_perf.c +4
-4@@ -44,10 +44,10 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] == core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ];lcp->c2 = id[1];app/test/test_stack_perf.c +4
-4@@ -70,10 +70,10 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] != core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ];lcp->c2 = id[1];app/test/test_stack_perf.c +2
-3@@ -95,8 +95,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if (socket[0 ] != socket[1 ]) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ]; --
Quoted 2 lines
2.17.1
Signature · 1 line
David Marchand
PATCH 5/5 eal: make lcore_config private
In reply to Stephen HemmingerThe internal structure of lcore_config should not be part of visible API/ABI. Make it private to EAL.
Rearrange and resize the fields in the structure so it takes less memory (and cache footprint).
THIS BREAKS ABI OF PREVIOUS RELEASES.
--- lib/librte_eal/common/eal_common_launch.c | 2 ++ lib/librte_eal/common/eal_private.h | 22 +++++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 24 ----------------------- lib/librte_eal/common/rte_service.c | 2 ++ lib/librte_eal/rte_eal_version.map | 1 - 5 files changed, 26 insertions(+), 25 deletions(-)
lib/librte_eal/common/eal_common_launch.c +2 -0
@@ -15,6 +15,8 @@#include <rte_per_lcore.h> #include <rte_lcore.h> +#include "eal_private.h" +/* * Wait until a lcore finished its job. */
lib/librte_eal/common/eal_private.h +22 -0
@@ -10,6 +10,28 @@#include <stdio.h> #include <rte_dev.h> +#include <rte_lcore.h> + +/** +* Structure storing internal configuration (per-lcore) +*/ +struct lcore_config { +uint32_t core_id;/**< core number on socket for this lcore */ +uint32_t core_index;/**< relative index, starting from 0 */ +uint16_t socket_id;/**< physical socket id for this lcore */ +uint8_t core_role;/**< role of core eg: OFF, RTE, SERVICE */ +uint8_t detected;/**< true if lcore was detected */ +volatile enum rte_lcore_state_t state;/**< lcore state */ +rte_cpuset_t cpuset;/**< cpu set which the lcore affinity to */ +pthread_t thread_id;/**< pthread identifier */ +int pipe_master2slave[2 ];/**< communication pipe with master */ +int pipe_slave2master[2 ];/**< communication pipe with master */ +lcore_function_t *volatile f;/**< function to call */ +void *volatile arg;/**< argument of function */ +volatile int ret;/**< return value of function */ +}; + +extern struct lcore_config lcore_config[RTE_MAX_LCORE ];/** * Initialize the memzone subsystem (private to eal).
lib/librte_eal/common/include/rte_lcore.h +0 -24
@@ -37,30 +37,6 @@ typedef cpuset_t rte_cpuset_t; } while (0)#endif -/** -* Structure storing internal configuration (per-lcore) -*/ -struct lcore_config { -unsigned detected;/**< true if lcore was detected */ -pthread_t thread_id;/**< pthread identifier */ -int pipe_master2slave[2 ];/**< communication pipe with master */ -int pipe_slave2master[2 ];/**< communication pipe with master */ -lcore_function_t *volatile f;/**< function to call */ -void *volatile arg;/**< argument of function */ -volatile int ret;/**< return value of function */ -volatile enum rte_lcore_state_t state;/**< lcore state */ -unsigned socket_id;/**< physical socket id for this lcore */ -unsigned core_id;/**< core number on socket for this lcore */ -int core_index;/**< relative index, starting from 0 */ -rte_cpuset_t cpuset;/**< cpu set which the lcore affinity to */ -uint8_t core_role;/**< role of core eg: OFF, RTE, SERVICE */ -}; - -/** -* Internal configuration (per-lcore) -*/ -extern struct lcore_config lcore_config[RTE_MAX_LCORE ]; -RTE_DECLARE_PER_LCORE (unsigned, _lcore_id);/**< Per thread "lcore id". */ RTE_DECLARE_PER_LCORE (rte_cpuset_t, _cpuset);/**< Per thread "cpuset". */
lib/librte_eal/common/rte_service.c +2 -0
@@ -21,6 +21,8 @@#include <rte_memory.h> #include <rte_malloc.h> +#include "eal_private.h" +#define RTE_SERVICE_NUM_MAX 64#define SERVICE_F_REGISTERED (1 << 0)
lib/librte_eal/rte_eal_version.map +0 -1
@@ -4,7 +4,6 @@ DPDK_2.0 { __rte_panic; eal_parse_sysfs_value; eal_timer_source; - lcore_config; per_lcore__lcore_id; per_lcore__rte_errno; rte_calloc;
Signature · 1 line
2.17.1
v2 cover make lcore_config internal
In reply to Stephen HemmingerThis set of patches makes the lcore_config structure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moves lcore_config into eal_private.h
The changes in v2 is to:
- new patch to use unsigned int in lcore.h first
- incorporate feedback from David
- don't include last patch to make it private
(to avoid accidental early merge)
Stephen Hemminger (5):
eal: use unsigned int in rte_lcore.h functions
eal: add accessor functions for lcore_config
bus: use lcore accessor functions
examples/bond: use lcore accessor
app/test: use lcore accessor functions
app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++--- app/test/test_ring_perf.c | 22 +++++---- app/test/test_stack_perf.c | 20 ++++---- doc/guides/rel_notes/release_19_05.rst | 6 +++ drivers/bus/dpaa/dpaa_bus.c | 6 ++- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +- examples/bond/main.c | 5 +- lib/librte_eal/common/eal_common_lcore.c | 39 +++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 58 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 11 files changed, 136 insertions(+), 51 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/5 eal: use unsigned int in rte_lcore.h functions
Purely cosmetic change, use unsigned int instead of unsigned alone.
--- lib/librte_eal/common/include/rte_lcore.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/librte_eal/common/include/rte_lcore.h +6 -6
@@ -137,7 +137,7 @@ rte_lcore_index(int lcore_id)* @return * the ID of current lcoreid's physical socket */ -unsigned rte_socket_id (void ); +unsigned int rte_socket_id (void );/** * Return number of physical sockets detected on the system.
@@ -177,8 +177,8 @@ rte_socket_id_by_idx(unsigned int idx);* @return * the ID of lcoreid's physical socket */ -static inline unsigned -rte_lcore_to_socket_id (unsigned lcore_id) +static inline unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) {return lcore_config[lcore_id].socket_id; }
@@ -193,7 +193,7 @@ rte_lcore_to_socket_id(unsigned lcore_id)* True if the given lcore is enabled; false otherwise. */ static inline int -rte_lcore_is_enabled (unsigned lcore_id) +rte_lcore_is_enabled (unsigned int lcore_id) {struct rte_config *cfg =rte_eal_get_configuration ();if (lcore_id >=RTE_MAX_LCORE )
@@ -214,8 +214,8 @@ rte_lcore_is_enabled(unsigned lcore_id)* @return * The next lcore_id or RTE_MAX_LCORE if not found. */ -static inline unsigned -rte_get_next_lcore (unsigned i,int skip_master,int wrap) +static inline unsigned int +rte_get_next_lcore (unsigned int i,int skip_master,int wrap) { i++;if (wrap)
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 1/5] eal: use unsigned int in rte_lcore.h functions
Quoted 53 lines · Stephen Hemminger
Purely cosmetic change, use unsigned int instead of unsigned alone.
Signed-off-by Stephen Hemminger <[email protected]>--- lib/librte_eal/common/include/rte_lcore.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)lib/librte_eal/common/include/rte_lcore.h +6
-7@@ -137,7 +137,7 @@ rte_lcore_index(int lcore_id)* @return * the ID of current lcoreid's physical socket */ -unsigned rte_socket_id (void ); +unsigned int rte_socket_id (void );/** * Return number of physical sockets detected on the system. @@ -177,8 +177,8 @@ rte_socket_id_by_idx(unsigned int idx);* @return * the ID of lcoreid's physical socket */ -static inline unsigned -rte_lcore_to_socket_id (unsigned lcore_id) +static inline unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) {return lcore_config[lcore_id].socket_id; }@@ -193,7 +193,7 @@ rte_lcore_to_socket_id(unsigned lcore_id)* True if the given lcore is enabled; false otherwise. */ static inline int -rte_lcore_is_enabled (unsigned lcore_id) +rte_lcore_is_enabled (unsigned int lcore_id) {struct rte_config *cfg =rte_eal_get_configuration ();if (lcore_id >=RTE_MAX_LCORE )@@ -214,8 +214,8 @@ rte_lcore_is_enabled(unsigned lcore_id)* @return * The next lcore_id or RTE_MAX_LCORE if not found. */ -static inline unsigned -rte_get_next_lcore (unsigned i,int skip_master,int wrap) +static inline unsigned int +rte_get_next_lcore (unsigned int i,int skip_master,int wrap) { i++;if (wrap) --
Quoted 3 lines
2.17.1
Signature · 1 line
David Marchand
PATCH v2 2/5 eal: add accessor functions for lcore_config
In reply to Stephen HemmingerThe fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples. Mark return code functions as experimental since this value might change in the future and probably shouldn't have been used by non EAL code anyway.
--- doc/guides/rel_notes/release_19_05.rst | 6 +++ lib/librte_eal/common/eal_common_lcore.c | 39 ++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 50 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 4 files changed, 92 insertions(+), 14 deletions(-)
doc/guides/rel_notes/release_19_05.rst +6 -0
@@ -222,6 +222,12 @@ ABI Changes alignment for ``rte_crypto_asym_op`` to restore expected ``rte_crypto_op`` layout and alignment. +* eal: the lcore config structure ``struct lcore_config`` will be made + internal to the EAL in a future release. This will allow the structure to + change without impacting API or ABI. All accesses to fields of this + structure should be done by the corresponding accessor functions. + For example, instead of using ``lcore_config[lcore_id].socket_id`` + the function ``rte_lcore_socket_id(lcore_id)`` should be used instead. Shared Library Versions -----------------------
lib/librte_eal/common/eal_common_lcore.c +39 -0
@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset (unsigned int lcore_id) +{ +return lcore_config[lcore_id].cpuset; +} + +unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) +{ +return lcore_config[lcore_id].socket_id; +} + +int +rte_lcore_return_code (unsigned int lcore_id) +{ +return lcore_config[lcore_id].ret; +} +static int socket_id_cmp (const void *a,const void *b) {
lib/librte_eal/common/include/rte_lcore.h +36 -14
62 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +11 -0
@@ -268,6 +268,16 @@ DPDK_18.11 { } DPDK_18.08; +DPDK_19.05 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_18.08; + EXPERIMENTAL { global:
@@ -329,6 +339,7 @@ EXPERIMENTAL { rte_fbarray_set_free; rte_fbarray_set_used; rte_intr_callback_unregister_pending; + rte_lcore_return_code; rte_log_register_type_and_pick_level; rte_malloc_dump_heaps; rte_malloc_heap_create;
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 2/5] eal: add accessor functions for lcore_config
Quoted 28 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Stephen Hemminger
Sent: Wednesday, April 10, 2019 10:46 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v2 2/5] eal: add accessor functions forlcore_configThe fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples. Mark return code functions as experimental since this value might change in the future and probably shouldn't have been used by non EAL code anyway.
Signed-off-by Stephen Hemminger <[email protected]>Reviewed-by David Marchand <[email protected]>Shared Library Versions
-----------------------lib/librte_eal/common/eal_common_lcore.c +0
-0@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h"
lib/librte_eal/common/eal_common_lcore.c line 28
Quoted 10 lines
lib/librte_eal/common/eal_common_lcore.c +10
-0+int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +}
If I understand it correctly, We are planning to do this scheme only for slow path functions. Right? Is rte_lcore_* functions comes in slow path category? I thought a few of them can be used In fast path too.
I am bit concerned about a low end arm cores where function invocation overhead significant vs inline. ODP has taken a route of introducing a compile time config to choose inline vs separate function to address the performance regression . I am not sure what would be the correct way to handle this.
Re: [dpdk-dev] [PATCH v2 2/5] eal: add accessor functions for lcore_config
Quoted 37 lines · On Tue, 16 Apr 2019 17:03:47 +0000 Jerin Jacob Kollanukkaran…
Quoted 37 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Stephen Hemminger
Sent: Wednesday, April 10, 2019 10:46 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v2 2/5] eal: add accessor functions forlcore_configThe fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples. Mark return code functions as experimental since this value might change in the future and probably shouldn't have been used by non EAL code anyway.
Signed-off-by Stephen Hemminger <[email protected]>Reviewed-by David Marchand <[email protected]>Shared Library Versions
-----------------------lib/librte_eal/common/eal_common_lcore.c +9
-0@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index;
Quoted 8 lines
lib/librte_eal/common/eal_common_lcore.c line 28
Quoted 1 line
lib/librte_eal/common/eal_common_lcore.c +1
-0+}If I understand it correctly, We are planning to do this scheme only for slow path functions. Right? Is rte_lcore_* functions comes in slow path category? I thought a few of them can be used In fast path too.
I am bit concerned about a low end arm cores where function invocation overhead significant vs inline. ODP has taken a route of introducing a compile time config to choose inline vs separate function to address the performance regression . I am not sure what would be the correct way to handle this.
The lcore config itself is not accessed anywhere in fastpath of any of the examples. It is usually is part of the setup process. The rte_lcore_index is only used by lthread in a log message.
The main fastpath is rte_lcore_id() which is already done by per-thread variable and is unchanged by these patches.
I don't have facilities to do any deep dive performance testing on ARM.
Re: [dpdk-dev] [EXT] Re: [PATCH v2 2/5] eal: add accessor functions for lcore_config
Quoted 57 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, May 1, 2019 2:23 AM
To: Jerin Jacob Kollanukkaran <[email protected]>
Cc: [email protected]
Subject: [EXT] Re: [dpdk-dev] [PATCH v2 2/5] eal: add accessor functions forlcore_configQuoted 10 lines · On Tue, 16 Apr 2019 17:03:47 +0000 Jerin Jacob Kollanukkaran…
Quoted 10 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Stephen Hemminger
Sent: Wednesday, April 10, 2019 10:46 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v2 2/5] eal: add accessor functions forlcore_configThe fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with
layout and sizes.
Quoted 19 lines
Quoted 19 lines
Make new accessor functions for the fields used by current drivers and examples. Mark return code functions as experimental since this value might change in the future and probably shouldn't have been used by non EAL code anyway.
Signed-off-by Stephen Hemminger <[email protected]>Reviewed-by David Marchand <[email protected]> SharedLibrary Versions
-----------------------lib/librte_eal/common/eal_common_lcore.c +0
-0@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h" Quoted 12 lines
lib/librte_eal/common/eal_common_lcore.c line 28
Quoted 10 lines
lib/librte_eal/common/eal_common_lcore.c +10
-0+int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +}If I understand it correctly, We are planning to do this scheme only for slow
path functions. Right?
Quoted 3 lines
Is rte_lcore_* functions comes in slow path category? I thought a few of them can be used In fast path too.
I am bit concerned about a low end arm cores where function invocationoverhead significant vs inline.
Quoted 8 lines
Quoted 2 lines
ODP has taken a route of introducing a compile time config to choose inline vs separate function to address the performance regression . I am not
sure what would be the correct way to handle this.
The lcore config itself is not accessed anywhere in fastpath of any of the examples.
It is usually is part of the setup process. Therte_lcore_indexis only used by lthread in a log message.
Makes sense.
Quoted 4 lines
The main fastpath is
rte_lcore_id()which is already done by per-thread variable and is unchanged by these patches.
How about creating a tag like __rte_experimental, say __rte_fastpath for fastpath functions to avoid confusion between what is fastpath and what is not between developers and end users. By creating new section in linker, will make all fast path function in one area.
Quoted 1 line
I don't have facilities to do any deep dive performance testing on ARM.
Re: [dpdk-dev] [PATCH v2 2/5] eal: add accessor functions for lcore_config
In reply to Stephen HemmingerQuoted 100 lines · Stephen Hemminger
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples. Mark return code functions as experimental since this value might change in the future and probably shouldn't have been used by non EAL code anyway.
Signed-off-by Stephen Hemminger <[email protected]>Reviewed-by David Marchand <[email protected]>--- doc/guides/rel_notes/release_19_05.rst | 6 +++ lib/librte_eal/common/eal_common_lcore.c | 39 ++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 50 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 4 files changed, 92 insertions(+), 14 deletions(-)doc/guides/rel_notes/release_19_05.rst +0
-0@@ -222,6 +222,12 @@ ABI Changes alignment for ``rte_crypto_asym_op`` to restore expected``rte_crypto_op``
layout and alignment.doc/guides/rel_notes/release_19_05.rst +2
-0+* eal: the lcore config structure ``struct lcore_config`` will be made + internal to the EAL in a future release. This will allow the structureto
doc/guides/rel_notes/release_19_05.rst +4
-0+ change without impacting API or ABI. All accesses to fields of this + structure should be done by the corresponding accessor functions. + For example, instead of using ``lcore_config[lcore_id].socket_id`` + the function ``rte_lcore_socket_id(lcore_id)`` should be used instead. Shared Library Versions -----------------------lib/librte_eal/common/eal_common_lcore.c +39
-0@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset (unsigned int lcore_id) +{ +return lcore_config[lcore_id].cpuset; +} + +unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) +{ +return lcore_config[lcore_id].socket_id; +} + +int +rte_lcore_return_code (unsigned int lcore_id) +{ +return lcore_config[lcore_id].ret; +} +static int socket_id_cmp (const void *a,const void *b) {lib/librte_eal/common/include/rte_lcore.h +0
-2@@ -121,15 +121,8 @@ rte_lcore_count(void)* @return * The relative index, or -1 if not enabled. */ -static inline int -rte_lcore_index (int lcore_id)
lib/librte_eal/common/include/rte_lcore.h rte_lcore_count(void) · line 126
Quoted 10 lines
lib/librte_eal/common/include/rte_lcore.h +2
-7-{ -if (lcore_id >=RTE_MAX_LCORE ) -return -1 ; -if (lcore_id <0 ) - lcore_id = (int )rte_lcore_id (); -return lcore_config[lcore_id].core_index; -} +int __rte_experimental +rte_lcore_index (int lcore_id);
This is new from v2.
Please remove this __rte_experimental tag.
Quoted 58 lines
lib/librte_eal/common/include/rte_lcore.h +34
-5/** * Return the ID of the physical socket of the logical core we are @@ -177,11 +170,40 @@ rte_socket_id_by_idx(unsigned int idx);* @return * the ID of lcoreid's physical socket */ -static inline unsigned int -rte_lcore_to_socket_id (unsigned int lcore_id) -{ -return lcore_config[lcore_id].socket_id; -} +unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id); + +/** +* Return the id of the lcore on a socket starting from zero. +* +* @param lcore_id +* The targeted lcore, or -1 for the current one. +* @return +* The relative index, or -1 if not enabled. +*/ +int +rte_lcore_to_cpu_id (int lcore_id); + +/** +* Return the cpuset for a given lcore. +* @param lcore_id +* the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1. +* @return +* The cpuset of that lcore +*/ +rte_cpuset_t +rte_lcore_cpuset (unsigned int lcore_id); + +/** +* Get the return code from a lcore thread. +* @param lcore_id +* the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1 +* and finished +* @return +* the return code from the lcore thread +*/ +int __rte_experimental +rte_lcore_return_code (unsigned int lcore_id);/** * Test if an lcore is enabled. lib/librte_eal/rte_eal_version.map +1
-0@@ -268,6 +268,16 @@ DPDK_18.11 { } DPDK_18.08; +DPDK_19.05 {
lib/librte_eal/rte_eal_version.map DPDK_18.11 { · line 281
Quoted 10 lines
lib/librte_eal/rte_eal_version.map +9
-0+ global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_18.08; +
19.05 inherits from 18.11 not 18.08.
EXPERIMENTAL {
Quoted 11 lines
lib/librte_eal/rte_eal_version.map +1
-1global:@@ -329,6 +339,7 @@ EXPERIMENTAL { rte_fbarray_set_free; rte_fbarray_set_used; rte_intr_callback_unregister_pending; + rte_lcore_return_code; rte_log_register_type_and_pick_level; rte_malloc_dump_heaps; rte_malloc_heap_create; --
Quoted 2 lines
2.17.1
And with these two changes, renewing my tag.
Signature · 1 line
David Marchand
PATCH v2 3/5 bus: use lcore accessor functions
In reply to Stephen HemmingerThe lcore_config structure will be hidden in future release.
--- drivers/bus/dpaa/dpaa_bus.c | 6 ++++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +4 -2
@@ -254,6 +254,7 @@ int rte_dpaa_portal_init(void *arg)unsigned int cpu, lcore =rte_lcore_id ();int ret;struct dpaa_portal *dpaa_io_portal; +rte_cpuset_t cpuset;BUS_INIT_FUNC_TRACE ();
@@ -263,12 +264,13 @@ int rte_dpaa_portal_init(void *arg)if (lcore >=RTE_MAX_LCORE )return -1 ; - cpu = lcore_config[lcore].core_id; + cpu =rte_lcore_to_cpu_id (lcore);/* Set CPU affinity for this thread.*/ id =pthread_self (); + cpuset =rte_lcore_cpuset (lcore); ret =pthread_setaffinity_np (id,sizeof (cpu_set_t), - &lcore_config[lcore].cpuset); + &cpuset);if (ret) {DPAA_BUS_LOG (ERR ,"pthread_setaffinity_np failed on core :%u" " (lcore=%u) with ret: %d" , cpu, lcore, ret);
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -1
@@ -366,7 +366,9 @@ dpaa2_check_lcore_cpuset(void)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (CPU_ISSET (i, &lcore_config[lcore_id].cpuset)) { +rte_cpuset_t cpuset =rte_lcore_cpuset (lcore_id); + +if (CPU_ISSET (i, &cpuset)) {RTE_LOG (DEBUG ,EAL ,"lcore id = %u cpu=%u\n" , lcore_id, i);if (dpaa2_cpu[lcore_id] !=0xffffffff ) {
Signature · 1 line
2.17.1
PATCH v2 4/5 examples/bond: use lcore accessor
In reply to Stephen HemmingerReferring to lcore_config directly is no longer recommended.
--- examples/bond/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
examples/bond/main.c +3 -2
@@ -526,8 +526,9 @@ static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,int slave_core_id =rte_lcore_id ();rte_spinlock_trylock (&global_flag_stru_p->lock); -if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { -if (lcore_config[global_flag_stru_p->LcoreMainCore].state !=WAIT ) { +if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { +if (rte_eal_get_lcore_state (global_flag_stru_p->LcoreMainCore) + !=WAIT ) {rte_spinlock_unlock (&global_flag_stru_p->lock);return ; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v2 4/5] examples/bond: use lcore accessor
Quoted 26 lines · Stephen Hemminger
Referring to
lcore_configdirectly is no longer recommended.Signed-off-by Stephen Hemminger <[email protected]>--- examples/bond/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)examples/bond/main.c +3
-2@@ -526,8 +526,9 @@ static void cmd_start_parsed(__attribute__((unused))void *parsed_result, int slave_core_id = rte_lcore_id();rte_spinlock_trylock (&global_flag_stru_p->lock); -if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { -if (lcore_config[global_flag_stru_p->LcoreMainCore].state != WAIT) { +if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { +if (rte_eal_get_lcore_state (global_flag_stru_p->LcoreMainCore) + !=WAIT ) {rte_spinlock_unlock(&global_flag_stru_p->lock); return; }
Quoted 4 lines
--
2.17.1
Same comment than in v2, you missed another lcore_config in this file at line 800.
Signature · 1 line
David Marchand
PATCH v2 5/5 app/test: use lcore accessor functions
In reply to Stephen HemmingerDon't refer to lcore_config directly.
--- app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++++++------- app/test/test_ring_perf.c | 22 ++++++++++++---------- app/test/test_stack_perf.c | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 28 deletions(-)
app/test/test_cryptodev.c +1 -1
@@ -378,7 +378,7 @@ testsuite_setup(void)strcpy (temp_str, vdev_args);strlcat (temp_str,";" ,sizeof (temp_str)); slave_core_count++; - socket_id = lcore_config[i].socket_id; + socket_id =rte_lcore_to_socket_id (i); }if (slave_core_count !=2 ) { RTE_LOG(ERR, USER1,
app/test/test_hash_readwrite_lf.c +7 -7
@@ -741,7 +741,7 @@ test_hash_add_no_ks_lookup_hit(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -813,7 +813,7 @@ test_hash_add_no_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -889,7 +889,7 @@ test_hash_add_ks_lookup_hit_non_sp(struct rwc_perf *rwc_perf_results,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -965,7 +965,7 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1040,7 +1040,7 @@ test_hash_add_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, intif (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1141,7 +1141,7 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1225,7 +1225,7 @@ test_hash_add_ks_lookup_hit_extbkt(struct rwc_perf *rwc_perf_results,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
app/test/test_ring_perf.c +12 -10
@@ -52,10 +52,11 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 == c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -75,10 +76,11 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 != c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -98,8 +100,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if (s1 != s2){ lcp->c1 = id1; lcp->c2 = id2;
app/test/test_stack_perf.c +10 -10
@@ -44,10 +44,10 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] == core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -70,10 +70,10 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] != core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -95,8 +95,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if (socket[0 ] != socket[1 ]) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
Signature · 1 line
2.17.1
Quoted 17 lines · On Wed, 10 Apr 2019 10:15:58 -0700 Stephen Hemminger…
This set of patches makes the
lcore_configstructure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moveslcore_configintoeal_private.hThe changes in v2 is to:
- new patch to use unsigned int inlcore.hfirst
- incorporate feedback from David
- don't include last patch to make it private
(to avoid accidental early merge)Stephen Hemminger (5):
eal: use unsigned int inrte_lcore.hfunctions
eal: add accessor functions forlcore_config
bus: use lcore accessor functions
examples/bond: use lcore accessor
app/test: use lcore accessor functions
Quoted 13 lines
app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++--- app/test/test_ring_perf.c | 22 +++++---- app/test/test_stack_perf.c | 20 ++++---- doc/guides/rel_notes/release_19_05.rst | 6 +++ drivers/bus/dpaa/dpaa_bus.c | 6 ++- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +- examples/bond/main.c | 5 +- lib/librte_eal/common/eal_common_lcore.c | 39 +++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 58 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 11 files changed, 136 insertions(+), 51 deletions(-)
Why is this patchset still stuck in the queue?
The parts with deprecation and accessor functions should really go in 19.05 but since it has sat around for so long, it is probably too late.
v3 cover prepare to make lcore_config not visible in ABI
In reply to Stephen HemmingerThis set of patches makes the lcore_config structure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moves lcore_config into eal_private.h
Changes for v3 (based on David's feedback):
- rte_lcore_index should not be experimental
- eal map should chain from 18.11
- more fixes in bond example
Stephen Hemminger (5):
eal: use unsigned int in rte_lcore.h functions
eal: add accessor functions for lcore_config
bus: use lcore accessor functions
examples/bond: use lcore accessor
app/test: use lcore accessor functions
app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++--- app/test/test_ring_perf.c | 22 +++++---- app/test/test_stack_perf.c | 20 ++++---- doc/guides/rel_notes/release_19_05.rst | 6 +++ drivers/bus/dpaa/dpaa_bus.c | 6 ++- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +- examples/bond/main.c | 13 +++--- lib/librte_eal/common/eal_common_lcore.c | 39 ++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 57 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 11 files changed, 139 insertions(+), 55 deletions(-)
Signature · 1 line
2.20.1
PATCH v3 1/5 eal: use unsigned int in rte_lcore.h functions
Purely cosmetic change, use unsigned int instead of unsigned alone.
--- lib/librte_eal/common/include/rte_lcore.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/librte_eal/common/include/rte_lcore.h +6 -6
@@ -137,7 +137,7 @@ rte_lcore_index(int lcore_id)* @return * the ID of current lcoreid's physical socket */ -unsigned rte_socket_id (void ); +unsigned int rte_socket_id (void );/** * Return number of physical sockets detected on the system.
@@ -177,8 +177,8 @@ rte_socket_id_by_idx(unsigned int idx);* @return * the ID of lcoreid's physical socket */ -static inline unsigned -rte_lcore_to_socket_id (unsigned lcore_id) +static inline unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) {return lcore_config[lcore_id].socket_id; }
@@ -193,7 +193,7 @@ rte_lcore_to_socket_id(unsigned lcore_id)* True if the given lcore is enabled; false otherwise. */ static inline int -rte_lcore_is_enabled (unsigned lcore_id) +rte_lcore_is_enabled (unsigned int lcore_id) {struct rte_config *cfg =rte_eal_get_configuration ();if (lcore_id >=RTE_MAX_LCORE )
@@ -214,8 +214,8 @@ rte_lcore_is_enabled(unsigned lcore_id)* @return * The next lcore_id or RTE_MAX_LCORE if not found. */ -static inline unsigned -rte_get_next_lcore (unsigned i,int skip_master,int wrap) +static inline unsigned int +rte_get_next_lcore (unsigned int i,int skip_master,int wrap) { i++;if (wrap)
Signature · 1 line
2.20.1
PATCH v3 2/5 eal: add accessor functions for lcore_config
In reply to Stephen HemmingerThe fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples. Mark return code functions as experimental since this value might change in the future and probably shouldn't have been used by non EAL code anyway.
--- doc/guides/rel_notes/release_19_05.rst | 6 +++ lib/librte_eal/common/eal_common_lcore.c | 39 ++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 49 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 4 files changed, 91 insertions(+), 14 deletions(-)
doc/guides/rel_notes/release_19_05.rst +6 -0
@@ -275,6 +275,12 @@ ABI Changes alignment for ``rte_crypto_asym_op`` to restore expected ``rte_crypto_op`` layout and alignment. +* eal: the lcore config structure ``struct lcore_config`` will be made + internal to the EAL in a future release. This will allow the structure to + change without impacting API or ABI. All accesses to fields of this + structure should be done by the corresponding accessor functions. + For example, instead of using ``lcore_config[lcore_id].socket_id`` + the function ``rte_lcore_socket_id(lcore_id)`` should be used instead. Shared Library Versions -----------------------
lib/librte_eal/common/eal_common_lcore.c +39 -0
@@ -16,6 +16,45 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset (unsigned int lcore_id) +{ +return lcore_config[lcore_id].cpuset; +} + +unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) +{ +return lcore_config[lcore_id].socket_id; +} + +int +rte_lcore_return_code (unsigned int lcore_id) +{ +return lcore_config[lcore_id].ret; +} +static int socket_id_cmp (const void *a,const void *b) {
lib/librte_eal/common/include/rte_lcore.h +35 -14
61 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +11 -0
@@ -287,6 +287,16 @@ DPDK_19.05 { } DPDK_18.11; +DPDK_19.05 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_18.11; + EXPERIMENTAL { global:
@@ -337,6 +347,7 @@ EXPERIMENTAL { rte_fbarray_set_free; rte_fbarray_set_used; rte_intr_callback_unregister_pending; + rte_lcore_return_code; rte_log_register_type_and_pick_level; rte_malloc_dump_heaps; rte_malloc_heap_create;
Signature · 1 line
2.20.1
PATCH v3 3/5 bus: use lcore accessor functions
In reply to Stephen HemmingerThe lcore_config structure will be hidden in future release.
--- drivers/bus/dpaa/dpaa_bus.c | 6 ++++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +4 -2
@@ -254,6 +254,7 @@ int rte_dpaa_portal_init(void *arg)unsigned int cpu, lcore =rte_lcore_id ();int ret;struct dpaa_portal *dpaa_io_portal; +rte_cpuset_t cpuset;BUS_INIT_FUNC_TRACE ();
@@ -263,12 +264,13 @@ int rte_dpaa_portal_init(void *arg)if (lcore >=RTE_MAX_LCORE )return -1 ; - cpu = lcore_config[lcore].core_id; + cpu =rte_lcore_to_cpu_id (lcore);/* Set CPU affinity for this thread.*/ id =pthread_self (); + cpuset =rte_lcore_cpuset (lcore); ret =pthread_setaffinity_np (id,sizeof (cpu_set_t), - &lcore_config[lcore].cpuset); + &cpuset);if (ret) {DPAA_BUS_LOG (ERR ,"pthread_setaffinity_np failed on core :%u" " (lcore=%u) with ret: %d" , cpu, lcore, ret);
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -1
@@ -366,7 +366,9 @@ dpaa2_check_lcore_cpuset(void)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (CPU_ISSET (i, &lcore_config[lcore_id].cpuset)) { +rte_cpuset_t cpuset =rte_lcore_cpuset (lcore_id); + +if (CPU_ISSET (i, &cpuset)) {RTE_LOG (DEBUG ,EAL ,"lcore id = %u cpu=%u\n" , lcore_id, i);if (dpaa2_cpu[lcore_id] !=0xffffffff ) {
Signature · 1 line
2.20.1
PATCH v3 4/5 examples/bond: use lcore accessor
In reply to Stephen HemmingerReferring to lcore_config directly is no longer recommended. Also remove unnecessary assignment of slave_core_id.
--- examples/bond/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
examples/bond/main.c +7 -6
@@ -526,8 +526,9 @@ static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,int slave_core_id =rte_lcore_id ();rte_spinlock_trylock (&global_flag_stru_p->lock); -if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { -if (lcore_config[global_flag_stru_p->LcoreMainCore].state !=WAIT ) { +if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { +if (rte_eal_get_lcore_state (global_flag_stru_p->LcoreMainCore) + !=WAIT ) {rte_spinlock_unlock (&global_flag_stru_p->lock);return ; }
@@ -760,7 +761,7 @@ static void prompt(__attribute__((unused)) void *arg1)int main (int argc,char *argv[]) { -int ret; +int ret, slave_core_id;uint16_t nb_ports, i;/* init EAL */
@@ -792,13 +793,13 @@ main(int argc, char *argv[])bond_port_init (mbuf_pool);rte_spinlock_init (&global_flag_stru_p->lock); -int slave_core_id =rte_lcore_id ();/* check state of lcores */ RTE_LCORE_FOREACH_SLAVE (slave_core_id) { -if (lcore_config[slave_core_id].state !=WAIT ) -return -EBUSY ; +if (rte_eal_get_lcore_state (slave_core_id) !=WAIT ) +return -EBUSY ; } +/* start lcore main on core != master_core - ARP response thread */ slave_core_id =rte_get_next_lcore (rte_lcore_id (),1 ,0 );if ((slave_core_id >=RTE_MAX_LCORE ) || (slave_core_id ==0 ))
Signature · 1 line
2.20.1
PATCH v3 5/5 app/test: use lcore accessor functions
In reply to Stephen HemmingerDon't refer to lcore_config directly.
--- app/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++++++------- app/test/test_ring_perf.c | 22 ++++++++++++---------- app/test/test_stack_perf.c | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 28 deletions(-)
app/test/test_cryptodev.c +1 -1
@@ -378,7 +378,7 @@ testsuite_setup(void)strcpy (temp_str, vdev_args);strlcat (temp_str,";" ,sizeof (temp_str)); slave_core_count++; - socket_id = lcore_config[i].socket_id; + socket_id =rte_lcore_to_socket_id (i); }if (slave_core_count !=2 ) { RTE_LOG(ERR, USER1,
app/test/test_hash_readwrite_lf.c +7 -7
@@ -741,7 +741,7 @@ test_hash_add_no_ks_lookup_hit(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -813,7 +813,7 @@ test_hash_add_no_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -889,7 +889,7 @@ test_hash_add_ks_lookup_hit_non_sp(struct rwc_perf *rwc_perf_results,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -965,7 +965,7 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf,if (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1040,7 +1040,7 @@ test_hash_add_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, intif (ret <0 ) goto err;for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1141,7 +1141,7 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
@@ -1225,7 +1225,7 @@ test_hash_add_ks_lookup_hit_extbkt(struct rwc_perf *rwc_perf_results,rte_eal_mp_wait_lcore ();for (i =1 ; i <= rwc_core_cnt[n]; i++) -if (lcore_config[i].ret <0 ) +if (rte_lcore_return_code (i) <0 ) goto err; unsigned long long cycles_per_lookup =
app/test/test_ring_perf.c +12 -10
@@ -52,10 +52,11 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 == c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -75,10 +76,11 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 != c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -98,8 +100,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if (s1 != s2){ lcp->c1 = id1; lcp->c2 = id2;
app/test/test_stack_perf.c +10 -10
@@ -44,10 +44,10 @@ get_two_hyperthreads(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] == core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -70,10 +70,10 @@ get_two_cores(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] != core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -95,8 +95,8 @@ get_two_sockets(struct lcore_pair *lcp)RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if (socket[0 ] != socket[1 ]) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v3 0/5] prepare to make lcore_config not visible in ABI
In reply to Stephen HemmingerQuoted 29 lines · Stephen Hemminger
This set of patches makes the
lcore_configstructure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moveslcore_configintoeal_private.hChanges for v3 (based on David's feedback):
-rte_lcore_indexshould not be experimental
- eal map should chain from 18.11
- more fixes in bond exampleStephen Hemminger (5):
eal: use unsigned int inrte_lcore.hfunctions
eal: add accessor functions forlcore_config
bus: use lcore accessor functions
examples/bond: use lcore accessor
app/test: use lcore accessor functionsapp/test/test_cryptodev.c | 2 +- app/test/test_hash_readwrite_lf.c | 14 +++--- app/test/test_ring_perf.c | 22 +++++---- app/test/test_stack_perf.c | 20 ++++---- doc/guides/rel_notes/release_19_05.rst | 6 +++ drivers/bus/dpaa/dpaa_bus.c | 6 ++- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +- examples/bond/main.c | 13 +++--- lib/librte_eal/common/eal_common_lcore.c | 39 ++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 57 ++++++++++++++++------- lib/librte_eal/rte_eal_version.map | 11 +++++ 11 files changed, 139 insertions(+), 55 deletions(-)
Quoted 4 lines
--
2.20.1
LGTM.
Signature · 1 line
David Marchand
v4 cover make lcore_config internal
In reply to Stephen HemmingerThis set of patches makes the lcore_config structure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moves lcore_config into eal_private.h
Changelog since v3:
I took the liberty of taking over Stephen series.
I rebased and did some adjustments following [1] cleanups. As stated before, we will still need a deprecation notice when hiding lcore_config but this series does not break API nor ABI.
Changelog since v2:
- new patch to use unsigned int in lcore.h first
- incorporate feedback from David
- don't include last patch to make it private
(to avoid accidental early merge)
1: http://patchwork.dpdk.org/patch/53621/
Signature · 22 lines
David Marchand Stephen Hemminger (5): eal: use unsigned int in lcore API prototypes eal: add lcore accessors drivers/bus: use lcore accessors examples/bond: use lcore accessors test: use lcore accessors app/test/test_cryptodev.c | 2 +- app/test/test_ring_perf.c | 22 ++++++++------- app/test/test_stack_perf.c | 20 +++++++------- drivers/bus/dpaa/dpaa_bus.c | 6 ++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 ++- examples/bond/main.c | 13 +++++---- lib/librte_eal/common/eal_common_lcore.c | 33 ++++++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 46 +++++++++++++++++++------------ lib/librte_eal/rte_eal_version.map | 10 +++++++ 9 files changed, 108 insertions(+), 48 deletions(-) -- 1.8.3.1
PATCH v4 1/5 eal: use unsigned int in lcore API prototypes
From: Stephen Hemminger <[email protected]>
Purely cosmetic change, use unsigned int instead of unsigned alone.
--- lib/librte_eal/common/include/rte_lcore.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Changelog since v3:
- updated title
lib/librte_eal/common/include/rte_lcore.h +6 -6
@@ -137,7 +137,7 @@ struct lcore_config {* @return * the ID of current lcoreid's physical socket */ -unsigned rte_socket_id (void ); +unsigned int rte_socket_id (void );/** * Return number of physical sockets detected on the system.
@@ -177,8 +177,8 @@ struct lcore_config {* @return * the ID of lcoreid's physical socket */ -static inline unsigned -rte_lcore_to_socket_id (unsigned lcore_id) +static inline unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) {return lcore_config[lcore_id].socket_id; }
@@ -193,7 +193,7 @@ struct lcore_config {* True if the given lcore is enabled; false otherwise. */ static inline int -rte_lcore_is_enabled (unsigned lcore_id) +rte_lcore_is_enabled (unsigned int lcore_id) {struct rte_config *cfg =rte_eal_get_configuration ();if (lcore_id >=RTE_MAX_LCORE )
@@ -214,8 +214,8 @@ struct lcore_config {* @return * The next lcore_id or RTE_MAX_LCORE if not found. */ -static inline unsigned -rte_get_next_lcore (unsigned i,int skip_master,int wrap) +static inline unsigned int +rte_get_next_lcore (unsigned int i,int skip_master,int wrap) { i++;if (wrap)
Signature · 1 line
1.8.3.1
PATCH v4 2/5 eal: add lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
--- lib/librte_eal/common/eal_common_lcore.c | 33 +++++++++++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 38 +++++++++++++++++++------------ lib/librte_eal/rte_eal_version.map | 10 ++++++++ 3 files changed, 67 insertions(+), 14 deletions(-)
---
Changelog since v3:
- updated title
- rebased on master
- removed doc update
- removed unneeded rte_lcore_return_code
lib/librte_eal/common/eal_common_lcore.c +33 -0
@@ -16,6 +16,39 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset (unsigned int lcore_id) +{ +return lcore_config[lcore_id].cpuset; +} + +unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) +{ +return lcore_config[lcore_id].socket_id; +} +static int socket_id_cmp (const void *a,const void *b) {
lib/librte_eal/common/include/rte_lcore.h +24 -14
@@ -121,15 +121,7 @@ struct lcore_config {* @return * The relative index, or -1 if not enabled. */ -static inline int -rte_lcore_index (int lcore_id) -{ -if (lcore_id >=RTE_MAX_LCORE ) -return -1 ; -if (lcore_id <0 ) - lcore_id = (int )rte_lcore_id (); -return lcore_config[lcore_id].core_index; -} +int rte_lcore_index (int lcore_id);/** * Return the ID of the physical socket of the logical core we are
@@ -177,11 +169,29 @@ struct lcore_config {* @return * the ID of lcoreid's physical socket */ -static inline unsigned int -rte_lcore_to_socket_id (unsigned int lcore_id) -{ -return lcore_config[lcore_id].socket_id; -} +unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id); + +/** +* Return the id of the lcore on a socket starting from zero. +* +* @param lcore_id +* The targeted lcore, or -1 for the current one. +* @return +* The relative index, or -1 if not enabled. +*/ +int +rte_lcore_to_cpu_id (int lcore_id); + +/** +* Return the cpuset for a given lcore. +* @param lcore_id +* the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1. +* @return +* The cpuset of that lcore +*/ +rte_cpuset_t +rte_lcore_cpuset (unsigned int lcore_id);/** * Test if an lcore is enabled.
lib/librte_eal/rte_eal_version.map +10 -0
@@ -287,6 +287,16 @@ DPDK_19.05 { } DPDK_18.11; +DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
23/05/2019 15:58, David Marchand:
Quoted 8 lines
From: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
[...]
lib/librte_eal/rte_eal_version.map DPDK_19.05 { · line 301
Quoted 12 lines
lib/librte_eal/rte_eal_version.map +10
-0+DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:
Just to make sure, are we OK to introduce these functions as non-experimental?
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
Quoted 10 lines · On Thu, 30 May 2019 00:46:30 +0200 Thomas Monjalon <[email protected]> wrote:
23/05/2019 15:58, David Marchand:
Quoted 8 lines
From: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
[...]
Quoted 15 lines
lib/librte_eal/rte_eal_version.map DPDK_19.05 { · line 301
Quoted 12 lines
lib/librte_eal/rte_eal_version.map +10
-0+DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:Just to make sure, are we OK to introduce these functions as non-experimental?
They were in previous releases as inlines this patch converts them to real functions.
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
Quoted 29 lines · Stephen Hemminger
Quoted 10 lines · On Thu, 30 May 2019 00:46:30 +0200 Thomas Monjalon <[email protected]> wrote:
23/05/2019 15:58, David Marchand:
Quoted 8 lines
From: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
[...]
Quoted 15 lines
lib/librte_eal/rte_eal_version.map DPDK_19.05 { · line 301
Quoted 12 lines
lib/librte_eal/rte_eal_version.map +10
-0+DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:Just to make sure, are we OK to introduce these functions as non-experimental?
Quoted 4 lines
They were in previous releases as inlines this patch converts them to real functions.
Well, yes and no.
rte_lcore_index and rte_lcore_to_socket_id already existed, so making them part of the ABI is fine for me.
rte_lcore_to_cpu_id is new but seems quite safe in how it can be used, adding it to the ABI is ok for me.
rte_lcore_cpuset is new too, and still a bit obscure to me. I am not really convinced we need it until I understand why dpaa2 and fslmc bus need to know about this.
I might need more time to look at it, so flag this as experimental sounds fair to me.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
30/05/2019 09:31, David Marchand:
Quoted 36 lines
Quoted 29 lines · Stephen Hemminger
Quoted 10 lines · On Thu, 30 May 2019 00:46:30 +0200 Thomas Monjalon <[email protected]> wrote:
23/05/2019 15:58, David Marchand:
Quoted 8 lines
From: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
[...]
Quoted 15 lines
lib/librte_eal/rte_eal_version.map DPDK_19.05 { · line 301
Quoted 12 lines
lib/librte_eal/rte_eal_version.map +10
-0+DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:Just to make sure, are we OK to introduce these functions as non-experimental?
Quoted 4 lines
They were in previous releases as inlines this patch converts them to real functions.
Quoted 7 lines
Well, yes and no.
rte_lcore_indexandrte_lcore_to_socket_idalready existed, so making them part of the ABI is fine for me.
rte_lcore_to_cpu_idis new but seems quite safe in how it can be used, adding it to the ABI is ok for me.
It is used by DPAA and some test.
I guess adding as experimental is fine too?
I'm fine with both options, I'm just trying to apply the policy we agreed on. Does this case deserve an exception?
Quoted 5 lines
rte_lcore_cpusetis new too, and still a bit obscure to me. I am not really convinced we need it until I understand why dpaa2 and fslmc bus need to know about this.
I might need more time to look at it, so flag this as experimental sounds fair to me.
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
Quoted 42 lines · Thomas Monjalon
30/05/2019 09:31, David Marchand:
Quoted 41 lines
Quoted 29 lines · Stephen Hemminger
Quoted 10 lines · On Thu, 30 May 2019 00:46:30 +0200 Thomas Monjalon <[email protected]> wrote:
23/05/2019 15:58, David Marchand:
Quoted 8 lines
From: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
[...]
Quoted 15 lines
lib/librte_eal/rte_eal_version.map DPDK_19.05 { · line 301
Quoted 12 lines
lib/librte_eal/rte_eal_version.map +10
-0+DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:Just to make sure, are we OK to introduce these functions as non-experimental?
Quoted 4 lines
They were in previous releases as inlines this patch converts them to real functions.
Well, yes and no.
rte_lcore_indexandrte_lcore_to_socket_idalready existed, so making them part of the ABI is fine for me.
Quoted 8 lines
Quoted 2 lines
rte_lcore_to_cpu_idis new but seems quite safe in how it can be used, adding it to the ABI is ok for me.It is used by DPAA and some test.
I guess adding as experimental is fine too?
I'm fine with both options, I'm just trying to apply the policy we agreed on. Does this case deserve an exception?
While it may be a good candidate, I'm not sure how much making an exception for it really matters. I'd be tempted to just mark it experimental and then have it stable for the 19.11 release. What do we really lose by waiting a release to stabilize it?
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
30/05/2019 12:11, Bruce Richardson:
Quoted 52 lines · Thomas Monjalon
Quoted 42 lines
30/05/2019 09:31, David Marchand:
Quoted 41 lines
Quoted 29 lines · Stephen Hemminger
Quoted 10 lines · On Thu, 30 May 2019 00:46:30 +0200 Thomas Monjalon <[email protected]> wrote:
23/05/2019 15:58, David Marchand:
Quoted 8 lines
From: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
[...]
Quoted 15 lines
lib/librte_eal/rte_eal_version.map DPDK_19.05 { · line 301
Quoted 12 lines
lib/librte_eal/rte_eal_version.map +10
-0+DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:Just to make sure, are we OK to introduce these functions as non-experimental?
Quoted 4 lines
They were in previous releases as inlines this patch converts them to real functions.
Well, yes and no.
rte_lcore_indexandrte_lcore_to_socket_idalready existed, so making them part of the ABI is fine for me.Quoted 8 lines
Quoted 2 lines
rte_lcore_to_cpu_idis new but seems quite safe in how it can be used, adding it to the ABI is ok for me.It is used by DPAA and some test.
I guess adding as experimental is fine too?
I'm fine with both options, I'm just trying to apply the policy we agreed on. Does this case deserve an exception?
Quoted 4 lines
While it may be a good candidate, I'm not sure how much making an exception for it really matters. I'd be tempted to just mark it experimental and then have it stable for the 19.11 release. What do we really lose by waiting a release to stabilize it?
I would agree Bruce.
If no more comment, I will wait for a v5 of this series.
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
Quoted 58 lines · Thomas Monjalon
30/05/2019 12:11, Bruce Richardson:
Quoted 5 lines · Thomas Monjalon
Quoted 4 lines
30/05/2019 09:31, David Marchand:
Quoted 3 lines
On Thu, May 30, 2019 at 12:51 AM Stephen Hemminger < [email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines · On Thu, 30 May 2019 00:46:30 +0200 Thomas Monjalon <[email protected]> wrote:
23/05/2019 15:58, David Marchand:
Quoted 4 lines
From: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and
limits
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
fixing issues with layout and sizes.
Make new accessor functions for the fields used by current
drivers
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 1 line
and examples.
[...]
Review
Quoted 12 lines
(quoted diff) +10
-0+DPDK_19.08 { + global: + + rte_lcore_cpuset; + rte_lcore_index; + rte_lcore_to_cpu_id; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:Just to make sure, are we OK to introduce these functions as non-experimental?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
They were in previous releases as inlines this patch converts them to real functions.
Well, yes and no.
rte_lcore_indexandrte_lcore_to_socket_idalready existed, somaking them
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
part of the ABI is fine for me.
rte_lcore_to_cpu_idis new but seems quite safe in how it can beused,
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
adding it to the ABI is ok for me.
It is used by DPAA and some test.
I guess adding as experimental is fine too?
I'm fine with both options, I'm just trying to apply the policy we agreed on. Does this case deserve an exception?While it may be a good candidate, I'm not sure how much making an
Quoted 9 lines
exception
Quoted 1 line
for it really matters. I'd be tempted to just mark it experimental and
then
Quoted 2 lines
have it stable for the 19.11 release. What do we really lose by waiting a release to stabilize it?
I would agree Bruce.
If no more comment, I will wait for a v5 of this series.
I agree that there is no reason we make an exception for those 2 new ones.
But to me the existing rte_lcore_index and rte_lcore_to_socket_id must be marked as stable.
This is to avoid breaking existing users that did not set ALLOW_EXPERIMENTAL_API.
I will prepare a v5 later.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v4 2/5] eal: add lcore accessors
Quoted 72 lines · David Marchand
On Thu, May 30, 2019 at 3:39 PM Thomas Monjalon <[1][email protected]> wrote: 30/05/2019 12:11, Bruce Richardson: > On Thu, May 30, 2019 at 09:40:08AM +0200, Thomas Monjalon wrote: > > 30/05/2019 09:31, David Marchand: > > > On Thu, May 30, 2019 at 12:51 AM Stephen Hemminger < > > > [2][email protected]> wrote: > > > > > > > On Thu, 30 May 2019 00:46:30 +0200 > > > > Thomas Monjalon <[3][email protected]> wrote: > > > > > > > > > 23/05/2019 15:58, David Marchand: > > > > > > From: Stephen Hemminger <[4][email protected]> > > > > > > > > > > > > The fields of the internal EAL core configuration are currently > > > > > > laid bare as part of the API. This is not good practice and limits > > > > > > fixing issues with layout and sizes. > > > > > > > > > > > > Make new accessor functions for the fields used by current drivers > > > > > > and examples. > > > > > [...] > > > > > > +DPDK_19.08 { > > > > > > + global: > > > > > > + > > > > > > + rte_lcore_cpuset; > > > > > > + rte_lcore_index; > > > > > > + rte_lcore_to_cpu_id; > > > > > > + rte_lcore_to_socket_id; > > > > > > + > > > > > > +} DPDK_19.05; > > > > > > + > > > > > > EXPERIMENTAL { > > > > > > global: > > > > > > > > > > Just to make sure, are we OK to introduce these functions > > > > > as non-experimental? > > > > > > > > They were in previous releases as inlines this patch converts them > > > > to real functions. > > > > > > > > > > > Well, yes and no. > > > > > > rte_lcore_index and rte_lcore_to_socket_id already existed, so making them > > > part of the ABI is fine for me. > > > > > > rte_lcore_to_cpu_id is new but seems quite safe in how it can be used, > > > adding it to the ABI is ok for me. > > > > It is used by DPAA and some test. > > I guess adding as experimental is fine too? > > I'm fine with both options, I'm just trying to apply the policy > > we agreed on. Does this case deserve an exception? > > > > While it may be a good candidate, I'm not sure how much making an exception > for it really matters. I'd be tempted to just mark it experimental and then > have it stable for the 19.11 release. What do we really lose by waiting a > release to stabilize it? I would agree Bruce. If no more comment, I will wait for a v5 of this series.
Quoted 8 lines
I agree that there is no reason we make an exception for those 2 new ones. But to me the existing rte_lcore_index and rte_lcore_to_socket_id must be marked as stable. This is to avoid breaking existing users that did not set ALLOW_EXPERIMENTAL_API. I will prepare a v5 later. --
Yes, agreed. Any existing APIs that were already present as static inlines can go straight to stable when added to the .map file.
/Bruce
PATCH v4 3/5 drivers/bus: use lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
The lcore_config structure will be hidden in future release.
--- drivers/bus/dpaa/dpaa_bus.c | 6 ++++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)
---
Changelog since v3:
- updated title
drivers/bus/dpaa/dpaa_bus.c +4 -2
@@ -254,6 +254,7 @@ int rte_dpaa_portal_init(void *arg)unsigned int cpu, lcore =rte_lcore_id ();int ret;struct dpaa_portal *dpaa_io_portal; +rte_cpuset_t cpuset;BUS_INIT_FUNC_TRACE ();
@@ -263,12 +264,13 @@ int rte_dpaa_portal_init(void *arg)if (lcore >=RTE_MAX_LCORE )return -1 ; - cpu = lcore_config[lcore].core_id; + cpu =rte_lcore_to_cpu_id (lcore);/* Set CPU affinity for this thread.*/ id =pthread_self (); + cpuset =rte_lcore_cpuset (lcore); ret =pthread_setaffinity_np (id,sizeof (cpu_set_t), - &lcore_config[lcore].cpuset); + &cpuset);if (ret) {DPAA_BUS_LOG (ERR ,"pthread_setaffinity_np failed on core :%u" " (lcore=%u) with ret: %d" , cpu, lcore, ret);
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -1
@@ -366,7 +366,9 @@ static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (CPU_ISSET (i, &lcore_config[lcore_id].cpuset)) { +rte_cpuset_t cpuset =rte_lcore_cpuset (lcore_id); + +if (CPU_ISSET (i, &cpuset)) {RTE_LOG (DEBUG ,EAL ,"lcore id = %u cpu=%u\n" , lcore_id, i);if (dpaa2_cpu[lcore_id] !=0xffffffff ) {
Signature · 1 line
1.8.3.1
PATCH v4 4/5 examples/bond: use lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
Referring to lcore_config directly is no longer recommended. Also remove unnecessary assignment of slave_core_id.
--- examples/bond/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
---
Changelog since v3:
- updated title
examples/bond/main.c +7 -6
@@ -526,8 +526,9 @@ static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,int slave_core_id =rte_lcore_id ();rte_spinlock_trylock (&global_flag_stru_p->lock); -if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { -if (lcore_config[global_flag_stru_p->LcoreMainCore].state !=WAIT ) { +if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { +if (rte_eal_get_lcore_state (global_flag_stru_p->LcoreMainCore) + !=WAIT ) {rte_spinlock_unlock (&global_flag_stru_p->lock);return ; }
@@ -760,7 +761,7 @@ static void prompt(__attribute__((unused)) void *arg1)int main (int argc,char *argv[]) { -int ret; +int ret, slave_core_id;uint16_t nb_ports, i;/* init EAL */
@@ -792,13 +793,13 @@ static void prompt(__attribute__((unused)) void *arg1)bond_port_init (mbuf_pool);rte_spinlock_init (&global_flag_stru_p->lock); -int slave_core_id =rte_lcore_id ();/* check state of lcores */ RTE_LCORE_FOREACH_SLAVE (slave_core_id) { -if (lcore_config[slave_core_id].state !=WAIT ) -return -EBUSY ; +if (rte_eal_get_lcore_state (slave_core_id) !=WAIT ) +return -EBUSY ; } +/* start lcore main on core != master_core - ARP response thread */ slave_core_id =rte_get_next_lcore (rte_lcore_id (),1 ,0 );if ((slave_core_id >=RTE_MAX_LCORE ) || (slave_core_id ==0 ))
Signature · 1 line
1.8.3.1
PATCH v4 5/5 test: use lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
Don't refer to lcore_config directly.
--- app/test/test_cryptodev.c | 2 +- app/test/test_ring_perf.c | 22 ++++++++++++---------- app/test/test_stack_perf.c | 20 ++++++++++---------- 3 files changed, 23 insertions(+), 21 deletions(-)
---
Changelog since v3:
- updated title
- removed parts on test_hash_readwrite_lf
app/test/test_cryptodev.c +1 -1
@@ -378,7 +378,7 @@ struct crypto_unittest_params {strcpy (temp_str, vdev_args);strlcat (temp_str,";" ,sizeof (temp_str)); slave_core_count++; - socket_id = lcore_config[i].socket_id; + socket_id =rte_lcore_to_socket_id (i); }if (slave_core_count !=2 ) { RTE_LOG(ERR, USER1,
app/test/test_ring_perf.c +12 -10
@@ -52,10 +52,11 @@ struct lcore_pair {RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 == c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -75,10 +76,11 @@ struct lcore_pair {RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 != c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -98,8 +100,8 @@ struct lcore_pair {RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if (s1 != s2){ lcp->c1 = id1; lcp->c2 = id2;
app/test/test_stack_perf.c +10 -10
@@ -44,10 +44,10 @@ struct lcore_pair {RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] == core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -70,10 +70,10 @@ struct lcore_pair {RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] != core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -95,8 +95,8 @@ struct lcore_pair {RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if (socket[0 ] != socket[1 ]) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
Signature · 1 line
1.8.3.1
Quoted 10 lines · On Thu, 23 May 2019 15:58:56 +0200 David Marchand <[email protected]>…
This set of patches makes the
lcore_configstructure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moveslcore_configintoeal_private.hChangelog since v3:
I took the liberty of taking over Stephen series.
I rebased and did some adjustments following [1] cleanups. As stated before, we will still need a deprecation notice when hidinglcore_configbut this series does not break API nor ABI.
Quoted 8 lines
Changelog since v2:
- new patch to use unsigned int inlcore.hfirst
- incorporate feedback from David
- don't include last patch to make it private
(to avoid accidental early merge)
Thanks for doing this.
We still need the documentation update to indicate deprecation.
v5 cover make lcore_config internal
In reply to Stephen HemmingerThis set of patches makes the lcore_config structure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moves lcore_config into eal_private.h
Changelog since v4:
The only change is in patch 2: marked new apis as experimental.
Changelog since v3:
I took the liberty of taking over Stephen series.
I rebased and did some adjustments following [1] cleanups. As stated before, we will still need a deprecation notice when hiding lcore_config but this series does not break API nor ABI.
Changelog since v2:
- new patch to use unsigned int in lcore.h first
- incorporate feedback from David
- don't include last patch to make it private
(to avoid accidental early merge)
1: http://patchwork.dpdk.org/patch/53621/
Signature · 22 lines
David Marchand Stephen Hemminger (5): eal: use unsigned int in lcore API prototypes eal: add lcore accessors drivers/bus: use lcore accessors examples/bond: use lcore accessors test: use lcore accessors app/test/test_cryptodev.c | 2 +- app/test/test_ring_perf.c | 22 +++++++------ app/test/test_stack_perf.c | 20 ++++++------ drivers/bus/dpaa/dpaa_bus.c | 6 ++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 ++- examples/bond/main.c | 13 ++++---- lib/librte_eal/common/eal_common_lcore.c | 33 ++++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 52 ++++++++++++++++++++----------- lib/librte_eal/rte_eal_version.map | 12 +++++++ 9 files changed, 116 insertions(+), 48 deletions(-) -- 1.8.3.1
PATCH v5 1/5 eal: use unsigned int in lcore API prototypes
From: Stephen Hemminger <[email protected]>
Purely cosmetic change, use unsigned int instead of unsigned alone.
--- lib/librte_eal/common/include/rte_lcore.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Changelog since v3:
- updated title
lib/librte_eal/common/include/rte_lcore.h +6 -6
@@ -137,7 +137,7 @@ struct lcore_config {* @return * the ID of current lcoreid's physical socket */ -unsigned rte_socket_id (void ); +unsigned int rte_socket_id (void );/** * Return number of physical sockets detected on the system.
@@ -177,8 +177,8 @@ struct lcore_config {* @return * the ID of lcoreid's physical socket */ -static inline unsigned -rte_lcore_to_socket_id (unsigned lcore_id) +static inline unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) {return lcore_config[lcore_id].socket_id; }
@@ -193,7 +193,7 @@ struct lcore_config {* True if the given lcore is enabled; false otherwise. */ static inline int -rte_lcore_is_enabled (unsigned lcore_id) +rte_lcore_is_enabled (unsigned int lcore_id) {struct rte_config *cfg =rte_eal_get_configuration ();if (lcore_id >=RTE_MAX_LCORE )
@@ -214,8 +214,8 @@ struct lcore_config {* @return * The next lcore_id or RTE_MAX_LCORE if not found. */ -static inline unsigned -rte_get_next_lcore (unsigned i,int skip_master,int wrap) +static inline unsigned int +rte_get_next_lcore (unsigned int i,int skip_master,int wrap) { i++;if (wrap)
Signature · 1 line
1.8.3.1
PATCH v5 2/5 eal: add lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
The fields of the internal EAL core configuration are currently laid bare as part of the API. This is not good practice and limits fixing issues with layout and sizes.
Make new accessor functions for the fields used by current drivers and examples.
--- lib/librte_eal/common/eal_common_lcore.c | 33 +++++++++++++++++++++++ lib/librte_eal/common/include/rte_lcore.h | 44 +++++++++++++++++++++---------- lib/librte_eal/rte_eal_version.map | 12 +++++++++ 3 files changed, 75 insertions(+), 14 deletions(-)
---
Changelog since v4:
- marked rte_lcore_to_cpu_id and rte_lcore_cpuset as experimental
Changelog since v3:
- updated title
- rebased on master
- removed doc update
- removed unneeded rte_lcore_return_code
lib/librte_eal/common/eal_common_lcore.c +33 -0
@@ -16,6 +16,39 @@#include "eal_private.h" #include "eal_thread.h" +int rte_lcore_index (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_index; +} + +int rte_lcore_to_cpu_id (int lcore_id) +{ +if (unlikely (lcore_id >=RTE_MAX_LCORE )) +return -1 ; + +if (lcore_id <0 ) + lcore_id = (int )rte_lcore_id (); + +return lcore_config[lcore_id].core_id; +} + +rte_cpuset_t rte_lcore_cpuset (unsigned int lcore_id) +{ +return lcore_config[lcore_id].cpuset; +} + +unsigned int +rte_lcore_to_socket_id (unsigned int lcore_id) +{ +return lcore_config[lcore_id].socket_id; +} +static int socket_id_cmp (const void *a,const void *b) {
lib/librte_eal/common/include/rte_lcore.h +30 -14
56 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +12 -0
@@ -287,6 +287,14 @@ DPDK_19.05 { } DPDK_18.11; +DPDK_19.08 { + global: + + rte_lcore_index; + rte_lcore_to_socket_id; + +} DPDK_19.05; + EXPERIMENTAL { global:
@@ -378,4 +386,8 @@ EXPERIMENTAL { rte_service_lcore_attr_get; rte_service_lcore_attr_reset_all; rte_service_may_be_active; + + # added in 19.08 + rte_lcore_cpuset; + rte_lcore_to_cpu_id; };
Signature · 1 line
1.8.3.1
PATCH v5 3/5 drivers/bus: use lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
The lcore_config structure will be hidden in future release.
--- drivers/bus/dpaa/dpaa_bus.c | 6 ++++-- drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-)
---
Changelog since v3:
- updated title
drivers/bus/dpaa/dpaa_bus.c +4 -2
@@ -254,6 +254,7 @@ int rte_dpaa_portal_init(void *arg)unsigned int cpu, lcore =rte_lcore_id ();int ret;struct dpaa_portal *dpaa_io_portal; +rte_cpuset_t cpuset;BUS_INIT_FUNC_TRACE ();
@@ -263,12 +264,13 @@ int rte_dpaa_portal_init(void *arg)if (lcore >=RTE_MAX_LCORE )return -1 ; - cpu = lcore_config[lcore].core_id; + cpu =rte_lcore_to_cpu_id (lcore);/* Set CPU affinity for this thread.*/ id =pthread_self (); + cpuset =rte_lcore_cpuset (lcore); ret =pthread_setaffinity_np (id,sizeof (cpu_set_t), - &lcore_config[lcore].cpuset); + &cpuset);if (ret) {DPAA_BUS_LOG (ERR ,"pthread_setaffinity_np failed on core :%u" " (lcore=%u) with ret: %d" , cpu, lcore, ret);
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +3 -1
@@ -366,7 +366,9 @@ static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)for (lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) {for (i =0 ; i <RTE_MAX_LCORE ; i++) { -if (CPU_ISSET (i, &lcore_config[lcore_id].cpuset)) { +rte_cpuset_t cpuset =rte_lcore_cpuset (lcore_id); + +if (CPU_ISSET (i, &cpuset)) {RTE_LOG (DEBUG ,EAL ,"lcore id = %u cpu=%u\n" , lcore_id, i);if (dpaa2_cpu[lcore_id] !=0xffffffff ) {
Signature · 1 line
1.8.3.1
PATCH v5 4/5 examples/bond: use lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
Referring to lcore_config directly is no longer recommended. Also remove unnecessary assignment of slave_core_id.
--- examples/bond/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
---
Changelog since v3:
- updated title
examples/bond/main.c +7 -6
@@ -531,8 +531,9 @@ static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,int slave_core_id =rte_lcore_id ();rte_spinlock_trylock (&global_flag_stru_p->lock); -if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { -if (lcore_config[global_flag_stru_p->LcoreMainCore].state !=WAIT ) { +if (global_flag_stru_p->LcoreMainIsRunning ==0 ) { +if (rte_eal_get_lcore_state (global_flag_stru_p->LcoreMainCore) + !=WAIT ) {rte_spinlock_unlock (&global_flag_stru_p->lock);return ; }
@@ -765,7 +766,7 @@ static void prompt(__attribute__((unused)) void *arg1)int main (int argc,char *argv[]) { -int ret; +int ret, slave_core_id;uint16_t nb_ports, i;/* init EAL */
@@ -797,13 +798,13 @@ static void prompt(__attribute__((unused)) void *arg1)bond_port_init (mbuf_pool);rte_spinlock_init (&global_flag_stru_p->lock); -int slave_core_id =rte_lcore_id ();/* check state of lcores */ RTE_LCORE_FOREACH_SLAVE (slave_core_id) { -if (lcore_config[slave_core_id].state !=WAIT ) -return -EBUSY ; +if (rte_eal_get_lcore_state (slave_core_id) !=WAIT ) +return -EBUSY ; } +/* start lcore main on core != master_core - ARP response thread */ slave_core_id =rte_get_next_lcore (rte_lcore_id (),1 ,0 );if ((slave_core_id >=RTE_MAX_LCORE ) || (slave_core_id ==0 ))
Signature · 1 line
1.8.3.1
PATCH v5 5/5 test: use lcore accessors
In reply to David MarchandFrom: Stephen Hemminger <[email protected]>
Don't refer to lcore_config directly.
--- app/test/test_cryptodev.c | 2 +- app/test/test_ring_perf.c | 22 ++++++++++++---------- app/test/test_stack_perf.c | 20 ++++++++++---------- 3 files changed, 23 insertions(+), 21 deletions(-)
---
Changelog since v3:
- updated title
- removed parts on test_hash_readwrite_lf
app/test/test_cryptodev.c +1 -1
@@ -378,7 +378,7 @@ struct crypto_unittest_params {strcpy (temp_str, vdev_args);strlcat (temp_str,";" ,sizeof (temp_str)); slave_core_count++; - socket_id = lcore_config[i].socket_id; + socket_id =rte_lcore_to_socket_id (i); }if (slave_core_count !=2 ) { RTE_LOG(ERR, USER1,
app/test/test_ring_perf.c +12 -10
@@ -52,10 +52,11 @@ struct lcore_pair {RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 == c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -75,10 +76,11 @@ struct lcore_pair {RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - c1 = lcore_config[id1].core_id; - c2 = lcore_config[id2].core_id; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + + c1 =rte_lcore_to_cpu_id (id1); + c2 =rte_lcore_to_cpu_id (id2); + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if ((c1 != c2) && (s1 == s2)){ lcp->c1 = id1; lcp->c2 = id2;
@@ -98,8 +100,8 @@ struct lcore_pair {RTE_LCORE_FOREACH (id2) {if (id1 == id2)continue ; - s1 = lcore_config[id1].socket_id; - s2 = lcore_config[id2].socket_id; + s1 =rte_lcore_to_socket_id (id1); + s2 =rte_lcore_to_socket_id (id2);if (s1 != s2){ lcp->c1 = id1; lcp->c2 = id2;
app/test/test_stack_perf.c +10 -10
@@ -44,10 +44,10 @@ struct lcore_pair {RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] == core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -70,10 +70,10 @@ struct lcore_pair {RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - core[0 ] = lcore_config[id[0 ]].core_id; - core[1 ] = lcore_config[id[1 ]].core_id; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + core[0 ] =rte_lcore_to_cpu_id (id[0 ]); + core[1 ] =rte_lcore_to_cpu_id (id[1 ]); + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if ((core[0 ] != core[1 ]) && (socket[0 ] == socket[1 ])) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
@@ -95,8 +95,8 @@ struct lcore_pair {RTE_LCORE_FOREACH (id[1 ]) {if (id[0 ] == id[1 ])continue ; - socket[0 ] = lcore_config[id[0 ]].socket_id; - socket[1 ] = lcore_config[id[1 ]].socket_id; + socket[0 ] =rte_lcore_to_socket_id (id[0 ]); + socket[1 ] =rte_lcore_to_socket_id (id[1 ]);if (socket[0 ] != socket[1 ]) { lcp->c1 = id[0 ]; lcp->c2 = id[1 ];
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v5 5/5] test: use lcore accessors
Quoted 6 lines
From: Stephen Hemminger <[email protected]>
Don't refer to
lcore_configdirectly.Signed-off-by Stephen Hemminger <[email protected]>Signed-off-by David Marchand <[email protected]>
Thomas Monjalon
Applied31/05/2019 17:36, David Marchand:
Quoted 13 lines
This set of patches makes the
lcore_configstructure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moveslcore_configintoeal_private.hChangelog since v4:
The only change is in patch 2: marked new apis as experimental.Changelog since v3:
I took the liberty of taking over Stephen series.
I rebased and did some adjustments following [1] cleanups. As stated before, we will still need a deprecation notice when hidinglcore_configbut this series does not break API nor ABI.
Quoted 5 lines
Changelog since v2:
- new patch to use unsigned int inlcore.hfirst
- incorporate feedback from David
- don't include last patch to make it private
(to avoid accidental early merge)
Applied, thanks
Quoted 14 lines · On Mon, 03 Jun 2019 12:32:02 +0200 Thomas Monjalon <[email protected]> wrote:
31/05/2019 17:36, David Marchand:
Quoted 13 lines
This set of patches makes the
lcore_configstructure less visible as part of the ABI. This version does not break the ABI (yet) follow on patch moveslcore_configintoeal_private.hChangelog since v4:
The only change is in patch 2: marked new apis as experimental.Changelog since v3:
I took the liberty of taking over Stephen series.
I rebased and did some adjustments following [1] cleanups. As stated before, we will still need a deprecation notice when hidinglcore_configbut this series does not break API nor ABI.
Quoted 9 lines
Quoted 5 lines
Changelog since v2:
- new patch to use unsigned int inlcore.hfirst
- incorporate feedback from David
- don't include last patch to make it private
(to avoid accidental early merge)Applied, thanks
Thanks. Now to get to eal_config