From: "tip-bot2 for Waiman Long" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Waiman Long <longman@redhat.com>, Ingo Molnar <mingo@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/urgent] locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini()
Date: Wed, 17 Mar 2021 12:38:22 -0000 [thread overview]
Message-ID: <161598470224.398.10597010936099036923.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210316153119.13802-3-longman@redhat.com>
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: bee645788e07eea63055d261d2884ea45c2ba857
Gitweb: https://git.kernel.org/tip/bee645788e07eea63055d261d2884ea45c2ba857
Author: Waiman Long <longman@redhat.com>
AuthorDate: Tue, 16 Mar 2021 11:31:17 -04:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 17 Mar 2021 09:56:45 +01:00
locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini()
In ww_acquire_init(), mutex_acquire() is gated by CONFIG_DEBUG_LOCK_ALLOC.
The dep_map in the ww_acquire_ctx structure is also gated by the
same config. However mutex_release() in ww_acquire_fini() is gated by
CONFIG_DEBUG_MUTEXES. It is possible to set CONFIG_DEBUG_MUTEXES without
setting CONFIG_DEBUG_LOCK_ALLOC though it is an unlikely configuration.
That may cause a compilation error as dep_map isn't defined in this
case. Fix this potential problem by enclosing mutex_release() inside
CONFIG_DEBUG_LOCK_ALLOC.
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210316153119.13802-3-longman@redhat.com
---
include/linux/ww_mutex.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h
index 850424e..6ecf2a0 100644
--- a/include/linux/ww_mutex.h
+++ b/include/linux/ww_mutex.h
@@ -173,9 +173,10 @@ static inline void ww_acquire_done(struct ww_acquire_ctx *ctx)
*/
static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx)
{
-#ifdef CONFIG_DEBUG_MUTEXES
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
mutex_release(&ctx->dep_map, _THIS_IP_);
-
+#endif
+#ifdef CONFIG_DEBUG_MUTEXES
DEBUG_LOCKS_WARN_ON(ctx->acquired);
if (!IS_ENABLED(CONFIG_PROVE_LOCKING))
/*
next prev parent reply other threads:[~2021-03-17 12:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 15:31 [PATCH 0/4] locking/ww_mutex: Fix locktorture ww_mutex test problems Waiman Long
2021-03-16 15:31 ` [PATCH 1/4] locking/ww_mutex: Simplify use_ww_ctx & ww_ctx handling Waiman Long
2021-03-16 18:55 ` Davidlohr Bueso
2021-03-17 12:38 ` [tip: locking/urgent] " tip-bot2 for Waiman Long
2021-03-17 12:59 ` Peter Zijlstra
2021-03-17 13:43 ` Waiman Long
2021-03-17 13:55 ` Peter Zijlstra
2021-03-17 14:10 ` Waiman Long
2021-03-17 14:17 ` Peter Zijlstra
2021-03-17 14:33 ` Waiman Long
2021-03-16 15:31 ` [PATCH 2/4] locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini() Waiman Long
2021-03-17 12:38 ` tip-bot2 for Waiman Long [this message]
2021-03-16 15:31 ` [PATCH 3/4] locking/ww_mutex: Treat ww_mutex_lock() like a trylock Waiman Long
2021-03-17 3:01 ` Davidlohr Bueso
2021-03-17 12:38 ` [tip: locking/urgent] " tip-bot2 for Waiman Long
2021-03-17 13:12 ` Peter Zijlstra
2021-03-17 13:31 ` Peter Zijlstra
2021-03-17 14:03 ` Waiman Long
2021-03-17 15:35 ` Waiman Long
2021-03-17 16:48 ` Peter Zijlstra
2021-03-17 17:40 ` Peter Zijlstra
2021-03-17 17:45 ` Peter Zijlstra
2021-03-17 18:32 ` Waiman Long
2021-03-17 19:58 ` Peter Zijlstra
2021-03-17 20:20 ` Waiman Long
2021-03-17 18:14 ` Waiman Long
2021-03-18 2:24 ` [PATCH 3/4] " Boqun Feng
2021-03-18 2:54 ` Waiman Long
2021-03-18 6:36 ` Boqun Feng
2021-03-16 15:31 ` [PATCH 4/4] locking/locktorture: Fix incorrect use of ww_acquire_ctx in ww_mutex test Waiman Long
2021-03-17 5:16 ` Davidlohr Bueso
2021-03-17 13:21 ` Waiman Long
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=161598470224.398.10597010936099036923.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@kernel.org \
--cc=x86@kernel.org \
/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).