public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/T PATCH 00/12] lockdep: annotate lock_page
@ 2007-07-17 17:34 Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 01/12] lockdep: annotate journal_start() Peter Zijlstra
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

These patches are only for the brave!

I have not even tried to compile without lockdep support, one can have
both pieces if it breaks :-)

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 01/12] lockdep: annotate journal_start()
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 02/12] mm: trylock_page Peter Zijlstra
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: jbd-lock.patch --]
[-- Type: text/plain, Size: 1990 bytes --]

On Fri, 2007-07-13 at 02:05 -0700, Andrew Morton wrote:

> Except lockdep doesn't know about journal_start(), which has ranking
> requirements similar to a semaphore.  

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 fs/jbd/transaction.c |    9 +++++++++
 include/linux/jbd.h  |    5 +++++
 2 files changed, 14 insertions(+)

Index: linux-2.6/fs/jbd/transaction.c
===================================================================
--- linux-2.6.orig/fs/jbd/transaction.c
+++ linux-2.6/fs/jbd/transaction.c
@@ -233,6 +233,8 @@ out:
 	return ret;
 }
 
+static struct lock_class_key jbd_handle_key;
+
 /* Allocate a new handle.  This should probably be in a slab... */
 static handle_t *new_handle(int nblocks)
 {
@@ -243,6 +245,8 @@ static handle_t *new_handle(int nblocks)
 	handle->h_buffer_credits = nblocks;
 	handle->h_ref = 1;
 
+	lockdep_init_map(&handle->h_lockdep_map, "jbd_handle", &jbd_handle_key, 0);
+
 	return handle;
 }
 
@@ -286,6 +290,9 @@ handle_t *journal_start(journal_t *journ
 		current->journal_info = NULL;
 		handle = ERR_PTR(err);
 	}
+
+	lock_acquire(&handle->h_lockdep_map, 0, 0, 0, 2, _THIS_IP_);
+
 	return handle;
 }
 
@@ -1411,6 +1418,8 @@ int journal_stop(handle_t *handle)
 		spin_unlock(&journal->j_state_lock);
 	}
 
+	lock_release(&handle->h_lockdep_map, 1, _THIS_IP_);
+
 	jbd_free_handle(handle);
 	return err;
 }
Index: linux-2.6/include/linux/jbd.h
===================================================================
--- linux-2.6.orig/include/linux/jbd.h
+++ linux-2.6/include/linux/jbd.h
@@ -30,6 +30,7 @@
 #include <linux/bit_spinlock.h>
 #include <linux/mutex.h>
 #include <linux/timer.h>
+#include <linux/lockdep.h>
 
 #include <asm/semaphore.h>
 #endif
@@ -405,6 +406,10 @@ struct handle_s
 	unsigned int	h_sync:		1;	/* sync-on-close */
 	unsigned int	h_jdata:	1;	/* force data journaling */
 	unsigned int	h_aborted:	1;	/* fatal error on handle */
+
+#ifdef CONFIG_LOCKDEP
+	struct lockdep_map	h_lockdep_map;
+#endif
 };
 
 

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 02/12] mm: trylock_page
  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 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 03/12] mm: remove raw SetPageLocked() usage Peter Zijlstra
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: trylock_page.patch --]
[-- Type: text/plain, Size: 9957 bytes --]

Replace raw TestSetPageLocked() usage with trylock_page()

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 fs/afs/write.c              |    2 +-
 fs/cifs/file.c              |    2 +-
 fs/jbd/commit.c             |    2 +-
 fs/jbd2/commit.c            |    2 +-
 fs/splice.c                 |    2 +-
 fs/xfs/linux-2.6/xfs_aops.c |    4 ++--
 include/linux/pagemap.h     |    5 +++++
 mm/filemap.c                |    2 +-
 mm/memory.c                 |    2 +-
 mm/migrate.c                |    4 ++--
 mm/rmap.c                   |    2 +-
 mm/shmem.c                  |    4 ++--
 mm/slub.c                   |    5 ++---
 mm/swap.c                   |    2 +-
 mm/swap_state.c             |    2 +-
 mm/swapfile.c               |    2 +-
 mm/truncate.c               |    4 ++--
 mm/vmscan.c                 |    4 ++--
 18 files changed, 28 insertions(+), 24 deletions(-)

Index: linux-2.6/fs/afs/write.c
===================================================================
--- linux-2.6.orig/fs/afs/write.c
+++ linux-2.6/fs/afs/write.c
@@ -404,7 +404,7 @@ static int afs_write_back_from_locked_pa
 			page = pages[loop];
 			if (page->index > wb->last)
 				break;
-			if (TestSetPageLocked(page))
+			if (!trylock_page(page))
 				break;
 			if (!PageDirty(page) ||
 			    page_private(page) != (unsigned long) wb) {
Index: linux-2.6/fs/cifs/file.c
===================================================================
--- linux-2.6.orig/fs/cifs/file.c
+++ linux-2.6/fs/cifs/file.c
@@ -1198,7 +1198,7 @@ retry:
 
 			if (first < 0)
 				lock_page(page);
-			else if (TestSetPageLocked(page))
+			else if (!trylock_page(page))
 				break;
 
 			if (unlikely(page->mapping != mapping)) {
Index: linux-2.6/fs/jbd/commit.c
===================================================================
--- linux-2.6.orig/fs/jbd/commit.c
+++ linux-2.6/fs/jbd/commit.c
@@ -63,7 +63,7 @@ static void release_buffer_page(struct b
 		goto nope;
 
 	/* OK, it's a truncated page */
-	if (TestSetPageLocked(page))
+	if (!trylock_page(page))
 		goto nope;
 
 	page_cache_get(page);
Index: linux-2.6/fs/jbd2/commit.c
===================================================================
--- linux-2.6.orig/fs/jbd2/commit.c
+++ linux-2.6/fs/jbd2/commit.c
@@ -63,7 +63,7 @@ static void release_buffer_page(struct b
 		goto nope;
 
 	/* OK, it's a truncated page */
-	if (TestSetPageLocked(page))
+	if (!trylock_page(page))
 		goto nope;
 
 	page_cache_get(page);
Index: linux-2.6/fs/splice.c
===================================================================
--- linux-2.6.orig/fs/splice.c
+++ linux-2.6/fs/splice.c
@@ -377,7 +377,7 @@ __generic_file_splice_read(struct file *
 			 * for an in-flight io page
 			 */
 			if (flags & SPLICE_F_NONBLOCK) {
-				if (TestSetPageLocked(page))
+				if (!trylock_page(page))
 					break;
 			} else
 				lock_page(page);
Index: linux-2.6/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- linux-2.6.orig/fs/xfs/linux-2.6/xfs_aops.c
+++ linux-2.6/fs/xfs/linux-2.6/xfs_aops.c
@@ -657,7 +657,7 @@ xfs_probe_cluster(
 			} else
 				pg_offset = PAGE_CACHE_SIZE;
 
-			if (page->index == tindex && !TestSetPageLocked(page)) {
+			if (page->index == tindex && trylock_page(page)) {
 				len = xfs_probe_page(page, pg_offset, mapped);
 				unlock_page(page);
 			}
@@ -741,7 +741,7 @@ xfs_convert_page(
 
 	if (page->index != tindex)
 		goto fail;
-	if (TestSetPageLocked(page))
+	if (!trylock_page(page))
 		goto fail;
 	if (PageWriteback(page))
 		goto fail_unlock_page;
Index: linux-2.6/include/linux/pagemap.h
===================================================================
--- linux-2.6.orig/include/linux/pagemap.h
+++ linux-2.6/include/linux/pagemap.h
@@ -365,6 +365,11 @@ static inline void lock_page(struct page
 		__lock_page(page);
 }
 
+static inline int trylock_page(struct page *page)
+{
+	return !TestSetPageLocked(page);
+}
+
 /*
  * lock_page_nosync should only be used if we can't pin the page's inode.
  * Doesn't play quite so well with block device plugging.
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c
+++ linux-2.6/mm/filemap.c
@@ -885,7 +885,7 @@ grab_cache_page_nowait(struct address_sp
 	struct page *page = find_get_page(mapping, index);
 
 	if (page) {
-		if (!TestSetPageLocked(page))
+		if (trylock_page(page))
 			return page;
 		page_cache_release(page);
 		return NULL;
Index: linux-2.6/mm/memory.c
===================================================================
--- linux-2.6.orig/mm/memory.c
+++ linux-2.6/mm/memory.c
@@ -1683,7 +1683,7 @@ static int do_wp_page(struct mm_struct *
 	 * not dirty accountable.
 	 */
 	if (PageAnon(old_page)) {
-		if (!TestSetPageLocked(old_page)) {
+		if (trylock_page(old_page)) {
 			reuse = can_share_swap_page(old_page);
 			unlock_page(old_page);
 		}
Index: linux-2.6/mm/migrate.c
===================================================================
--- linux-2.6.orig/mm/migrate.c
+++ linux-2.6/mm/migrate.c
@@ -573,7 +573,7 @@ static int move_to_new_page(struct page 
 	 * establishing additional references. We are the only one
 	 * holding a reference to the new page at this point.
 	 */
-	if (TestSetPageLocked(newpage))
+	if (!trylock_page(newpage))
 		BUG();
 
 	/* Prepare mapping for the new page.*/
@@ -625,7 +625,7 @@ static int unmap_and_move(new_page_t get
 		goto move_newpage;
 
 	rc = -EAGAIN;
-	if (TestSetPageLocked(page)) {
+	if (!trylock_page(page)) {
 		if (!force)
 			goto move_newpage;
 		lock_page(page);
Index: linux-2.6/mm/rmap.c
===================================================================
--- linux-2.6.orig/mm/rmap.c
+++ linux-2.6/mm/rmap.c
@@ -401,7 +401,7 @@ int page_referenced(struct page *page, i
 			referenced += page_referenced_anon(page);
 		else if (is_locked)
 			referenced += page_referenced_file(page);
-		else if (TestSetPageLocked(page))
+		else if (!trylock_page(page))
 			referenced++;
 		else {
 			if (page->mapping)
Index: linux-2.6/mm/shmem.c
===================================================================
--- linux-2.6.orig/mm/shmem.c
+++ linux-2.6/mm/shmem.c
@@ -1156,7 +1156,7 @@ repeat:
 		}
 
 		/* We have to do this with page locked to prevent races */
-		if (TestSetPageLocked(swappage)) {
+		if (!trylock_page(swappage)) {
 			shmem_swp_unmap(entry);
 			spin_unlock(&info->lock);
 			wait_on_page_locked(swappage);
@@ -1215,7 +1215,7 @@ repeat:
 		shmem_swp_unmap(entry);
 		filepage = find_get_page(mapping, idx);
 		if (filepage &&
-		    (!PageUptodate(filepage) || TestSetPageLocked(filepage))) {
+		    (!PageUptodate(filepage) || !trylock_page(filepage))) {
 			spin_unlock(&info->lock);
 			wait_on_page_locked(filepage);
 			page_cache_release(filepage);
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c
+++ linux-2.6/mm/slub.c
@@ -1191,7 +1191,7 @@ static __always_inline void slab_unlock(
 
 static __always_inline int slab_trylock(struct page *page)
 {
-	return !TestSetPageLocked(page);
+	return trylock_page(page);
 }
 #endif
 
Index: linux-2.6/mm/swap.c
===================================================================
--- linux-2.6.orig/mm/swap.c
+++ linux-2.6/mm/swap.c
@@ -412,7 +412,7 @@ void pagevec_strip(struct pagevec *pvec)
 	for (i = 0; i < pagevec_count(pvec); i++) {
 		struct page *page = pvec->pages[i];
 
-		if (PagePrivate(page) && !TestSetPageLocked(page)) {
+		if (PagePrivate(page) && trylock_page(page)) {
 			if (PagePrivate(page))
 				try_to_release_page(page, 0);
 			unlock_page(page);
Index: linux-2.6/mm/swap_state.c
===================================================================
--- linux-2.6.orig/mm/swap_state.c
+++ linux-2.6/mm/swap_state.c
@@ -258,7 +258,7 @@ int move_from_swap_cache(struct page *pa
  */
 static inline void free_swap_cache(struct page *page)
 {
-	if (PageSwapCache(page) && !TestSetPageLocked(page)) {
+	if (PageSwapCache(page) && trylock_page(page)) {
 		remove_exclusive_swap_page(page);
 		unlock_page(page);
 	}
Index: linux-2.6/mm/swapfile.c
===================================================================
--- linux-2.6.orig/mm/swapfile.c
+++ linux-2.6/mm/swapfile.c
@@ -401,7 +401,7 @@ void free_swap_and_cache(swp_entry_t ent
 	if (p) {
 		if (swap_entry_free(p, swp_offset(entry)) == 1) {
 			page = find_get_page(&swapper_space, entry.val);
-			if (page && unlikely(TestSetPageLocked(page))) {
+			if (page && unlikely(!trylock_page(page))) {
 				page_cache_release(page);
 				page = NULL;
 			}
Index: linux-2.6/mm/truncate.c
===================================================================
--- linux-2.6.orig/mm/truncate.c
+++ linux-2.6/mm/truncate.c
@@ -186,7 +186,7 @@ void truncate_inode_pages_range(struct a
 			if (page_index > next)
 				next = page_index;
 			next++;
-			if (TestSetPageLocked(page))
+			if (!trylock_page(page))
 				continue;
 			if (PageWriteback(page)) {
 				unlock_page(page);
@@ -282,7 +282,7 @@ unsigned long invalidate_mapping_pages(s
 			pgoff_t index;
 			int lock_failed;
 
-			lock_failed = TestSetPageLocked(page);
+			lock_failed = !trylock_page(page);
 
 			/*
 			 * We really shouldn't be looking at the ->index of an
Index: linux-2.6/mm/vmscan.c
===================================================================
--- linux-2.6.orig/mm/vmscan.c
+++ linux-2.6/mm/vmscan.c
@@ -463,7 +463,7 @@ static unsigned long shrink_page_list(st
 		page = lru_to_page(page_list);
 		list_del(&page->lru);
 
-		if (TestSetPageLocked(page))
+		if (!trylock_page(page))
 			goto keep;
 
 		VM_BUG_ON(PageActive(page));
@@ -535,7 +535,7 @@ static unsigned long shrink_page_list(st
 				 * A synchronous write - probably a ramdisk.  Go
 				 * ahead and try to reclaim the page.
 				 */
-				if (TestSetPageLocked(page))
+				if (!trylock_page(page))
 					goto keep;
 				if (PageDirty(page) || PageWriteback(page))
 					goto keep_locked;

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 03/12] mm: remove raw SetPageLocked() usage
  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 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 04/12] mm: remove raw ClearPageLocked() usage Peter Zijlstra
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: lock_page.patch --]
[-- Type: text/plain, Size: 2736 bytes --]

Remove the last few SetPageLocked() instances and replace them with
lock_page().

If any of these spots would suffer performance wise (or cannot suffer
the might_sleep()) then we could introduce another primitive for this.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 drivers/char/agp/generic.c   |    2 +-
 drivers/char/agp/intel-agp.c |    2 +-
 drivers/char/agp/sgi-agp.c   |    2 +-
 include/linux/pagemap.h      |    5 +++++
 mm/filemap.c                 |    2 +-
 mm/swap_state.c              |    2 +-
 6 files changed, 10 insertions(+), 5 deletions(-)

Index: linux-2.6/drivers/char/agp/generic.c
===================================================================
--- linux-2.6.orig/drivers/char/agp/generic.c
+++ linux-2.6/drivers/char/agp/generic.c
@@ -1170,7 +1170,7 @@ void *agp_generic_alloc_page(struct agp_
 	map_page_into_agp(page);
 
 	get_page(page);
-	SetPageLocked(page);
+	lock_page(page);
 	atomic_inc(&agp_bridge->current_memory_agp);
 	return page_address(page);
 }
Index: linux-2.6/drivers/char/agp/intel-agp.c
===================================================================
--- linux-2.6.orig/drivers/char/agp/intel-agp.c
+++ linux-2.6/drivers/char/agp/intel-agp.c
@@ -213,7 +213,7 @@ static void *i8xx_alloc_pages(void)
 	}
 	global_flush_tlb();
 	get_page(page);
-	SetPageLocked(page);
+	lock_page(page);
 	atomic_inc(&agp_bridge->current_memory_agp);
 	return page_address(page);
 }
Index: linux-2.6/drivers/char/agp/sgi-agp.c
===================================================================
--- linux-2.6.orig/drivers/char/agp/sgi-agp.c
+++ linux-2.6/drivers/char/agp/sgi-agp.c
@@ -51,7 +51,7 @@ static void *sgi_tioca_alloc_page(struct
 		return NULL;
 
 	get_page(page);
-	SetPageLocked(page);
+	lock_page(page);
 	atomic_inc(&agp_bridge->current_memory_agp);
 	return page_address(page);
 }
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c
+++ linux-2.6/mm/filemap.c
@@ -449,7 +449,7 @@ int add_to_page_cache(struct page *page,
 		radix_tree_unlock(&ctx);
 		if (!error) {
 			page_cache_get(page);
-			SetPageLocked(page);
+			lock_page(page);
 			page->mapping = mapping;
 			page->index = offset;
 			mapping_nrpages_inc(mapping);
Index: linux-2.6/mm/swap_state.c
===================================================================
--- linux-2.6.orig/mm/swap_state.c
+++ linux-2.6/mm/swap_state.c
@@ -343,7 +343,7 @@ struct page *read_swap_cache_async(swp_e
 			new_page = alloc_page_vma(GFP_HIGHUSER, vma, addr);
 			if (!new_page)
 				break;		/* Out of memory */
-			SetPageLocked(new_page);/* could be non-atomic op */
+			lock_page(new_page);/* could be non-atomic op */
 		}
 
 		/*

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 04/12] mm: remove raw ClearPageLocked() usage
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (2 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 03/12] mm: remove raw SetPageLocked() usage Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 05/12] lockdep: add initial lockdep support for lock_page Peter Zijlstra
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: unlock_page.patch --]
[-- Type: text/plain, Size: 590 bytes --]

remove the last raw ClearPageLocked() user

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 mm/swap_state.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/mm/swap_state.c
===================================================================
--- linux-2.6.orig/mm/swap_state.c
+++ linux-2.6/mm/swap_state.c
@@ -368,7 +368,7 @@ struct page *read_swap_cache_async(swp_e
 	} while (err != -ENOENT && err != -ENOMEM);
 
 	if (new_page) {
-		ClearPageLocked(new_page);
+		unlock_page(new_page);
 		page_cache_release(new_page);
 	}
 	return found_page;

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 05/12] lockdep: add initial lockdep support for lock_page
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (3 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 04/12] mm: remove raw ClearPageLocked() usage Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 06/12] lockdep: lock_page: handle IO-completions Peter Zijlstra
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- 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();

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 06/12] lockdep: lock_page: handle IO-completions
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (4 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 05/12] lockdep: add initial lockdep support for lock_page Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 07/12] lockdep: non-recursive validation Peter Zijlstra
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: lockdep-page-async.patch --]
[-- Type: text/plain, Size: 3693 bytes --]

IO-completions unlock the page in interrupt context, which is not the same
context as that locked the page.

Avoid this problem by doing the unlock tracking when submitting the page for
IO.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 fs/buffer.c             |    4 +++-
 fs/mpage.c              |   19 +++++++++++++++----
 include/linux/pagemap.h |   13 ++++++++++++-
 mm/filemap.c            |    5 ++---
 4 files changed, 32 insertions(+), 9 deletions(-)

Index: linux-2.6/include/linux/pagemap.h
===================================================================
--- linux-2.6.orig/include/linux/pagemap.h
+++ linux-2.6/include/linux/pagemap.h
@@ -353,7 +353,7 @@ static inline pgoff_t linear_page_index(
 
 extern void FASTCALL(__lock_page(struct page *page));
 extern void FASTCALL(__lock_page_nosync(struct page *page));
-extern void FASTCALL(unlock_page(struct page *page));
+extern void FASTCALL(unlock_page_nocheck(struct page *page));
 
 extern struct lockdep_map page_lockdep_map;
 
@@ -376,6 +376,17 @@ static inline int trylock_page(struct pa
 	return ret;
 }
 
+static inline void __unlock_page_check(struct page *page)
+{
+	spin_release(&page_lockdep_map, 1, _RET_IP_);
+}
+
+static inline void unlock_page(struct page *page)
+{
+	__unlock_page_check(page);
+	unlock_page_nocheck(page);
+}
+
 /*
  * lock_page_nosync should only be used if we can't pin the page's inode.
  * Doesn't play quite so well with block device plugging.
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c
+++ linux-2.6/mm/filemap.c
@@ -530,16 +530,15 @@ struct lockdep_map page_lockdep_map =
 
 EXPORT_SYMBOL(page_lockdep_map);
 
-void fastcall unlock_page(struct page *page)
+void fastcall unlock_page_nocheck(struct page *page)
 {
-	spin_release(&page_lockdep_map, 1, _RET_IP_);
 	smp_mb__before_clear_bit();
 	if (!TestClearPageLocked(page))
 		BUG();
 	smp_mb__after_clear_bit(); 
 	wake_up_page(page, PG_locked);
 }
-EXPORT_SYMBOL(unlock_page);
+EXPORT_SYMBOL(unlock_page_nocheck);
 
 /**
  * end_page_writeback - end writeback against a page
Index: linux-2.6/fs/buffer.c
===================================================================
--- linux-2.6.orig/fs/buffer.c
+++ linux-2.6/fs/buffer.c
@@ -410,7 +410,7 @@ static void end_buffer_async_read(struct
 	 */
 	if (page_uptodate && !PageError(page))
 		SetPageUptodate(page);
-	unlock_page(page);
+	unlock_page_nocheck(page);
 	return;
 
 still_busy:
@@ -1970,6 +1970,8 @@ int block_read_full_page(struct page *pa
 		mark_buffer_async_read(bh);
 	}
 
+	__unlock_page_check(page);
+
 	/*
 	 * Stage 3: start the IO.  Check for uptodateness
 	 * inside the buffer lock in case another process reading
Index: linux-2.6/fs/mpage.c
===================================================================
--- linux-2.6.orig/fs/mpage.c
+++ linux-2.6/fs/mpage.c
@@ -59,7 +59,7 @@ static int mpage_end_io_read(struct bio 
 			ClearPageUptodate(page);
 			SetPageError(page);
 		}
-		unlock_page(page);
+		unlock_page_nocheck(page);
 	} while (bvec >= bio->bi_io_vec);
 	bio_put(bio);
 	return 0;
@@ -92,9 +92,20 @@ static int mpage_end_io_write(struct bio
 
 static struct bio *mpage_bio_submit(int rw, struct bio *bio)
 {
-	bio->bi_end_io = mpage_end_io_read;
-	if (rw == WRITE)
-		bio->bi_end_io = mpage_end_io_write;
+	bio->bi_end_io = mpage_end_io_write;
+	if (rw == READ) {
+		struct bio_vec *bvec = bio->bi_io_vec;
+		int i;
+
+		bio->bi_end_io = mpage_end_io_read;
+
+		for (i = 0; i < bio->bi_vcnt; i++) {
+			struct page *page = bvec[i].bv_page;
+
+			if (page)
+				__unlock_page_check(page);
+		}
+	}
 	submit_bio(rw, bio);
 	return NULL;
 }

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 07/12] lockdep: non-recursive validation
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (5 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 06/12] lockdep: lock_page: handle IO-completions Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 08/12] lockdep: lock_page: recursion Peter Zijlstra
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: lockdep-norecursion.patch --]
[-- Type: text/plain, Size: 4116 bytes --]

Add a validation mode that diregards all recursive locking errors.
This is useful for locks like lock_page where there is a high degree
of nested locking.

Obviously it will not report a useful class of errors :-/

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/lockdep.h |   15 ++++++++-------
 kernel/lockdep.c        |   15 ++++++++++++---
 2 files changed, 20 insertions(+), 10 deletions(-)

Index: linux-2.6/include/linux/lockdep.h
===================================================================
--- linux-2.6.orig/include/linux/lockdep.h
+++ linux-2.6/include/linux/lockdep.h
@@ -286,7 +286,8 @@ extern void lockdep_init_map(struct lock
  *
  *   0: disabled
  *   1: simple checks (freeing, held-at-exit-time, etc.)
- *   2: full validation
+ *   2: validation without recursion checks
+ *   3: full validation
  */
 extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
 			 int trylock, int read, int check, unsigned long ip);
@@ -426,7 +427,7 @@ static inline void print_irqtrace_events
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # ifdef CONFIG_PROVE_LOCKING
-#  define spin_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, i)
+#  define spin_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 3, i)
 # else
 #  define spin_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, i)
 # endif
@@ -438,8 +439,8 @@ static inline void print_irqtrace_events
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # ifdef CONFIG_PROVE_LOCKING
-#  define rwlock_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, i)
-#  define rwlock_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 2, 2, i)
+#  define rwlock_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 3, i)
+#  define rwlock_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 2, 3, i)
 # else
 #  define rwlock_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, i)
 #  define rwlock_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 2, 1, i)
@@ -453,7 +454,7 @@ static inline void print_irqtrace_events
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # ifdef CONFIG_PROVE_LOCKING
-#  define mutex_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, i)
+#  define mutex_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 3, i)
 # else
 #  define mutex_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, i)
 # endif
@@ -465,8 +466,8 @@ static inline void print_irqtrace_events
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # ifdef CONFIG_PROVE_LOCKING
-#  define rwsem_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 2, i)
-#  define rwsem_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 1, 2, i)
+#  define rwsem_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 3, i)
+#  define rwsem_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 1, 3, i)
 # else
 #  define rwsem_acquire(l, s, t, i)		lock_acquire(l, s, t, 0, 1, i)
 #  define rwsem_acquire_read(l, s, t, i)	lock_acquire(l, s, t, 1, 1, i)
Index: linux-2.6/kernel/lockdep.c
===================================================================
--- linux-2.6.orig/kernel/lockdep.c
+++ linux-2.6/kernel/lockdep.c
@@ -2176,7 +2176,7 @@ static int __lock_acquire(struct lockdep
 	struct task_struct *curr = current;
 	struct lock_class *class = NULL;
 	struct held_lock *hlock;
-	unsigned int depth, id;
+	unsigned int depth, id, first;
 	int chain_head = 0;
 	u64 chain_key;
 
@@ -2225,6 +2225,14 @@ static int __lock_acquire(struct lockdep
 		return 0;
 
 	hlock = curr->held_locks + depth;
+	if (check == 2 && depth > 0) {
+		struct held_lock *prev_hlock = NULL;
+
+		prev_hlock = curr->held_locks + depth - 1;
+		if (prev_hlock->class == class)
+			first = 0;
+	} else
+		first = 1;
 
 	hlock->class = class;
 	hlock->acquire_ip = ip;
@@ -2238,7 +2246,7 @@ static int __lock_acquire(struct lockdep
 	hlock->holdtime_stamp = sched_clock();
 #endif
 
-	if (check != 2)
+	if (check < 2)
 		goto out_calc_hash;
 #ifdef CONFIG_TRACE_IRQFLAGS
 	/*
@@ -2347,7 +2355,8 @@ out_calc_hash:
 	 * graph_lock for us)
 	 */
 #ifdef CONFIG_PROVE_LOCKING
-	if (!trylock && (check == 2) && lookup_chain_cache(chain_key, class)) {
+	if (!trylock && (check >= 2 && first) &&
+			lookup_chain_cache(chain_key, class)) {
 		/*
 		 * Check whether last held lock:
 		 *

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 08/12] lockdep: lock_page: recursion
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (6 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 07/12] lockdep: non-recursive validation Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 09/12] lockdep: increase MAX_LOCK_DEPTH Peter Zijlstra
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: lockdep-page-recursion.patch --]
[-- Type: text/plain, Size: 2151 bytes --]

avoid the need to annotate lock_page nestings (which are abundant)

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/pagemap.h |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

Index: linux-2.6/include/linux/pagemap.h
===================================================================
--- linux-2.6.orig/include/linux/pagemap.h
+++ linux-2.6/include/linux/pagemap.h
@@ -357,13 +357,23 @@ extern void FASTCALL(unlock_page_nocheck
 
 extern struct lockdep_map page_lockdep_map;
 
+static inline void __lock_page_acquire(int try, unsigned long ip)
+{
+	lock_acquire(&page_lockdep_map, 0, try, 0, 2, ip);
+}
+
+static inline void __unlock_page_release(unsigned long ip)
+{
+	lock_release(&page_lockdep_map, 1, ip);
+}
+
 /*
  * 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_);
+	__lock_page_acquire(0, _RET_IP_);
 	if (TestSetPageLocked(page))
 		__lock_page(page);
 }
@@ -372,13 +382,13 @@ static inline int trylock_page(struct pa
 {
 	int ret = !TestSetPageLocked(page);
 	if (ret)
-		spin_acquire(&page_lockdep_map, 0, 1, _RET_IP_);
+		__lock_page_acquire(1, _RET_IP_);
 	return ret;
 }
 
 static inline void __unlock_page_check(struct page *page)
 {
-	spin_release(&page_lockdep_map, 1, _RET_IP_);
+	__unlock_page_release(_RET_IP_);
 }
 
 static inline void unlock_page(struct page *page)
@@ -394,7 +404,7 @@ static inline void unlock_page(struct pa
 static inline void lock_page_nosync(struct page *page)
 {
 	might_sleep();
-	spin_acquire(&page_lockdep_map, 0, 0, _RET_IP_);
+	__lock_page_acquire(0, _RET_IP_);
 	if (TestSetPageLocked(page))
 		__lock_page_nosync(page);
 }
@@ -414,10 +424,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_);
+	__lock_page_acquire(0, _RET_IP_);
 	if (PageLocked(page))
 		wait_on_page_bit(page, PG_locked);
-	spin_release(&page_lockdep_map, 1, _RET_IP_);
+	__unlock_page_release(_RET_IP_);
 }
 
 /* 

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 09/12] lockdep: increase MAX_LOCK_DEPTH
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (7 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 08/12] lockdep: lock_page: recursion Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 10/12] lockdep: fs: per file-system type lock_page class Peter Zijlstra
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: lockdep-depth.patch --]
[-- Type: text/plain, Size: 638 bytes --]

we can easily hold PAGE_VEC (and more in places) page locks.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/sched.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/include/linux/sched.h
===================================================================
--- linux-2.6.orig/include/linux/sched.h
+++ linux-2.6/include/linux/sched.h
@@ -1246,7 +1246,7 @@ struct task_struct {
 	int softirq_context;
 #endif
 #ifdef CONFIG_LOCKDEP
-# define MAX_LOCK_DEPTH 30UL
+# define MAX_LOCK_DEPTH 48UL
 	u64 curr_chain_key;
 	int lockdep_depth;
 	struct held_lock held_locks[MAX_LOCK_DEPTH];

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 10/12] lockdep: fs: per file-system type lock_page class
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (8 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 09/12] lockdep: increase MAX_LOCK_DEPTH Peter Zijlstra
@ 2007-07-17 17:34 ` 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
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: lockdep-filesystem.patch --]
[-- Type: text/plain, Size: 38275 bytes --]

static struct file_system_type foo_fs_type {
	...
	FS_TYPE_INIT(foo_fs),
};

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 arch/ia64/kernel/perfmon.c                |    1 +
 arch/powerpc/platforms/cell/spufs/inode.c |    1 +
 arch/s390/hypfs/inode.c                   |    3 ++-
 drivers/infiniband/core/uverbs_main.c     |    3 ++-
 drivers/infiniband/hw/ipath/ipath_fs.c    |    1 +
 drivers/isdn/capi/capifs.c                |    1 +
 drivers/kvm/kvm_main.c                    |    1 +
 drivers/misc/ibmasm/ibmasmfs.c            |    1 +
 drivers/oprofile/oprofilefs.c             |    1 +
 drivers/usb/core/inode.c                  |    1 +
 drivers/usb/gadget/inode.c                |    1 +
 fs/9p/vfs_super.c                         |    1 +
 fs/adfs/super.c                           |    1 +
 fs/affs/super.c                           |    1 +
 fs/afs/super.c                            |    1 +
 fs/anon_inodes.c                          |    1 +
 fs/autofs/init.c                          |    1 +
 fs/autofs4/init.c                         |    1 +
 fs/befs/linuxvfs.c                        |    1 +
 fs/bfs/inode.c                            |    1 +
 fs/binfmt_misc.c                          |    1 +
 fs/block_dev.c                            |    1 +
 fs/cifs/cifsfs.c                          |    1 +
 fs/coda/inode.c                           |    1 +
 fs/configfs/mount.c                       |    1 +
 fs/cramfs/inode.c                         |    1 +
 fs/debugfs/inode.c                        |    1 +
 fs/devpts/inode.c                         |    1 +
 fs/ecryptfs/main.c                        |    3 ++-
 fs/efs/super.c                            |    1 +
 fs/ext2/super.c                           |    1 +
 fs/ext3/super.c                           |    1 +
 fs/ext4/super.c                           |    1 +
 fs/freevxfs/vxfs_super.c                  |    1 +
 fs/fuse/control.c                         |    1 +
 fs/fuse/inode.c                           |    2 ++
 fs/gfs2/ops_fstype.c                      |    2 ++
 fs/hfs/super.c                            |    1 +
 fs/hfsplus/super.c                        |    1 +
 fs/hostfs/hostfs_kern.c                   |    1 +
 fs/hpfs/super.c                           |    1 +
 fs/hppfs/hppfs_kern.c                     |    1 +
 fs/hugetlbfs/inode.c                      |    1 +
 fs/inotify_user.c                         |    1 +
 fs/isofs/inode.c                          |    1 +
 fs/jffs2/super.c                          |    1 +
 fs/jfs/super.c                            |    1 +
 fs/minix/inode.c                          |    1 +
 fs/msdos/namei.c                          |    1 +
 fs/ncpfs/inode.c                          |    1 +
 fs/nfs/super.c                            |    5 +++++
 fs/nfsd/nfsctl.c                          |    1 +
 fs/ntfs/super.c                           |    1 +
 fs/ocfs2/dlm/dlmfs.c                      |    1 +
 fs/ocfs2/super.c                          |    3 ++-
 fs/openpromfs/inode.c                     |    1 +
 fs/pipe.c                                 |    1 +
 fs/proc/root.c                            |    1 +
 fs/qnx4/inode.c                           |    1 +
 fs/ramfs/inode.c                          |    2 ++
 fs/reiserfs/super.c                       |    1 +
 fs/romfs/inode.c                          |    1 +
 fs/smbfs/inode.c                          |    1 +
 fs/sysfs/mount.c                          |    1 +
 fs/sysv/super.c                           |    2 ++
 fs/udf/super.c                            |    1 +
 fs/ufs/super.c                            |    1 +
 fs/vfat/namei.c                           |    1 +
 fs/xfs/linux-2.6/xfs_super.c              |    1 +
 include/linux/fs.h                        |   15 +++++++++++++++
 ipc/mqueue.c                              |    1 +
 kernel/cpuset.c                           |    1 +
 kernel/futex.c                            |    1 +
 mm/shmem.c                                |    1 +
 mm/tiny-shmem.c                           |    1 +
 net/socket.c                              |    1 +
 net/sunrpc/rpc_pipe.c                     |    1 +
 security/inode.c                          |    1 +
 security/selinux/selinuxfs.c              |    1 +
 79 files changed, 105 insertions(+), 4 deletions(-)

Index: linux-2.6/arch/ia64/kernel/perfmon.c
===================================================================
--- linux-2.6.orig/arch/ia64/kernel/perfmon.c
+++ linux-2.6/arch/ia64/kernel/perfmon.c
@@ -648,6 +648,7 @@ static struct file_system_type pfm_fs_ty
 	.name     = "pfmfs",
 	.get_sb   = pfmfs_get_sb,
 	.kill_sb  = kill_anon_super,
+	FS_TYPE_INIT(pfm_fs),
 };
 
 DEFINE_PER_CPU(unsigned long, pfm_syst_info);
Index: linux-2.6/arch/powerpc/platforms/cell/spufs/inode.c
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/inode.c
+++ linux-2.6/arch/powerpc/platforms/cell/spufs/inode.c
@@ -645,6 +645,7 @@ static struct file_system_type spufs_typ
 	.name = "spufs",
 	.get_sb = spufs_get_sb,
 	.kill_sb = kill_litter_super,
+	FS_TYPE_INIT(spufs),
 };
 
 static int __init spufs_init(void)
Index: linux-2.6/arch/s390/hypfs/inode.c
===================================================================
--- linux-2.6.orig/arch/s390/hypfs/inode.c
+++ linux-2.6/arch/s390/hypfs/inode.c
@@ -453,7 +453,8 @@ static struct file_system_type hypfs_typ
 	.owner		= THIS_MODULE,
 	.name		= "s390_hypfs",
 	.get_sb		= hypfs_get_super,
-	.kill_sb	= hypfs_kill_super
+	.kill_sb	= hypfs_kill_super,
+	FS_TYPE_INIT(hypfs),
 };
 
 static struct super_operations hypfs_s_ops = {
Index: linux-2.6/drivers/infiniband/core/uverbs_main.c
===================================================================
--- linux-2.6.orig/drivers/infiniband/core/uverbs_main.c
+++ linux-2.6/drivers/infiniband/core/uverbs_main.c
@@ -829,7 +829,8 @@ static struct file_system_type uverbs_ev
 	/* No owner field so module can be unloaded */
 	.name    = "infinibandeventfs",
 	.get_sb  = uverbs_event_get_sb,
-	.kill_sb = kill_litter_super
+	.kill_sb = kill_litter_super,
+	FS_TYPE_INIT(uverbs_event_fs),
 };
 
 static int __init ib_uverbs_init(void)
Index: linux-2.6/drivers/infiniband/hw/ipath/ipath_fs.c
===================================================================
--- linux-2.6.orig/drivers/infiniband/hw/ipath/ipath_fs.c
+++ linux-2.6/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -602,6 +602,7 @@ static struct file_system_type ipathfs_f
 	.name =		"ipathfs",
 	.get_sb =	ipathfs_get_sb,
 	.kill_sb =	ipathfs_kill_super,
+	FS_TYPE_INIT(ipathfs_fs),
 };
 
 int __init ipath_init_ipathfs(void)
Index: linux-2.6/drivers/isdn/capi/capifs.c
===================================================================
--- linux-2.6.orig/drivers/isdn/capi/capifs.c
+++ linux-2.6/drivers/isdn/capi/capifs.c
@@ -131,6 +131,7 @@ static struct file_system_type capifs_fs
 	.name		= "capifs",
 	.get_sb		= capifs_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(capifs_fs),
 };
 
 static struct dentry *get_node(int num)
Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -3017,6 +3017,7 @@ static struct file_system_type kvm_fs_ty
 	.name		= "kvmfs",
 	.get_sb		= kvmfs_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(kvm_fs),
 };
 
 int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
Index: linux-2.6/drivers/misc/ibmasm/ibmasmfs.c
===================================================================
--- linux-2.6.orig/drivers/misc/ibmasm/ibmasmfs.c
+++ linux-2.6/drivers/misc/ibmasm/ibmasmfs.c
@@ -109,6 +109,7 @@ static struct file_system_type ibmasmfs_
 	.name           = "ibmasmfs",
 	.get_sb         = ibmasmfs_get_super,
 	.kill_sb        = kill_litter_super,
+	FS_TYPE_INIT(ibmasmfs),
 };
 
 static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent)
Index: linux-2.6/drivers/oprofile/oprofilefs.c
===================================================================
--- linux-2.6.orig/drivers/oprofile/oprofilefs.c
+++ linux-2.6/drivers/oprofile/oprofilefs.c
@@ -284,6 +284,7 @@ static struct file_system_type oprofilef
 	.name		= "oprofilefs",
 	.get_sb		= oprofilefs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(oprofilefs),
 };
 
 
Index: linux-2.6/drivers/usb/core/inode.c
===================================================================
--- linux-2.6.orig/drivers/usb/core/inode.c
+++ linux-2.6/drivers/usb/core/inode.c
@@ -552,6 +552,7 @@ static struct file_system_type usb_fs_ty
 	.name =		"usbfs",
 	.get_sb =	usb_get_sb,
 	.kill_sb =	kill_litter_super,
+	FS_TYPE_INIT(usb_fs),
 };
 
 /* --------------------------------------------------------------------- */
Index: linux-2.6/drivers/usb/gadget/inode.c
===================================================================
--- linux-2.6.orig/drivers/usb/gadget/inode.c
+++ linux-2.6/drivers/usb/gadget/inode.c
@@ -2132,6 +2132,7 @@ static struct file_system_type gadgetfs_
 	.name		= shortname,
 	.get_sb		= gadgetfs_get_sb,
 	.kill_sb	= gadgetfs_kill_sb,
+	FS_TYPE_INIT(gadgetfs),
 };
 
 /*----------------------------------------------------------------------*/
Index: linux-2.6/fs/9p/vfs_super.c
===================================================================
--- linux-2.6.orig/fs/9p/vfs_super.c
+++ linux-2.6/fs/9p/vfs_super.c
@@ -275,4 +275,5 @@ struct file_system_type v9fs_fs_type = {
 	.get_sb = v9fs_get_sb,
 	.kill_sb = v9fs_kill_super,
 	.owner = THIS_MODULE,
+	FS_TYPE_INIT(v9fs_fs),
 };
Index: linux-2.6/fs/adfs/super.c
===================================================================
--- linux-2.6.orig/fs/adfs/super.c
+++ linux-2.6/fs/adfs/super.c
@@ -479,6 +479,7 @@ static struct file_system_type adfs_fs_t
 	.get_sb		= adfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(adfs_fs),
 };
 
 static int __init init_adfs_fs(void)
Index: linux-2.6/fs/affs/super.c
===================================================================
--- linux-2.6.orig/fs/affs/super.c
+++ linux-2.6/fs/affs/super.c
@@ -538,6 +538,7 @@ static struct file_system_type affs_fs_t
 	.get_sb		= affs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(affs_fs),
 };
 
 static int __init init_affs_fs(void)
Index: linux-2.6/fs/afs/super.c
===================================================================
--- linux-2.6.orig/fs/afs/super.c
+++ linux-2.6/fs/afs/super.c
@@ -43,6 +43,7 @@ struct file_system_type afs_fs_type = {
 	.get_sb		= afs_get_sb,
 	.kill_sb	= kill_anon_super,
 	.fs_flags	= 0,
+	FS_TYPE_INIT(afs_fs),
 };
 
 static const struct super_operations afs_super_ops = {
Index: linux-2.6/fs/anon_inodes.c
===================================================================
--- linux-2.6.orig/fs/anon_inodes.c
+++ linux-2.6/fs/anon_inodes.c
@@ -47,6 +47,7 @@ static struct file_system_type anon_inod
 	.name		= "anon_inodefs",
 	.get_sb		= anon_inodefs_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(anon_inode_fs),
 };
 static struct dentry_operations anon_inodefs_dentry_operations = {
 	.d_delete	= anon_inodefs_delete_dentry,
Index: linux-2.6/fs/autofs/init.c
===================================================================
--- linux-2.6.orig/fs/autofs/init.c
+++ linux-2.6/fs/autofs/init.c
@@ -25,6 +25,7 @@ static struct file_system_type autofs_fs
 	.name		= "autofs",
 	.get_sb		= autofs_get_sb,
 	.kill_sb	= autofs_kill_sb,
+	FS_TYPE_INIT(autofs_fs),
 };
 
 static int __init init_autofs_fs(void)
Index: linux-2.6/fs/autofs4/init.c
===================================================================
--- linux-2.6.orig/fs/autofs4/init.c
+++ linux-2.6/fs/autofs4/init.c
@@ -25,6 +25,7 @@ static struct file_system_type autofs_fs
 	.name		= "autofs",
 	.get_sb		= autofs_get_sb,
 	.kill_sb	= autofs4_kill_sb,
+	FS_TYPE_INIT(autofs_fs),
 };
 
 static int __init init_autofs4_fs(void)
Index: linux-2.6/fs/befs/linuxvfs.c
===================================================================
--- linux-2.6.orig/fs/befs/linuxvfs.c
+++ linux-2.6/fs/befs/linuxvfs.c
@@ -914,6 +914,7 @@ static struct file_system_type befs_fs_t
 	.get_sb		= befs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,	
+	FS_TYPE_INIT(befs_fs),
 };
 
 static int __init
Index: linux-2.6/fs/bfs/inode.c
===================================================================
--- linux-2.6.orig/fs/bfs/inode.c
+++ linux-2.6/fs/bfs/inode.c
@@ -417,6 +417,7 @@ static struct file_system_type bfs_fs_ty
 	.get_sb		= bfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(bfs_fs),
 };
 
 static int __init init_bfs_fs(void)
Index: linux-2.6/fs/binfmt_misc.c
===================================================================
--- linux-2.6.orig/fs/binfmt_misc.c
+++ linux-2.6/fs/binfmt_misc.c
@@ -742,6 +742,7 @@ static struct file_system_type bm_fs_typ
 	.name		= "binfmt_misc",
 	.get_sb		= bm_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(bm_fs),
 };
 
 static int __init init_misc_binfmt(void)
Index: linux-2.6/fs/block_dev.c
===================================================================
--- linux-2.6.orig/fs/block_dev.c
+++ linux-2.6/fs/block_dev.c
@@ -506,6 +506,7 @@ static struct file_system_type bd_type =
 	.name		= "bdev",
 	.get_sb		= bd_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(bd),
 };
 
 static struct vfsmount *bd_mnt __read_mostly;
Index: linux-2.6/fs/cifs/cifsfs.c
===================================================================
--- linux-2.6.orig/fs/cifs/cifsfs.c
+++ linux-2.6/fs/cifs/cifsfs.c
@@ -552,6 +552,7 @@ static struct file_system_type cifs_fs_t
 	.get_sb = cifs_get_sb,
 	.kill_sb = kill_anon_super,
 	/*  .fs_flags */
+	FS_TYPE_INIT(cifs_fs),
 };
 const struct inode_operations cifs_dir_inode_ops = {
 	.create = cifs_create,
Index: linux-2.6/fs/coda/inode.c
===================================================================
--- linux-2.6.orig/fs/coda/inode.c
+++ linux-2.6/fs/coda/inode.c
@@ -316,5 +316,6 @@ struct file_system_type coda_fs_type = {
 	.get_sb		= coda_get_sb,
 	.kill_sb	= kill_anon_super,
 	.fs_flags	= FS_BINARY_MOUNTDATA,
+	FS_TYPE_INIT(coda_fs),
 };
 
Index: linux-2.6/fs/configfs/mount.c
===================================================================
--- linux-2.6.orig/fs/configfs/mount.c
+++ linux-2.6/fs/configfs/mount.c
@@ -114,6 +114,7 @@ static struct file_system_type configfs_
 	.name		= "configfs",
 	.get_sb		= configfs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(configfs_fs),
 };
 
 int configfs_pin_fs(void)
Index: linux-2.6/fs/cramfs/inode.c
===================================================================
--- linux-2.6.orig/fs/cramfs/inode.c
+++ linux-2.6/fs/cramfs/inode.c
@@ -542,6 +542,7 @@ static struct file_system_type cramfs_fs
 	.get_sb		= cramfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(cramfs_fs),
 };
 
 static int __init init_cramfs_fs(void)
Index: linux-2.6/fs/debugfs/inode.c
===================================================================
--- linux-2.6.orig/fs/debugfs/inode.c
+++ linux-2.6/fs/debugfs/inode.c
@@ -142,6 +142,7 @@ static struct file_system_type debug_fs_
 	.name =		"debugfs",
 	.get_sb =	debug_get_sb,
 	.kill_sb =	kill_litter_super,
+	FS_TYPE_INIT(debug_fs),
 };
 
 static int debugfs_create_by_name(const char *name, mode_t mode,
Index: linux-2.6/fs/devpts/inode.c
===================================================================
--- linux-2.6.orig/fs/devpts/inode.c
+++ linux-2.6/fs/devpts/inode.c
@@ -141,6 +141,7 @@ static struct file_system_type devpts_fs
 	.name		= "devpts",
 	.get_sb		= devpts_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(devpts_fs),
 };
 
 /*
Index: linux-2.6/fs/ecryptfs/main.c
===================================================================
--- linux-2.6.orig/fs/ecryptfs/main.c
+++ linux-2.6/fs/ecryptfs/main.c
@@ -570,7 +570,8 @@ static struct file_system_type ecryptfs_
 	.name = "ecryptfs",
 	.get_sb = ecryptfs_get_sb,
 	.kill_sb = ecryptfs_kill_block_super,
-	.fs_flags = 0
+	.fs_flags = 0,
+	FS_TYPE_INIT(ecryptfs_fs),
 };
 
 /**
Index: linux-2.6/fs/efs/super.c
===================================================================
--- linux-2.6.orig/fs/efs/super.c
+++ linux-2.6/fs/efs/super.c
@@ -30,6 +30,7 @@ static struct file_system_type efs_fs_ty
 	.get_sb		= efs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(efs_fs),
 };
 
 static struct pt_types sgi_pt_types[] = {
Index: linux-2.6/fs/ext2/super.c
===================================================================
--- linux-2.6.orig/fs/ext2/super.c
+++ linux-2.6/fs/ext2/super.c
@@ -1267,6 +1267,7 @@ static struct file_system_type ext2_fs_t
 	.get_sb		= ext2_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(ext2_fs),
 };
 
 static int __init init_ext2_fs(void)
Index: linux-2.6/fs/ext3/super.c
===================================================================
--- linux-2.6.orig/fs/ext3/super.c
+++ linux-2.6/fs/ext3/super.c
@@ -2747,6 +2747,7 @@ static struct file_system_type ext3_fs_t
 	.get_sb		= ext3_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(ext3_fs),
 };
 
 static int __init init_ext3_fs(void)
Index: linux-2.6/fs/ext4/super.c
===================================================================
--- linux-2.6.orig/fs/ext4/super.c
+++ linux-2.6/fs/ext4/super.c
@@ -2822,6 +2822,7 @@ static struct file_system_type ext4dev_f
 	.get_sb		= ext4_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(ext4dev_fs),
 };
 
 static int __init init_ext4_fs(void)
Index: linux-2.6/fs/freevxfs/vxfs_super.c
===================================================================
--- linux-2.6.orig/fs/freevxfs/vxfs_super.c
+++ linux-2.6/fs/freevxfs/vxfs_super.c
@@ -255,6 +255,7 @@ static struct file_system_type vxfs_fs_t
 	.get_sb		= vxfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(vxfs_fs),
 };
 
 static int __init
Index: linux-2.6/fs/fuse/control.c
===================================================================
--- linux-2.6.orig/fs/fuse/control.c
+++ linux-2.6/fs/fuse/control.c
@@ -209,6 +209,7 @@ static struct file_system_type fuse_ctl_
 	.name		= "fusectl",
 	.get_sb		= fuse_ctl_get_sb,
 	.kill_sb	= fuse_ctl_kill_sb,
+	FS_TYPE_INIT(fuse_ctl_fs),
 };
 
 int __init fuse_ctl_init(void)
Index: linux-2.6/fs/fuse/inode.c
===================================================================
--- linux-2.6.orig/fs/fuse/inode.c
+++ linux-2.6/fs/fuse/inode.c
@@ -641,6 +641,7 @@ static struct file_system_type fuse_fs_t
 	.fs_flags	= FS_HAS_SUBTYPE,
 	.get_sb		= fuse_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(fuse_fs),
 };
 
 #ifdef CONFIG_BLOCK
@@ -658,6 +659,7 @@ static struct file_system_type fuseblk_f
 	.get_sb		= fuse_get_sb_blk,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV | FS_HAS_SUBTYPE,
+	FS_TYPE_INIT(fuseblk_fs),
 };
 
 static inline int register_fuseblk(void)
Index: linux-2.6/fs/gfs2/ops_fstype.c
===================================================================
--- linux-2.6.orig/fs/gfs2/ops_fstype.c
+++ linux-2.6/fs/gfs2/ops_fstype.c
@@ -917,6 +917,7 @@ struct file_system_type gfs2_fs_type = {
 	.get_sb = gfs2_get_sb,
 	.kill_sb = gfs2_kill_sb,
 	.owner = THIS_MODULE,
+	FS_TYPE_INIT(gfs2_fs),
 };
 
 struct file_system_type gfs2meta_fs_type = {
@@ -925,5 +926,6 @@ struct file_system_type gfs2meta_fs_type
 	.get_sb = gfs2_get_sb_meta,
 	.kill_sb = gfs2_kill_sb_meta,
 	.owner = THIS_MODULE,
+	FS_TYPE_INIT(gfs2meta_fs),
 };
 
Index: linux-2.6/fs/hfs/super.c
===================================================================
--- linux-2.6.orig/fs/hfs/super.c
+++ linux-2.6/fs/hfs/super.c
@@ -428,6 +428,7 @@ static struct file_system_type hfs_fs_ty
 	.get_sb		= hfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(hfs_fs),
 };
 
 static void hfs_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
Index: linux-2.6/fs/hfsplus/super.c
===================================================================
--- linux-2.6.orig/fs/hfsplus/super.c
+++ linux-2.6/fs/hfsplus/super.c
@@ -464,6 +464,7 @@ static struct file_system_type hfsplus_f
 	.get_sb		= hfsplus_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(hfsplus_fs),
 };
 
 static void hfsplus_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
Index: linux-2.6/fs/hostfs/hostfs_kern.c
===================================================================
--- linux-2.6.orig/fs/hostfs/hostfs_kern.c
+++ linux-2.6/fs/hostfs/hostfs_kern.c
@@ -1022,6 +1022,7 @@ static struct file_system_type hostfs_ty
 	.get_sb 	= hostfs_read_sb,
 	.kill_sb	= kill_anon_super,
 	.fs_flags 	= 0,
+	FS_TYPE_INIT(hostfs),
 };
 
 static int __init init_hostfs(void)
Index: linux-2.6/fs/hpfs/super.c
===================================================================
--- linux-2.6.orig/fs/hpfs/super.c
+++ linux-2.6/fs/hpfs/super.c
@@ -668,6 +668,7 @@ static struct file_system_type hpfs_fs_t
 	.get_sb		= hpfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(hpfs_fs),
 };
 
 static int __init init_hpfs_fs(void)
Index: linux-2.6/fs/hppfs/hppfs_kern.c
===================================================================
--- linux-2.6.orig/fs/hppfs/hppfs_kern.c
+++ linux-2.6/fs/hppfs/hppfs_kern.c
@@ -781,6 +781,7 @@ static struct file_system_type hppfs_typ
 	.get_sb 	= hppfs_read_super,
 	.kill_sb	= kill_anon_super,
 	.fs_flags 	= 0,
+	FS_TYPE_INIT(hppfs),
 };
 
 static int __init init_hppfs(void)
Index: linux-2.6/fs/hugetlbfs/inode.c
===================================================================
--- linux-2.6.orig/fs/hugetlbfs/inode.c
+++ linux-2.6/fs/hugetlbfs/inode.c
@@ -725,6 +725,7 @@ static struct file_system_type hugetlbfs
 	.name		= "hugetlbfs",
 	.get_sb		= hugetlbfs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(hugetlbfs_fs),
 };
 
 static struct vfsmount *hugetlbfs_vfsmount;
Index: linux-2.6/fs/inotify_user.c
===================================================================
--- linux-2.6.orig/fs/inotify_user.c
+++ linux-2.6/fs/inotify_user.c
@@ -691,6 +691,7 @@ static struct file_system_type inotify_f
     .name           = "inotifyfs",
     .get_sb         = inotify_get_sb,
     .kill_sb        = kill_anon_super,
+    FS_TYPE_INIT(inotify_fs),
 };
 
 /*
Index: linux-2.6/fs/isofs/inode.c
===================================================================
--- linux-2.6.orig/fs/isofs/inode.c
+++ linux-2.6/fs/isofs/inode.c
@@ -1407,6 +1407,7 @@ static struct file_system_type iso9660_f
 	.get_sb		= isofs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(iso9660_fs),
 };
 
 static int __init init_iso9660_fs(void)
Index: linux-2.6/fs/jffs2/super.c
===================================================================
--- linux-2.6.orig/fs/jffs2/super.c
+++ linux-2.6/fs/jffs2/super.c
@@ -161,6 +161,7 @@ static struct file_system_type jffs2_fs_
 	.name =		"jffs2",
 	.get_sb =	jffs2_get_sb,
 	.kill_sb =	jffs2_kill_sb,
+	FS_TYPE_INIT(jffs2_fs),
 };
 
 static int __init init_jffs2_fs(void)
Index: linux-2.6/fs/jfs/super.c
===================================================================
--- linux-2.6.orig/fs/jfs/super.c
+++ linux-2.6/fs/jfs/super.c
@@ -746,6 +746,7 @@ static struct file_system_type jfs_fs_ty
 	.get_sb		= jfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(jfs_fs),
 };
 
 static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
Index: linux-2.6/fs/minix/inode.c
===================================================================
--- linux-2.6.orig/fs/minix/inode.c
+++ linux-2.6/fs/minix/inode.c
@@ -597,6 +597,7 @@ static struct file_system_type minix_fs_
 	.get_sb		= minix_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(minix_fs),
 };
 
 static int __init init_minix_fs(void)
Index: linux-2.6/fs/msdos/namei.c
===================================================================
--- linux-2.6.orig/fs/msdos/namei.c
+++ linux-2.6/fs/msdos/namei.c
@@ -684,6 +684,7 @@ static struct file_system_type msdos_fs_
 	.get_sb		= msdos_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(msdos_fs),
 };
 
 static int __init init_msdos_fs(void)
Index: linux-2.6/fs/ncpfs/inode.c
===================================================================
--- linux-2.6.orig/fs/ncpfs/inode.c
+++ linux-2.6/fs/ncpfs/inode.c
@@ -982,6 +982,7 @@ static struct file_system_type ncp_fs_ty
 	.name		= "ncpfs",
 	.get_sb		= ncp_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(ncp_fs),
 };
 
 static int __init init_ncp_fs(void)
Index: linux-2.6/fs/nfs/super.c
===================================================================
--- linux-2.6.orig/fs/nfs/super.c
+++ linux-2.6/fs/nfs/super.c
@@ -72,6 +72,7 @@ static struct file_system_type nfs_fs_ty
 	.get_sb		= nfs_get_sb,
 	.kill_sb	= nfs_kill_super,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+	FS_TYPE_INIT(nfs_fs),
 };
 
 struct file_system_type nfs_xdev_fs_type = {
@@ -80,6 +81,7 @@ struct file_system_type nfs_xdev_fs_type
 	.get_sb		= nfs_xdev_get_sb,
 	.kill_sb	= nfs_kill_super,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+	FS_TYPE_INIT(nfs_xdev_fs),
 };
 
 static const struct super_operations nfs_sops = {
@@ -108,6 +110,7 @@ static struct file_system_type nfs4_fs_t
 	.get_sb		= nfs4_get_sb,
 	.kill_sb	= nfs4_kill_super,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+	FS_TYPE_INIT(nfs4_fs),
 };
 
 struct file_system_type nfs4_xdev_fs_type = {
@@ -116,6 +119,7 @@ struct file_system_type nfs4_xdev_fs_typ
 	.get_sb		= nfs4_xdev_get_sb,
 	.kill_sb	= nfs4_kill_super,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+	FS_TYPE_INIT(nfs4_xdev_fs),
 };
 
 struct file_system_type nfs4_referral_fs_type = {
@@ -124,6 +128,7 @@ struct file_system_type nfs4_referral_fs
 	.get_sb		= nfs4_referral_get_sb,
 	.kill_sb	= nfs4_kill_super,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
+	FS_TYPE_INIT(nfs4_referral_fs),
 };
 
 static const struct super_operations nfs4_sops = {
Index: linux-2.6/fs/nfsd/nfsctl.c
===================================================================
--- linux-2.6.orig/fs/nfsd/nfsctl.c
+++ linux-2.6/fs/nfsd/nfsctl.c
@@ -673,6 +673,7 @@ static struct file_system_type nfsd_fs_t
 	.name		= "nfsd",
 	.get_sb		= nfsd_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(nfsd_fs),
 };
 
 static int __init init_nfsd(void)
Index: linux-2.6/fs/ntfs/super.c
===================================================================
--- linux-2.6.orig/fs/ntfs/super.c
+++ linux-2.6/fs/ntfs/super.c
@@ -3111,6 +3111,7 @@ static struct file_system_type ntfs_fs_t
 	.get_sb		= ntfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(ntfs_fs),
 };
 
 /* Stable names for the slab caches. */
Index: linux-2.6/fs/ocfs2/dlm/dlmfs.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/dlm/dlmfs.c
+++ linux-2.6/fs/ocfs2/dlm/dlmfs.c
@@ -579,6 +579,7 @@ static struct file_system_type dlmfs_fs_
 	.name		= "ocfs2_dlmfs",
 	.get_sb		= dlmfs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(dlmfs_fs),
 };
 
 static int __init init_dlmfs_fs(void)
Index: linux-2.6/fs/ocfs2/super.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/super.c
+++ linux-2.6/fs/ocfs2/super.c
@@ -707,7 +707,8 @@ static struct file_system_type ocfs2_fs_
 					     * right now, but do we
 					     * need to change that? */
 	.fs_flags       = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE,
-	.next           = NULL
+	.next           = NULL,
+	FS_TYPE_INIT(ocfs2_fs),
 };
 
 static int ocfs2_parse_options(struct super_block *sb,
Index: linux-2.6/fs/openpromfs/inode.c
===================================================================
--- linux-2.6.orig/fs/openpromfs/inode.c
+++ linux-2.6/fs/openpromfs/inode.c
@@ -413,6 +413,7 @@ static struct file_system_type openprom_
 	.name		= "openpromfs",
 	.get_sb		= openprom_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(openprom_fs),
 };
 
 static void op_inode_init_once(void *data, struct kmem_cache * cachep, unsigned long flags)
Index: linux-2.6/fs/pipe.c
===================================================================
--- linux-2.6.orig/fs/pipe.c
+++ linux-2.6/fs/pipe.c
@@ -1050,6 +1050,7 @@ static struct file_system_type pipe_fs_t
 	.name		= "pipefs",
 	.get_sb		= pipefs_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(pipe_fs),
 };
 
 static int __init init_pipe_fs(void)
Index: linux-2.6/fs/proc/root.c
===================================================================
--- linux-2.6.orig/fs/proc/root.c
+++ linux-2.6/fs/proc/root.c
@@ -44,6 +44,7 @@ static struct file_system_type proc_fs_t
 	.name		= "proc",
 	.get_sb		= proc_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(proc_fs),
 };
 
 void __init proc_root_init(void)
Index: linux-2.6/fs/qnx4/inode.c
===================================================================
--- linux-2.6.orig/fs/qnx4/inode.c
+++ linux-2.6/fs/qnx4/inode.c
@@ -569,6 +569,7 @@ static struct file_system_type qnx4_fs_t
 	.get_sb		= qnx4_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(qnx4_fs),
 };
 
 static int __init init_qnx4_fs(void)
Index: linux-2.6/fs/ramfs/inode.c
===================================================================
--- linux-2.6.orig/fs/ramfs/inode.c
+++ linux-2.6/fs/ramfs/inode.c
@@ -200,11 +200,13 @@ static struct file_system_type ramfs_fs_
 	.name		= "ramfs",
 	.get_sb		= ramfs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(ramfs_fs),
 };
 static struct file_system_type rootfs_fs_type = {
 	.name		= "rootfs",
 	.get_sb		= rootfs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(rootfs_fs),
 };
 
 static int __init init_ramfs_fs(void)
Index: linux-2.6/fs/reiserfs/super.c
===================================================================
--- linux-2.6.orig/fs/reiserfs/super.c
+++ linux-2.6/fs/reiserfs/super.c
@@ -2165,6 +2165,7 @@ struct file_system_type reiserfs_fs_type
 	.get_sb = get_super_block,
 	.kill_sb = reiserfs_kill_sb,
 	.fs_flags = FS_REQUIRES_DEV,
+	FS_TYPE_INIT(reiserfs_fs),
 };
 
 MODULE_DESCRIPTION("ReiserFS journaled filesystem");
Index: linux-2.6/fs/romfs/inode.c
===================================================================
--- linux-2.6.orig/fs/romfs/inode.c
+++ linux-2.6/fs/romfs/inode.c
@@ -617,6 +617,7 @@ static struct file_system_type romfs_fs_
 	.get_sb		= romfs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(romfs_fs),
 };
 
 static int __init init_romfs_fs(void)
Index: linux-2.6/fs/smbfs/inode.c
===================================================================
--- linux-2.6.orig/fs/smbfs/inode.c
+++ linux-2.6/fs/smbfs/inode.c
@@ -790,6 +790,7 @@ static struct file_system_type smb_fs_ty
 	.get_sb		= smb_get_sb,
 	.kill_sb	= kill_anon_super,
 	.fs_flags	= FS_BINARY_MOUNTDATA,
+	FS_TYPE_INIT(smb_fs),
 };
 
 static int __init init_smb_fs(void)
Index: linux-2.6/fs/sysfs/mount.c
===================================================================
--- linux-2.6.orig/fs/sysfs/mount.c
+++ linux-2.6/fs/sysfs/mount.c
@@ -86,6 +86,7 @@ static struct file_system_type sysfs_fs_
 	.name		= "sysfs",
 	.get_sb		= sysfs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(sysfs_fs),
 };
 
 int __init sysfs_init(void)
Index: linux-2.6/fs/sysv/super.c
===================================================================
--- linux-2.6.orig/fs/sysv/super.c
+++ linux-2.6/fs/sysv/super.c
@@ -518,6 +518,7 @@ static struct file_system_type sysv_fs_t
 	.get_sb		= sysv_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(sysv_fs),
 };
 
 static struct file_system_type v7_fs_type = {
@@ -526,6 +527,7 @@ static struct file_system_type v7_fs_typ
 	.get_sb		= v7_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(v7_fs),
 };
 
 static int __init init_sysv_fs(void)
Index: linux-2.6/fs/udf/super.c
===================================================================
--- linux-2.6.orig/fs/udf/super.c
+++ linux-2.6/fs/udf/super.c
@@ -105,6 +105,7 @@ static struct file_system_type udf_fstyp
 	.get_sb		= udf_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(udf_fstype),
 };
 
 static struct kmem_cache * udf_inode_cachep;
Index: linux-2.6/fs/ufs/super.c
===================================================================
--- linux-2.6.orig/fs/ufs/super.c
+++ linux-2.6/fs/ufs/super.c
@@ -1382,6 +1382,7 @@ static struct file_system_type ufs_fs_ty
 	.get_sb		= ufs_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(ufs_fs),
 };
 
 static int __init init_ufs_fs(void)
Index: linux-2.6/fs/vfat/namei.c
===================================================================
--- linux-2.6.orig/fs/vfat/namei.c
+++ linux-2.6/fs/vfat/namei.c
@@ -1037,6 +1037,7 @@ static struct file_system_type vfat_fs_t
 	.get_sb		= vfat_get_sb,
 	.kill_sb	= kill_block_super,
 	.fs_flags	= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(vfat_fs),
 };
 
 static int __init init_vfat_fs(void)
Index: linux-2.6/fs/xfs/linux-2.6/xfs_super.c
===================================================================
--- linux-2.6.orig/fs/xfs/linux-2.6/xfs_super.c
+++ linux-2.6/fs/xfs/linux-2.6/xfs_super.c
@@ -904,6 +904,7 @@ static struct file_system_type xfs_fs_ty
 	.get_sb			= xfs_fs_get_sb,
 	.kill_sb		= kill_block_super,
 	.fs_flags		= FS_REQUIRES_DEV,
+	FS_TYPE_INIT(xfs_fs),
 };
 
 
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h
+++ linux-2.6/include/linux/fs.h
@@ -1441,8 +1441,23 @@ struct file_system_type {
 	struct list_head fs_supers;
 	struct lock_class_key s_lock_key;
 	struct lock_class_key s_umount_key;
+	struct lock_class_key s_mapping_key;
+	struct lockdep_map s_mapping_map;
 };
 
+#define __CONCAT(x, y)		__CONCAT_I(x, y)
+#define __CONCAT_I(x, y)	__CONCAT_II(x ## y)
+#define __CONCAT_II(res)	res
+
+#define __STRING(x)		__STRING_I(x)
+#define __STRING_I(x)		#x
+
+#define STR_CONCAT(x, y)	__STRING(__CONCAT(x, y))
+
+#define FS_TYPE_INIT(name) \
+	.s_mapping_map = STATIC_LOCKDEP_MAP_INIT(STR_CONCAT(name, _page), \
+			&__CONCAT(name, _type).s_mapping_key)
+
 extern int get_sb_bdev(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data,
 	int (*fill_super)(struct super_block *, void *, int),
Index: linux-2.6/ipc/mqueue.c
===================================================================
--- linux-2.6.orig/ipc/mqueue.c
+++ linux-2.6/ipc/mqueue.c
@@ -1192,6 +1192,7 @@ static struct file_system_type mqueue_fs
 	.name = "mqueue",
 	.get_sb = mqueue_get_sb,
 	.kill_sb = kill_litter_super,
+	FS_TYPE_INIT(mqueue_fs),
 };
 
 static int msg_max_limit_min = DFLT_MSGMAX;
Index: linux-2.6/kernel/cpuset.c
===================================================================
--- linux-2.6.orig/kernel/cpuset.c
+++ linux-2.6/kernel/cpuset.c
@@ -401,6 +401,7 @@ static struct file_system_type cpuset_fs
 	.name = "cpuset",
 	.get_sb = cpuset_get_sb,
 	.kill_sb = kill_litter_super,
+	FS_TYPE_INIT(cpuset_fs),
 };
 
 /* struct cftype:
Index: linux-2.6/kernel/futex.c
===================================================================
--- linux-2.6.orig/kernel/futex.c
+++ linux-2.6/kernel/futex.c
@@ -2081,6 +2081,7 @@ static struct file_system_type futex_fs_
 	.name		= "futexfs",
 	.get_sb		= futexfs_get_sb,
 	.kill_sb	= kill_anon_super,
+	FS_TYPE_INIT(futex_fs),
 };
 
 static int __init init(void)
Index: linux-2.6/mm/shmem.c
===================================================================
--- linux-2.6.orig/mm/shmem.c
+++ linux-2.6/mm/shmem.c
@@ -2483,6 +2483,7 @@ static struct file_system_type tmpfs_fs_
 	.name		= "tmpfs",
 	.get_sb		= shmem_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(tmpfs_fs),
 };
 static struct vfsmount *shm_mnt;
 
Index: linux-2.6/mm/tiny-shmem.c
===================================================================
--- linux-2.6.orig/mm/tiny-shmem.c
+++ linux-2.6/mm/tiny-shmem.c
@@ -24,6 +24,7 @@ static struct file_system_type tmpfs_fs_
 	.name		= "tmpfs",
 	.get_sb		= ramfs_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(tmpfs_fs),
 };
 
 static struct vfsmount *shm_mnt;
Index: linux-2.6/net/socket.c
===================================================================
--- linux-2.6.orig/net/socket.c
+++ linux-2.6/net/socket.c
@@ -299,6 +299,7 @@ static struct file_system_type sock_fs_t
 	.name =		"sockfs",
 	.get_sb =	sockfs_get_sb,
 	.kill_sb =	kill_anon_super,
+	FS_TYPE_INIT(sock_fs),
 };
 
 static int sockfs_delete_dentry(struct dentry *dentry)
Index: linux-2.6/net/sunrpc/rpc_pipe.c
===================================================================
--- linux-2.6.orig/net/sunrpc/rpc_pipe.c
+++ linux-2.6/net/sunrpc/rpc_pipe.c
@@ -821,6 +821,7 @@ static struct file_system_type rpc_pipe_
 	.name		= "rpc_pipefs",
 	.get_sb		= rpc_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(rpc_pipe_fs),
 };
 
 static void
Index: linux-2.6/security/inode.c
===================================================================
--- linux-2.6.orig/security/inode.c
+++ linux-2.6/security/inode.c
@@ -145,6 +145,7 @@ static struct file_system_type fs_type =
 	.name =		"securityfs",
 	.get_sb =	get_sb,
 	.kill_sb =	kill_litter_super,
+	FS_TYPE_INIT(fs),
 };
 
 static int create_by_name(const char *name, mode_t mode,
Index: linux-2.6/security/selinux/selinuxfs.c
===================================================================
--- linux-2.6.orig/security/selinux/selinuxfs.c
+++ linux-2.6/security/selinux/selinuxfs.c
@@ -1426,6 +1426,7 @@ static struct file_system_type sel_fs_ty
 	.name		= "selinuxfs",
 	.get_sb		= sel_get_sb,
 	.kill_sb	= kill_litter_super,
+	FS_TYPE_INIT(sel_fs),
 };
 
 struct vfsmount *selinuxfs_mount;

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 11/12] lockdep: lock_page: use per fs-type lock_page class
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (9 preceding siblings ...)
  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 ` Peter Zijlstra
  2007-07-17 17:34 ` [RFC/T PATCH 12/12] mm: set_page_mapping() Peter Zijlstra
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: lockdep-fs-map.patch --]
[-- Type: text/plain, Size: 2951 bytes --]

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> 
---
 include/linux/pagemap.h |   55 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 45 insertions(+), 10 deletions(-)

Index: linux-2.6/include/linux/pagemap.h
===================================================================
--- linux-2.6.orig/include/linux/pagemap.h
+++ linux-2.6/include/linux/pagemap.h
@@ -357,14 +357,44 @@ extern void FASTCALL(unlock_page_nocheck
 
 extern struct lockdep_map page_lockdep_map;
 
-static inline void __lock_page_acquire(int try, unsigned long ip)
+static inline struct lockdep_map *page_map(struct page *page)
 {
-	lock_acquire(&page_lockdep_map, 0, try, 0, 2, ip);
+	struct address_space *mapping;
+	struct inode *inode;
+	struct super_block *sb;
+	struct file_system_type *type;
+	struct lockdep_map *map = &page_lockdep_map;
+
+	mapping = page_mapping(page);
+	if (!mapping)
+		goto out;
+
+	inode = mapping->host;
+	if (!inode)
+		goto out;
+
+	sb = inode->i_sb;
+	if (!sb)
+		goto out;
+
+	type = sb->s_type;
+	if (type)
+		map = &type->s_mapping_map;
+
+out:
+	return map;
 }
 
-static inline void __unlock_page_release(unsigned long ip)
+static inline void __lock_page_acquire(struct page *page, int try, unsigned long ip)
 {
-	lock_release(&page_lockdep_map, 1, ip);
+	struct lockdep_map *map = page_map(page);
+	lock_acquire(map, 0, try, 0, 2, ip);
+}
+
+static inline void __unlock_page_release(struct page *page, unsigned long ip)
+{
+	struct lockdep_map *map = page_map(page);
+	lock_release(map, 1, ip);
 }
 
 /*
@@ -373,22 +403,27 @@ static inline void __unlock_page_release
 static inline void lock_page(struct page *page)
 {
 	might_sleep();
-	__lock_page_acquire(0, _RET_IP_);
+	__lock_page_acquire(page, 0, _RET_IP_);
 	if (TestSetPageLocked(page))
 		__lock_page(page);
 }
 
+static inline void __lock_page_check(struct page *page)
+{
+	__lock_page_acquire(page, 0, _RET_IP_);
+}
+
 static inline int trylock_page(struct page *page)
 {
 	int ret = !TestSetPageLocked(page);
 	if (ret)
-		__lock_page_acquire(1, _RET_IP_);
+		__lock_page_acquire(page, 1, _RET_IP_);
 	return ret;
 }
 
 static inline void __unlock_page_check(struct page *page)
 {
-	__unlock_page_release(_RET_IP_);
+	__unlock_page_release(page, _RET_IP_);
 }
 
 static inline void unlock_page(struct page *page)
@@ -404,7 +439,7 @@ static inline void unlock_page(struct pa
 static inline void lock_page_nosync(struct page *page)
 {
 	might_sleep();
-	__lock_page_acquire(0, _RET_IP_);
+	__lock_page_acquire(page, 0, _RET_IP_);
 	if (TestSetPageLocked(page))
 		__lock_page_nosync(page);
 }
@@ -424,10 +459,10 @@ extern void FASTCALL(wait_on_page_bit(st
  */
 static inline void wait_on_page_locked(struct page *page)
 {
-	__lock_page_acquire(0, _RET_IP_);
+	__lock_page_acquire(page, 0, _RET_IP_);
 	if (PageLocked(page))
 		wait_on_page_bit(page, PG_locked);
-	__unlock_page_release(_RET_IP_);
+	__unlock_page_release(page, _RET_IP_);
 }
 
 /* 

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFC/T PATCH 12/12] mm: set_page_mapping()
  2007-07-17 17:34 [RFC/T PATCH 00/12] lockdep: annotate lock_page Peter Zijlstra
                   ` (10 preceding siblings ...)
  2007-07-17 17:34 ` [RFC/T PATCH 11/12] lockdep: lock_page: use per fs-type " Peter Zijlstra
@ 2007-07-17 17:34 ` Peter Zijlstra
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2007-07-17 17:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Zach Brown, Ingo Molnar, Peter Zijlstra

[-- Attachment #1: set_page_mapping.patch --]
[-- Type: text/plain, Size: 2821 bytes --]

wrap:
 	page->mapping = some_mapping;

because the lock class is dependent on page_mapping()

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 include/linux/pagemap.h |    9 +++++++++
 mm/filemap.c            |    4 ++--
 mm/migrate.c            |    8 ++++----
 3 files changed, 15 insertions(+), 6 deletions(-)

Index: linux-2.6/include/linux/pagemap.h
===================================================================
--- linux-2.6.orig/include/linux/pagemap.h
+++ linux-2.6/include/linux/pagemap.h
@@ -432,6 +432,15 @@ static inline void unlock_page(struct pa
 	unlock_page_nocheck(page);
 }
 
+static inline struct address_space *set_page_mapping(struct page *page,
+		struct address_space *mapping)
+{
+	__unlock_page_check(page);
+	page->mapping = mapping;
+	__lock_page_check(page);
+	return mapping;
+}
+
 /*
  * lock_page_nosync should only be used if we can't pin the page's inode.
  * Doesn't play quite so well with block device plugging.
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c
+++ linux-2.6/mm/filemap.c
@@ -120,7 +120,7 @@ void __remove_from_page_cache(struct pag
 	radix_tree_lock(&ctx);
 	radix_tree_delete(ctx.tree, page->index);
 	radix_tree_unlock(&ctx);
-	page->mapping = NULL;
+	set_page_mapping(page, NULL);
 	mapping_nrpages_dec(mapping);
 	__dec_zone_page_state(page, NR_FILE_PAGES);
 }
@@ -450,7 +450,7 @@ int add_to_page_cache(struct page *page,
 		if (!error) {
 			page_cache_get(page);
 			lock_page(page);
-			page->mapping = mapping;
+			set_page_mapping(page, mapping);
 			page->index = offset;
 			mapping_nrpages_inc(mapping);
 			__inc_zone_page_state(page, NR_FILE_PAGES);
Index: linux-2.6/mm/migrate.c
===================================================================
--- linux-2.6.orig/mm/migrate.c
+++ linux-2.6/mm/migrate.c
@@ -328,7 +328,7 @@ static int migrate_page_move_mapping(str
 #endif
 
 	radix_tree_replace_slot(pslot, newpage);
-	page->mapping = NULL;
+	set_page_mapping(page, NULL);
 	radix_tree_unlock(&ctx);
 
 	/*
@@ -386,7 +386,7 @@ static void migrate_page_copy(struct pag
 	ClearPageActive(page);
 	ClearPagePrivate(page);
 	set_page_private(page, 0);
-	page->mapping = NULL;
+	set_page_mapping(page, NULL);
 
 	/*
 	 * If any waiters have accumulated on the new page then
@@ -578,7 +578,7 @@ static int move_to_new_page(struct page 
 
 	/* Prepare mapping for the new page.*/
 	newpage->index = page->index;
-	newpage->mapping = page->mapping;
+	set_page_mapping(newpage, page->mapping);
 
 	mapping = page_mapping(page);
 	if (!mapping)
@@ -599,7 +599,7 @@ static int move_to_new_page(struct page 
 	if (!rc)
 		remove_migration_ptes(page, newpage);
 	else
-		newpage->mapping = NULL;
+		set_page_mapping(newpage, NULL);
 
 	unlock_page(newpage);
 

--


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-07-17 15:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [RFC/T PATCH 05/12] lockdep: add initial lockdep support for lock_page Peter Zijlstra
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox