[PATCH] Updates for page migration

This adds some additional comments in order to help others figure out how
exactly the code works. And fix a variable name.

Also swap_page does need to ignore all reference bits when unmapping a
page. Otherwise we may have to repeatedly unmap a frequently touched page.
So change the try_to_unmap parameter to 1.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Christoph Lameter and committed by Linus Torvalds 418aade4 8977d929

+20 -5
+20 -5
mm/vmscan.c
··· 632 struct address_space *mapping = page_mapping(page); 633 634 if (page_mapped(page) && mapping) 635 - if (try_to_unmap(page, 0) != SWAP_SUCCESS) 636 goto unlock_retry; 637 638 if (PageDirty(page)) { ··· 839 * pages are swapped out. 840 * 841 * The function returns after 10 attempts or if no pages 842 - * are movable anymore because t has become empty 843 * or no retryable pages exist anymore. 844 * 845 * Return: Number of pages not migrated when "to" ran empty. ··· 928 goto unlock_both; 929 930 if (mapping->a_ops->migratepage) { 931 rc = mapping->a_ops->migratepage(newpage, page); 932 goto unlock_both; 933 } 934 935 /* 936 - * Trigger writeout if page is dirty 937 */ 938 if (PageDirty(page)) { 939 switch (pageout(page, mapping)) { ··· 958 ; /* try to migrate the page below */ 959 } 960 } 961 /* 962 - * If we have no buffer or can release the buffer 963 - * then do a simple migration. 964 */ 965 if (!page_has_buffers(page) || 966 try_to_release_page(page, GFP_KERNEL)) { ··· 976 * swap them out. 977 */ 978 if (pass > 4) { 979 unlock_page(newpage); 980 newpage = NULL; 981 rc = swap_page(page);
··· 632 struct address_space *mapping = page_mapping(page); 633 634 if (page_mapped(page) && mapping) 635 + if (try_to_unmap(page, 1) != SWAP_SUCCESS) 636 goto unlock_retry; 637 638 if (PageDirty(page)) { ··· 839 * pages are swapped out. 840 * 841 * The function returns after 10 attempts or if no pages 842 + * are movable anymore because to has become empty 843 * or no retryable pages exist anymore. 844 * 845 * Return: Number of pages not migrated when "to" ran empty. ··· 928 goto unlock_both; 929 930 if (mapping->a_ops->migratepage) { 931 + /* 932 + * Most pages have a mapping and most filesystems 933 + * should provide a migration function. Anonymous 934 + * pages are part of swap space which also has its 935 + * own migration function. This is the most common 936 + * path for page migration. 937 + */ 938 rc = mapping->a_ops->migratepage(newpage, page); 939 goto unlock_both; 940 } 941 942 /* 943 + * Default handling if a filesystem does not provide 944 + * a migration function. We can only migrate clean 945 + * pages so try to write out any dirty pages first. 946 */ 947 if (PageDirty(page)) { 948 switch (pageout(page, mapping)) { ··· 949 ; /* try to migrate the page below */ 950 } 951 } 952 + 953 /* 954 + * Buffers are managed in a filesystem specific way. 955 + * We must have no buffers or drop them. 956 */ 957 if (!page_has_buffers(page) || 958 try_to_release_page(page, GFP_KERNEL)) { ··· 966 * swap them out. 967 */ 968 if (pass > 4) { 969 + /* 970 + * Persistently unable to drop buffers..... As a 971 + * measure of last resort we fall back to 972 + * swap_page(). 973 + */ 974 unlock_page(newpage); 975 newpage = NULL; 976 rc = swap_page(page);