From: Christoph Hellwig <hch@lst.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>, xfs@oss.sgi.com
Subject: Re: [PATCH, RFC] xfs: remove i_iolock and use i_rwsem in the VFS inode instead
Date: Mon, 5 Sep 2016 17:12:44 +0200 [thread overview]
Message-ID: <20160905151244.GA16726@lst.de> (raw)
In-Reply-To: <20160822083455.GH10153@twins.programming.kicks-ass.net>
Peter, this is the fixed up patch. Can you write a proper changelog
and add your signoff?
---
include/linux/lockdep.h | 18 ++++++++++++++++--
kernel/locking/lockdep.c | 43 ++++++++++++++++++++++++++-----------------
2 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index eabe013..4cef9f8 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -338,9 +338,15 @@ extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
extern void lock_release(struct lockdep_map *lock, int nested,
unsigned long ip);
-#define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
+extern int _lock_is_held(struct lockdep_map *lock, int read);
-extern int lock_is_held(struct lockdep_map *lock);
+static inline int lock_is_held(struct lockdep_map *lock)
+{
+ return _lock_is_held(lock, -1);
+}
+
+#define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
+#define _lockdep_is_held(lock, r) _lock_is_held(&(lock)->dep_map, (r))
extern void lock_set_class(struct lockdep_map *lock, const char *name,
struct lock_class_key *key, unsigned int subclass,
@@ -372,6 +378,14 @@ extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie);
WARN_ON(debug_locks && !lockdep_is_held(l)); \
} while (0)
+#define lockdep_assert_held_exclusive(l) do { \
+ WARN_ON(debug_locks && !_lockdep_is_held(l, 0));\
+ } while (0)
+
+#define lockdep_assert_held_read(l) do { \
+ WARN_ON(debug_locks && !_lockdep_is_held(l, 1));\
+ } while (0)
+
#define lockdep_assert_held_once(l) do { \
WARN_ON_ONCE(debug_locks && !lockdep_is_held(l)); \
} while (0)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 589d763..f39573b 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3188,7 +3188,7 @@ print_lock_nested_lock_not_held(struct task_struct *curr,
return 0;
}
-static int __lock_is_held(struct lockdep_map *lock);
+static int __lock_is_held(struct lockdep_map *lock, int read);
/*
* This gets called for every mutex_lock*()/spin_lock*() operation.
@@ -3329,7 +3329,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
}
chain_key = iterate_chain_key(chain_key, class_idx);
- if (nest_lock && !__lock_is_held(nest_lock))
+ if (nest_lock && !__lock_is_held(nest_lock, -1))
return print_lock_nested_lock_not_held(curr, hlock, ip);
if (!validate_chain(curr, lock, hlock, chain_head, chain_key))
@@ -3390,10 +3390,17 @@ print_unlock_imbalance_bug(struct task_struct *curr, struct lockdep_map *lock,
return 0;
}
-static int match_held_lock(struct held_lock *hlock, struct lockdep_map *lock)
+static int match_held_lock(struct held_lock *hlock, struct lockdep_map *lock, int read)
{
- if (hlock->instance == lock)
- return 1;
+ if (hlock->instance == lock) {
+ if (read == -1)
+ return 1;
+
+ if (hlock->read == read)
+ return 1;
+
+ return 0;
+ }
if (hlock->references) {
struct lock_class *class = lock->class_cache[0];
@@ -3420,6 +3427,8 @@ static int match_held_lock(struct held_lock *hlock, struct lockdep_map *lock)
if (hlock->class_idx == class - lock_classes + 1)
return 1;
+
+ /* XXX do we want @read stuff for nested locks !? */
}
return 0;
@@ -3452,7 +3461,7 @@ __lock_set_class(struct lockdep_map *lock, const char *name,
*/
if (prev_hlock && prev_hlock->irq_context != hlock->irq_context)
break;
- if (match_held_lock(hlock, lock))
+ if (match_held_lock(hlock, lock, -1))
goto found_it;
prev_hlock = hlock;
}
@@ -3523,7 +3532,7 @@ __lock_release(struct lockdep_map *lock, int nested, unsigned long ip)
*/
if (prev_hlock && prev_hlock->irq_context != hlock->irq_context)
break;
- if (match_held_lock(hlock, lock))
+ if (match_held_lock(hlock, lock, -1))
goto found_it;
prev_hlock = hlock;
}
@@ -3576,7 +3585,7 @@ found_it:
return 1;
}
-static int __lock_is_held(struct lockdep_map *lock)
+static int __lock_is_held(struct lockdep_map *lock, int read)
{
struct task_struct *curr = current;
int i;
@@ -3584,7 +3593,7 @@ static int __lock_is_held(struct lockdep_map *lock)
for (i = 0; i < curr->lockdep_depth; i++) {
struct held_lock *hlock = curr->held_locks + i;
- if (match_held_lock(hlock, lock))
+ if (match_held_lock(hlock, lock, read))
return 1;
}
@@ -3603,7 +3612,7 @@ static struct pin_cookie __lock_pin_lock(struct lockdep_map *lock)
for (i = 0; i < curr->lockdep_depth; i++) {
struct held_lock *hlock = curr->held_locks + i;
- if (match_held_lock(hlock, lock)) {
+ if (match_held_lock(hlock, lock, -1)) {
/*
* Grab 16bits of randomness; this is sufficient to not
* be guessable and still allows some pin nesting in
@@ -3630,7 +3639,7 @@ static void __lock_repin_lock(struct lockdep_map *lock, struct pin_cookie cookie
for (i = 0; i < curr->lockdep_depth; i++) {
struct held_lock *hlock = curr->held_locks + i;
- if (match_held_lock(hlock, lock)) {
+ if (match_held_lock(hlock, lock, -1)) {
hlock->pin_count += cookie.val;
return;
}
@@ -3650,7 +3659,7 @@ static void __lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie cookie
for (i = 0; i < curr->lockdep_depth; i++) {
struct held_lock *hlock = curr->held_locks + i;
- if (match_held_lock(hlock, lock)) {
+ if (match_held_lock(hlock, lock, -1)) {
if (WARN(!hlock->pin_count, "unpinning an unpinned lock\n"))
return;
@@ -3769,7 +3778,7 @@ void lock_release(struct lockdep_map *lock, int nested,
}
EXPORT_SYMBOL_GPL(lock_release);
-int lock_is_held(struct lockdep_map *lock)
+int _lock_is_held(struct lockdep_map *lock, int read)
{
unsigned long flags;
int ret = 0;
@@ -3781,13 +3790,13 @@ int lock_is_held(struct lockdep_map *lock)
check_flags(flags);
current->lockdep_recursion = 1;
- ret = __lock_is_held(lock);
+ ret = __lock_is_held(lock, read);
current->lockdep_recursion = 0;
raw_local_irq_restore(flags);
return ret;
}
-EXPORT_SYMBOL_GPL(lock_is_held);
+EXPORT_SYMBOL_GPL(_lock_is_held);
struct pin_cookie lock_pin_lock(struct lockdep_map *lock)
{
@@ -3908,7 +3917,7 @@ __lock_contended(struct lockdep_map *lock, unsigned long ip)
*/
if (prev_hlock && prev_hlock->irq_context != hlock->irq_context)
break;
- if (match_held_lock(hlock, lock))
+ if (match_held_lock(hlock, lock, -1))
goto found_it;
prev_hlock = hlock;
}
@@ -3961,7 +3970,7 @@ __lock_acquired(struct lockdep_map *lock, unsigned long ip)
*/
if (prev_hlock && prev_hlock->irq_context != hlock->irq_context)
break;
- if (match_held_lock(hlock, lock))
+ if (match_held_lock(hlock, lock, -1))
goto found_it;
prev_hlock = hlock;
}
--
2.1.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2016-09-05 15:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 17:10 [PATCH, RFC] xfs: remove i_iolock and use i_rwsem in the VFS inode instead Christoph Hellwig
2016-08-11 21:54 ` Peter Zijlstra
2016-08-18 17:37 ` Christoph Hellwig
2016-08-19 13:27 ` Peter Zijlstra
2016-08-20 6:37 ` Christoph Hellwig
2016-08-22 8:34 ` Peter Zijlstra
2016-09-05 15:12 ` Christoph Hellwig [this message]
2016-09-07 7:43 ` Peter Zijlstra
2016-09-08 6:06 ` Ingo Molnar
2016-08-11 23:43 ` Dave Chinner
2016-08-12 2:50 ` Christoph Hellwig
2016-08-12 9:58 ` Dave Chinner
2016-09-05 15:15 ` Christoph Hellwig
2016-09-07 21:45 ` Dave Chinner
2016-09-08 6:54 ` Peter Zijlstra
2016-09-09 1:06 ` Dave Chinner
2016-09-09 8:21 ` Peter Zijlstra
2016-09-09 8:34 ` Christoph Hellwig
2016-09-11 0:17 ` Dave Chinner
2016-09-13 19:42 ` Peter Zijlstra
2016-09-09 8:33 ` Christoph Hellwig
2016-09-09 8:44 ` Peter Zijlstra
2016-09-09 9:05 ` Christoph Hellwig
2016-09-09 9:51 ` Peter Zijlstra
2016-09-10 16:20 ` Christoph Hellwig
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=20160905151244.GA16726@lst.de \
--to=hch@lst.de \
--cc=peterz@infradead.org \
--cc=xfs@oss.sgi.com \
/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).