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-08-01 15:15:25 -0400
commit2021137ead88b82fb6167d2b3f9258386b99e4d7 (patch)
tree75bfdc37c3f691d577b81381816782a373450f4f
parent3339e9e6a9b1dd10a4c1db2818435cf7df0b4fd4 (diff)
hmm/dummy: show how to use allocate device page on migration of empty entryhmm-v25-4.9
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 3fa1fcda5da7..308eaae117a2 100644
--- a/drivers/char/hmm_dmirror.c
+++ b/drivers/char/hmm_dmirror.c
@@ -737,7 +737,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;
@@ -793,9 +793,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;
}
@@ -810,7 +814,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;