Skip to contentSkip to conversation

mem: explicitly initialise shared locks

PATCH Applied David Marchand 2 participants 3 messages Oct 27, 2023 – Feb 1, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mem: explicitly initialise shared locks

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.

---
 lib/eal/common/eal_common_config.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/eal/common/eal_common_config.c +8 -1
index 0daf0f3188..2d6c04a49a 100644
@@ -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 = {
Signature · 1 line
2.41.0
Acked-by on v1 1/1
#1 lore raw
Quoted 33 lines · David Marchand

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.

---
 lib/eal/common/eal_common_config.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
lib/eal/common/eal_common_config.c +8 -1
index 0daf0f3188..2d6c04a49a 100644
@@ -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 = {
author Applied
#2 lore raw
In reply to David Marchand
Quoted 10 lines · David Marchand

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.

Applied, thanks.

Signature · 1 line
David Marchand