lockdep: annotate lock_page
Subsystems (57)
cover lockdep: annotate lock_page
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 :-)
--
PATCH 1/12 lockdep: annotate journal_start()
Quoted 2 lines · Andrew Morton
Except lockdep doesn't know about
journal_start(), which has ranking requirements similar to a semaphore.
--- fs/jbd/transaction.c | 9 +++++++++ include/linux/jbd.h | 5 +++++ 2 files changed, 14 insertions(+)
fs/jbd/transaction.c +9 -0
@@ -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; }
include/linux/jbd.h +5 -0
@@ -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 };
--
PATCH 2/12 mm: trylock_page
In reply to Peter ZijlstraReplace raw TestSetPageLocked() usage with trylock_page()
--- 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(-)
fs/afs/write.c +1 -1
@@ -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) {
fs/cifs/file.c +1 -1
@@ -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)) {
fs/jbd/commit.c +1 -1
@@ -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);
fs/jbd2/commit.c +1 -1
@@ -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);
fs/splice.c +1 -1
@@ -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);
fs/xfs/linux-2.6/xfs_aops.c +2 -2
@@ -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;
include/linux/pagemap.h +5 -0
@@ -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.
mm/filemap.c +1 -1
@@ -885,7 +885,7 @@ grab_cache_page_nowait(struct address_spstruct page *page =find_get_page (mapping, index);if (page) { -if (!TestSetPageLocked (page)) +if (trylock_page (page))return page;page_cache_release (page);return NULL ;
mm/memory.c +1 -1
@@ -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); }
mm/migrate.c +2 -2
@@ -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);
mm/rmap.c +1 -1
@@ -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)
mm/shmem.c +2 -2
@@ -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);
mm/slub.c +1 -1
@@ -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
mm/swap.c +1 -1
@@ -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);
mm/swap_state.c +1 -1
@@ -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); }
mm/swapfile.c +1 -1
@@ -401,7 +401,7 @@ void free_swap_and_cache(swp_entry_t entif (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 ; }
mm/truncate.c +2 -2
@@ -186,7 +186,7 @@ void truncate_inode_pages_range(struct aif (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(spgoff_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
mm/vmscan.c +2 -2
@@ -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;
--
PATCH 3/12 mm: remove raw SetPageLocked() usage
In reply to Peter ZijlstraRemove 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.
--- 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(-)
drivers/char/agp/generic.c +1 -1
@@ -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); }
drivers/char/agp/intel-agp.c +1 -1
@@ -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); }
drivers/char/agp/sgi-agp.c +1 -1
@@ -51,7 +51,7 @@ static void *sgi_tioca_alloc_page(structreturn NULL ;get_page (page); -SetPageLocked (page); +lock_page (page);atomic_inc (&agp_bridge->current_memory_agp);return page_address (page); }
mm/filemap.c +1 -1
@@ -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);
mm/swap_state.c +1 -1
@@ -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 */ }/*
--
PATCH 4/12 mm: remove raw ClearPageLocked() usage
In reply to Peter Zijlstraremove the last raw ClearPageLocked() user
--- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/swap_state.c +1 -1
@@ -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;
--
PATCH 5/12 lockdep: add initial lockdep support for lock_page
In reply to Peter Zijlstrause a global lockdep_map instance for all pages.
--- 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(-)
include/linux/lockdep.h +7 -0
@@ -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)
include/linux/mm_types.h +1 -0
@@ -5,6 +5,7 @@#include <linux/threads.h> #include <linux/list.h> #include <linux/spinlock.h> +#include <linux/lockdep.h> struct address_space ;
include/linux/pagemap.h +10 -1
@@ -355,19 +355,25 @@ extern void FASTCALL(__lock_page(structextern 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 pastatic 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_); }/*
mm/filemap.c +7 -0
@@ -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 ();
--
PATCH 6/12 lockdep: lock_page: handle IO-completions
In reply to Peter ZijlstraIO-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.
--- fs/buffer.c | 4 +++- fs/mpage.c | 19 +++++++++++++++---- include/linux/pagemap.h | 13 ++++++++++++- mm/filemap.c | 5 ++--- 4 files changed, 32 insertions(+), 9 deletions(-)
include/linux/pagemap.h +12 -1
@@ -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 pareturn 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.
mm/filemap.c +2 -3
@@ -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
fs/buffer.c +3 -1
@@ -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 *pamark_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
fs/mpage.c +15 -4
@@ -59,7 +59,7 @@ static int mpage_end_io_read(struct bioClearPageUptodate (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 biostatic 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 ; }
--
PATCH 7/12 lockdep: non-recursive validation
In reply to Peter ZijlstraAdd 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 :-/
--- include/linux/lockdep.h | 15 ++++++++------- kernel/lockdep.c | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-)
include/linux/lockdep.h +8 -7
@@ -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)
kernel/lockdep.c +12 -3
@@ -2176,7 +2176,7 @@ static int __lock_acquire(struct lockdepstruct 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 lockdepreturn 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: *
--
PATCH 8/12 lockdep: lock_page: recursion
In reply to Peter Zijlstraavoid the need to annotate lock_page nestings (which are abundant)
--- include/linux/pagemap.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
include/linux/pagemap.h +16 -6
@@ -357,13 +357,23 @@ extern void FASTCALL(unlock_page_nocheckextern 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 pastatic 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_); }/*
--
PATCH 9/12 lockdep: increase MAX_LOCK_DEPTH
In reply to Peter Zijlstrawe can easily hold PAGE_VEC (and more in places) page locks.
--- include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched.h +1 -1
@@ -1246,7 +1246,7 @@ struct task_struct {int softirq_context;#endif #ifdef CONFIG_LOCKDEP -# define MAX_LOCK_DEPTH 30UL +# define MAX_LOCK_DEPTH 48ULu64 curr_chain_key;int lockdep_depth;struct held_lock held_locks[MAX_LOCK_DEPTH ];
--
PATCH 10/12 lockdep: fs: per file-system type lock_page class
In reply to Peter Zijlstrastatic struct file_system_type foo_fs_type {
...
FS_TYPE_INIT(foo_fs),
};--- 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(-)
arch/ia64/kernel/perfmon.c +1 -0
@@ -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 );
arch/powerpc/platforms/cell/spufs/inode.c +1 -0
@@ -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 )
arch/s390/hypfs/inode.c +2 -1
@@ -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 = {
drivers/infiniband/core/uverbs_main.c +2 -1
@@ -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 )
drivers/infiniband/hw/ipath/ipath_fs.c +1 -0
@@ -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 )
drivers/isdn/capi/capifs.c +1 -0
@@ -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)
drivers/kvm/kvm_main.c +1 -0
@@ -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)
drivers/misc/ibmasm/ibmasmfs.c +1 -0
@@ -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)
drivers/oprofile/oprofilefs.c +1 -0
@@ -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), };
drivers/usb/core/inode.c +1 -0
@@ -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), };/* --------------------------------------------------------------------- */
drivers/usb/gadget/inode.c +1 -0
@@ -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), };/*----------------------------------------------------------------------*/
fs/9p/vfs_super.c +1 -0
@@ -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), };
fs/adfs/super.c +1 -0
@@ -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 )
fs/affs/super.c +1 -0
@@ -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 )
fs/afs/super.c +1 -0
@@ -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 = {
fs/anon_inodes.c +1 -0
@@ -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,
fs/autofs/init.c +1 -0
@@ -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 )
fs/autofs4/init.c +1 -0
@@ -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 )
fs/befs/linuxvfs.c +1 -0
@@ -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
fs/bfs/inode.c +1 -0
@@ -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 )
fs/binfmt_misc.c +1 -0
@@ -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 )
fs/block_dev.c +1 -0
@@ -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 ;
fs/cifs/cifsfs.c +1 -0
@@ -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,
fs/coda/inode.c +1 -0
@@ -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), };
fs/configfs/mount.c +1 -0
@@ -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 )
fs/cramfs/inode.c +1 -0
@@ -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 )
fs/debugfs/inode.c +1 -0
@@ -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,
fs/devpts/inode.c +1 -0
@@ -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), };/*
fs/ecryptfs/main.c +2 -1
@@ -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), };/**
fs/efs/super.c +1 -0
@@ -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[] = {
fs/ext2/super.c +1 -0
@@ -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 )
fs/ext3/super.c +1 -0
@@ -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 )
fs/ext4/super.c +1 -0
@@ -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 )
fs/freevxfs/vxfs_super.c +1 -0
@@ -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
fs/fuse/control.c +1 -0
@@ -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 )
fs/fuse/inode.c +2 -0
@@ -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 )
fs/gfs2/ops_fstype.c +2 -0
@@ -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), };
fs/hfs/super.c +1 -0
@@ -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)
fs/hfsplus/super.c +1 -0
@@ -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)
fs/hostfs/hostfs_kern.c +1 -0
@@ -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 )
fs/hpfs/super.c +1 -0
@@ -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 )
fs/hppfs/hppfs_kern.c +1 -0
@@ -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 )
fs/hugetlbfs/inode.c +1 -0
@@ -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;
fs/inotify_user.c +1 -0
@@ -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), };/*
fs/isofs/inode.c +1 -0
@@ -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 )
fs/jffs2/super.c +1 -0
@@ -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 )
fs/jfs/super.c +1 -0
@@ -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)
fs/minix/inode.c +1 -0
@@ -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 )
fs/msdos/namei.c +1 -0
@@ -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 )
fs/ncpfs/inode.c +1 -0
@@ -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 )
fs/nfs/super.c +5 -0
@@ -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 = {
fs/nfsd/nfsctl.c +1 -0
@@ -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 )
fs/ntfs/super.c +1 -0
@@ -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. */
fs/ocfs2/dlm/dlmfs.c +1 -0
@@ -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 )
fs/ocfs2/super.c +2 -1
@@ -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,
fs/openpromfs/inode.c +1 -0
@@ -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)
fs/pipe.c +1 -0
@@ -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 )
fs/proc/root.c +1 -0
@@ -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 )
fs/qnx4/inode.c +1 -0
@@ -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 )
fs/ramfs/inode.c +2 -0
@@ -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 )
fs/reiserfs/super.c +1 -0
@@ -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" );
fs/romfs/inode.c +1 -0
@@ -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 )
fs/smbfs/inode.c +1 -0
@@ -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 )
fs/sysfs/mount.c +1 -0
@@ -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 )
fs/sysv/super.c +2 -0
@@ -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 )
fs/udf/super.c +1 -0
@@ -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;
fs/ufs/super.c +1 -0
@@ -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 )
fs/vfat/namei.c +1 -0
@@ -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 )
fs/xfs/linux-2.6/xfs_super.c +1 -0
@@ -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), };
include/linux/fs.h +15 -0
@@ -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),
ipc/mqueue.c +1 -0
@@ -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 ;
kernel/cpuset.c +1 -0
@@ -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:
kernel/futex.c +1 -0
@@ -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 )
mm/shmem.c +1 -0
@@ -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;
mm/tiny-shmem.c +1 -0
@@ -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;
net/socket.c +1 -0
@@ -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)
net/sunrpc/rpc_pipe.c +1 -0
@@ -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
security/inode.c +1 -0
@@ -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,
security/selinux/selinuxfs.c +1 -0
@@ -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;
--
PATCH 11/12 lockdep: lock_page: use per fs-type lock_page class
In reply to Peter Zijlstra--- include/linux/pagemap.h | 55 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 10 deletions(-)
include/linux/pagemap.h +45 -10
@@ -357,14 +357,44 @@ extern void FASTCALL(unlock_page_nocheckextern 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_releasestatic 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 pastatic 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_); }/*
--
PATCH 12/12 mm: set_page_mapping()
In reply to Peter Zijlstrawrap:
page->mapping = some_mapping;
because the lock class is dependent on page_mapping()
--- include/linux/pagemap.h | 9 +++++++++ mm/filemap.c | 4 ++-- mm/migrate.c | 8 ++++---- 3 files changed, 15 insertions(+), 6 deletions(-)
include/linux/pagemap.h +9 -0
@@ -432,6 +432,15 @@ static inline void unlock_page(struct paunlock_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.
mm/filemap.c +2 -2
@@ -120,7 +120,7 @@ void __remove_from_page_cache(struct pagradix_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 );
mm/migrate.c +4 -4
@@ -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 pagClearPageActive (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 pageif (!rc)remove_migration_ptes (page, newpage);else - newpage->mapping =NULL ; +set_page_mapping (newpage,NULL );unlock_page (newpage);
--