From: Namhyung Kim <namhyung@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 06/12] rmap: annotate lock context change on page_[un]lock_anon_vma()
Date: Thu, 30 Sep 2010 12:50:15 +0900 [thread overview]
Message-ID: <1285818621-29890-7-git-send-email-namhyung@gmail.com> (raw)
In-Reply-To: <1285818621-29890-1-git-send-email-namhyung@gmail.com>
The page_lock_anon_vma() conditionally grabs RCU and anon_vma lock
but page_unlock_anon_vma() releases them unconditionally. This leads
sparse to complain about context imbalance. Annotate them.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
include/linux/rmap.h | 15 ++++++++++++++-
mm/rmap.c | 4 +++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 31b2fd7..0fa7769 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -230,7 +230,20 @@ int try_to_munlock(struct page *);
/*
* Called by memory-failure.c to kill processes.
*/
-struct anon_vma *page_lock_anon_vma(struct page *page);
+struct anon_vma *__page_lock_anon_vma(struct page *page);
+
+static inline struct anon_vma *page_lock_anon_vma(struct page *page)
+{
+ struct anon_vma *anon_vma;
+
+ __cond_lock(RCU, anon_vma = __page_lock_anon_vma(page));
+
+ /* (void) is needed to make gcc happy */
+ (void) __cond_lock(&anon_vma->root->lock, anon_vma);
+
+ return anon_vma;
+}
+
void page_unlock_anon_vma(struct anon_vma *anon_vma);
int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma);
diff --git a/mm/rmap.c b/mm/rmap.c
index 9d2ba01..244ff06 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -314,7 +314,7 @@ void __init anon_vma_init(void)
* Getting a lock on a stable anon_vma from a page off the LRU is
* tricky: page_lock_anon_vma rely on RCU to guard against the races.
*/
-struct anon_vma *page_lock_anon_vma(struct page *page)
+struct anon_vma *__page_lock_anon_vma(struct page *page)
{
struct anon_vma *anon_vma, *root_anon_vma;
unsigned long anon_mapping;
@@ -348,6 +348,8 @@ out:
}
void page_unlock_anon_vma(struct anon_vma *anon_vma)
+ __releases(&anon_vma->root->lock)
+ __releases(RCU)
{
anon_vma_unlock(anon_vma);
rcu_read_unlock();
--
1.7.2.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-09-30 3:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-30 3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
2010-09-30 3:50 ` [PATCH 01/12] mm: remove temporary variable on generic_file_direct_write() Namhyung Kim
2010-09-30 3:50 ` [PATCH 02/12] mm: add casts to/from gfp_t in gfp_to_alloc_flags() Namhyung Kim
2010-09-30 3:50 ` [PATCH 03/12] mm: wrap get_locked_pte() using __cond_lock() Namhyung Kim
2010-09-30 3:50 ` [PATCH 04/12] mm: add lock release annotation on do_wp_page() Namhyung Kim
2010-09-30 3:50 ` [PATCH 05/12] mm: wrap follow_pte() using __cond_lock() Namhyung Kim
2010-09-30 3:50 ` Namhyung Kim [this message]
2010-09-30 3:50 ` [PATCH 07/12] rmap: wrap page_check_address() " Namhyung Kim
2010-09-30 3:50 ` [PATCH 08/12] rmap: make anon_vma_[chain_]free() static Namhyung Kim
2010-09-30 3:50 ` [PATCH 09/12] vmalloc: rename temporary variable in __insert_vmap_area() Namhyung Kim
2010-09-30 3:50 ` [PATCH 10/12] vmalloc: annotate lock context change on s_start/stop() Namhyung Kim
2010-09-30 3:50 ` [PATCH 11/12] mm: declare some external symbols Namhyung Kim
2010-09-30 3:50 ` [PATCH 12/12] vmstat: include compaction.h when CONFIG_COMPACTION Namhyung Kim
2010-10-05 21:27 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1285818621-29890-7-git-send-email-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).