From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, Zach Brown <zach.brown@oracle.com>,
Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [RFC/T PATCH 05/12] lockdep: add initial lockdep support for lock_page
Date: Tue, 17 Jul 2007 19:34:33 +0200 [thread overview]
Message-ID: <20070717173757.755618000@chello.nl> (raw)
In-Reply-To: 20070717173428.355522000@chello.nl
[-- Attachment #1: lockdep-page.patch --]
[-- Type: text/plain, Size: 3520 bytes --]
use a global lockdep_map instance for all pages.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
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();
--
next prev parent reply other threads:[~2007-07-17 15:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 01/12] lockdep: annotate journal_start() Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 02/12] mm: trylock_page Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 03/12] mm: remove raw SetPageLocked() usage Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 04/12] mm: remove raw ClearPageLocked() usage Peter Zijlstra
2007-07-17 17:34 ` Peter Zijlstra [this message]
2007-07-17 17:34 ` [RFC/T PATCH 06/12] lockdep: lock_page: handle IO-completions Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 07/12] lockdep: non-recursive validation Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 08/12] lockdep: lock_page: recursion Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 09/12] lockdep: increase MAX_LOCK_DEPTH Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 10/12] lockdep: fs: per file-system type lock_page class Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 11/12] lockdep: lock_page: use per fs-type " Peter Zijlstra
2007-07-17 17:34 ` [RFC/T PATCH 12/12] mm: set_page_mapping() Peter Zijlstra
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=20070717173757.755618000@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=zach.brown@oracle.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