Skip to contentSkip to conversation

tmpfs: Insert tmpfs cache pages to inactive list at first

PATCH In review KOSAKI Motohiro 8 participants 15 messages May 19, 2010 – May 22, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tmpfs: Insert tmpfs cache pages to inactive list at first

Shaohua Li reported parallel file copy on tmpfs can lead to OOM killer. This is regression of caused by commit 9ff473b9a7 (vmscan: evict streaming IO first). Wow, It is 2 years old patch!

Currently, tmpfs file cache is inserted active list at first. It mean the insertion doesn't only increase numbers of pages in anon LRU, but also reduce anon scanning ratio. Therefore, vmscan will get totally confusion. It scan almost only file LRU even though the system have plenty unused tmpfs pages.

Historically, lru_cache_add_active_anon() was used by two reasons.
1) Intend to priotize shmem page rather than regular file cache.
2) Intend to avoid reclaim priority inversion of used once pages.

But we've lost both motivation because (1) Now we have separate anon and file LRU list. then, to insert active list doesn't help such priotize. (2) In past, one pte access bit will cause page activation. then to insert inactive list with pte access bit mean higher priority than to insert active list. Its priority inversion may lead to uninteded lru chun. but it was already solved by commit 645747462 (vmscan: detect mapped file pages used only once). (Thanks Hannes, you are great!)

Thus, now we can use lru_cache_add_anon() instead.

Cc Wu Fengguang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Hugh Dickins <[email protected]>
---
 mm/filemap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/filemap.c +1 -1
index b941996..023ef61 100644
@@ -452,7 +452,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 		if (page_is_file_cache(page))
 			lru_cache_add_file(page);
 		else
-			lru_cache_add_active_anon(page);
+			lru_cache_add_anon(page);
 	}
 	return ret;
 }
Signature · 9 lines
1.6.5.2



--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · KOSAKI Motohiro

Shaohua Li reported parallel file copy on tmpfs can lead to OOM killer. This is regression of caused by commit 9ff473b9a7 (vmscan: evict streaming IO first). Wow, It is 2 years old patch!

Thus, now we can use lru_cache_add_anon() instead.

Quoted 7 lines
Cc Wu Fengguang<[email protected]>
Cc Johannes Weiner<[email protected]>
Cc Rik van Riel<[email protected]>
Cc Minchan Kim<[email protected]>
Cc Hugh Dickins<[email protected]>
Signature · 7 lines
All rights reversed

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#2 lore raw
In reply to KOSAKI Motohiro
Quoted 23 lines · KOSAKI Motohiro

Shaohua Li reported parallel file copy on tmpfs can lead to OOM killer. This is regression of caused by commit 9ff473b9a7 (vmscan: evict streaming IO first). Wow, It is 2 years old patch!

Currently, tmpfs file cache is inserted active list at first. It mean the insertion doesn't only increase numbers of pages in anon LRU, but also reduce anon scanning ratio. Therefore, vmscan will get totally confusion. It scan almost only file LRU even though the system have plenty unused tmpfs pages.

Historically, lru_cache_add_active_anon() was used by two reasons.
1) Intend to priotize shmem page rather than regular file cache.
2) Intend to avoid reclaim priority inversion of used once pages.

But we've lost both motivation because (1) Now we have separate anon and file LRU list. then, to insert active list doesn't help such priotize. (2) In past, one pte access bit will cause page activation. then to insert inactive list with pte access bit mean higher priority than to insert active list. Its priority inversion may lead to uninteded lru chun. but it was already solved by commit 645747462 (vmscan: detect mapped file pages used only once). (Thanks Hannes, you are great!)

Quoted 5 lines

Thus, now we can use lru_cache_add_anon() instead.

Cc Wu Fengguang <[email protected]>
Cc Johannes Weiner <[email protected]>
Quoted 13 lines
Cc Rik van Riel <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Hugh Dickins <[email protected]>
---
 mm/filemap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/filemap.c +0 -0
index b941996..023ef61 100644

mm/filemap.c int add_to_page_cache_lru(struct page *page, struct address_space *mapping, · line 455

Quoted 5 lines
mm/filemap.c +1 -1
@@ -452,7 +452,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 		if (page_is_file_cache(page))
 			lru_cache_add_file(page);
 		else
-			lru_cache_add_active_anon(page);
+			lru_cache_add_anon(page);

Looks like the active_anon and active_file versions have no users anymore..

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Reviewed-by on v1 1/1
#3 lore raw
In reply to KOSAKI Motohiro
Quoted 25 lines · KOSAKI Motohiro

Shaohua Li reported parallel file copy on tmpfs can lead to OOM killer. This is regression of caused by commit 9ff473b9a7 (vmscan: evict streaming IO first). Wow, It is 2 years old patch!

Currently, tmpfs file cache is inserted active list at first. It mean the insertion doesn't only increase numbers of pages in anon LRU, but also reduce anon scanning ratio. Therefore, vmscan will get totally confusion. It scan almost only file LRU even though the system have plenty unused tmpfs pages.

Historically, lru_cache_add_active_anon() was used by two reasons.
1) Intend to priotize shmem page rather than regular file cache.
2) Intend to avoid reclaim priority inversion of used once pages.

But we've lost both motivation because (1) Now we have separate anon and file LRU list. then, to insert active list doesn't help such priotize. (2) In past, one pte access bit will cause page activation. then to insert inactive list with pte access bit mean higher priority than to insert active list. Its priority inversion may lead to uninteded lru chun. but it was already solved by commit 645747462 (vmscan: detect mapped file pages used only once). (Thanks Hannes, you are great!)

Thus, now we can use lru_cache_add_anon() instead.

Quoted 7 lines
Cc Wu Fengguang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Hugh Dickins <[email protected]>

The description itself is valuable. :)
Thanks, Kosaki.

Signature · 8 lines
Kind regards,
Minchan Kim

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw
Quoted 5 lines

The preceding comment "they need to go on the active_anon lru below" also needs update.

Thanks. incremental patch is here.

---
 include/linux/swap.h |   10 ----------
 mm/filemap.c         |    2 +-
 2 files changed, 1 insertions(+), 11 deletions(-)
include/linux/swap.h +0 -10
index 18420a9..4bfd932 100644
@@ -224,21 +224,11 @@ static inline void lru_cache_add_anon(struct page *page)
 	__lru_cache_add(page, LRU_INACTIVE_ANON);
 }
 
-static inline void lru_cache_add_active_anon(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_ANON);
-}
-
 static inline void lru_cache_add_file(struct page *page)
 {
 	__lru_cache_add(page, LRU_INACTIVE_FILE);
 }
 
-static inline void lru_cache_add_active_file(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_FILE);
-}
-
 /* LRU Isolation modes. */
 #define ISOLATE_INACTIVE 0	/* Isolate inactive pages. */
 #define ISOLATE_ACTIVE 1	/* Isolate active pages. */
mm/filemap.c +1 -1
index 023ef61..a57931a 100644
@@ -441,7 +441,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 	/*
 	 * Splice_read and readahead add shmem/tmpfs pages into the page cache
 	 * before shmem_readpage has a chance to mark them as SwapBacked: they
-	 * need to go on the active_anon lru below, and mem_cgroup_cache_charge
+	 * need to go on the anon lru below, and mem_cgroup_cache_charge
 	 * (called in add_to_page_cache) needs to know where they're going too.
 	 */
 	if (mapping_cap_swap_backed(mapping))
Signature · 11 lines
1.6.5.2





--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#9 lore raw
In reply to KOSAKI Motohiro
Quoted 25 lines · KOSAKI Motohiro

Shaohua Li reported parallel file copy on tmpfs can lead to OOM killer. This is regression of caused by commit 9ff473b9a7 (vmscan: evict streaming IO first). Wow, It is 2 years old patch!

Currently, tmpfs file cache is inserted active list at first. It mean the insertion doesn't only increase numbers of pages in anon LRU, but also reduce anon scanning ratio. Therefore, vmscan will get totally confusion. It scan almost only file LRU even though the system have plenty unused tmpfs pages.

Historically, lru_cache_add_active_anon() was used by two reasons.
1) Intend to priotize shmem page rather than regular file cache.
2) Intend to avoid reclaim priority inversion of used once pages.

But we've lost both motivation because (1) Now we have separate anon and file LRU list. then, to insert active list doesn't help such priotize. (2) In past, one pte access bit will cause page activation. then to insert inactive list with pte access bit mean higher priority than to insert active list. Its priority inversion may lead to uninteded lru chun. but it was already solved by commit 645747462 (vmscan: detect mapped file pages used only once). (Thanks Hannes, you are great!)

Thus, now we can use lru_cache_add_anon() instead.

Quoted 7 lines
Cc Wu Fengguang <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Hugh Dickins <[email protected]>

Thanks - though I don't quite agree with your description: I can't see why the lru_cache_add_active_anon() was ever justified - that "active" came in along with the separate anon and file LRU lists.

Hugh

#10 lore raw

Hi

Quoted 5 lines

Thanks - though I don't quite agree with your description: I can't see why the lru_cache_add_active_anon() was ever justified - that "active" came in along with the separate anon and file LRU lists.

If you have any worry, can you please share it? I'll test such workload and fix the issue if necessary. You are expert than me in this area.

#14 lore raw
In reply to Hugh Dickins
Quoted 5 lines · Hugh Dickins

Thanks - though I don't quite agree with your description: I can't see why the lru_cache_add_active_anon() was ever justified - that "active" came in along with the separate anon and file LRU lists.

I guess I kind of expected that function to be used by anonymous pages, when I wrote it. Except we use a different variant from do_anonymous_page :)

Signature · 7 lines
All rights reversed

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw
In reply to KOSAKI Motohiro
Quoted 9 lines · KOSAKI Motohiro
Quoted 6 lines

Thanks - though I don't quite agree with your description: I can't see why the lru_cache_add_active_anon() was ever justified - that "active" came in along with the separate anon and file LRU lists.

If you have any worry, can you please share it? I'll test such workload and fix the issue if necessary. You are expert than me in this area.

?? I've acked the patch: my worry is only with the detail of your comments on the history - in my view it was always wrong to put on the active LRU there, and I'm glad that you have now fixed it.

If you really want to test some workload on 2.6.28 to see if it too works better with your fix, I won't stop you - but I'd much prefer you to be applying your mind to 2.6.35 and 2.6.36!

Hugh

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw
Quoted 8 lines · KOSAKI Motohiro
Quoted 7 lines
Quoted 6 lines

Thanks - though I don't quite agree with your description: I can't see why the lru_cache_add_active_anon() was ever justified - that "active" came in along with the separate anon and file LRU lists.

Quoted 6 lines
Quoted 2 lines

If you have any worry, can you please share it? I'll test such workload and fix the issue if necessary. You are expert than me in this area.

?? I've acked the patch: my worry is only with the detail of your comments on the history - in my view it was always wrong to put on the active LRU there, and I'm glad that you have now fixed it.

Oops, I misparsed your text. very sorry. I thought you said opposite ;)

Thanks.

Quoted 10 lines

If you really want to test some workload on 2.6.28 to see if it too works better with your fix, I won't stop you - but I'd much prefer you to be applying your mind to 2.6.35 and 2.6.36!

Hugh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#13 lore raw
In reply to Hugh Dickins
Quoted 3 lines · Hugh Dickins

If you really want to test some workload on 2.6.28 to see if it too works better with your fix, I won't stop you - but I'd much prefer you to be applying your mind to 2.6.35 and 2.6.36!

And sending it to -stable (after merged in mainline) if it should be on 2.6.32/33/34, please.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
maintainer
#6 lore raw
In reply to KOSAKI Motohiro
Quoted 26 lines · On Fri, 21 May 2010 09:36:50 +0900 (JST) KOSAKI Motohiro…
Quoted 5 lines

The preceding comment "they need to go on the active_anon lru below" also needs update.

Thanks. incremental patch is here.

---
 include/linux/swap.h |   10 ----------
 mm/filemap.c         |    2 +-
 2 files changed, 1 insertions(+), 11 deletions(-)
include/linux/swap.h +0 -4
index 18420a9..4bfd932 100644
@@ -224,21 +224,11 @@ static inline void lru_cache_add_anon(struct page *page)
 	__lru_cache_add(page, LRU_INACTIVE_ANON);
 }
 
-static inline void lru_cache_add_active_anon(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_ANON);
-}

include/linux/swap.h static inline void lru_cache_add_anon(struct page *page) · line 240

Quoted 10 lines
include/linux/swap.h +0 -5
-
 static inline void lru_cache_add_file(struct page *page)
 {
 	__lru_cache_add(page, LRU_INACTIVE_FILE);
 }
 
-static inline void lru_cache_add_active_file(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_FILE);
-}

Did you intend to remove these two functions?

They do appear to be unused now, but they still make sense and might be used in the future, perhaps. It's OK to remove them, but I'm wondering if it was deliberately included in this patch?

Quoted 22 lines
include/linux/swap.h +0 -0
 /* LRU Isolation modes. */
 #define ISOLATE_INACTIVE 0	/* Isolate inactive pages. */
 #define ISOLATE_ACTIVE 1	/* Isolate active pages. */
mm/filemap.c +1 -1
index 023ef61..a57931a 100644
@@ -441,7 +441,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 	/*
 	 * Splice_read and readahead add shmem/tmpfs pages into the page cache
 	 * before shmem_readpage has a chance to mark them as SwapBacked: they
-	 * need to go on the active_anon lru below, and mem_cgroup_cache_charge
+	 * need to go on the anon lru below, and mem_cgroup_cache_charge
 	 * (called in add_to_page_cache) needs to know where they're going too.
 	 */
 	if (mapping_cap_swap_backed(mapping))
Signature · 1 line
1.6.5.2

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw
Quoted 10 lines
Quoted 10 lines
include/linux/swap.h +0 -5
-static inline void lru_cache_add_active_anon(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_ANON);
-}
-
 static inline void lru_cache_add_file(struct page *page)
 {
 	__lru_cache_add(page, LRU_INACTIVE_FILE);
 }
Quoted 6 lines

include/linux/swap.h static inline void lru_cache_add_anon(struct page *page) · line 240

Quoted 4 lines
include/linux/swap.h +0 -4
-static inline void lru_cache_add_active_file(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_FILE);
-}

Did you intend to remove these two functions?

This is for applying Hannes's commnet.

Quoted 2 lines

They do appear to be unused now, but they still make sense and might be used in the future, perhaps.

Personally, I don't like the strategy that anyone without me might use this function in the future. because It often never come.

Quoted 2 lines

It's OK to remove them, but I'm wondering
if it was deliberately included in this patch?

Makes sense.
OK, please drop current patch at once. I'll post V2.

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#8 lore raw
Quoted 22 lines · On Sat, 22 May 2010 09:04:30 +0900 (JST) KOSAKI Motohiro…
Quoted 10 lines
Quoted 10 lines
include/linux/swap.h +0 -5
-static inline void lru_cache_add_active_anon(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_ANON);
-}
-
 static inline void lru_cache_add_file(struct page *page)
 {
 	__lru_cache_add(page, LRU_INACTIVE_FILE);
 }
Quoted 6 lines

include/linux/swap.h static inline void lru_cache_add_anon(struct page *page) · line 240

Quoted 4 lines
include/linux/swap.h +0 -4
-static inline void lru_cache_add_active_file(struct page *page)
-{
-	__lru_cache_add(page, LRU_ACTIVE_FILE);
-}

Did you intend to remove these two functions?

This is for applying Hannes's commnet.

Quoted 2 lines

They do appear to be unused now, but they still make sense and might be used in the future, perhaps.

Quoted 8 lines

Personally, I don't like the strategy that anyone without me might use this function in the future. because It often never come.

Quoted 2 lines

It's OK to remove them, but I'm wondering
if it was deliberately included in this patch?

Makes sense.
OK, please drop current patch at once. I'll post V2.

Is OK, let's keep the change. I just wanted to check that it wasn't made accidentally.

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>