aboutsummarylogtreecommitdiffstats
path: root/mpss-modules-page-cache.patch
blob: d036c98ed2b157938baf2311154b6ffa8165f431 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
From 784943a81e3fe80af4a393ea6112a4f178489ce2 Mon Sep 17 00:00:00 2001
From: Marcel Huber <marcel.huber@hsr.ch>
Date: Fri, 10 Feb 2017 09:52:56 +0100
Subject: use newer functions for get_user_pages

---
 host/tools_support.c  | 12 ++++++++++++
 host/vhost/mic_blk.c  |  8 ++++++++
 micscif/micscif_api.c | 12 ++++++++++++
 micscif/micscif_rma.c |  4 ++++
 4 files changed, 36 insertions(+)

diff --git mpss-modules/host/tools_support.c mpss-modules/host/tools_support.c
index 93922f8..ff8efcb 100644
--- mpss-modules/host/tools_support.c
+++ mpss-modules/host/tools_support.c
@@ -64,7 +64,11 @@ mic_unpin_user_pages(struct page **pages, uint32_t nf_pages)
 		for (j = 0; j < nf_pages; j++) {
 			if (pages[j]) {
 				SetPageDirty(pages[j]);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+				put_page(pages[j]);
+#else
 				page_cache_release(pages[j]);
+#endif
 			}
 		}
 		kfree(pages);
@@ -89,8 +93,16 @@ mic_pin_user_pages (void *data, struct page **pages, uint32_t len, int32_t *nf_p
 
 	// pin the user pages; use semaphores on linux for doing the same
 	down_read(&current->mm->mmap_sem);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
+	*nf_pages = (int32_t)get_user_pages_remote(current, current->mm,
+			  (uint64_t)data, nr_pages, FOLL_WRITE|FOLL_FORCE, pages, NULL);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+	*nf_pages = (int32_t)get_user_pages_remote(current, current->mm,
+			  (uint64_t)data, nr_pages, PROT_WRITE, 1, pages, NULL);
+#else
 	*nf_pages = (int32_t)get_user_pages(current, current->mm, (uint64_t)data,
 			  nr_pages, PROT_WRITE, 1, pages, NULL);
+#endif
 	up_read(&current->mm->mmap_sem);
 
 	// compare if the no of final pages is equal to no of requested pages
diff --git mpss-modules/host/vhost/mic_blk.c mpss-modules/host/vhost/mic_blk.c
index 12bc880..47a0924 100644
--- mpss-modules/host/vhost/mic_blk.c
+++ mpss-modules/host/vhost/mic_blk.c
@@ -153,12 +153,20 @@ static void handle_io_work(struct work_struct *work)
 	  for (iov = vbio->iov; iov < &vbio->iov[vbio->nvecs]; iov++) {
 		iov->iov_base = mic_addr_in_host(aper_va, iov->iov_base);
 	  }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+		ret = vfs_writev(vbio->file, vbio->iov, vbio->nvecs, &pos, 0);
+#else
 		ret = vfs_writev(vbio->file, vbio->iov, vbio->nvecs, &pos);
+#endif
 	} else {
 	  for (iov = vbio->iov; iov < &vbio->iov[vbio->nvecs]; iov++) {
 		iov->iov_base = mic_addr_in_host(aper_va, iov->iov_base);
 	  }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+		ret = vfs_readv(vbio->file, vbio->iov, vbio->nvecs, &pos, 0);
+#else
 		ret = vfs_readv(vbio->file, vbio->iov, vbio->nvecs, &pos);
+#endif
 	}
 	status = (ret < 0) ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK;
 	if (vbio->head != -1) {
diff --git mpss-modules/micscif/micscif_api.c mpss-modules/micscif/micscif_api.c
index e13e59d..1c06105 100644
--- mpss-modules/micscif/micscif_api.c
+++ mpss-modules/micscif/micscif_api.c
@@ -1981,13 +1981,21 @@ retry:
 			}
 		}
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+		pinned_pages->nr_pages = get_user_pages_remote(
+#else
 		pinned_pages->nr_pages = get_user_pages(
+#endif
 				current,
 				mm,
 				(uint64_t)addr,
 				nr_pages,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
+				FOLL_WRITE,
+#else
 				!!(prot & SCIF_PROT_WRITE),
 				0,
+#endif
 				pinned_pages->pages,
 				pinned_pages->vma);
 		up_write(&mm->mmap_sem);
@@ -2007,7 +2015,11 @@ retry:
 				/* Roll back any pinned pages */
 				for (i = 0; i < pinned_pages->nr_pages; i++) {
 					if (pinned_pages->pages[i])
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+						put_page(pinned_pages->pages[i]);
+#else
 						page_cache_release(pinned_pages->pages[i]);
+#endif
 				}
 				prot &= ~SCIF_PROT_WRITE;
 				try_upgrade = false;
diff --git mpss-modules/micscif/micscif_rma.c mpss-modules/micscif/micscif_rma.c
index 9c6de2e..f0bf6c7 100644
--- mpss-modules/micscif/micscif_rma.c
+++ mpss-modules/micscif/micscif_rma.c
@@ -413,7 +413,11 @@ int micscif_destroy_pinned_pages(struct scif_pinned_pages *pinned_pages)
 				BUG_ON(!page_count(pinned_pages->pages[j]));
 				BUG_ON(atomic_long_sub_return(1, &ms_info.rma_pin_cnt) < 0);
 #endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)
+				put_page(pinned_pages->pages[j]);
+#else
 				page_cache_release(pinned_pages->pages[j]);
+#endif
 			}
 		}
 	}
-- 
2.11.1