Re: [RFC] 2/4 Migration Cache - add mm checks

Christoph Lameter
2006-02-17T16:32:52Z

On Fri, 17 Feb 2006, Lee Schermerhorn wrote:

> Index: linux-2.6.16-rc3-mm1/mm/vmscan.c
> ===================================================================
> --- linux-2.6.16-rc3-mm1.orig/mm/vmscan.c 2006-02-15 10:50:43.000000000 -0500
> +++ linux-2.6.16-rc3-mm1/mm/vmscan.c 2006-02-15 10:50:53.000000000 -0500
> @@ -457,11 +457,19 @@ static unsigned long shrink_page_list(st
> * Anonymous process memory has backing store?
> * Try to allocate it some swap space here.
> */
> - if (PageAnon(page) && !PageSwapCache(page)) {
> - if (!sc->may_swap)
> + if (PageAnon(page)) {
> + if (!PageSwapCache(page)) {
> + if (!sc->may_swap)
> + goto keep_locked;
> + if (!add_to_swap(page, GFP_ATOMIC))
> + goto activate_locked;
> + } else if (page_is_migration(page)) {
> + /*
> + * For now, skip migration cache pages.
> + * TODO: move to swap cache [difficult?]
> + */
> goto keep_locked;
> - if (!add_to_swap(page, GFP_ATOMIC))
> - goto activate_locked;
> + }
> }
> #endif /* CONFIG_SWAP */

Would it not be simpler to modify add_to_swap to switch from migration
pte to a real swap pte or simply fail? Then you wont have to touch
shrink_page().

> Index: linux-2.6.16-rc3-mm1/mm/rmap.c
> ===================================================================
> --- linux-2.6.16-rc3-mm1.orig/mm/rmap.c 2006-02-15 10:50:43.000000000 -0500
> +++ linux-2.6.16-rc3-mm1/mm/rmap.c 2006-02-15 10:50:53.000000000 -0500
> @@ -232,7 +232,13 @@ void remove_from_swap(struct page *page)
>
> spin_unlock(&anon_vma->lock);
>
> - delete_from_swap_cache(page);
> + if (PageSwapCache(page))
> + delete_from_swap_cache(page);
> + /*
> + * if page was in migration cache, it will have been
> + * removed when the last swap pte referencing the entry
> + * was removed by the loop above.
> + */
> }
> EXPORT_SYMBOL(remove_from_swap);
> #endif

Hmmm. That points to inconsistent behavior of the swap functions in case
these are working on the migration cache. Could you keep PageSwapCache
until delete_from_swap_cache is called?