Skip to contentSkip to conversation

shrink_list skip anon pages if not may_swap

PATCH In review Lee Schermerhorn 3 participants 3 messages Sep 12, 2005 – Sep 13, 2005

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

PATCH 1/1 shrink_list skip anon pages if not may_swap

Martin Hicks' page cache reclaim patch added the 'may_swap' flag to the scan_control struct; and modified shrink_list() not to add anon pages to the swap cache if may_swap is not asserted.

Ref: http://marc.theaimsgroup.com/?l=linux-mm&m=111461480725322&w=4

However, further down, if the page is mapped, shrink_list() calls try_to_unmap() which will call try_to_unmap_one() via try_to_unmap_anon (). try_to_unmap_one() will BUG_ON() an anon page that is NOT in the swap cache. Martin says he never encountered this path in his testing, but agrees that it might happen.

This patch modifies shrink_list() to skip anon pages that are not already in the swap cache when !may_swap, rather than just not adding them to the cache.

Cc to lhms-devel because memory hotplug page migration also uses shrink_list.

============================================================

mm/vmscan.c renamed from mm/vmscan.c~original +3 -1
@@ -417,7 +417,9 @@ static int shrink_list(struct list_head 
 		 * Anonymous process memory has backing store?
 		 * Try to allocate it some swap space here.
 		 */
-		if (PageAnon(page) && !PageSwapCache(page) && sc->may_swap) {
+		if (PageAnon(page) && !PageSwapCache(page)) {
+			if (!sc->may_swap)
+				goto keep_locked;
 			if (!add_to_swap(page))
 				goto activate_locked;
 		}

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

#1 lore raw
Quoted 3 lines · Lee Schermerhorn

This patch modifies shrink_list() to skip anon pages that are not already in the swap cache when !may_swap, rather than just not adding them to the cache.

Nice catch!

Signature · 6 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>
Acked-by on v1 1/1
#2 lore raw
In reply to Lee Schermerhorn
Quoted 5 lines · Lee Schermerhorn

Cc to lhms-devel because memory hotplug page migration also uses shrink_list.

Lee already e-mail me privately about this issue. Nice catch indeed.

thanks
mh

Quoted 16 lines

============================================================

mm/vmscan.c renamed from mm/vmscan.c~original +3 -1
@@ -417,7 +417,9 @@ static int shrink_list(struct list_head 
 		 * Anonymous process memory has backing store?
 		 * Try to allocate it some swap space here.
 		 */
-		if (PageAnon(page) && !PageSwapCache(page) && sc->may_swap) {
+		if (PageAnon(page) && !PageSwapCache(page)) {
+			if (!sc->may_swap)
+				goto keep_locked;
 			if (!add_to_swap(page))
 				goto activate_locked;
 		}
Signature · 6 lines
Martin Hicks   ||   Silicon Graphics Inc.   ||   [email protected]
--
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>