Skip to contentSkip to conversation

3.15-rc8 mm/filemap.c:202 BUG

DISCUSSION 张静(长谷) 2 participants 2 messages Jun 9, 2014 Memory management

lore
Share & tools
lore
#0 lore raw

Hi Hugh

Quoted 5 lines · Hugh Dickins

Though I'd wanted to see the remove_migration_pte oops as a key to the page_mapped bug, my guess is that they're actually independent.

In the 3.15-rc8 tree, along the migration path

/*

    * Corner case handling:

    * 1. When a new swap-cache page is read into, it is added to the LRU

    * and treated as swapcache but it has no rmap yet.

    * Calling try_to_unmap() against a page->mapping==NULL page will

    * trigger a BUG.  So handle it here.

    * 2. An orphaned page (see truncate_complete_page) might have

    * fs-private metadata. The page can be picked up due to memory

    * offlining.  Everywhere else except page reclaim, the page is

    * invisible to the vm, so the page can not be migrated.  So try to

    * free the metadata, so the page can be freed.

    */

    if (!page->mapping) {

       VM_BUG_ON_PAGE(PageAnon(page), page);

       if (page_has_private(page)) {

           try_to_free_buffers(page);

           goto uncharge;

       }

       goto skip_unmap;

    }

 

    /* Establish migration ptes or remove ptes */

    try_to_unmap(page, TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);

skip_unmap:

    if (!page_mapped(page))

       rc = move_to_new_page(newpage, page, remap_swapcache, mode);

Here a page is migrated even not mapped and with no mapping!

    mapping = page_mapping(page);

    if (!mapping)

       rc = migrate_page(mapping, newpage, page, mode);

 

 

    if (!mapping) {

       /* Anonymous page without mapping */

       if (page_count(page) != expected_count)

           return -EAGAIN;

       return MIGRATEPAGE_SUCCESS;

    }

And seems a file cache page is treated in the way of Anon.

Is that right?

Thanks

Hillf

#1 lore raw
Quoted 8 lines · hillf
Quoted 4 lines · Hugh Dickins

Though I'd wanted to see the remove_migration_pte oops as a key to the page_mapped bug, my guess is that they're actually independent.

In the 3.15-rc8 tree, along the migration path

Quoted 11 lines

/*
* Corner case handling:
* 1. When a new swap-cache page is read into, it is added to the LRU
* and treated as swapcache but it has no rmap yet.
* Calling try_to_unmap() against a page->mapping==NULL page will
* trigger a BUG. So handle it here.
* 2. An orphaned page (see truncate_complete_page) might have
* fs-private metadata. The page can be picked up due to memory
* offlining. Everywhere else except page reclaim, the page is
* invisible to the vm, so the page can not be migrated. So try to
* free the metadata, so the page can be freed.

I don't think I'd say that an orphaned page cannot be migrated; but I do agree that it's better just to try free the page than migrate it.

Quoted 4 lines
    */
    if (!page->mapping) {
       VM_BUG_ON_PAGE(PageAnon(page), page);
       if (page_has_private(page)) {
Quoted 8 lines
           try_to_free_buffers(page);
           goto uncharge;
       }
       goto skip_unmap;
    }

    /* Establish migration ptes or remove ptes */
    try_to_unmap(page, TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);

(There is an inefficiency here: it would better check page_mapped(page) before calling try_to_unmap(), which would save getting i_mmap_mutex unnecessarily. But that's an aside, it's not wrong as it stands.)

Quoted 6 lines

skip_unmap:

    if (!page_mapped(page))
       rc = move_to_new_page(newpage, page, remap_swapcache, mode);

Here a page is migrated even not mapped and with no mapping!

Why the exclamation mark? We have just tried to unmap it, so no surprise that the page is now not mapped. As to "no mapping": we hold the page lock, so it's a bug if the state of "page->mapping" has changed since we tested it above.

Quoted 4 lines
    mapping = page_mapping(page);
    if (!mapping)
       rc = migrate_page(mapping, newpage, page, mode);

You need to check the way page_mapping(page) works: it doesn't simply return page->mapping, but supplies swap_address_space if PageSwapCache is set, or otherwise NULL on an anonymous page. I think your "no mapping" above amounts to swapless anonymous.

Quoted 9 lines

    if (!mapping) {
       /* Anonymous page without mapping */
       if (page_count(page) != expected_count)
           return -EAGAIN;
       return MIGRATEPAGE_SUCCESS;
    }
Quoted 3 lines

And seems a file cache page is treated in the way of Anon.

Is that right?

Nothing wrong with it that I see: the truncated file !page->mapping case has already been skipped in the "Corner case handling" block, though it would not worry me if an orphan page did reach here - the page count check will still refuse to migrate "unexplainable" pages.

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>