Skip to contentSkip to conversation

mm/compation.c: checking page in lru twice

PATCH NAK Figo.zhang 3 participants 4 messages May 6, 2011

Subsystems (2)
lore
Share & tools
lore

Figo.zhang

author
#0 lore raw

PATCH 1/1 mm/compation.c: checking page in lru twice

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

---

mm/compaction.c | 3 ---

 1 files changed, 0 insertions(+), 3 deletions(-)
mm/compaction.c +0 -3
index 021a296..ac605cb 100644
@@ -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 [email protected]. 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:"[email protected]"> [email protected] </a>

Nacked-by on v1 1/1 NAK
#1 lore raw
Quoted 5 lines · Figo.zhang

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

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.

Quoted 20 lines

mm/compaction.c | 3 ---

 1 files changed, 0 insertions(+), 3 deletions(-)
mm/compaction.c +0 -3
index 021a296..ac605cb 100644
@@ -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
Signature · 2 lines
Mel Gorman
SUSE Labs
#3 lore raw
In reply to Figo.zhang
Quoted 3 lines · Figo.zhang

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 [email protected]. 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:"[email protected]"> [email protected] </a>

#2 lore raw
In reply to Mel Gorman
Quoted 5 lines · Mel Gorman
Quoted 4 lines · Figo.zhang

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

Quoted 7 lines
Quoted 1 line

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 [email protected]. 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:"[email protected]"> [email protected] </a>