From: "Robin Jarry" <rjarry@redhat.com>
To: "Thomas Monjalon" <thomas@monjalon.net>, <dev@dpdk.org>
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
"Konstantin Ananyev" <konstantin.ananyev@huawei.com>,
"Bruce Richardson" <bruce.richardson@intel.com>
Subject: Re: [PATCH v3 2/3] spinlock: add debug checks in recursive unlock
Date: Tue, 19 May 2026 13:47:39 +0200 [thread overview]
Message-ID: <DIMMNX51I02T.DRHRXO9HTQCT@redhat.com> (raw)
In-Reply-To: <20260519103640.3986710-2-thomas@monjalon.net>
Thomas Monjalon, May 19, 2026 at 12:34:
> The recursive unlock assumes that the caller owns the lock.
> This behavior will be checked when RTE_ENABLE_ASSERT is on.
> There is an additional check for the count which should be positive
> if no corruption happened.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v3: new patch in the series
> ---
> lib/eal/include/generic/rte_spinlock.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/eal/include/generic/rte_spinlock.h b/lib/eal/include/generic/rte_spinlock.h
> index ffdcb8fa3d..e7cd18a8e2 100644
> --- a/lib/eal/include/generic/rte_spinlock.h
> +++ b/lib/eal/include/generic/rte_spinlock.h
> @@ -21,6 +21,7 @@
> #ifdef RTE_FORCE_INTRINSICS
> #include <rte_common.h>
> #endif
> +#include <rte_debug.h>
> #include <rte_lock_annotations.h>
> #include <rte_pause.h>
> #include <rte_stdatomic.h>
> @@ -245,6 +246,8 @@ static inline void rte_spinlock_recursive_lock(rte_spinlock_recursive_t *slr)
> static inline void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr)
> __rte_no_thread_safety_analysis
> {
> + RTE_ASSERT(rte_atomic_load_explicit(&slr->owner, rte_memory_order_relaxed) == rte_gettid());
> + RTE_ASSERT(slr->count > 0);
> if (--(slr->count) == 0) {
> rte_atomic_store_explicit(&slr->owner, -1, rte_memory_order_relaxed);
> rte_spinlock_unlock(&slr->sl);
Acked-by: Robin Jarry <rjarry@redhat.com>
next prev parent reply other threads:[~2026-05-19 11:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 8:37 [PATCH] spinlock: remove volatile qualifier Thomas Monjalon
2026-05-04 9:06 ` Thomas Monjalon
2026-05-04 9:12 ` [PATCH] spinlock: fix API comments Thomas Monjalon
2026-05-04 12:46 ` Thomas Monjalon
2026-05-18 13:57 ` [PATCH] spinlock: remove volatile qualifier Thomas Monjalon
2026-05-04 17:02 ` Stephen Hemminger
2026-05-05 7:01 ` Thomas Monjalon
2026-05-05 13:24 ` Stephen Hemminger
2026-05-18 15:07 ` [PATCH v2 1/2] " Thomas Monjalon
2026-05-18 15:07 ` [PATCH v2 2/2] spinlock: fix API comments Thomas Monjalon
2026-05-18 15:14 ` [PATCH v2 1/2] spinlock: remove volatile qualifier Robin Jarry
2026-05-18 15:25 ` Thomas Monjalon
2026-05-18 15:28 ` Bruce Richardson
2026-05-19 9:17 ` Robin Jarry
2026-05-19 10:35 ` Thomas Monjalon
2026-05-18 16:26 ` Stephen Hemminger
2026-05-18 16:28 ` Stephen Hemminger
2026-05-19 10:34 ` [PATCH v3 1/3] " Thomas Monjalon
2026-05-19 10:34 ` [PATCH v3 2/3] spinlock: add debug checks in recursive unlock Thomas Monjalon
2026-05-19 11:19 ` Thomas Monjalon
2026-05-19 11:47 ` Robin Jarry [this message]
2026-05-19 10:34 ` [PATCH v3 3/3] spinlock: fix API comments Thomas Monjalon
2026-05-19 11:03 ` [PATCH v3 1/3] spinlock: remove volatile qualifier Bruce Richardson
2026-05-19 13:32 ` Stephen Hemminger
2026-05-19 15:02 ` 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=DIMMNX51I02T.DRHRXO9HTQCT@redhat.com \
--to=rjarry@redhat.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@huawei.com \
--cc=stephen@networkplumber.org \
--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