I have some problems with migrate_pages understanding. Here is my
I need to change virtual page mapping (all stuff referring to the page)
to new physical location. Page is present for the process and new page is
already allocated (and not mapped anywhere). I thought that direct migration
code should help me, but there are some issues. Maybe I am missing something.
Here is my simple wrapper for migrate_pages (and related) function:
struct page * return_target(struct page * page, unsigned long private,
int ** result)
return (struct page *)private;
/* I am keeping non exclusive mmap_sem when entering and leaving */
int migrate_pfn_page(struct page *original, struct page *target)
if((ret = migrate_prep()))
ret = isolate_lru_page(original, &page_list);
ret = migrate_pages(&page_list, return_target, (unsigned long)target);
I think that I am loosing pages this way (reference count is not
decreased properly and so original page doesn't get to the free list).
As a example (from printk output):
* before function starts.
original: flags:0x00000060 mapping:dece8fa1 mapcount:1 count:1
target: flags:0x00000000 mapping:00000000 mapcount:0 count:1
* before migrate_pages is called
original flags:0x00000040 mapping:dece8fa1 mapcount:1 count:2
target flags:0x00000000 mapping:00000000 mapcount:0 count:1
* migrate_pages returns with 0 and
original flags:0x00000000 mapping:00000000 mapcount:0 count:1
target flags:0x00000010 mapping:dece8fa1 mapcount:1 count:2
When I try to put_page(original) (because I don't want it for this
moment) I get to bad_page path and need to reboot...
What am I missing? Am I using migrate_pages correctly?
Thanks for any suggestions.
(please add me to cc: because I am not list ...