public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2
@ 2008-05-02  0:42 Russ Anderson
  2008-05-02  1:12 ` Christoph Lameter
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Russ Anderson @ 2008-05-02  0:42 UTC (permalink / raw)
  To: linux-kernel, linux-ia64
  Cc: Linus Torvalds, Andrew Morton, Tony Luck, Christoph Lameter,
	Russ Anderson

Prevent a page with a physical memory error from being placed back
on the LRU.  A new page flag (PG_memerror) is added on 64 bit
architectures.  

Signed-off-by: Russ Anderson <rja@sgi.com>

---
 include/linux/mm.h         |    8 +++++++-
 include/linux/page-flags.h |    8 ++++++++
 include/linux/swap.h       |    1 +
 mm/migrate.c               |    3 +++
 mm/page_alloc.c            |    9 +++++----
 mm/swap.c                  |    4 ++++
 6 files changed, 28 insertions(+), 5 deletions(-)

Index: linus/mm/page_alloc.c
=================================--- linus.orig/mm/page_alloc.c	2008-05-01 19:06:04.000000000 -0500
+++ linus/mm/page_alloc.c	2008-05-01 19:06:15.000000000 -0500
@@ -71,6 +71,7 @@ unsigned long totalram_pages __read_most
 unsigned long totalreserve_pages __read_mostly;
 long nr_swap_pages;
 int percpu_pagelist_fraction;
+unsigned int totalbad_pages;
 
 #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE
 int pageblock_order __read_mostly;
@@ -602,10 +603,10 @@ static int prep_new_page(struct page *pa
 		bad_page(page);
 
 	/*
-	 * For now, we report if PG_reserved was found set, but do not
-	 * clear it, and do not allocate the page: as a safety net.
+	 * For now, we report if PG_reserved or PG_memerror was found set, but
+	 * do not clear it, and do not allocate the page: as a safety net.
 	 */
-	if (PageReserved(page))
+	if (PageReserved(page) || PageMemError(page))
 		return 1;
 
 	page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_reclaim |
@@ -2474,7 +2475,7 @@ static void setup_zone_migrate_reserve(s
 		page = pfn_to_page(pfn);
 
 		/* Blocks with reserved pages will never free, skip them. */
-		if (PageReserved(page))
+		if (PageReserved(page) || PageMemError(page))
 			continue;
 
 		block_migratetype = get_pageblock_migratetype(page);
Index: linus/mm/swap.c
=================================--- linus.orig/mm/swap.c	2008-05-01 19:05:33.000000000 -0500
+++ linus/mm/swap.c	2008-05-01 19:06:15.000000000 -0500
@@ -195,6 +195,8 @@ void lru_cache_add(struct page *page)
 	struct pagevec *pvec = &get_cpu_var(lru_add_pvecs);
 
 	page_cache_get(page);
+	if (unlikely(PageMemError(page)))
+		return;		/* Don't add bad pages to the page list */
 	if (!pagevec_add(pvec, page))
 		__pagevec_lru_add(pvec);
 	put_cpu_var(lru_add_pvecs);
@@ -205,6 +207,8 @@ void lru_cache_add_active(struct page *p
 	struct pagevec *pvec = &get_cpu_var(lru_add_active_pvecs);
 
 	page_cache_get(page);
+	if (unlikely(PageMemError(page)))
+		return;		/* Don't add bad pages to the page list */
 	if (!pagevec_add(pvec, page))
 		__pagevec_lru_add_active(pvec);
 	put_cpu_var(lru_add_active_pvecs);
Index: linus/include/linux/swap.h
=================================--- linus.orig/include/linux/swap.h	2008-05-01 19:05:33.000000000 -0500
+++ linus/include/linux/swap.h	2008-05-01 19:06:15.000000000 -0500
@@ -165,6 +165,7 @@ extern unsigned long totalreserve_pages;
 extern long nr_swap_pages;
 extern unsigned int nr_free_buffer_pages(void);
 extern unsigned int nr_free_pagecache_pages(void);
+extern unsigned int totalbad_pages;
 
 /* Definition of global_page_state not available yet */
 #define nr_free_pages() global_page_state(NR_FREE_PAGES)
Index: linus/mm/migrate.c
=================================--- linus.orig/mm/migrate.c	2008-05-01 19:05:33.000000000 -0500
+++ linus/mm/migrate.c	2008-05-01 19:06:15.000000000 -0500
@@ -380,6 +380,7 @@ static void migrate_page_copy(struct pag
 		SetPageChecked(newpage);
 	if (PageMappedToDisk(page))
 		SetPageMappedToDisk(newpage);
+	/* Do not migrate PG_memerror to the new page */
 
 	if (PageDirty(page)) {
 		clear_page_dirty_for_io(page);
@@ -721,6 +722,8 @@ unlock:
  		 */
  		list_del(&page->lru);
  		move_to_lru(page);
+		if (PageMemError(page))
+			totalbad_pages++;
 	}
 
 move_newpage:
Index: linus/include/linux/page-flags.h
=================================--- linus.orig/include/linux/page-flags.h	2008-05-01 19:05:33.000000000 -0500
+++ linus/include/linux/page-flags.h	2008-05-01 19:06:15.000000000 -0500
@@ -84,6 +84,7 @@ enum pageflags {
 	PG_private,		/* If pagecache, has fs-private data */
 	PG_writeback,		/* Page is under writeback */
 #ifdef CONFIG_PAGEFLAGS_EXTENDED
+	PG_memerror,		/* Page has a physical memory error */
 	PG_head,		/* A head page */
 	PG_tail,		/* A tail page */
 #else
@@ -306,5 +307,12 @@ static inline void __ClearPageTail(struc
 }
 
 #endif /* !PAGEFLAGS_EXTENDED */
+
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+PAGEFLAG(MemError, memerror)
+#else
+#define PageMemError(page)	0
+#endif
+
 #endif /* !__GENERATING_BOUNDS_H */
 #endif	/* PAGE_FLAGS_H */
Index: linus/include/linux/mm.h
=================================--- linus.orig/include/linux/mm.h	2008-05-01 19:06:04.000000000 -0500
+++ linus/include/linux/mm.h	2008-05-01 19:06:15.000000000 -0500
@@ -210,9 +210,15 @@ struct inode;
  */
 #include <linux/page-flags.h>
 
-#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
+#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
 			 1 << PG_buddy | 1 << PG_writeback | \
 			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
+
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
+#else
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
+#endif
 
 #define PAGE_FLAGS_RECLAIM      (PAGE_FLAGS | 1 << PG_reclaim | 1 << PG_dirty)
 #define PAGE_FLAGS_RESERVE	(PAGE_FLAGS | 1 << PG_reserved)
-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2
  2008-05-02  0:42 [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2 Russ Anderson
@ 2008-05-02  1:12 ` Christoph Lameter
  2008-05-02  2:33   ` Russ Anderson
  2008-05-09 15:10 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v3 Russ Anderson
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Christoph Lameter @ 2008-05-02  1:12 UTC (permalink / raw)
  To: Russ Anderson
  Cc: linux-kernel, linux-ia64, Linus Torvalds, Andrew Morton,
	Tony Luck

On Thu, 1 May 2008, Russ Anderson wrote:

> Index: linus/mm/migrate.c
> =================================> --- linus.orig/mm/migrate.c	2008-05-01 19:05:33.000000000 -0500
> +++ linus/mm/migrate.c	2008-05-01 19:06:15.000000000 -0500
> @@ -380,6 +380,7 @@ static void migrate_page_copy(struct pag
>  		SetPageChecked(newpage);
>  	if (PageMappedToDisk(page))
>  		SetPageMappedToDisk(newpage);
> +	/* Do not migrate PG_memerror to the new page */

Why is the comment here?

  
>  	if (PageDirty(page)) {
>  		clear_page_dirty_for_io(page);
> @@ -721,6 +722,8 @@ unlock:
>   		 */
>   		list_del(&page->lru);
>   		move_to_lru(page);
> +		if (PageMemError(page))
> +			totalbad_pages++;

Wouldnt this be taken care of by the lru handling?

> +#ifdef CONFIG_PAGEFLAGS_EXTENDED
> +PAGEFLAG(MemError, memerror)
> +#else
> +#define PageMemError(page)	0

Use

PAGEFLAG_FLAGS(MemError)

>  #include <linux/page-flags.h>
>  
> -#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
> +#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
>  			 1 << PG_buddy | 1 << PG_writeback | \
>  			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
> +
> +#ifdef CONFIG_PAGEFLAGS_EXTENDED
> +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
> +#else
> +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
> +#endif
>  
>  #define PAGE_FLAGS_RECLAIM      (PAGE_FLAGS | 1 << PG_reclaim | 1 << PG_dirty)
>  #define PAGE_FLAGS_RESERVE	(PAGE_FLAGS | 1 << PG_reserved)

The groups of page flags could also be put into page-flags.h.


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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2
  2008-05-02  1:12 ` Christoph Lameter
@ 2008-05-02  2:33   ` Russ Anderson
  0 siblings, 0 replies; 15+ messages in thread
From: Russ Anderson @ 2008-05-02  2:33 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: linux-kernel, linux-ia64, Linus Torvalds, Andrew Morton,
	Tony Luck

On Thu, May 01, 2008 at 06:12:49PM -0700, Christoph Lameter wrote:
> On Thu, 1 May 2008, Russ Anderson wrote:
> 
> > Index: linus/mm/migrate.c
> > =================================> > --- linus.orig/mm/migrate.c	2008-05-01 19:05:33.000000000 -0500
> > +++ linus/mm/migrate.c	2008-05-01 19:06:15.000000000 -0500
> > @@ -380,6 +380,7 @@ static void migrate_page_copy(struct pag
> >  		SetPageChecked(newpage);
> >  	if (PageMappedToDisk(page))
> >  		SetPageMappedToDisk(newpage);
> > +	/* Do not migrate PG_memerror to the new page */
> 
> Why is the comment here?

To let anyone that may think PG_memerror should get copied to 
the new page that it should not.  I can remove the comment.
  
> >  	if (PageDirty(page)) {
> >  		clear_page_dirty_for_io(page);
> > @@ -721,6 +722,8 @@ unlock:
> >   		 */
> >   		list_del(&page->lru);
> >   		move_to_lru(page);
> > +		if (PageMemError(page))
> > +			totalbad_pages++;
> 
> Wouldnt this be taken care of by the lru handling?

It is only for accounting purposes, keeping a count
of the bad pages.

> > +#ifdef CONFIG_PAGEFLAGS_EXTENDED
> > +PAGEFLAG(MemError, memerror)
> > +#else
> > +#define PageMemError(page)	0
> 
> Use
> 
> PAGEFLAG_FLAGS(MemError)

OK.

> >  #include <linux/page-flags.h>
> >  
> > -#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
> > +#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
> >  			 1 << PG_buddy | 1 << PG_writeback | \
> >  			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
> > +
> > +#ifdef CONFIG_PAGEFLAGS_EXTENDED
> > +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
> > +#else
> > +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
> > +#endif
> >  
> >  #define PAGE_FLAGS_RECLAIM      (PAGE_FLAGS | 1 << PG_reclaim | 1 << PG_dirty)
> >  #define PAGE_FLAGS_RESERVE	(PAGE_FLAGS | 1 << PG_reserved)
> 
> The groups of page flags could also be put into page-flags.h.

page-flags.h is where I originally put them.  Since they are only used in 
mm/page_alloc.c, I thought mm.h would be a more appropriate place.  
I can put them in page-flags.h.

-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v3
  2008-05-02  0:42 [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2 Russ Anderson
  2008-05-02  1:12 ` Christoph Lameter
@ 2008-05-09 15:10 ` Russ Anderson
  2008-05-09 20:11   ` Andrew Morton
  2008-05-13 23:03 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v4 Russ Anderson
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Russ Anderson @ 2008-05-09 15:10 UTC (permalink / raw)
  To: linux-kernel, linux-ia64
  Cc: Linus Torvalds, Andrew Morton, Tony Luck, Christoph Lameter,
	Russ Anderson

Prevent a page with a physical memory error from being placed back
on the LRU.  A new page flag (PG_memerror) is added on 64 bit
architectures.  

Signed-off-by: Russ Anderson <rja@sgi.com>

---
 include/linux/page-flags.h |   11 ++++++++++-
 include/linux/swap.h       |    1 +
 mm/migrate.c               |    2 ++
 mm/page_alloc.c            |    9 +++++----
 mm/swap.c                  |    4 ++++
 5 files changed, 22 insertions(+), 5 deletions(-)

Index: linus/mm/page_alloc.c
=================================--- linus.orig/mm/page_alloc.c	2008-05-09 09:20:04.389938802 -0500
+++ linus/mm/page_alloc.c	2008-05-09 09:20:11.302788361 -0500
@@ -71,6 +71,7 @@ unsigned long totalram_pages __read_most
 unsigned long totalreserve_pages __read_mostly;
 long nr_swap_pages;
 int percpu_pagelist_fraction;
+unsigned int totalbad_pages;
 
 #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE
 int pageblock_order __read_mostly;
@@ -602,10 +603,10 @@ static int prep_new_page(struct page *pa
 		bad_page(page);
 
 	/*
-	 * For now, we report if PG_reserved was found set, but do not
-	 * clear it, and do not allocate the page: as a safety net.
+	 * For now, we report if PG_reserved or PG_memerror was found set, but
+	 * do not clear it, and do not allocate the page: as a safety net.
 	 */
-	if (PageReserved(page))
+	if (PageReserved(page) || PageMemError(page))
 		return 1;
 
 	page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_reclaim |
@@ -2474,7 +2475,7 @@ static void setup_zone_migrate_reserve(s
 		page = pfn_to_page(pfn);
 
 		/* Blocks with reserved pages will never free, skip them. */
-		if (PageReserved(page))
+		if (PageReserved(page) || PageMemError(page))
 			continue;
 
 		block_migratetype = get_pageblock_migratetype(page);
Index: linus/mm/swap.c
=================================--- linus.orig/mm/swap.c	2008-05-09 09:19:40.466984064 -0500
+++ linus/mm/swap.c	2008-05-09 09:20:11.330791803 -0500
@@ -195,6 +195,8 @@ void lru_cache_add(struct page *page)
 	struct pagevec *pvec = &get_cpu_var(lru_add_pvecs);
 
 	page_cache_get(page);
+	if (unlikely(PageMemError(page)))
+		return;		/* Don't add bad pages to the page list */
 	if (!pagevec_add(pvec, page))
 		__pagevec_lru_add(pvec);
 	put_cpu_var(lru_add_pvecs);
@@ -205,6 +207,8 @@ void lru_cache_add_active(struct page *p
 	struct pagevec *pvec = &get_cpu_var(lru_add_active_pvecs);
 
 	page_cache_get(page);
+	if (unlikely(PageMemError(page)))
+		return;		/* Don't add bad pages to the page list */
 	if (!pagevec_add(pvec, page))
 		__pagevec_lru_add_active(pvec);
 	put_cpu_var(lru_add_active_pvecs);
Index: linus/include/linux/swap.h
=================================--- linus.orig/include/linux/swap.h	2008-05-09 09:19:40.470984561 -0500
+++ linus/include/linux/swap.h	2008-05-09 09:20:11.346793770 -0500
@@ -165,6 +165,7 @@ extern unsigned long totalreserve_pages;
 extern long nr_swap_pages;
 extern unsigned int nr_free_buffer_pages(void);
 extern unsigned int nr_free_pagecache_pages(void);
+extern unsigned int totalbad_pages;
 
 /* Definition of global_page_state not available yet */
 #define nr_free_pages() global_page_state(NR_FREE_PAGES)
Index: linus/mm/migrate.c
=================================--- linus.orig/mm/migrate.c	2008-05-09 09:19:40.470984561 -0500
+++ linus/mm/migrate.c	2008-05-09 09:20:11.366796228 -0500
@@ -721,6 +721,8 @@ unlock:
  		 */
  		list_del(&page->lru);
  		move_to_lru(page);
+		if (PageMemError(page))
+			totalbad_pages++;
 	}
 
 move_newpage:
Index: linus/include/linux/page-flags.h
=================================--- linus.orig/include/linux/page-flags.h	2008-05-09 09:20:04.401940277 -0500
+++ linus/include/linux/page-flags.h	2008-05-09 09:20:11.382798194 -0500
@@ -84,6 +84,7 @@ enum pageflags {
 	PG_private,		/* If pagecache, has fs-private data */
 	PG_writeback,		/* Page is under writeback */
 #ifdef CONFIG_PAGEFLAGS_EXTENDED
+	PG_memerror,		/* Page has a physical memory error */
 	PG_head,		/* A head page */
 	PG_tail,		/* A tail page */
 #else
@@ -307,9 +308,17 @@ static inline void __ClearPageTail(struc
 
 #endif /* !PAGEFLAGS_EXTENDED */
 
-#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
+#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
 			 1 << PG_buddy | 1 << PG_writeback | \
 			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
+
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+PAGEFLAG(MemError, memerror)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
+#else
+PAGEFLAG_FALSE(MemError)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
+#endif
 
 #define PAGE_FLAGS_RECLAIM	(PAGE_FLAGS | 1 << PG_reclaim | 1 << PG_dirty)
 #define PAGE_FLAGS_RESERVE	(PAGE_FLAGS | 1 << PG_reserved)
-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v3
  2008-05-09 15:10 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v3 Russ Anderson
@ 2008-05-09 20:11   ` Andrew Morton
  2008-05-09 21:51     ` Russ Anderson
  0 siblings, 1 reply; 15+ messages in thread
From: Andrew Morton @ 2008-05-09 20:11 UTC (permalink / raw)
  To: Russ Anderson; +Cc: linux-kernel, linux-ia64, torvalds, tony.luck, clameter

On Fri, 9 May 2008 10:10:58 -0500
Russ Anderson <rja@sgi.com> wrote:

> Prevent a page with a physical memory error from being placed back
> on the LRU.  A new page flag (PG_memerror) is added on 64 bit
> architectures.  
> 

A little thing:

> 
> Index: linus/mm/page_alloc.c
> =================================> --- linus.orig/mm/page_alloc.c	2008-05-09 09:20:04.389938802 -0500
> +++ linus/mm/page_alloc.c	2008-05-09 09:20:11.302788361 -0500
> @@ -71,6 +71,7 @@ unsigned long totalram_pages __read_most
>  unsigned long totalreserve_pages __read_mostly;
>  long nr_swap_pages;
>  int percpu_pagelist_fraction;
> +unsigned int totalbad_pages;
>  
>  #ifdef CONFIG_HUGETLB_PAGE_SIZE_VARIABLE
>  int pageblock_order __read_mostly;
> @@ -602,10 +603,10 @@ static int prep_new_page(struct page *pa
>  		bad_page(page);
>  
>  	/*
> -	 * For now, we report if PG_reserved was found set, but do not
> -	 * clear it, and do not allocate the page: as a safety net.
> +	 * For now, we report if PG_reserved or PG_memerror was found set, but
> +	 * do not clear it, and do not allocate the page: as a safety net.
>  	 */
> -	if (PageReserved(page))
> +	if (PageReserved(page) || PageMemError(page))
>  		return 1;
>  
>  	page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_reclaim |
> @@ -2474,7 +2475,7 @@ static void setup_zone_migrate_reserve(s
>  		page = pfn_to_page(pfn);
>  
>  		/* Blocks with reserved pages will never free, skip them. */
> -		if (PageReserved(page))
> +		if (PageReserved(page) || PageMemError(page))
>  			continue;
>  
>  		block_migratetype = get_pageblock_migratetype(page);
> Index: linus/mm/swap.c
> =================================> --- linus.orig/mm/swap.c	2008-05-09 09:19:40.466984064 -0500
> +++ linus/mm/swap.c	2008-05-09 09:20:11.330791803 -0500
> @@ -195,6 +195,8 @@ void lru_cache_add(struct page *page)
>  	struct pagevec *pvec = &get_cpu_var(lru_add_pvecs);
>  
>  	page_cache_get(page);
> +	if (unlikely(PageMemError(page)))
> +		return;		/* Don't add bad pages to the page list */
>  	if (!pagevec_add(pvec, page))
>  		__pagevec_lru_add(pvec);
>  	put_cpu_var(lru_add_pvecs);
> @@ -205,6 +207,8 @@ void lru_cache_add_active(struct page *p
>  	struct pagevec *pvec = &get_cpu_var(lru_add_active_pvecs);
>  
>  	page_cache_get(page);
> +	if (unlikely(PageMemError(page)))
> +		return;		/* Don't add bad pages to the page list */
>  	if (!pagevec_add(pvec, page))
>  		__pagevec_lru_add_active(pvec);
>  	put_cpu_var(lru_add_active_pvecs);

These PageMemError() tests are happening in some pretty darn hot paths. 
But we've gone and added this overhead to a lot of architectures and
configs which don't need it.

Should we tighten that up?  Arrange for PageMemError() to evaluate to
constant zero for all builds which don't actually implement "Migrate data
off physical pages with correctable errors"?

Probably the way to implement that would be to add a new
CONFIG_NEED_PAGE_MEM_ERROR and `select' that from the appropriate place in
ia64 Kconfig.  Which is pretty nasty, but a) we're nasty that way rather
often and b) this time it _is_ a hot-path, so some nastiness is
justifiable.


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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v3
  2008-05-09 20:11   ` Andrew Morton
@ 2008-05-09 21:51     ` Russ Anderson
  0 siblings, 0 replies; 15+ messages in thread
From: Russ Anderson @ 2008-05-09 21:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-ia64, torvalds, tony.luck, clameter

On Fri, May 09, 2008 at 01:11:34PM -0700, Andrew Morton wrote:
> On Fri, 9 May 2008 10:10:58 -0500
> Russ Anderson <rja@sgi.com> wrote:
> 
> > Index: linus/mm/swap.c
> > =================================> > --- linus.orig/mm/swap.c	2008-05-09 09:19:40.466984064 -0500
> > +++ linus/mm/swap.c	2008-05-09 09:20:11.330791803 -0500
> > @@ -195,6 +195,8 @@ void lru_cache_add(struct page *page)
> >  	struct pagevec *pvec = &get_cpu_var(lru_add_pvecs);
> >  
> >  	page_cache_get(page);
> > +	if (unlikely(PageMemError(page)))
> > +		return;		/* Don't add bad pages to the page list */
> >  	if (!pagevec_add(pvec, page))
> >  		__pagevec_lru_add(pvec);
> >  	put_cpu_var(lru_add_pvecs);
> > @@ -205,6 +207,8 @@ void lru_cache_add_active(struct page *p
> >  	struct pagevec *pvec = &get_cpu_var(lru_add_active_pvecs);
> >  
> >  	page_cache_get(page);
> > +	if (unlikely(PageMemError(page)))
> > +		return;		/* Don't add bad pages to the page list */
> >  	if (!pagevec_add(pvec, page))
> >  		__pagevec_lru_add_active(pvec);
> >  	put_cpu_var(lru_add_active_pvecs);
> 
> These PageMemError() tests are happening in some pretty darn hot paths. 
> But we've gone and added this overhead to a lot of architectures and
> configs which don't need it.
>
> Should we tighten that up?  Arrange for PageMemError() to evaluate to
> constant zero for all builds which don't actually implement "Migrate data
> off physical pages with correctable errors"?

Yes.

> Probably the way to implement that would be to add a new
> CONFIG_NEED_PAGE_MEM_ERROR and `select' that from the appropriate place in
> ia64 Kconfig.  Which is pretty nasty, but a) we're nasty that way rather
> often and b) this time it _is_ a hot-path, so some nastiness is
> justifiable.

Will do.

-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v4
  2008-05-02  0:42 [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2 Russ Anderson
  2008-05-02  1:12 ` Christoph Lameter
  2008-05-09 15:10 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v3 Russ Anderson
@ 2008-05-13 23:03 ` Russ Anderson
  2008-05-16 19:23 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v5 Russ Anderson
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Russ Anderson @ 2008-05-13 23:03 UTC (permalink / raw)
  To: linux-kernel, linux-ia64
  Cc: Linus Torvalds, Andrew Morton, Tony Luck, Christoph Lameter,
	Russ Anderson

Prevent a page with a physical memory error from being placed back
on the LRU.  A new page flag (PG_memerror) is added on 64 bit
architectures.  

Signed-off-by: Russ Anderson <rja@sgi.com>

---
 include/linux/migrate.h    |    1 +
 include/linux/page-flags.h |   11 ++++++++++-
 mm/migrate.c               |   12 ++++++++++--
 mm/page_alloc.c            |    8 ++++----
 4 files changed, 25 insertions(+), 7 deletions(-)

Index: linus/mm/page_alloc.c
=================================--- linus.orig/mm/page_alloc.c	2008-05-13 15:27:32.308804354 -0500
+++ linus/mm/page_alloc.c	2008-05-13 15:35:57.071584039 -0500
@@ -602,10 +602,10 @@ static int prep_new_page(struct page *pa
 		bad_page(page);
 
 	/*
-	 * For now, we report if PG_reserved was found set, but do not
-	 * clear it, and do not allocate the page: as a safety net.
+	 * For now, we report if PG_reserved or PG_memerror was found set, but
+	 * do not clear it, and do not allocate the page: as a safety net.
 	 */
-	if (PageReserved(page))
+	if (PageReserved(page) || PageMemError(page))
 		return 1;
 
 	page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_reclaim |
@@ -2474,7 +2474,7 @@ static void setup_zone_migrate_reserve(s
 		page = pfn_to_page(pfn);
 
 		/* Blocks with reserved pages will never free, skip them. */
-		if (PageReserved(page))
+		if (PageReserved(page) || PageMemError(page))
 			continue;
 
 		block_migratetype = get_pageblock_migratetype(page);
Index: linus/mm/migrate.c
=================================--- linus.orig/mm/migrate.c	2008-05-13 15:27:32.308804354 -0500
+++ linus/mm/migrate.c	2008-05-13 16:14:04.695801820 -0500
@@ -35,6 +35,8 @@
 
 #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
 
+unsigned int totalbad_pages;
+
 /*
  * Isolate one page from the LRU lists. If successful put it onto
  * the indicated list with elevated page count.
@@ -110,6 +112,8 @@ int putback_lru_pages(struct list_head *
 
 	list_for_each_entry_safe(page, page2, l, lru) {
 		list_del(&page->lru);
+		if (unlikely(PageMemError(page)))
+			continue;
 		move_to_lru(page);
 		count++;
 	}
@@ -717,10 +721,14 @@ unlock:
  		 * A page that has been migrated has all references
  		 * removed and will be freed. A page that has not been
  		 * migrated will have kepts its references and be
- 		 * restored.
+		 * restored.  A page with a memory error will not
+		 * be moved to the LRU.
  		 */
  		list_del(&page->lru);
- 		move_to_lru(page);
+		if (PageMemError(page))
+			totalbad_pages++;
+		else
+			move_to_lru(page);
 	}
 
 move_newpage:
Index: linus/include/linux/page-flags.h
=================================--- linus.orig/include/linux/page-flags.h	2008-05-13 15:27:32.308804354 -0500
+++ linus/include/linux/page-flags.h	2008-05-13 15:28:06.589058491 -0500
@@ -84,6 +84,7 @@ enum pageflags {
 	PG_private,		/* If pagecache, has fs-private data */
 	PG_writeback,		/* Page is under writeback */
 #ifdef CONFIG_PAGEFLAGS_EXTENDED
+	PG_memerror,		/* Page has a physical memory error */
 	PG_head,		/* A head page */
 	PG_tail,		/* A tail page */
 #else
@@ -307,9 +308,17 @@ static inline void __ClearPageTail(struc
 
 #endif /* !PAGEFLAGS_EXTENDED */
 
-#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
+#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
 			 1 << PG_buddy | 1 << PG_writeback | \
 			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
+
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+PAGEFLAG(MemError, memerror)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
+#else
+PAGEFLAG_FALSE(MemError)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
+#endif
 
 #define PAGE_FLAGS_RECLAIM	(PAGE_FLAGS | 1 << PG_reclaim | 1 << PG_dirty)
 #define PAGE_FLAGS_RESERVE	(PAGE_FLAGS | 1 << PG_reserved)
Index: linus/include/linux/migrate.h
=================================--- linus.orig/include/linux/migrate.h	2008-05-13 15:27:32.308804354 -0500
+++ linus/include/linux/migrate.h	2008-05-13 15:28:06.605060477 -0500
@@ -38,6 +38,7 @@ extern int migrate_prep(void);
 extern int migrate_vmas(struct mm_struct *mm,
 		const nodemask_t *from, const nodemask_t *to,
 		unsigned long flags);
+extern unsigned int totalbad_pages;
 #else
 static inline int vma_migratable(struct vm_area_struct *vma)
 					{ return 0; }
-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v5
  2008-05-02  0:42 [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2 Russ Anderson
                   ` (2 preceding siblings ...)
  2008-05-13 23:03 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v4 Russ Anderson
@ 2008-05-16 19:23 ` Russ Anderson
  2008-05-16 23:13   ` Christoph Lameter
  2008-06-09 16:19 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6 Russ Anderson
  2008-06-09 21:58 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v7 Russ Anderson
  5 siblings, 1 reply; 15+ messages in thread
From: Russ Anderson @ 2008-05-16 19:23 UTC (permalink / raw)
  To: linux-kernel, linux-ia64
  Cc: Linus Torvalds, Andrew Morton, Tony Luck, Christoph Lameter,
	Russ Anderson

Prevent a page with a physical memory error from being placed back
on the LRU.  A new page flag (PG_memerror) is added on 64 bit
architectures.  

Signed-off-by: Russ Anderson <rja@sgi.com>

---
 include/linux/migrate.h    |    1 +
 include/linux/page-flags.h |   11 ++++++++++-
 mm/migrate.c               |   12 ++++++++++--
 mm/page_alloc.c            |    8 ++++----
 4 files changed, 25 insertions(+), 7 deletions(-)

Index: linus/mm/page_alloc.c
=================================--- linus.orig/mm/page_alloc.c	2008-05-15 12:59:03.334381011 -0500
+++ linus/mm/page_alloc.c	2008-05-15 12:59:04.958581070 -0500
@@ -602,10 +602,10 @@ static int prep_new_page(struct page *pa
 		bad_page(page);
 
 	/*
-	 * For now, we report if PG_reserved was found set, but do not
-	 * clear it, and do not allocate the page: as a safety net.
+	 * For now, we report if PG_reserved or PG_memerror was found set, but
+	 * do not clear it, and do not allocate the page: as a safety net.
 	 */
-	if (PageReserved(page))
+	if (PageReserved(page) || PageMemError(page))
 		return 1;
 
 	page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_reclaim |
@@ -2474,7 +2474,7 @@ static void setup_zone_migrate_reserve(s
 		page = pfn_to_page(pfn);
 
 		/* Blocks with reserved pages will never free, skip them. */
-		if (PageReserved(page))
+		if (PageReserved(page) || PageMemError(page))
 			continue;
 
 		block_migratetype = get_pageblock_migratetype(page);
Index: linus/mm/migrate.c
=================================--- linus.orig/mm/migrate.c	2008-05-15 12:58:25.165679802 -0500
+++ linus/mm/migrate.c	2008-05-16 12:25:16.145557095 -0500
@@ -35,6 +35,8 @@
 
 #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
 
+unsigned int totalbad_pages;
+
 /*
  * Isolate one page from the LRU lists. If successful put it onto
  * the indicated list with elevated page count.
@@ -110,6 +112,8 @@ int putback_lru_pages(struct list_head *
 
 	list_for_each_entry_safe(page, page2, l, lru) {
 		list_del(&page->lru);
+		if (unlikely(PageMemError(page)))
+			continue;
 		move_to_lru(page);
 		count++;
 	}
@@ -717,10 +721,14 @@ unlock:
  		 * A page that has been migrated has all references
  		 * removed and will be freed. A page that has not been
  		 * migrated will have kepts its references and be
- 		 * restored.
+		 * restored.  A page with a memory error will not
+		 * be moved to the LRU.
  		 */
  		list_del(&page->lru);
- 		move_to_lru(page);
+		if (PageMemError(page))
+			totalbad_pages++;
+		else
+			move_to_lru(page);
 	}
 
 move_newpage:
Index: linus/include/linux/page-flags.h
=================================--- linus.orig/include/linux/page-flags.h	2008-05-15 12:59:03.362384460 -0500
+++ linus/include/linux/page-flags.h	2008-05-15 12:59:05.002586491 -0500
@@ -84,6 +84,7 @@ enum pageflags {
 	PG_private,		/* If pagecache, has fs-private data */
 	PG_writeback,		/* Page is under writeback */
 #ifdef CONFIG_PAGEFLAGS_EXTENDED
+	PG_memerror,		/* Page has a physical memory error */
 	PG_head,		/* A head page */
 	PG_tail,		/* A tail page */
 #else
@@ -307,9 +308,17 @@ static inline void __ClearPageTail(struc
 
 #endif /* !PAGEFLAGS_EXTENDED */
 
-#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
+#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
 			 1 << PG_buddy | 1 << PG_writeback | \
 			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
+
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+PAGEFLAG(MemError, memerror)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
+#else
+PAGEFLAG_FALSE(MemError)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
+#endif
 
 /*
  * Flags checked in bad_page().  Pages on the free list should not have
Index: linus/include/linux/migrate.h
=================================--- linus.orig/include/linux/migrate.h	2008-05-15 12:58:25.165679802 -0500
+++ linus/include/linux/migrate.h	2008-05-15 12:59:05.026589447 -0500
@@ -38,6 +38,7 @@ extern int migrate_prep(void);
 extern int migrate_vmas(struct mm_struct *mm,
 		const nodemask_t *from, const nodemask_t *to,
 		unsigned long flags);
+extern unsigned int totalbad_pages;
 #else
 static inline int vma_migratable(struct vm_area_struct *vma)
 					{ return 0; }
-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v5
  2008-05-16 19:23 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v5 Russ Anderson
@ 2008-05-16 23:13   ` Christoph Lameter
  2008-06-09 15:57     ` Russ Anderson
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Lameter @ 2008-05-16 23:13 UTC (permalink / raw)
  To: Russ Anderson
  Cc: linux-kernel, linux-ia64, Linus Torvalds, Andrew Morton,
	Tony Luck

On Fri, 16 May 2008, Russ Anderson wrote:

> Prevent a page with a physical memory error from being placed back
> on the LRU.  A new page flag (PG_memerror) is added on 64 bit
> architectures.  

Not 64 bit. Its added if CONFIG_PAGEFLAGS_EXTENDED is defined. That is 
the case when we are not in a configuration that uses lots ofpageflags for 
other purposes (like regular sparsemem).

> @@ -2474,7 +2474,7 @@ static void setup_zone_migrate_reserve(s
>  		page = pfn_to_page(pfn);
>  
>  		/* Blocks with reserved pages will never free, skip them. */

Update comment too?

> -		if (PageReserved(page))
> +		if (PageReserved(page) || PageMemError(page))
>  			continue;
>  
>  		block_migratetype = get_pageblock_migratetype(page);
> Index: linus/mm/migrate.c
> =================================> --- linus.orig/mm/migrate.c	2008-05-15 12:58:25.165679802 -0500
> +++ linus/mm/migrate.c	2008-05-16 12:25:16.145557095 -0500
> @@ -35,6 +35,8 @@
>  
>  #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
>  
> +unsigned int totalbad_pages;
> +

Why is this defined in migrate.c?

>  /*
>   * Isolate one page from the LRU lists. If successful put it onto
>   * the indicated list with elevated page count.
> @@ -110,6 +112,8 @@ int putback_lru_pages(struct list_head *
>  
>  	list_for_each_entry_safe(page, page2, l, lru) {
>  		list_del(&page->lru);
> +		if (unlikely(PageMemError(page)))
> +			continue;
>  		move_to_lru(page);
>  		count++;
>  	}
> @@ -717,10 +721,14 @@ unlock:
>   		 * A page that has been migrated has all references
>   		 * removed and will be freed. A page that has not been
>   		 * migrated will have kepts its references and be
> - 		 * restored.
> +		 * restored.  A page with a memory error will not
> +		 * be moved to the LRU.
>   		 */
>   		list_del(&page->lru);
> - 		move_to_lru(page);
> +		if (PageMemError(page))
> +			totalbad_pages++;
> +		else
> +			move_to_lru(page);
>  	}

So what happens if a page has acquired an additional ref count and 
PageMemError is set. Then we fail migration and the page will not be put 
back on the LRU? So it will not be migratable anymore?

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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v5
  2008-05-16 23:13   ` Christoph Lameter
@ 2008-06-09 15:57     ` Russ Anderson
  0 siblings, 0 replies; 15+ messages in thread
From: Russ Anderson @ 2008-06-09 15:57 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: linux-kernel, linux-ia64, Linus Torvalds, Andrew Morton,
	Tony Luck

On Fri, May 16, 2008 at 04:13:11PM -0700, Christoph Lameter wrote:
> >  /*
> >   * Isolate one page from the LRU lists. If successful put it onto
> >   * the indicated list with elevated page count.
> > @@ -110,6 +112,8 @@ int putback_lru_pages(struct list_head *
> >  
> >  	list_for_each_entry_safe(page, page2, l, lru) {
> >  		list_del(&page->lru);
> > +		if (unlikely(PageMemError(page)))
> > +			continue;
> >  		move_to_lru(page);
> >  		count++;
> >  	}
> > @@ -717,10 +721,14 @@ unlock:
> >   		 * A page that has been migrated has all references
> >   		 * removed and will be freed. A page that has not been
> >   		 * migrated will have kepts its references and be
> > - 		 * restored.
> > +		 * restored.  A page with a memory error will not
> > +		 * be moved to the LRU.
> >   		 */
> >   		list_del(&page->lru);
> > - 		move_to_lru(page);
> > +		if (PageMemError(page))
> > +			totalbad_pages++;
> > +		else
> > +			move_to_lru(page);
> >  	}
> 
> So what happens if a page has acquired an additional ref count and 
> PageMemError is set. Then we fail migration and the page will not be put 
> back on the LRU? So it will not be migratable anymore?

That was a problem.  If migration failed the page would end up with an extra 
page reference.  The new patch fixes that problem.  If the page fails
to migrate it will be put back on the LRU and the MemError bit cleared.
If the page gets another corrected error it will try to migrate the page
again.

-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6
  2008-05-02  0:42 [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2 Russ Anderson
                   ` (3 preceding siblings ...)
  2008-05-16 19:23 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v5 Russ Anderson
@ 2008-06-09 16:19 ` Russ Anderson
  2008-06-09 18:28   ` Christoph Lameter
  2008-06-09 21:58 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v7 Russ Anderson
  5 siblings, 1 reply; 15+ messages in thread
From: Russ Anderson @ 2008-06-09 16:19 UTC (permalink / raw)
  To: linux-kernel, linux-ia64
  Cc: Linus Torvalds, Andrew Morton, Tony Luck, Christoph Lameter,
	Russ Anderson

Prevent a page with a physical memory error from being placed back
on the LRU.  A new page flag (PG_memerror) is added if
CONFIG_PAGEFLAGS_EXTENDED is defined.

If the migration of data off the old page fails, PG_memerror is
cleared and the page placed back on the LRU.  If the page gets
another correctable error another attempt will be made to
migrate it.


Signed-off-by: Russ Anderson <rja@sgi.com>

---
 include/linux/page-flags.h |   11 ++++++++++-
 mm/migrate.c               |   31 ++++++++++++++++++++++++++++++-
 mm/page_alloc.c            |   13 ++++++++-----
 3 files changed, 48 insertions(+), 7 deletions(-)

Index: linux-next/mm/page_alloc.c
=================================--- linux-next.orig/mm/page_alloc.c	2008-06-09 09:26:52.203578218 -0500
+++ linux-next/mm/page_alloc.c	2008-06-09 09:26:54.715891226 -0500
@@ -602,10 +602,10 @@ static int prep_new_page(struct page *pa
 		bad_page(page);
 
 	/*
-	 * For now, we report if PG_reserved was found set, but do not
-	 * clear it, and do not allocate the page: as a safety net.
+	 * For now, we report if PG_reserved or PG_memerror was found set, but
+	 * do not clear it, and do not allocate the page: as a safety net.
 	 */
-	if (PageReserved(page))
+	if (PageReserved(page) || PageMemError(page))
 		return 1;
 
 	page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_reclaim |
@@ -2476,8 +2476,11 @@ static void setup_zone_migrate_reserve(s
 			continue;
 		page = pfn_to_page(pfn);
 
-		/* Blocks with reserved pages will never free, skip them. */
-		if (PageReserved(page))
+		/*
+		 * Blocks with reserved pages or memory errors will never
+		 * free, skip them.
+		 */
+		if (PageReserved(page) || PageMemError(page))
 			continue;
 
 		block_migratetype = get_pageblock_migratetype(page);
Index: linux-next/mm/migrate.c
=================================--- linux-next.orig/mm/migrate.c	2008-06-09 09:26:46.226833574 -0500
+++ linux-next/mm/migrate.c	2008-06-09 09:26:54.739894217 -0500
@@ -720,7 +720,25 @@ unlock:
  		 * restored.
  		 */
  		list_del(&page->lru);
- 		move_to_lru(page);
+		if (PageMemError(page))
+			if (rc = 0)
+				/*
+				 * A page with a memory error that has
+				 * been migrated will not be moved to
+				 * the LRU.
+				 */
+				goto move_newpage;
+			else
+				/*
+				 * The page failed to migrate and will not
+				 * be added to the bad page list.  Clearing
+				 * the error bit will allow another attempt
+				 * to migrate if it gets another correctable
+				 * error.
+				 */
+				ClearPageMemError(page);
+
+		move_to_lru(page);
 	}
 
 move_newpage:
@@ -790,6 +808,17 @@ int migrate_pages(struct list_head *from
 			}
 		}
 	}
+
+	if (rc != 0)
+		list_for_each_entry_safe(page, page2, from, lru)
+			if (PageMemError(page))
+				/*
+				 * The page failed to migrate.  Clearing
+				 * the error bit will allow another attempt
+				 * to migrate if it gets another correctable
+				 * error.
+				 */
+				ClearPageMemError(page);
 	rc = 0;
 out:
 	if (!swapwrite)
Index: linux-next/include/linux/page-flags.h
=================================--- linux-next.orig/include/linux/page-flags.h	2008-06-09 09:26:52.223580710 -0500
+++ linux-next/include/linux/page-flags.h	2008-06-09 09:26:54.763897207 -0500
@@ -84,6 +84,7 @@ enum pageflags {
 	PG_private,		/* If pagecache, has fs-private data */
 	PG_writeback,		/* Page is under writeback */
 #ifdef CONFIG_PAGEFLAGS_EXTENDED
+	PG_memerror,		/* Page has a physical memory error */
 	PG_head,		/* A head page */
 	PG_tail,		/* A tail page */
 #else
@@ -308,9 +309,17 @@ static inline void __ClearPageTail(struc
 
 #endif /* !PAGEFLAGS_EXTENDED */
 
-#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
+#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
 			 1 << PG_buddy | 1 << PG_writeback | \
 			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
+
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+PAGEFLAG(MemError, memerror)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
+#else
+PAGEFLAG_FALSE(MemError)
+#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
+#endif
 
 /*
  * Flags checked in bad_page().  Pages on the free list should not have
-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6
  2008-06-09 16:19 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6 Russ Anderson
@ 2008-06-09 18:28   ` Christoph Lameter
  2008-06-09 21:03     ` Russ Anderson
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Lameter @ 2008-06-09 18:28 UTC (permalink / raw)
  To: Russ Anderson
  Cc: linux-kernel, linux-ia64, Linus Torvalds, Andrew Morton,
	Tony Luck

On Mon, 9 Jun 2008, Russ Anderson wrote:

> -#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
> +#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
>  			 1 << PG_buddy | 1 << PG_writeback | \
>  			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
> +
> +#ifdef CONFIG_PAGEFLAGS_EXTENDED
> +PAGEFLAG(MemError, memerror)
> +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
> +#else
> +PAGEFLAG_FALSE(MemError)
> +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
> +#endif

Hmmmm... That doesnt look nice. It would be good if we had some definition 
that  allows the simple oring with a flag mask. That mask should be 
zero if the flag is always false.

#ifdef CONFIG_PAGEFLAGS_EXTENDED
PAGEFLAG(MemError, memerror)
#define MemError_mask (1 << PG_memerror)
#else
PAGEFLAG_FALSE(MemError)
#define MemError_mask 0
#endif

#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | MemError_mask)

Maybe we could have the PAGEFLAG and the PAGEFLAG_FALSE macros generate 
these definitions?


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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6
  2008-06-09 18:28   ` Christoph Lameter
@ 2008-06-09 21:03     ` Russ Anderson
  2008-06-09 21:15       ` Christoph Lameter
  0 siblings, 1 reply; 15+ messages in thread
From: Russ Anderson @ 2008-06-09 21:03 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: linux-kernel, linux-ia64, Linus Torvalds, Andrew Morton,
	Tony Luck

On Mon, Jun 09, 2008 at 11:28:00AM -0700, Christoph Lameter wrote:
> On Mon, 9 Jun 2008, Russ Anderson wrote:
> 
> > -#define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
> > +#define PAGE_FLAGS_BASE	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
> >  			 1 << PG_buddy | 1 << PG_writeback | \
> >  			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
> > +
> > +#ifdef CONFIG_PAGEFLAGS_EXTENDED
> > +PAGEFLAG(MemError, memerror)
> > +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE | 1UL << PG_memerror)
> > +#else
> > +PAGEFLAG_FALSE(MemError)
> > +#define	PAGE_FLAGS	(PAGE_FLAGS_BASE)
> > +#endif
> 
> Hmmmm... That doesnt look nice. It would be good if we had some definition 
> that  allows the simple oring with a flag mask. That mask should be 
> zero if the flag is always false.
> 
> #ifdef CONFIG_PAGEFLAGS_EXTENDED
> PAGEFLAG(MemError, memerror)
> #define MemError_mask (1 << PG_memerror)
> #else
> PAGEFLAG_FALSE(MemError)
> #define MemError_mask 0
> #endif
> 
> #define	PAGE_FLAGS	(PAGE_FLAGS_BASE | MemError_mask)
> 
> Maybe we could have the PAGEFLAG and the PAGEFLAG_FALSE macros generate 
> these definitions?

Does this look better?


Index: linus/include/linux/page-flags.h
=================================--- linus.orig/include/linux/page-flags.h	2008-06-09 13:48:10.072171477 -0500
+++ linus/include/linux/page-flags.h	2008-06-09 15:58:27.957729371 -0500
@@ -84,6 +84,7 @@ enum pageflags {
 	PG_private,		/* If pagecache, has fs-private data */
 	PG_writeback,		/* Page is under writeback */
 #ifdef CONFIG_PAGEFLAGS_EXTENDED
+	PG_memerror,		/* Page has a physical memory error */
 	PG_head,		/* A head page */
 	PG_tail,		/* A tail page */
 #else
@@ -132,15 +133,21 @@ static inline int TestSetPage##uname(str
 static inline int TestClearPage##uname(struct page *page)		\
 		{ return test_and_clear_bit(PG_##lname, &page->flags); }
 
+#define PAGEFLAGMASK(uname, lname)					\
+static inline int PAGEMASK_##uname(void)				\
+		{ return (1 << PG_##lname); }
 
 #define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)		\
-	SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
+	SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)		\
+	PAGEFLAGMASK(uname, lname)
 
 #define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)		\
 	__SETPAGEFLAG(uname, lname)  __CLEARPAGEFLAG(uname, lname)
 
 #define PAGEFLAG_FALSE(uname) 						\
 static inline int Page##uname(struct page *page) 			\
+			{ return 0; }					\
+static inline int PAGEMASK_##uname(void)				\
 			{ return 0; }
 
 #define TESTSCFLAG(uname, lname)					\
@@ -307,9 +314,16 @@ static inline void __ClearPageTail(struc
 
 #endif /* !PAGEFLAGS_EXTENDED */
 
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+PAGEFLAG(MemError, memerror)
+#else
+PAGEFLAG_FALSE(MemError)
+#endif
+
 #define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
 			 1 << PG_buddy | 1 << PG_writeback | \
-			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
+			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active) |\
+			 PAGEMASK_MemError()
 
 /*
  * Flags checked in bad_page().  Pages on the free list should not have

-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

* Re: [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6
  2008-06-09 21:03     ` Russ Anderson
@ 2008-06-09 21:15       ` Christoph Lameter
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Lameter @ 2008-06-09 21:15 UTC (permalink / raw)
  To: Russ Anderson
  Cc: linux-kernel, linux-ia64, Linus Torvalds, Andrew Morton,
	Tony Luck

On Mon, 9 Jun 2008, Russ Anderson wrote:

> Does this look better?

Excellent.

Reviewed-by: Christoph Lameter <clameter@sgi.com>


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

* [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v7
  2008-05-02  0:42 [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2 Russ Anderson
                   ` (4 preceding siblings ...)
  2008-06-09 16:19 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6 Russ Anderson
@ 2008-06-09 21:58 ` Russ Anderson
  5 siblings, 0 replies; 15+ messages in thread
From: Russ Anderson @ 2008-06-09 21:58 UTC (permalink / raw)
  To: linux-kernel, linux-ia64
  Cc: Linus Torvalds, Andrew Morton, Tony Luck, Christoph Lameter,
	Russ Anderson

Prevent a page with a physical memory error from being placed back
on the LRU.  A new page flag (PG_memerror) is added if
CONFIG_PAGEFLAGS_EXTENDED is defined.

Signed-off-by: Russ Anderson <rja@sgi.com>
Reviewed-by: Christoph Lameter <clameter@sgi.com>

---
 include/linux/page-flags.h |   18 ++++++++++++++++--
 mm/migrate.c               |   31 ++++++++++++++++++++++++++++++-
 mm/page_alloc.c            |   13 ++++++++-----
 3 files changed, 54 insertions(+), 8 deletions(-)

Index: linux-next/mm/page_alloc.c
=================================--- linux-next.orig/mm/page_alloc.c	2008-06-09 16:52:13.714381779 -0500
+++ linux-next/mm/page_alloc.c	2008-06-09 16:52:21.119299155 -0500
@@ -602,10 +602,10 @@ static int prep_new_page(struct page *pa
 		bad_page(page);
 
 	/*
-	 * For now, we report if PG_reserved was found set, but do not
-	 * clear it, and do not allocate the page: as a safety net.
+	 * For now, we report if PG_reserved or PG_memerror was found set, but
+	 * do not clear it, and do not allocate the page: as a safety net.
 	 */
-	if (PageReserved(page))
+	if (PageReserved(page) || PageMemError(page))
 		return 1;
 
 	page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_reclaim |
@@ -2476,8 +2476,11 @@ static void setup_zone_migrate_reserve(s
 			continue;
 		page = pfn_to_page(pfn);
 
-		/* Blocks with reserved pages will never free, skip them. */
-		if (PageReserved(page))
+		/*
+		 * Blocks with reserved pages or memory errors will never
+		 * free, skip them.
+		 */
+		if (PageReserved(page) || PageMemError(page))
 			continue;
 
 		block_migratetype = get_pageblock_migratetype(page);
Index: linux-next/mm/migrate.c
=================================--- linux-next.orig/mm/migrate.c	2008-06-09 13:46:32.892124708 -0500
+++ linux-next/mm/migrate.c	2008-06-09 16:52:21.147302624 -0500
@@ -720,7 +720,25 @@ unlock:
  		 * restored.
  		 */
  		list_del(&page->lru);
- 		move_to_lru(page);
+		if (PageMemError(page))
+			if (rc = 0)
+				/*
+				 * A page with a memory error that has
+				 * been migrated will not be moved to
+				 * the LRU.
+				 */
+				goto move_newpage;
+			else
+				/*
+				 * The page failed to migrate and will not
+				 * be added to the bad page list.  Clearing
+				 * the error bit will allow another attempt
+				 * to migrate if it gets another correctable
+				 * error.
+				 */
+				ClearPageMemError(page);
+
+		move_to_lru(page);
 	}
 
 move_newpage:
@@ -790,6 +808,17 @@ int migrate_pages(struct list_head *from
 			}
 		}
 	}
+
+	if (rc != 0)
+		list_for_each_entry_safe(page, page2, from, lru)
+			if (PageMemError(page))
+				/*
+				 * The page failed to migrate.  Clearing
+				 * the error bit will allow another attempt
+				 * to migrate if it gets another correctable
+				 * error.
+				 */
+				ClearPageMemError(page);
 	rc = 0;
 out:
 	if (!swapwrite)
Index: linux-next/include/linux/page-flags.h
=================================--- linux-next.orig/include/linux/page-flags.h	2008-06-09 16:52:13.746385743 -0500
+++ linux-next/include/linux/page-flags.h	2008-06-09 16:52:21.171305598 -0500
@@ -84,6 +84,7 @@ enum pageflags {
 	PG_private,		/* If pagecache, has fs-private data */
 	PG_writeback,		/* Page is under writeback */
 #ifdef CONFIG_PAGEFLAGS_EXTENDED
+	PG_memerror,		/* Page has a physical memory error */
 	PG_head,		/* A head page */
 	PG_tail,		/* A tail page */
 #else
@@ -132,15 +133,21 @@ static inline int TestSetPage##uname(str
 static inline int TestClearPage##uname(struct page *page)		\
 		{ return test_and_clear_bit(PG_##lname, &page->flags); }
 
+#define PAGEFLAGMASK(uname, lname)					\
+static inline int PAGEMASK_##uname(void)				\
+		{ return (1 << PG_##lname); }
 
 #define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)		\
-	SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
+	SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)		\
+	PAGEFLAGMASK(uname, lname)
 
 #define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)		\
 	__SETPAGEFLAG(uname, lname)  __CLEARPAGEFLAG(uname, lname)
 
 #define PAGEFLAG_FALSE(uname) 						\
 static inline int Page##uname(struct page *page) 			\
+			{ return 0; }					\
+static inline int PAGEMASK_##uname(void)				\
 			{ return 0; }
 
 #define TESTSCFLAG(uname, lname)					\
@@ -308,9 +315,16 @@ static inline void __ClearPageTail(struc
 
 #endif /* !PAGEFLAGS_EXTENDED */
 
+#ifdef CONFIG_PAGEFLAGS_EXTENDED
+PAGEFLAG(MemError, memerror)
+#else
+PAGEFLAG_FALSE(MemError)
+#endif
+
 #define PAGE_FLAGS	(1 << PG_lru   | 1 << PG_private   | 1 << PG_locked | \
 			 1 << PG_buddy | 1 << PG_writeback | \
-			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active)
+			 1 << PG_slab  | 1 << PG_swapcache | 1 << PG_active) |\
+			 PAGEMASK_MemError()
 
 /*
  * Flags checked in bad_page().  Pages on the free list should not have
-- 
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          rja@sgi.com

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

end of thread, other threads:[~2008-06-09 21:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-02  0:42 [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v2 Russ Anderson
2008-05-02  1:12 ` Christoph Lameter
2008-05-02  2:33   ` Russ Anderson
2008-05-09 15:10 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v3 Russ Anderson
2008-05-09 20:11   ` Andrew Morton
2008-05-09 21:51     ` Russ Anderson
2008-05-13 23:03 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v4 Russ Anderson
2008-05-16 19:23 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v5 Russ Anderson
2008-05-16 23:13   ` Christoph Lameter
2008-06-09 15:57     ` Russ Anderson
2008-06-09 16:19 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v6 Russ Anderson
2008-06-09 18:28   ` Christoph Lameter
2008-06-09 21:03     ` Russ Anderson
2008-06-09 21:15       ` Christoph Lameter
2008-06-09 21:58 ` [PATCH 2/3] mm: Avoid putting a bad page back on the LRU v7 Russ Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox