mem: explicitly initialise shared locks

Message ID 20231027080048.251483-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series mem: explicitly initialise shared locks |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing fail Testing issues
ci/iol-compile-arm64-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

David Marchand Oct. 27, 2023, 8 a.m. UTC
  Locks in the DPDK shared memory were not initialised so far.
This is not really a problem as the early_mem_config structure is stored
in the bss section (and so set to 0 by default).
Yet, for consistency, explicitly initialise those locks with relevant
initialiser macros.

Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/eal/common/eal_common_config.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Comments

fengchengwen Oct. 27, 2023, 9:33 a.m. UTC | #1
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2023/10/27 16:00, David Marchand wrote:
> Locks in the DPDK shared memory were not initialised so far.
> This is not really a problem as the early_mem_config structure is stored
> in the bss section (and so set to 0 by default).
> Yet, for consistency, explicitly initialise those locks with relevant
> initialiser macros.
> 
> Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  lib/eal/common/eal_common_config.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/eal/common/eal_common_config.c b/lib/eal/common/eal_common_config.c
> index 0daf0f3188..2d6c04a49a 100644
> --- a/lib/eal/common/eal_common_config.c
> +++ b/lib/eal/common/eal_common_config.c
> @@ -8,7 +8,14 @@
>  #include "eal_memcfg.h"
>  
>  /* early configuration structure, when memory config is not mmapped */
> -static struct rte_mem_config early_mem_config;
> +static struct rte_mem_config early_mem_config = {
> +	.mlock = RTE_RWLOCK_INITIALIZER,
> +	.qlock = RTE_RWLOCK_INITIALIZER,
> +	.mplock = RTE_RWLOCK_INITIALIZER,
> +	.tlock = RTE_SPINLOCK_INITIALIZER,
> +	.ethdev_lock = RTE_SPINLOCK_INITIALIZER,
> +	.memory_hotplug_lock = RTE_RWLOCK_INITIALIZER,
> +};
>  
>  /* Address of global and public configuration */
>  static struct rte_config rte_config = {
>
  
David Marchand Feb. 1, 2024, 3:36 p.m. UTC | #2
On Fri, Oct 27, 2023 at 10:01 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> Locks in the DPDK shared memory were not initialised so far.
> This is not really a problem as the early_mem_config structure is stored
> in the bss section (and so set to 0 by default).
> Yet, for consistency, explicitly initialise those locks with relevant
> initialiser macros.
>
> Suggested-by: Thomas Monjalon <thomas@monjalon.net>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>

Applied, thanks.
  

Patch

diff --git a/lib/eal/common/eal_common_config.c b/lib/eal/common/eal_common_config.c
index 0daf0f3188..2d6c04a49a 100644
--- a/lib/eal/common/eal_common_config.c
+++ b/lib/eal/common/eal_common_config.c
@@ -8,7 +8,14 @@ 
 #include "eal_memcfg.h"
 
 /* early configuration structure, when memory config is not mmapped */
-static struct rte_mem_config early_mem_config;
+static struct rte_mem_config early_mem_config = {
+	.mlock = RTE_RWLOCK_INITIALIZER,
+	.qlock = RTE_RWLOCK_INITIALIZER,
+	.mplock = RTE_RWLOCK_INITIALIZER,
+	.tlock = RTE_SPINLOCK_INITIALIZER,
+	.ethdev_lock = RTE_SPINLOCK_INITIALIZER,
+	.memory_hotplug_lock = RTE_RWLOCK_INITIALIZER,
+};
 
 /* Address of global and public configuration */
 static struct rte_config rte_config = {