linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] mm: fix sparse warnings
@ 2010-09-30  3:50 Namhyung Kim
  2010-09-30  3:50 ` [PATCH 01/12] mm: remove temporary variable on generic_file_direct_write() Namhyung Kim
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

Hello,

This patchset tries to remove various warnings from sparse. Each patch
contains the warnings it removes in changelog. I compile-tested with
all{yes,no}config on x86. Any comments would be welcomed.

Thanks.

---

Namhyung Kim (12):
  mm: remove temporary variable on generic_file_direct_write()
  mm: add casts to/from gfp_t in gfp_to_alloc_flags()
  mm: wrap get_locked_pte() using __cond_lock()
  mm: add lock release annotation on do_wp_page()
  mm: wrap follow_pte() using __cond_lock()
  rmap: annotate lock context change on page_[un]lock_anon_vma()
  rmap: wrap page_check_address() using __cond_lock()
  rmap: make anon_vma_[chain_]free() static
  vmalloc: rename temporary variable in __insert_vmap_area()
  vmalloc: annotate lock context change on s_start/stop()
  mm: declare some external symbols
  vmstat: include compaction.h when CONFIG_COMPACTION

 include/linux/backing-dev.h |    1 +
 include/linux/mm.h          |   10 +++++++++-
 include/linux/rmap.h        |   29 ++++++++++++++++++++++++++---
 include/linux/writeback.h   |    2 ++
 mm/filemap.c                |    8 ++++----
 mm/memory.c                 |   16 ++++++++++++++--
 mm/page_alloc.c             |    4 ++--
 mm/rmap.c                   |   10 ++++++----
 mm/vmalloc.c                |   10 ++++++----
 mm/vmstat.c                 |    2 ++
 10 files changed, 72 insertions(+), 20 deletions(-)

--
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>

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

* [PATCH 01/12] mm: remove temporary variable on generic_file_direct_write()
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 02/12] mm: add casts to/from gfp_t in gfp_to_alloc_flags() Namhyung Kim
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

'end' shadows earlier one and is not necessary at all. Remove it
and use 'pos' instead. This removes following sparse warnings:

 mm/filemap.c:2180:24: warning: symbol 'end' shadows an earlier one
 mm/filemap.c:2132:25: originally declared here

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 mm/filemap.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 3d4df44..4a05bf1 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2177,12 +2177,12 @@ generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
 	}
 
 	if (written > 0) {
-		loff_t end = pos + written;
-		if (end > i_size_read(inode) && !S_ISBLK(inode->i_mode)) {
-			i_size_write(inode,  end);
+		pos += written;
+		if (pos > i_size_read(inode) && !S_ISBLK(inode->i_mode)) {
+			i_size_write(inode, pos);
 			mark_inode_dirty(inode);
 		}
-		*ppos = end;
+		*ppos = pos;
 	}
 out:
 	return written;
-- 
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>

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

* [PATCH 02/12] mm: add casts to/from gfp_t in gfp_to_alloc_flags()
  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 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 03/12] mm: wrap get_locked_pte() using __cond_lock() Namhyung Kim
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

This removes following warning from sparse:

 mm/page_alloc.c:1934:9: warning: restricted gfp_t degrades to integer

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 mm/page_alloc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a8cfa9c..7c4e5b1 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1931,7 +1931,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
 	const gfp_t wait = gfp_mask & __GFP_WAIT;
 
 	/* __GFP_HIGH is assumed to be the same as ALLOC_HIGH to save a branch. */
-	BUILD_BUG_ON(__GFP_HIGH != ALLOC_HIGH);
+	BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_HIGH);
 
 	/*
 	 * The caller may dip into page reserves a bit more if the caller
@@ -1939,7 +1939,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
 	 * policy or is asking for __GFP_HIGH memory.  GFP_ATOMIC requests will
 	 * set both ALLOC_HARDER (!wait) and ALLOC_HIGH (__GFP_HIGH).
 	 */
-	alloc_flags |= (gfp_mask & __GFP_HIGH);
+	alloc_flags |= (__force int) (gfp_mask & __GFP_HIGH);
 
 	if (!wait) {
 		alloc_flags |= ALLOC_HARDER;
-- 
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>

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

* [PATCH 03/12] mm: wrap get_locked_pte() using __cond_lock()
  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 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 04/12] mm: add lock release annotation on do_wp_page() Namhyung Kim
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

The get_locked_pte() conditionally grabs 'ptl' in case of returning
non-NULL. This leads sparse to complain about context imbalance.
Rename and wrap it using __cond_lock() to make sparse happy.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 include/linux/mm.h |   10 +++++++++-
 mm/memory.c        |    2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 74949fb..e48616d 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1023,7 +1023,15 @@ extern void unregister_shrinker(struct shrinker *);
 
 int vma_wants_writenotify(struct vm_area_struct *vma);
 
-extern pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl);
+extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
+			       spinlock_t **ptl);
+static inline pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,
+				    spinlock_t **ptl)
+{
+	pte_t *ptep;
+	__cond_lock(*ptl, ptep = __get_locked_pte(mm, addr, ptl));
+	return ptep;
+}
 
 #ifdef __PAGETABLE_PUD_FOLDED
 static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
diff --git a/mm/memory.c b/mm/memory.c
index 0e18b4d..219b50a 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1590,7 +1590,7 @@ struct page *get_dump_page(unsigned long addr)
 }
 #endif /* CONFIG_ELF_CORE */
 
-pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,
+pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
 			spinlock_t **ptl)
 {
 	pgd_t * pgd = pgd_offset(mm, addr);
-- 
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>

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

* [PATCH 04/12] mm: add lock release annotation on do_wp_page()
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (2 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 03/12] mm: wrap get_locked_pte() using __cond_lock() Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 05/12] mm: wrap follow_pte() using __cond_lock() Namhyung Kim
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

The do_wp_page() releases @ptl but was missing proper annotation.
Add it. This removes following warnings from sparse:

 mm/memory.c:2337:9: warning: context imbalance in 'do_wp_page' - unexpected unlock
 mm/memory.c:3142:19: warning: context imbalance in 'handle_mm_fault' - different lock contexts for basic block

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 mm/memory.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 219b50a..76fa60e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2107,6 +2107,7 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
 static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
 		unsigned long address, pte_t *page_table, pmd_t *pmd,
 		spinlock_t *ptl, pte_t orig_pte)
+	__releases(ptl)
 {
 	struct page *old_page, *new_page;
 	pte_t entry;
-- 
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>

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

* [PATCH 05/12] mm: wrap follow_pte() using __cond_lock()
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (3 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 04/12] mm: add lock release annotation on do_wp_page() Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 06/12] rmap: annotate lock context change on page_[un]lock_anon_vma() Namhyung Kim
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

The follow_pte() conditionally grabs *@ptlp in case of returning 0.
Rename and wrap it using __cond_lock() removes following warnings:

 mm/memory.c:2337:9: warning: context imbalance in 'do_wp_page' - unexpected unlock
 mm/memory.c:3142:19: warning: context imbalance in 'handle_mm_fault' - different lock contexts for basic block

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 mm/memory.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 76fa60e..6892fe8 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3344,7 +3344,7 @@ int in_gate_area_no_task(unsigned long addr)
 
 #endif	/* __HAVE_ARCH_GATE_AREA */
 
-static int follow_pte(struct mm_struct *mm, unsigned long address,
+static int __follow_pte(struct mm_struct *mm, unsigned long address,
 		pte_t **ptepp, spinlock_t **ptlp)
 {
 	pgd_t *pgd;
@@ -3381,6 +3381,17 @@ out:
 	return -EINVAL;
 }
 
+static inline int follow_pte(struct mm_struct *mm, unsigned long address,
+			     pte_t **ptepp, spinlock_t **ptlp)
+{
+	int res;
+
+	/* (void) is needed to make gcc happy */
+	(void) __cond_lock(*ptlp,
+			   !(res = __follow_pte(mm, address, ptepp, ptlp)));
+	return res;
+}
+
 /**
  * follow_pfn - look up PFN at a user virtual address
  * @vma: memory mapping
-- 
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>

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

* [PATCH 06/12] rmap: annotate lock context change on page_[un]lock_anon_vma()
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (4 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 05/12] mm: wrap follow_pte() using __cond_lock() Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 07/12] rmap: wrap page_check_address() using __cond_lock() Namhyung Kim
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

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>

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

* [PATCH 07/12] rmap: wrap page_check_address() using __cond_lock()
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (5 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 06/12] rmap: annotate lock context change on page_[un]lock_anon_vma() Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 08/12] rmap: make anon_vma_[chain_]free() static Namhyung Kim
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

The page_check_address() conditionally grabs *@ptlp in case of returning
non-NULL. Rename and wrap it using __cond_lock() removes following
warnings from sparse:

 mm/rmap.c:472:9: warning: context imbalance in 'page_mapped_in_vma' - unexpected unlock
 mm/rmap.c:524:9: warning: context imbalance in 'page_referenced_one' - unexpected unlock
 mm/rmap.c:706:9: warning: context imbalance in 'page_mkclean_one' - unexpected unlock
 mm/rmap.c:1066:9: warning: context imbalance in 'try_to_unmap_one' - unexpected unlock

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 include/linux/rmap.h |   13 ++++++++++++-
 mm/rmap.c            |    2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 0fa7769..490206c 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -205,9 +205,20 @@ int try_to_unmap_one(struct page *, struct vm_area_struct *,
 /*
  * Called from mm/filemap_xip.c to unmap empty zero page
  */
-pte_t *page_check_address(struct page *, struct mm_struct *,
+pte_t *__page_check_address(struct page *, struct mm_struct *,
 				unsigned long, spinlock_t **, int);
 
+static inline pte_t *page_check_address(struct page *page, struct mm_struct *mm,
+					unsigned long address,
+					spinlock_t **ptlp, int sync)
+{
+	pte_t *ptep;
+
+	__cond_lock(*ptlp, ptep = __page_check_address(page, mm, address,
+						       ptlp, sync));
+	return ptep;
+}
+
 /*
  * Used by swapoff to help locate where page is expected in vma.
  */
diff --git a/mm/rmap.c b/mm/rmap.c
index 244ff06..9c900dd 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -403,7 +403,7 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
  *
  * On success returns with pte mapped and locked.
  */
-pte_t *page_check_address(struct page *page, struct mm_struct *mm,
+pte_t *__page_check_address(struct page *page, struct mm_struct *mm,
 			  unsigned long address, spinlock_t **ptlp, int sync)
 {
 	pgd_t *pgd;
-- 
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>

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

* [PATCH 08/12] rmap: make anon_vma_[chain_]free() static
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (6 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 07/12] rmap: wrap page_check_address() using __cond_lock() Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 09/12] vmalloc: rename temporary variable in __insert_vmap_area() Namhyung Kim
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

Make anon_vma_free() and anon_vma_chain_free() static. They are
called only in rmap.c and corresponding alloc functions are
already static.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 include/linux/rmap.h |    1 -
 mm/rmap.c            |    4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 490206c..be92e78 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -148,7 +148,6 @@ void unlink_anon_vmas(struct vm_area_struct *);
 int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
 int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
 void __anon_vma_link(struct vm_area_struct *);
-void anon_vma_free(struct anon_vma *);
 
 static inline void anon_vma_merge(struct vm_area_struct *vma,
 				  struct vm_area_struct *next)
diff --git a/mm/rmap.c b/mm/rmap.c
index 9c900dd..af7dc02 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -70,7 +70,7 @@ static inline struct anon_vma *anon_vma_alloc(void)
 	return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
 }
 
-void anon_vma_free(struct anon_vma *anon_vma)
+static void anon_vma_free(struct anon_vma *anon_vma)
 {
 	kmem_cache_free(anon_vma_cachep, anon_vma);
 }
@@ -80,7 +80,7 @@ static inline struct anon_vma_chain *anon_vma_chain_alloc(void)
 	return kmem_cache_alloc(anon_vma_chain_cachep, GFP_KERNEL);
 }
 
-void anon_vma_chain_free(struct anon_vma_chain *anon_vma_chain)
+static void anon_vma_chain_free(struct anon_vma_chain *anon_vma_chain)
 {
 	kmem_cache_free(anon_vma_chain_cachep, anon_vma_chain);
 }
-- 
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>

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

* [PATCH 09/12] vmalloc: rename temporary variable in __insert_vmap_area()
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (7 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 08/12] rmap: make anon_vma_[chain_]free() static Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 10/12] vmalloc: annotate lock context change on s_start/stop() Namhyung Kim
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

Rename redundant 'tmp' to fix following sparse warnings:

 mm/vmalloc.c:296:34: warning: symbol 'tmp' shadows an earlier one
 mm/vmalloc.c:293:24: originally declared here

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 mm/vmalloc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 6b8889d..7ce8ca5 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -293,13 +293,13 @@ static void __insert_vmap_area(struct vmap_area *va)
 	struct rb_node *tmp;
 
 	while (*p) {
-		struct vmap_area *tmp;
+		struct vmap_area *tmp_va;
 
 		parent = *p;
-		tmp = rb_entry(parent, struct vmap_area, rb_node);
-		if (va->va_start < tmp->va_end)
+		tmp_va = rb_entry(parent, struct vmap_area, rb_node);
+		if (va->va_start < tmp_va->va_end)
 			p = &(*p)->rb_left;
-		else if (va->va_end > tmp->va_start)
+		else if (va->va_end > tmp_va->va_start)
 			p = &(*p)->rb_right;
 		else
 			BUG();
-- 
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>

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

* [PATCH 10/12] vmalloc: annotate lock context change on s_start/stop()
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (8 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 09/12] vmalloc: rename temporary variable in __insert_vmap_area() Namhyung Kim
@ 2010-09-30  3:50 ` 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
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

s_start() and s_stop() grab/release vmlist_lock but were missing proper
annotations. Add them.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 mm/vmalloc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 7ce8ca5..0be8470 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2339,6 +2339,7 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
 
 #ifdef CONFIG_PROC_FS
 static void *s_start(struct seq_file *m, loff_t *pos)
+	__acquires(&vmlist_lock)
 {
 	loff_t n = *pos;
 	struct vm_struct *v;
@@ -2365,6 +2366,7 @@ static void *s_next(struct seq_file *m, void *p, loff_t *pos)
 }
 
 static void s_stop(struct seq_file *m, void *p)
+	__releases(&vmlist_lock)
 {
 	read_unlock(&vmlist_lock);
 }
-- 
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>

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

* [PATCH 11/12] mm: declare some external symbols
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (9 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 10/12] vmalloc: annotate lock context change on s_start/stop() Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-09-30  3:50 ` [PATCH 12/12] vmstat: include compaction.h when CONFIG_COMPACTION Namhyung Kim
  11 siblings, 0 replies; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

Declare 'bdi_pending_list' and 'tag_pages_for_writeback()' to remove
following sparse warnings:

 mm/backing-dev.c:46:1: warning: symbol 'bdi_pending_list' was not declared. Should it be static?
 mm/page-writeback.c:825:6: warning: symbol 'tag_pages_for_writeback' was not declared. Should it be static?

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 include/linux/backing-dev.h |    1 +
 include/linux/writeback.h   |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 35b0074..8b0ae8b 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -111,6 +111,7 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi);
 
 extern spinlock_t bdi_lock;
 extern struct list_head bdi_list;
+extern struct list_head bdi_pending_list;
 
 static inline int wb_has_dirty_io(struct bdi_writeback *wb)
 {
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index 72a5d64..c7299d2 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -149,6 +149,8 @@ int write_cache_pages(struct address_space *mapping,
 int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
 void set_page_dirty_balance(struct page *page, int page_mkwrite);
 void writeback_set_ratelimit(void);
+void tag_pages_for_writeback(struct address_space *mapping,
+			     pgoff_t start, pgoff_t end);
 
 /* pdflush.c */
 extern int nr_pdflush_threads;	/* Global so it can be exported to sysctl
-- 
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>

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

* [PATCH 12/12] vmstat: include compaction.h when CONFIG_COMPACTION
  2010-09-30  3:50 [PATCH 00/12] mm: fix sparse warnings Namhyung Kim
                   ` (10 preceding siblings ...)
  2010-09-30  3:50 ` [PATCH 11/12] mm: declare some external symbols Namhyung Kim
@ 2010-09-30  3:50 ` Namhyung Kim
  2010-10-05 21:27   ` Andrew Morton
  11 siblings, 1 reply; 14+ messages in thread
From: Namhyung Kim @ 2010-09-30  3:50 UTC (permalink / raw)
  To: Andrew Morton, linux-mm; +Cc: linux-kernel

This removes following warning from sparse:

 mm/vmstat.c:466:5: warning: symbol 'fragmentation_index' was not declared. Should it be static?

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 mm/vmstat.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 355a9e6..30054ea 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -394,6 +394,8 @@ void zone_statistics(struct zone *preferred_zone, struct zone *z)
 #endif
 
 #ifdef CONFIG_COMPACTION
+#include <linux/compaction.h>
+
 struct contig_page_info {
 	unsigned long free_pages;
 	unsigned long free_blocks_total;
-- 
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>

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

* Re: [PATCH 12/12] vmstat: include compaction.h when CONFIG_COMPACTION
  2010-09-30  3:50 ` [PATCH 12/12] vmstat: include compaction.h when CONFIG_COMPACTION Namhyung Kim
@ 2010-10-05 21:27   ` Andrew Morton
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2010-10-05 21:27 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: linux-mm, linux-kernel


Some of these patches do make the code significantly more complex to
read and follow.  Boy, I hope it's all useful!

On Thu, 30 Sep 2010 12:50:21 +0900
Namhyung Kim <namhyung@gmail.com> wrote:

> This removes following warning from sparse:
> 
>  mm/vmstat.c:466:5: warning: symbol 'fragmentation_index' was not declared. Should it be static?
> 
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> ---
>  mm/vmstat.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 355a9e6..30054ea 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -394,6 +394,8 @@ void zone_statistics(struct zone *preferred_zone, struct zone *z)
>  #endif
>  
>  #ifdef CONFIG_COMPACTION
> +#include <linux/compaction.h>
> +
>  struct contig_page_info {
>  	unsigned long free_pages;
>  	unsigned long free_blocks_total;

This isn't a good idea: there's a good chance that someone will later
add a #include <linux/compaction.h> at the top of the file to support
future changes.  So we end up including it twice.

So I assume the below will work OK??

--- a/mm/vmstat.c~vmstat-include-compactionh-when-config_compaction-fix
+++ a/mm/vmstat.c
@@ -18,6 +18,7 @@
 #include <linux/sched.h>
 #include <linux/math64.h>
 #include <linux/writeback.h>
+#include <linux/compaction.h>
 
 #ifdef CONFIG_VM_EVENT_COUNTERS
 DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
@@ -395,7 +396,6 @@ void zone_statistics(struct zone *prefer
 #endif
 
 #ifdef CONFIG_COMPACTION
-#include <linux/compaction.h>
 
 struct contig_page_info {
 	unsigned long free_pages;
_

--
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>

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

end of thread, other threads:[~2010-10-05 21:28 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 06/12] rmap: annotate lock context change on page_[un]lock_anon_vma() Namhyung Kim
2010-09-30  3:50 ` [PATCH 07/12] rmap: wrap page_check_address() using __cond_lock() 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

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).