From 2a8584c291a4aac9021c914580f588903ba4e38a Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Fri, 4 May 2018 13:53:44 -0400 Subject: [PATCH 01/14] Module installed to extra directory Let dkms handle the entire install sequence from cold. --- dkms.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dkms.conf b/dkms.conf index 38100db..625f174 100644 --- a/dkms.conf +++ b/dkms.conf @@ -11,9 +11,9 @@ BUILT_MODULE_NAME[0]="xpmem" # where we find the .ko file under the build directory BUILT_MODULE_LOCATION[0]="kernel" # where we put it under the kernel modules directory -DEST_MODULE_LOCATION[0]="/kernel/../updates/" +DEST_MODULE_LOCATION[0]="/kernel/../extra/" # how to build it -MAKE[0]="./configure --prefix=/opt/xpmem; make clean; make install" +MAKE[0]="./autogen.sh && ./configure --prefix=/opt/xpmem && make clean && make install && cp 56-xpmem.rules /etc/udev/rules.d/" # clean up command CLEAN="make distclean" From 7db095d496e9a0da29a6fa4d8deb72b273801a5d Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Fri, 14 Sep 2018 17:37:28 -0400 Subject: [PATCH 02/14] API changed slightly in kernel 4.18 so void'ing affected call zap_vma_ptes in kernel/xpmem_attach.c --- kernel/xpmem_attach.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/xpmem_attach.c b/kernel/xpmem_attach.c index a7b3023..64ed7ad 100644 --- a/kernel/xpmem_attach.c +++ b/kernel/xpmem_attach.c @@ -397,7 +397,7 @@ xpmem_attach(struct file *file, xpmem_apid_t apid, off_t offset, size_t size, return -EINVAL; /* If the size is not page aligned, fix it */ - if (offset_in_page(size) != 0) + if (offset_in_page(size) != 0) size += PAGE_SIZE - offset_in_page(size); ap_tg = xpmem_tg_ref_by_apid(apid); @@ -712,8 +712,6 @@ static void xpmem_clear_PTEs_of_att(struct xpmem_attachment *att, u64 start, u64 end, int from_mmu) { - int ret; - /* * This function should ideally acquire both att->mm->mmap_sem * and att->mutex. However, if it is called from a MMU notifier @@ -750,7 +748,7 @@ xpmem_clear_PTEs_of_att(struct xpmem_attachment *att, u64 start, u64 end, u64 offset_start, offset_end, unpin_at; u64 att_vaddr_end = att->vaddr + att->at_size; - /* + /* * SOURCE [ PG 0 | PG 1 | PG 2 | PG 3 | PG 4 | ... ] * ^ ^ * | | @@ -806,9 +804,7 @@ xpmem_clear_PTEs_of_att(struct xpmem_attachment *att, u64 start, u64 end, /* NTH: is this a viable alternative to zap_page_range(). The * benefit of zap_vma_ptes is that it is exported by default. */ - ret = zap_vma_ptes (vma, unpin_at, invalidate_len); - - XPMEM_DEBUG("zap_vma_ptes returned %d", ret); + (void) zap_vma_ptes (vma, unpin_at, invalidate_len); /* Only clear the flag if all pages were zapped */ if (offset_start == 0 && att->at_size == invalidate_len) From dda9a19a238f52678e3ed6f089f1aa27db3ae5f1 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Wed, 12 Dec 2018 10:09:34 -0500 Subject: [PATCH 03/14] Fix up dkms config: wasn't running on new kernel install, added kernelvers --- dkms.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dkms.conf b/dkms.conf index 625f174..136881d 100644 --- a/dkms.conf +++ b/dkms.conf @@ -13,10 +13,10 @@ BUILT_MODULE_LOCATION[0]="kernel" # where we put it under the kernel modules directory DEST_MODULE_LOCATION[0]="/kernel/../extra/" # how to build it -MAKE[0]="./autogen.sh && ./configure --prefix=/opt/xpmem && make clean && make install && cp 56-xpmem.rules /etc/udev/rules.d/" +MAKE[0]="./autogen.sh && ./configure --with-kernelvers=${kernelver} --prefix=/opt/xpmem && make install && cp -f 56-xpmem.rules /etc/udev/rules.d/" # clean up command -CLEAN="make distclean" +CLEAN="make clean" # rebuild and autoinstall automatically when dkms_autoinstaller runs # for a new kernel From 123118d44d197d8d022d89ab1002b9a246993d48 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Tue, 18 Dec 2018 10:36:57 -0500 Subject: [PATCH 04/14] Another attempt to fix DKMS stuf --- dkms.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dkms.conf b/dkms.conf index 136881d..c517c0f 100644 --- a/dkms.conf +++ b/dkms.conf @@ -13,7 +13,7 @@ BUILT_MODULE_LOCATION[0]="kernel" # where we put it under the kernel modules directory DEST_MODULE_LOCATION[0]="/kernel/../extra/" # how to build it -MAKE[0]="./autogen.sh && ./configure --with-kernelvers=${kernelver} --prefix=/opt/xpmem && make install && cp -f 56-xpmem.rules /etc/udev/rules.d/" +MAKE[0]="./autogen.sh && ./configure --with-kernelvers=${kernelver} --prefix=/opt/xpmem && make -j3 install && rm -f /etc/udev/rules.d/56-xpmem.rules && install -c -m 644 56-xpmem.rules /etc/udev/rules.d/" # clean up command CLEAN="make clean" From 0e462d53533352355d7604146901eda761301189 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Mon, 25 Mar 2019 18:16:21 -0400 Subject: [PATCH 05/14] Update to kernel 5.x --- kernel/xpmem_attach.c | 2 +- kernel/xpmem_mmu_notifier.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/xpmem_attach.c b/kernel/xpmem_attach.c index 64ed7ad..a107819 100644 --- a/kernel/xpmem_attach.c +++ b/kernel/xpmem_attach.c @@ -804,7 +804,7 @@ xpmem_clear_PTEs_of_att(struct xpmem_attachment *att, u64 start, u64 end, /* NTH: is this a viable alternative to zap_page_range(). The * benefit of zap_vma_ptes is that it is exported by default. */ - (void) zap_vma_ptes (vma, unpin_at, invalidate_len); + zap_vma_ptes (vma, unpin_at, invalidate_len); /* Only clear the flag if all pages were zapped */ if (offset_start == 0 && att->at_size == invalidate_len) diff --git a/kernel/xpmem_mmu_notifier.c b/kernel/xpmem_mmu_notifier.c index 11cece5..047df82 100644 --- a/kernel/xpmem_mmu_notifier.c +++ b/kernel/xpmem_mmu_notifier.c @@ -66,9 +66,12 @@ xpmem_invalidate_PTEs_range(struct xpmem_thread_group *seg_tg, * in the range have been unmapped and the pages have been freed by the VM. */ static void -xpmem_invalidate_range(struct mmu_notifier *mn, struct mm_struct *mm, - unsigned long start, unsigned long end) +xpmem_invalidate_range(struct mmu_notifier *mn, + const struct mmu_notifier_range *rp) { + unsigned long start = rp->start; + unsigned long end = rp->end; + struct mm_struct *mm = rp->mm; struct xpmem_thread_group *seg_tg; struct vm_area_struct *vma; From c0d19e911a23cb38ebc5865b6299afa68f8c04c2 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Tue, 26 Mar 2019 13:37:54 -0400 Subject: [PATCH 06/14] Guard 'xpmem_invalidate_range' for changed kernel interface v5 --- kernel/xpmem_mmu_notifier.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/xpmem_mmu_notifier.c b/kernel/xpmem_mmu_notifier.c index 047df82..0d7189e 100644 --- a/kernel/xpmem_mmu_notifier.c +++ b/kernel/xpmem_mmu_notifier.c @@ -66,12 +66,19 @@ xpmem_invalidate_PTEs_range(struct xpmem_thread_group *seg_tg, * in the range have been unmapped and the pages have been freed by the VM. */ static void +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) xpmem_invalidate_range(struct mmu_notifier *mn, const struct mmu_notifier_range *rp) +#else +xpmem_invalidate_range(struct mmu_notifier *mn, struct mm_struct *mm, + unsigned long start, unsigned long end) +#endif { - unsigned long start = rp->start; - unsigned long end = rp->end; - struct mm_struct *mm = rp->mm; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) + unsigned long start = rp->start; + unsigned long end = rp->end; + struct mm_struct *mm = rp->mm; +#endif struct xpmem_thread_group *seg_tg; struct vm_area_struct *vma; From afceea856923a624a4f3fe2da880a5df687300e8 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Tue, 26 Mar 2019 13:55:14 -0400 Subject: [PATCH 07/14] Update version to 2.6.6 after kernel v5 changes --- dkms.conf | 2 +- kernel/xpmem_main.c | 2 +- kernel/xpmem_private.h | 4 ++-- xpmem-kmod.spec | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dkms.conf b/dkms.conf index c517c0f..16519f8 100644 --- a/dkms.conf +++ b/dkms.conf @@ -4,7 +4,7 @@ # DKMS module name and version PACKAGE_NAME="xpmem" -PACKAGE_VERSION="2.6.5" +PACKAGE_VERSION="2.6.6" # module name BUILT_MODULE_NAME[0]="xpmem" diff --git a/kernel/xpmem_main.c b/kernel/xpmem_main.c index 8fe24f0..b552730 100644 --- a/kernel/xpmem_main.c +++ b/kernel/xpmem_main.c @@ -490,6 +490,6 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Silicon Graphics, Inc."); MODULE_INFO(supported, "external"); MODULE_DESCRIPTION("XPMEM support"); -MODULE_VERSION("2.6.5"); +MODULE_VERSION("2.6.6"); module_init(xpmem_init); module_exit(xpmem_exit); diff --git a/kernel/xpmem_private.h b/kernel/xpmem_private.h index d86933b..43acf41 100644 --- a/kernel/xpmem_private.h +++ b/kernel/xpmem_private.h @@ -69,8 +69,8 @@ * major - major revision number (12-bits) * minor - minor revision number (16-bits) */ -#define XPMEM_CURRENT_VERSION 0x00026005 -#define XPMEM_CURRENT_VERSION_STRING "2.6.5" +#define XPMEM_CURRENT_VERSION 0x00026006 +#define XPMEM_CURRENT_VERSION_STRING "2.6.6" #define XPMEM_MODULE_NAME "xpmem" diff --git a/xpmem-kmod.spec b/xpmem-kmod.spec index a1acbc8..f1e4020 100644 --- a/xpmem-kmod.spec +++ b/xpmem-kmod.spec @@ -7,7 +7,7 @@ Summary: XPMEM: Cross-partition memory Name: xpmem-kmod-%{kernel_release} -Version: 2.6.5 +Version: 2.6.6 Release: 0 License: GPLv2 Group: System Environment/Kernel From 5a814415947296d31cc438834b27b194d562c529 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Thu, 28 Mar 2019 11:05:34 -0400 Subject: [PATCH 08/14] Handle different return type for zap_vma_ptes() between kernel <= 4.17 and up (int -> void) --- kernel/xpmem_attach.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/xpmem_attach.c b/kernel/xpmem_attach.c index a107819..4d18fa5 100644 --- a/kernel/xpmem_attach.c +++ b/kernel/xpmem_attach.c @@ -747,6 +747,9 @@ xpmem_clear_PTEs_of_att(struct xpmem_attachment *att, u64 start, u64 end, u64 invalidate_start, invalidate_end, invalidate_len; u64 offset_start, offset_end, unpin_at; u64 att_vaddr_end = att->vaddr + att->at_size; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 17, 0) + int ret; +#endif /* * SOURCE [ PG 0 | PG 1 | PG 2 | PG 3 | PG 4 | ... ] @@ -804,7 +807,13 @@ xpmem_clear_PTEs_of_att(struct xpmem_attachment *att, u64 start, u64 end, /* NTH: is this a viable alternative to zap_page_range(). The * benefit of zap_vma_ptes is that it is exported by default. */ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 17, 0) + ret = zap_vma_ptes (vma, unpin_at, invalidate_len); + + XPMEM_DEBUG("zap_vma_ptes returned %d", ret); +#else zap_vma_ptes (vma, unpin_at, invalidate_len); +#endif /* Only clear the flag if all pages were zapped */ if (offset_start == 0 && att->at_size == invalidate_len) From a7ab2f508d432be2bdfa7f907fa633f22f0fe650 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Thu, 28 Mar 2019 15:58:59 -0500 Subject: [PATCH 09/14] Add me as author, and SBU in copyright in affected files --- AUTHORS | 2 ++ kernel/xpmem_attach.c | 1 + kernel/xpmem_mmu_notifier.c | 1 + 3 files changed, 4 insertions(+) diff --git a/AUTHORS b/AUTHORS index 5ec20a0..1133c74 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1,3 @@ Cray Inc. + +Tony Curtis diff --git a/kernel/xpmem_attach.c b/kernel/xpmem_attach.c index 4d18fa5..316a722 100644 --- a/kernel/xpmem_attach.c +++ b/kernel/xpmem_attach.c @@ -8,6 +8,7 @@ * Copyright (c) 2014-2017 Los Alamos National Security, LLC. All rights * reserved. * Copyright 2017 ARM, Inc. All Rights Reserved + * Copyright 2019 Stony Brook University. All Rights Reserved */ /* diff --git a/kernel/xpmem_mmu_notifier.c b/kernel/xpmem_mmu_notifier.c index 0d7189e..8f731d7 100644 --- a/kernel/xpmem_mmu_notifier.c +++ b/kernel/xpmem_mmu_notifier.c @@ -5,6 +5,7 @@ * Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2016 Nathan Hjelm + * Copyright (c) 2019 Stony Brook University. All Rights Reserved * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive for From c52975d635aa636bc02fe7e4188d03615e3c9ae0 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Sat, 1 Jun 2019 08:04:59 -0400 Subject: [PATCH 10/14] fault handler return type changes in kernel 5.1 ++ --- kernel/xpmem_attach.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/xpmem_attach.c b/kernel/xpmem_attach.c index 316a722..752be94 100644 --- a/kernel/xpmem_attach.c +++ b/kernel/xpmem_attach.c @@ -157,7 +157,12 @@ xpmem_close_handler(struct vm_area_struct *vma) force_sig(SIGKILL, current); } -static int +static +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) +int +#else +vm_fault_t +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) xpmem_fault_handler(struct vm_fault *vmf) #else From 7b004d9354b73ceb6c8d132bedcd5759ae365a3c Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Tue, 17 Sep 2019 19:34:25 -0400 Subject: [PATCH 11/14] force_sig() signature changes in 5.3 to have 1 param = signal --- kernel/xpmem_attach.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/xpmem_attach.c b/kernel/xpmem_attach.c index 752be94..0ace417 100644 --- a/kernel/xpmem_attach.c +++ b/kernel/xpmem_attach.c @@ -154,7 +154,11 @@ xpmem_close_handler(struct vm_area_struct *vma) /* cause the demise of the current thread group */ XPMEM_DEBUG("xpmem_close_handler: unexpected unmap of XPMEM segment at " "[0x%lx - 0x%lx]\n", vma->vm_start, vma->vm_end); - force_sig(SIGKILL, current); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) + force_sig(SIGKILL); +#else + force_sig(SIGKILL, current); +#endif } static From 6e0e26dfd4fc3666b23644f216d70869346b1041 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Tue, 17 Sep 2019 19:34:49 -0400 Subject: [PATCH 12/14] cpu mask field changes name in 5.3 to mask from allowed --- kernel/xpmem_pfn.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/xpmem_pfn.c b/kernel/xpmem_pfn.c index d9b81e0..51628ba 100644 --- a/kernel/xpmem_pfn.c +++ b/kernel/xpmem_pfn.c @@ -249,7 +249,11 @@ xpmem_pin_page(struct xpmem_thread_group *tg, struct task_struct *src_task, */ if (xpmem_vaddr_to_pte_offset(src_mm, vaddr, NULL) == NULL && cpu_to_node(task_cpu(current)) != cpu_to_node(task_cpu(src_task))) { - saved_mask = current->cpus_allowed; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) + saved_mask = current->cpus_mask; +#else + saved_mask = current->cpus_allowed; +#endif set_cpus_allowed_ptr(current, cpumask_of(task_cpu(src_task))); } From 2c4dc731c3a1a528f141353da6323d13a4dd56f5 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Sun, 26 Apr 2020 13:59:53 -0400 Subject: [PATCH 13/14] Handle kernel proc/file ops interface changes in 5.6.x --- kernel/xpmem_misc.c | 14 ++++++++++++-- kernel/xpmem_pfn.c | 11 +++++++++++ kernel/xpmem_private.h | 11 +++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/kernel/xpmem_misc.c b/kernel/xpmem_misc.c index a2099b8..9b46661 100644 --- a/kernel/xpmem_misc.c +++ b/kernel/xpmem_misc.c @@ -290,11 +290,11 @@ xpmem_debug_printk_procfs_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { char buf; - + if(copy_from_user(&buf, buffer, 1)) return -EFAULT; - if (buf == '0') + if (buf == '0') xpmem_debug_on = 0; else if (buf == '1') xpmem_debug_on = 1; @@ -315,6 +315,15 @@ xpmem_debug_printk_procfs_open(struct inode *inode, struct file *file) return single_open(file, xpmem_debug_printk_procfs_show, NULL); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +struct proc_ops xpmem_debug_printk_procfs_ops = { + .proc_lseek = seq_lseek, + .proc_read = seq_read, + .proc_write = xpmem_debug_printk_procfs_write, + .proc_open = xpmem_debug_printk_procfs_open, + .proc_release = single_release, +}; +#else struct file_operations xpmem_debug_printk_procfs_ops = { .owner = THIS_MODULE, .llseek = seq_lseek, @@ -323,3 +332,4 @@ struct file_operations xpmem_debug_printk_procfs_ops = { .open = xpmem_debug_printk_procfs_open, .release = single_release, }; +#endif /* kernel 5.6 */ diff --git a/kernel/xpmem_pfn.c b/kernel/xpmem_pfn.c index 51628ba..e591076 100644 --- a/kernel/xpmem_pfn.c +++ b/kernel/xpmem_pfn.c @@ -621,6 +621,15 @@ xpmem_unpin_procfs_open(struct inode *inode, struct file *file) return single_open(file, xpmem_unpin_procfs_show, PDE_DATA(inode)); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +struct proc_ops xpmem_unpin_procfs_ops = { + .proc_lseek = seq_lseek, + .proc_read = seq_read, + .proc_write = xpmem_unpin_procfs_write, + .proc_open = xpmem_unpin_procfs_open, + .proc_release = single_release, +}; +#else struct file_operations xpmem_unpin_procfs_ops = { .owner = THIS_MODULE, .llseek = seq_lseek, @@ -629,3 +638,5 @@ struct file_operations xpmem_unpin_procfs_ops = { .open = xpmem_unpin_procfs_open, .release = single_release, }; +#endif /* kernel 5.6 */ + diff --git a/kernel/xpmem_private.h b/kernel/xpmem_private.h index 43acf41..761816b 100644 --- a/kernel/xpmem_private.h +++ b/kernel/xpmem_private.h @@ -296,7 +296,12 @@ extern int xpmem_fork_end(void); #define XPMEM_TGID_STRING_LEN 11 extern spinlock_t xpmem_unpin_procfs_lock; extern struct proc_dir_entry *xpmem_unpin_procfs_dir; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +extern struct proc_ops xpmem_unpin_procfs_ops; +#else extern struct file_operations xpmem_unpin_procfs_ops; +#endif /* kernel 5.6 */ /* found in xpmem_main.c */ extern struct xpmem_partition *xpmem_my_part; @@ -339,7 +344,13 @@ extern int xpmem_seg_down_read(struct xpmem_thread_group *, struct xpmem_segment *, int, int); extern int xpmem_validate_access(struct xpmem_access_permit *, off_t, size_t, int, u64 *); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +extern struct proc_ops xpmem_debug_printk_procfs_ops; +#else extern struct file_operations xpmem_debug_printk_procfs_ops; +#endif /* kernel 5.6 */ + /* found in xpmem_mmu_notifier.c */ extern int xpmem_mmu_notifier_init(struct xpmem_thread_group *); extern void xpmem_mmu_notifier_unlink(struct xpmem_thread_group *); From 599430646567df6bbbbb19ed8d1bc164c6d0fbd2 Mon Sep 17 00:00:00 2001 From: Tony Curtis Date: Sun, 26 Apr 2020 14:20:36 -0400 Subject: [PATCH 14/14] void on ptes call to handle all versions --- kernel/xpmem_attach.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/xpmem_attach.c b/kernel/xpmem_attach.c index 0ace417..0d5b79c 100644 --- a/kernel/xpmem_attach.c +++ b/kernel/xpmem_attach.c @@ -822,7 +822,7 @@ xpmem_clear_PTEs_of_att(struct xpmem_attachment *att, u64 start, u64 end, XPMEM_DEBUG("zap_vma_ptes returned %d", ret); #else - zap_vma_ptes (vma, unpin_at, invalidate_len); + (void) zap_vma_ptes (vma, unpin_at, invalidate_len); #endif /* Only clear the flag if all pages were zapped */