From 784943a81e3fe80af4a393ea6112a4f178489ce2 Mon Sep 17 00:00:00 2001 From: Marcel Huber 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(¤t->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(¤t->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