Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705158

[PATCH v8 12/14] lockdep: Apply lock_acquire(release) on __Set(__Clear)PageLocked

From Byungchul Park <byungchul.park@lge.com>
Newsgroups linux.kernel
Subject [PATCH v8 12/14] lockdep: Apply lock_acquire(release) on __Set(__Clear)PageLocked
Date 2017-08-07 09:20 +0200
Message-ID <ubKuu-59V-33@gated-at.bofh.it> (permalink)
References <ubKut-59V-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Usually PG_locked bit is updated by lock_page() or unlock_page().
However, it can be also updated through __SetPageLocked() or
__ClearPageLockded(). They have to be considered, to get paired between
acquire and release.

Furthermore, e.g. __SetPageLocked() in add_to_page_cache_lru() is called
frequently. We might miss many chances to check deadlock if we ignore it.
Make __Set(__Clear)PageLockded considered as well.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 include/linux/page-flags.h | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index d33e328..b793342 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -261,7 +261,6 @@ static __always_inline int PageCompound(struct page *page)
 #define TESTSCFLAG_FALSE(uname)						\
 	TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname)
 
-__PAGEFLAG(Locked, locked, PF_NO_TAIL)
 PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD)
 PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
 PAGEFLAG(Referenced, referenced, PF_HEAD)
@@ -373,6 +372,35 @@ static __always_inline int PageSwapCache(struct page *page)
 PAGEFLAG(Idle, idle, PF_ANY)
 #endif
 
+#ifdef CONFIG_LOCKDEP_PAGELOCK
+#include <linux/lockdep.h>
+
+TESTPAGEFLAG(Locked, locked, PF_NO_TAIL)
+
+static __always_inline void __SetPageLocked(struct page *page)
+{
+	__set_bit(PG_locked, &PF_NO_TAIL(page, 1)->flags);
+
+	page = compound_head(page);
+	lock_acquire_exclusive((struct lockdep_map *)&page->map, 0, 1, NULL, _RET_IP_);
+}
+
+static __always_inline void __ClearPageLocked(struct page *page)
+{
+	__clear_bit(PG_locked, &PF_NO_TAIL(page, 1)->flags);
+
+	page = compound_head(page);
+	/*
+	 * lock_commit_crosslock() is necessary for crosslock
+	 * when the lock is released, before lock_release().
+	 */
+	lock_commit_crosslock((struct lockdep_map *)&page->map);
+	lock_release((struct lockdep_map *)&page->map, 0, _RET_IP_);
+}
+#else
+__PAGEFLAG(Locked, locked, PF_NO_TAIL)
+#endif
+
 /*
  * On an anonymous page mapped into a user virtual memory area,
  * page->mapping points to its anon_vma, not to a struct address_space;
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v8 00/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
  [PATCH v8 08/14] lockdep: Make print_circular_bug() aware of crossrelease Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
    [tip:locking/core] locking/lockdep: Make print_circular_bug() aware  of crossrelease tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-10 14:30 +0200
  [PATCH v8 05/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
    Re: [PATCH v8 05/14] lockdep: Implement crossrelease feature Peter Zijlstra <peterz@infradead.org> - 2017-08-09 16:10 +0200
      Re: [PATCH v8 05/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-10 03:40 +0200
        Re: [PATCH v8 05/14] lockdep: Implement crossrelease feature Peter Zijlstra <peterz@infradead.org> - 2017-08-10 11:30 +0200
    [tip:locking/core] locking/lockdep: Implement the 'crossrelease'  feature tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-10 14:30 +0200
  [PATCH v8 11/14] lockdep: Apply crossrelease to PG_locked locks Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
    Re: [PATCH v8 11/14] lockdep: Apply crossrelease to PG_locked locks Byungchul Park <byungchul.park@lge.com> - 2017-08-10 03:40 +0200
      Re: [PATCH v8 11/14] lockdep: Apply crossrelease to PG_locked locks Peter Zijlstra <peterz@infradead.org> - 2017-08-10 11:30 +0200
  [PATCH v8 10/14] pagemap.h: Remove trailing white space Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
  [PATCH v8 07/14] lockdep: Handle non(or multi)-acquisition of a crosslock Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
    [tip:locking/core] locking/lockdep: Handle non(or  multi)-acquisition of a crosslock tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-10 14:30 +0200
  [PATCH v8 12/14] lockdep: Apply lock_acquire(release) on __Set(__Clear)PageLocked Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
  [PATCH v8 14/14] lockdep: Crossrelease feature documentation Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
    [tip:locking/core] locking/lockdep: Add 'crossrelease' feature  documentation tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-10 14:30 +0200
  [PATCH v8 09/14] lockdep: Apply crossrelease to completions Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
    Re: [PATCH v8 09/14] lockdep: Apply crossrelease to completions Peter Zijlstra <peterz@infradead.org> - 2017-08-09 12:00 +0200
      Re: [PATCH v8 09/14] lockdep: Apply crossrelease to completions Peter Zijlstra <peterz@infradead.org> - 2017-08-09 12:30 +0200
        Re: [PATCH v8 09/14] lockdep: Apply crossrelease to completions Byungchul Park <byungchul.park@lge.com> - 2017-08-10 03:30 +0200
    [tip:locking/core] locking/lockdep: Apply crossrelease to  completions tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-10 14:30 +0200
  [PATCH v8 04/14] lockdep: Make check_prev_add() able to handle external stack_trace Byungchul Park <byungchul.park@lge.com> - 2017-08-07 09:20 +0200
    [tip:locking/core] locking/lockdep: Make check_prev_add() able to  handle external stack_trace tip-bot for Byungchul Park <tipbot@zytor.com> - 2017-08-10 14:30 +0200
  Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Peter Zijlstra <peterz@infradead.org> - 2017-08-09 18:00 +0200
    Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-10 03:00 +0200
      Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-10 05:50 +0200
      Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-10 13:00 +0200
    Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-10 11:40 +0200
      Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Peter Zijlstra <peterz@infradead.org> - 2017-08-10 13:00 +0200
  Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Ingo Molnar <mingo@kernel.org> - 2017-08-10 13:20 +0200
    Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature Byungchul Park <byungchul.park@lge.com> - 2017-08-10 13:50 +0200

csiph-web