All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]mm/compation.c: checking page in lru twice
@ 2011-05-06 11:32 ` Figo.zhang
  0 siblings, 0 replies; 8+ messages in thread
From: Figo.zhang @ 2011-05-06 11:32 UTC (permalink / raw)
  To: lkml, mel; +Cc: linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton, aarcange


in isolate_migratepages() have check page in LRU twice, the next one
at _isolate_lru_page(). 

Signed-off-by: Figo.zhang <figo1802@gmail.com> 
---

mm/compaction.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 021a296..ac605cb 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -321,9 +321,6 @@ static unsigned long isolate_migratepages(struct zone *zone,
 			continue;
 		}
 
-		if (!PageLRU(page))
-			continue;
-
 		/*
 		 * PageLRU is set, and lru_lock excludes isolation,
 		 * splitting and collapsing (collapsing has already



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

* [PATCH]mm/compation.c: checking page in lru twice
@ 2011-05-06 11:32 ` Figo.zhang
  0 siblings, 0 replies; 8+ messages in thread
From: Figo.zhang @ 2011-05-06 11:32 UTC (permalink / raw)
  To: lkml, mel; +Cc: linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton, aarcange


in isolate_migratepages() have check page in LRU twice, the next one
at _isolate_lru_page(). 

Signed-off-by: Figo.zhang <figo1802@gmail.com> 
---

mm/compaction.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 021a296..ac605cb 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -321,9 +321,6 @@ static unsigned long isolate_migratepages(struct zone *zone,
 			continue;
 		}
 
-		if (!PageLRU(page))
-			continue;
-
 		/*
 		 * PageLRU is set, and lru_lock excludes isolation,
 		 * splitting and collapsing (collapsing has already


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH]mm/compation.c: checking page in lru twice
  2011-05-06 11:32 ` Figo.zhang
@ 2011-05-06 13:09   ` Mel Gorman
  -1 siblings, 0 replies; 8+ messages in thread
From: Mel Gorman @ 2011-05-06 13:09 UTC (permalink / raw)
  To: Figo.zhang
  Cc: lkml, linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton, aarcange

On Fri, May 06, 2011 at 07:32:46PM +0800, Figo.zhang wrote:
> 
> in isolate_migratepages() have check page in LRU twice, the next one
> at _isolate_lru_page(). 
> 
> Signed-off-by: Figo.zhang <figo1802@gmail.com> 

Not checking for PageLRU means that PageTransHuge() gets called
for each page. While the scanner is active and the lock released,
a transparent hugepage can be created and potentially we test
PageTransHuge() on a tail page. This will trigger a BUG if
CONFIG_DEBUG_VM is set.

Nacked-by: Mel Gorman <mel@csn.ul.ie>

> 
> mm/compaction.c |    3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 021a296..ac605cb 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -321,9 +321,6 @@ static unsigned long isolate_migratepages(struct zone *zone,
>  			continue;
>  		}
>  
> -		if (!PageLRU(page))
> -			continue;
> -
>  		/*
>  		 * PageLRU is set, and lru_lock excludes isolation,
>  		 * splitting and collapsing (collapsing has already
> 
> 

-- 
Mel Gorman
SUSE Labs

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

* Re: [PATCH]mm/compation.c: checking page in lru twice
@ 2011-05-06 13:09   ` Mel Gorman
  0 siblings, 0 replies; 8+ messages in thread
From: Mel Gorman @ 2011-05-06 13:09 UTC (permalink / raw)
  To: Figo.zhang
  Cc: lkml, linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton, aarcange

On Fri, May 06, 2011 at 07:32:46PM +0800, Figo.zhang wrote:
> 
> in isolate_migratepages() have check page in LRU twice, the next one
> at _isolate_lru_page(). 
> 
> Signed-off-by: Figo.zhang <figo1802@gmail.com> 

Not checking for PageLRU means that PageTransHuge() gets called
for each page. While the scanner is active and the lock released,
a transparent hugepage can be created and potentially we test
PageTransHuge() on a tail page. This will trigger a BUG if
CONFIG_DEBUG_VM is set.

Nacked-by: Mel Gorman <mel@csn.ul.ie>

> 
> mm/compaction.c |    3 ---
>  1 files changed, 0 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 021a296..ac605cb 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -321,9 +321,6 @@ static unsigned long isolate_migratepages(struct zone *zone,
>  			continue;
>  		}
>  
> -		if (!PageLRU(page))
> -			continue;
> -
>  		/*
>  		 * PageLRU is set, and lru_lock excludes isolation,
>  		 * splitting and collapsing (collapsing has already
> 
> 

-- 
Mel Gorman
SUSE Labs

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH]mm/compation.c: checking page in lru twice
  2011-05-06 11:32 ` Figo.zhang
@ 2011-05-06 18:21   ` Andrea Arcangeli
  -1 siblings, 0 replies; 8+ messages in thread
From: Andrea Arcangeli @ 2011-05-06 18:21 UTC (permalink / raw)
  To: Figo.zhang
  Cc: lkml, mel, linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton

On Fri, May 06, 2011 at 07:32:46PM +0800, Figo.zhang wrote:
> 
> in isolate_migratepages() have check page in LRU twice, the next one
> at _isolate_lru_page(). 

hugetlbfs or any other compound page won't have PageLRU set and they
may go away from under us leading to compound_order not being reliable
if we remove the PageLRU check before compound_order. So we need to
verify the page is in LRU before running compound_order safely. And if
we hold the lru_lock, the page won't be isolated under us, and we know
it's not going to get splitted either.

We might use compound_trans_order but that's only reliable if run on
the head page so it's not so reliable, and so far it's only used by
memory-failure to "diminish" the risk of races in reading the compound
order, but it's not the best having to use compound_trans_order (and
memory-failure remains unsafe w.r.t to hugetlbfs being released during
hwpoisoning, so compound_trans_order might have to be improved for
it).

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

* Re: [PATCH]mm/compation.c: checking page in lru twice
@ 2011-05-06 18:21   ` Andrea Arcangeli
  0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arcangeli @ 2011-05-06 18:21 UTC (permalink / raw)
  To: Figo.zhang
  Cc: lkml, mel, linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton

On Fri, May 06, 2011 at 07:32:46PM +0800, Figo.zhang wrote:
> 
> in isolate_migratepages() have check page in LRU twice, the next one
> at _isolate_lru_page(). 

hugetlbfs or any other compound page won't have PageLRU set and they
may go away from under us leading to compound_order not being reliable
if we remove the PageLRU check before compound_order. So we need to
verify the page is in LRU before running compound_order safely. And if
we hold the lru_lock, the page won't be isolated under us, and we know
it's not going to get splitted either.

We might use compound_trans_order but that's only reliable if run on
the head page so it's not so reliable, and so far it's only used by
memory-failure to "diminish" the risk of races in reading the compound
order, but it's not the best having to use compound_trans_order (and
memory-failure remains unsafe w.r.t to hugetlbfs being released during
hwpoisoning, so compound_trans_order might have to be improved for
it).

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH]mm/compation.c: checking page in lru twice
  2011-05-06 13:09   ` Mel Gorman
@ 2011-05-06 18:26     ` Andrea Arcangeli
  -1 siblings, 0 replies; 8+ messages in thread
From: Andrea Arcangeli @ 2011-05-06 18:26 UTC (permalink / raw)
  To: Mel Gorman
  Cc: Figo.zhang, lkml, linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton

On Fri, May 06, 2011 at 02:09:55PM +0100, Mel Gorman wrote:
> On Fri, May 06, 2011 at 07:32:46PM +0800, Figo.zhang wrote:
> > 
> > in isolate_migratepages() have check page in LRU twice, the next one
> > at _isolate_lru_page(). 
> > 
> > Signed-off-by: Figo.zhang <figo1802@gmail.com> 
> 
> Not checking for PageLRU means that PageTransHuge() gets called
> for each page. While the scanner is active and the lock released,
> a transparent hugepage can be created and potentially we test
> PageTransHuge() on a tail page. This will trigger a BUG if
> CONFIG_DEBUG_VM is set.

Agreed. The compound_order also would become unsafe even if it was
initially an head page (if it's a compound page not in lru). And
compound_trans_order isn't a solution either because we need to be
head for it to be safe like you said, better not having to use
compound_trans_order.

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

* Re: [PATCH]mm/compation.c: checking page in lru twice
@ 2011-05-06 18:26     ` Andrea Arcangeli
  0 siblings, 0 replies; 8+ messages in thread
From: Andrea Arcangeli @ 2011-05-06 18:26 UTC (permalink / raw)
  To: Mel Gorman
  Cc: Figo.zhang, lkml, linux-mm, kamezawa.hiroyu, minchan.kim, Andrew Morton

On Fri, May 06, 2011 at 02:09:55PM +0100, Mel Gorman wrote:
> On Fri, May 06, 2011 at 07:32:46PM +0800, Figo.zhang wrote:
> > 
> > in isolate_migratepages() have check page in LRU twice, the next one
> > at _isolate_lru_page(). 
> > 
> > Signed-off-by: Figo.zhang <figo1802@gmail.com> 
> 
> Not checking for PageLRU means that PageTransHuge() gets called
> for each page. While the scanner is active and the lock released,
> a transparent hugepage can be created and potentially we test
> PageTransHuge() on a tail page. This will trigger a BUG if
> CONFIG_DEBUG_VM is set.

Agreed. The compound_order also would become unsafe even if it was
initially an head page (if it's a compound page not in lru). And
compound_trans_order isn't a solution either because we need to be
head for it to be safe like you said, better not having to use
compound_trans_order.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2011-05-06 18:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 11:32 [PATCH]mm/compation.c: checking page in lru twice Figo.zhang
2011-05-06 11:32 ` Figo.zhang
2011-05-06 13:09 ` Mel Gorman
2011-05-06 13:09   ` Mel Gorman
2011-05-06 18:26   ` Andrea Arcangeli
2011-05-06 18:26     ` Andrea Arcangeli
2011-05-06 18:21 ` Andrea Arcangeli
2011-05-06 18:21   ` Andrea Arcangeli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.