DPDK patches and discussions
 help / color / mirror / Atom feed
From: Artemy Kovalyov <artemyko@nvidia.com>
To: <dev@dpdk.org>
Cc: Thomas Monjalon <thomas@monjalon.net>,
	Ophir Munk <ophirmu@nvidia.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [PATCH v4 2/2] eal: annotate rte_memseg_list_walk()
Date: Fri, 8 Sep 2023 16:17:36 +0300	[thread overview]
Message-ID: <20230908131737.1714750-3-artemyko@nvidia.com> (raw)
In-Reply-To: <20230908131737.1714750-1-artemyko@nvidia.com>

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(-)

diff --git a/lib/eal/common/eal_memalloc.h b/lib/eal/common/eal_memalloc.h
index ebc3a6f..286ffb7 100644
--- a/lib/eal/common/eal_memalloc.h
+++ b/lib/eal/common/eal_memalloc.h
@@ -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);
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 5eadba4..ebd496b 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -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
diff --git a/lib/eal/include/rte_lock_annotations.h b/lib/eal/include/rte_lock_annotations.h
index 9fc5008..2456a69 100644
--- a/lib/eal/include/rte_lock_annotations.h
+++ b/lib/eal/include/rte_lock_annotations.h
@@ -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 */
diff --git a/lib/eal/include/rte_memory.h b/lib/eal/include/rte_memory.h
index 3a1c607..842362d 100644
--- a/lib/eal/include/rte_memory.h
+++ b/lib/eal/include/rte_memory.h
@@ -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.
-- 
1.8.3.1


  parent reply	other threads:[~2023-09-08 13:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 10:33 [PATCH] eal: fix memory initialization deadlock Artemy Kovalyov
2023-08-30 19:13 ` Dmitry Kozlyuk
2023-09-04  8:24 ` [PATCH v2] " Artemy Kovalyov
2023-09-05  7:05   ` Dmitry Kozlyuk
2023-09-05  9:05     ` Artemy Kovalyov
2023-09-05 10:15       ` David Marchand
2023-09-06  9:52 ` [PATCH v3] " Artemy Kovalyov
2023-09-06 12:52   ` David Marchand
2023-09-08 13:17 ` [PATCH v4 0/2] " Artemy Kovalyov
2023-09-08 13:17   ` [PATCH v4 1/2] eal: " Artemy Kovalyov
2023-09-08 13:17   ` Artemy Kovalyov [this message]
2023-10-06 10:12     ` [PATCH v4 2/2] eal: annotate rte_memseg_list_walk() David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230908131737.1714750-3-artemyko@nvidia.com \
    --to=artemyko@nvidia.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=ophirmu@nvidia.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).