Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to handle kernel 5.6 series #32

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Cray Inc.

Tony Curtis <[email protected]>
8 changes: 4 additions & 4 deletions dkms.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

# 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"
# 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 --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 distclean"
CLEAN="make clean"

# rebuild and autoinstall automatically when dkms_autoinstaller runs
# for a new kernel
Expand Down
14 changes: 12 additions & 2 deletions kernel/xpmem_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Copyright (c) 2019 Google, LLC. All rights reserved.
* Copyright (c) 2019 Nathan Hjelm. All rights reserved.
* Copyright 2017 ARM, Inc. All Rights Reserved
* Copyright 2019 Stony Brook University. All Rights Reserved
*/

/*
Expand Down Expand Up @@ -414,7 +415,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);
Expand Down Expand Up @@ -764,8 +765,11 @@ 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 | ... ]
* ^ ^
* | |
Expand Down Expand Up @@ -821,7 +825,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
(void) 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)
Expand Down
2 changes: 1 addition & 1 deletion kernel/xpmem_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
14 changes: 12 additions & 2 deletions kernel/xpmem_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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 */
21 changes: 11 additions & 10 deletions kernel/xpmem_mmu_notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2016 Nathan Hjelm <[email protected]>
* 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
Expand Down Expand Up @@ -65,19 +66,19 @@ xpmem_invalidate_PTEs_range(struct xpmem_thread_group *seg_tg,
* XPMEM only uses the invalidate_range_end() portion. That is, when all pages
* in the range have been unmapped and the pages have been freed by the VM.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
static void
xpmem_invalidate_range(struct mmu_notifier *mn, struct mm_struct *mm,
unsigned long start, unsigned long end)
{
#else
static void
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
xpmem_invalidate_range(struct mmu_notifier *mn,
const struct mmu_notifier_range *mnr)
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
{
struct mm_struct *mm = mnr->mm;
unsigned long start = mnr->start;
unsigned long end = mnr->end;
#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;
Expand Down
11 changes: 11 additions & 0 deletions kernel/xpmem_pfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -629,3 +638,5 @@ struct file_operations xpmem_unpin_procfs_ops = {
.open = xpmem_unpin_procfs_open,
.release = single_release,
};
#endif /* kernel 5.6 */

15 changes: 13 additions & 2 deletions kernel/xpmem_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 *);
Expand Down
2 changes: 1 addition & 1 deletion xpmem-kmod.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down