summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Glisse <jglisse@redhat.com>2017-02-17 15:29:08 -0500
committerJérôme Glisse <jglisse@redhat.com>2017-07-31 12:57:55 -0400
commitbeb1a61fab3cc07fa4a28e5246668fa195e9bf0b (patch)
treeaa6a70ab899e10e17503c5d6ae7fb2a9ac6facf7
parentfd86ff8156f6d59006a6b40ecfd82566e75232df (diff)
hmm/dummy: show how to use allocate device page on migration of empty entryhmm-next
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
-rw-r--r--drivers/char/hmm_dmirror.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/char/hmm_dmirror.c b/drivers/char/hmm_dmirror.c
index 197d2f8bcdbc..c8b1aa11c871 100644
--- a/drivers/char/hmm_dmirror.c
+++ b/drivers/char/hmm_dmirror.c
@@ -738,7 +738,7 @@ static struct page *dummy_device_alloc_page(struct dmirror_device *mdevice)
* This is a fake device so we alloc real system memory to fake
* our device memory
*/
- rpage = alloc_page(GFP_HIGHUSER);
+ rpage = alloc_page(GFP_HIGHUSER | __GFP_ZERO);
if (!rpage)
return NULL;
@@ -794,9 +794,13 @@ static void dummy_migrate_alloc_and_copy(struct vm_area_struct *vma,
*dst_pfns = 0;
- if (!spage || !(*src_pfns & MIGRATE_PFN_MIGRATE))
+ if (!spage && !(*src_pfns & MIGRATE_PFN_MIGRATE))
+ continue;
+
+ if (spage && !(*src_pfns & MIGRATE_PFN_MIGRATE))
continue;
- if (*src_pfns & MIGRATE_PFN_DEVICE) {
+
+ if (spage && (*src_pfns & MIGRATE_PFN_DEVICE)) {
if (!dummy_device_is_mine(mdevice, spage)) {
continue;
}
@@ -811,7 +815,8 @@ static void dummy_migrate_alloc_and_copy(struct vm_area_struct *vma,
rpage = (void *)hmm_devmem_page_get_drvdata(dpage);
- copy_highpage(rpage, spage);
+ if (spage)
+ copy_highpage(rpage, spage);
*dst_pfns = migrate_pfn(page_to_pfn(dpage)) |
MIGRATE_PFN_DEVICE |
MIGRATE_PFN_LOCKED;