[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 632 struct address_space *mapping = page_mapping(page); 633 633 634 634 if (page_mapped(page) && mapping) 635 - if (try_to_unmap(page, 0) != SWAP_SUCCESS) 635 + if (try_to_unmap(page, 1) != SWAP_SUCCESS) 636 636 goto unlock_retry; 637 637 638 638 if (PageDirty(page)) { ··· 839 839 * pages are swapped out. 840 840 * 841 841 * The function returns after 10 attempts or if no pages 842 - * are movable anymore because t has become empty 842 + * are movable anymore because to has become empty 843 843 * or no retryable pages exist anymore. 844 844 * 845 845 * Return: Number of pages not migrated when "to" ran empty. ··· 928 928 goto unlock_both; 929 929 930 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 + */ 931 938 rc = mapping->a_ops->migratepage(newpage, page); 932 939 goto unlock_both; 933 940 } 934 941 935 942 /* 936 - * Trigger writeout if page is dirty 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. 937 946 */ 938 947 if (PageDirty(page)) { 939 948 switch (pageout(page, mapping)) { ··· 958 949 ; /* try to migrate the page below */ 959 950 } 960 951 } 952 + 961 953 /* 962 - * If we have no buffer or can release the buffer 963 - * then do a simple migration. 954 + * Buffers are managed in a filesystem specific way. 955 + * We must have no buffers or drop them. 964 956 */ 965 957 if (!page_has_buffers(page) || 966 958 try_to_release_page(page, GFP_KERNEL)) { ··· 976 966 * swap them out. 977 967 */ 978 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 + */ 979 974 unlock_page(newpage); 980 975 newpage = NULL; 981 976 rc = swap_page(page);