use a global lockdep_map instance for all pages.
Signed-off-by: Peter Zijlstra <[email protected]>
---
include/linux/lockdep.h | 7 +++++++
include/linux/mm_types.h | 1 +
include/linux/pagemap.h | 11 ++++++++++-
mm/filemap.c | 7 +++++++
4 files changed, 25 insertions(+), 1 deletion(-)
Index: linux-2.6/include/linux/lockdep.h
===================================================================
--- linux-2.6.orig/include/linux/lockdep.h
+++ linux-2.6/include/linux/lockdep.h
@@ -251,6 +251,13 @@ extern void lockdep_init_map(struct lock
struct lock_class_key *key, int subclass);
/*
+ * To initialize a lockdep_map statically use this macro.
+ * Note that _name must not be NULL.
+ */
+#define STATIC_LOCKDEP_MAP_INIT(_name, _key) \
+ { .name = (_name), .key = (void *)(_key), }
+
+/*
* Reinitialize a lock key - for cases where there is special locking or
* special initialization of locks so that the validator gets the scope
* of dependencies wrong: they are either too broad (they need a class-split)
Index: linux-2.6/include/linux/mm_types.h
===================================================================
--- linux-2.6.orig/include/linux/mm_types.h
+++ linux-2.6/include/linux/mm_types.h
@@ -5,6 +5,7 @@
#include <linux/threads.h>
#include <linux/list.h>
#include <linux/spinlock.h>
+#include <linux/lockdep.h>
struct address_space;
Index: linux-2.6/include/linux/pagemap.h
===================================================================
--- linux-2.6.orig/include/linux/pagemap.h
+++ linux-2.6/include/linux/pagemap.h
@@ -355,19 +355,25 @@ extern void FASTCALL(__lock_page(struct
extern void FASTCALL(__lock_page_nosync(struct page *page));
extern void FASTCALL(unlock_page(struct page *page));
+extern struct lockdep_map page_lockdep_map;
+
/*
* lock_page may only be called if we have the page's inode pinned.
*/
static inline void lock_page(struct page *page)
{
might_sleep();
+ spin_acquire(&page_lockdep_map, 0, 0, _RET_IP_);
if (TestSetPageLocked(page))
__lock_page(page);
}
static inline int trylock_page(struct page *page)
{
- return !TestSetPageLocked(page);
+ int ret = !TestSetPageLocked(page);
+ if (ret)
+ spin_acquire(&page_lockdep_map, 0, 1, _RET_IP_);
+ return ret;
}
/*
@@ -377,6 +383,7 @@ static inline int trylock_page(struct pa
static inline void lock_page_nosync(struct page *page)
{
might_sleep();
+ spin_acquire(&page_lockdep_map, 0, 0, _RET_IP_);
if (TestSetPageLocked(page))
__lock_page_nosync(page);
}
@@ -396,8 +403,10 @@ extern void FASTCALL(wait_on_page_bit(st
*/
static inline void wait_on_page_locked(struct page *page)
{
+ spin_acquire(&page_lockdep_map, 0, 0, _RET_IP_);
if (PageLocked(page))
wait_on_page_bit(page, PG_locked);
+ spin_release(&page_lockdep_map, 1, _RET_IP_);
}
/*
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c
+++ linux-2.6/mm/filemap.c
@@ -524,8 +524,15 @@ EXPORT_SYMBOL(wait_on_page_bit);
* the clear_bit and the read of the waitqueue (to avoid SMP races with a
* parallel wait_on_page_locked()).
*/
+struct lock_class_key page_lock_key;
+struct lockdep_map page_lockdep_map =
+ STATIC_LOCKDEP_MAP_INIT("lock_page", &page_lock_key);
+
+EXPORT_SYMBOL(page_lockdep_map);
+
void fastcall unlock_page(struct page *page)
{
+ spin_release(&page_lockdep_map, 1, _RET_IP_);
smp_mb__before_clear_bit();
if (!TestClearPageLocked(page))
BUG();
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]