[RFC/T PATCH 08/12] lockdep: lock_page: recursion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Peter Zijlstra <[email protected]>
---
 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_);
 }
 
 /* 

--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux