[v4,2/2] eal: annotate rte_memseg_list_walk()
Checks
Commit Message
Implementing a lock annotation for rte_memseg_list_walk() to
proactively identify bugs similar to memory_hotplug_lock deadlock during
initialization during compile time.
Bugzilla ID: 1277
Signed-off-by: Artemy Kovalyov <artemyko@nvidia.com>
---
lib/eal/common/eal_memalloc.h | 3 ++-
lib/eal/common/eal_private.h | 3 ++-
lib/eal/include/rte_lock_annotations.h | 5 +++++
lib/eal/include/rte_memory.h | 4 +++-
4 files changed, 12 insertions(+), 3 deletions(-)
Comments
On Fri, Sep 8, 2023 at 3:18 PM Artemy Kovalyov <artemyko@nvidia.com> wrote:
>
> Implementing a lock annotation for rte_memseg_list_walk() to
> proactively identify bugs similar to memory_hotplug_lock deadlock during
> initialization during compile time.
>
> Signed-off-by: Artemy Kovalyov <artemyko@nvidia.com>
Series applied, thanks Artemy.
@@ -91,7 +91,8 @@ struct rte_memseg *
eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset);
int
-eal_memalloc_init(void);
+eal_memalloc_init(void)
+ __rte_shared_locks_required(rte_mcfg_mem_get_lock());
int
eal_memalloc_cleanup(void);
@@ -115,7 +115,8 @@ struct rte_config {
* @return
* 0 on success, negative on error
*/
-int rte_eal_memory_init(void);
+int rte_eal_memory_init(void)
+ __rte_shared_locks_required(rte_mcfg_mem_get_lock());
/**
* Configure timers
@@ -40,6 +40,9 @@
#define __rte_unlock_function(...) \
__attribute__((unlock_function(__VA_ARGS__)))
+#define __rte_locks_excluded(...) \
+ __attribute__((locks_excluded(__VA_ARGS__)))
+
#define __rte_no_thread_safety_analysis \
__attribute__((no_thread_safety_analysis))
@@ -62,6 +65,8 @@
#define __rte_unlock_function(...)
+#define __rte_locks_excluded(...)
+
#define __rte_no_thread_safety_analysis
#endif /* RTE_ANNOTATE_LOCKS */
@@ -22,6 +22,7 @@
#include <rte_bitops.h>
#include <rte_common.h>
#include <rte_config.h>
+#include <rte_eal_memconfig.h>
#include <rte_fbarray.h>
#define RTE_PGSIZE_4K (1ULL << 12)
@@ -250,7 +251,8 @@ typedef int (*rte_memseg_list_walk_t)(const struct rte_memseg_list *msl,
* -1 if user function reported error
*/
int
-rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg);
+rte_memseg_list_walk(rte_memseg_list_walk_t func, void *arg)
+ __rte_locks_excluded(rte_mcfg_mem_get_lock());
/**
* Walk list of all memsegs without performing any locking.