From: Vyacheslav Cherkashin Date: Mon, 16 Oct 2017 17:57:28 +0000 (+0300) Subject: KI: add kernel patch for CONFIG_SWAP_HOOK_USAUX support X-Git-Tag: submit/tizen_4.0/20180109.094119~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d87f2bb1fc029e562af22eb5c1d0c3288d42195;p=platform%2Fkernel%2Fswap-modules.git KI: add kernel patch for CONFIG_SWAP_HOOK_USAUX support Change-Id: I5e1d849fee82b89eb16cbb9bb5b1771032763f6b Signed-off-by: Vyacheslav Cherkashin --- diff --git a/kernel_integration/patches/0005-SWAP-DA-arm64-add-CONFIG_SWAP_HOOK_USAUX.patch b/kernel_integration/patches/0005-SWAP-DA-arm64-add-CONFIG_SWAP_HOOK_USAUX.patch new file mode 100644 index 0000000..0d9aceb --- /dev/null +++ b/kernel_integration/patches/0005-SWAP-DA-arm64-add-CONFIG_SWAP_HOOK_USAUX.patch @@ -0,0 +1,188 @@ +From 726d66d3aac4953081a51af1bac9df3682bc1e42 Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Thu, 5 Oct 2017 09:43:52 +0300 +Subject: [PATCH 5/9] SWAP-DA(arm64): add CONFIG_SWAP_HOOK_USAUX + +--- + arch/arm64/mm/fault.c | 5 ++++- + fs/exec.c | 3 +++ + include/swap/hook_usaux.h | 38 ++++++++++++++++++++++++++++++++++++++ + kernel/fork.c | 6 ++++++ + mm/mmap.c | 9 ++++++++- + 5 files changed, 59 insertions(+), 2 deletions(-) + create mode 100644 include/swap/hook_usaux.h + +diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c +index 6094c64..74bc366 100644 +--- a/arch/arm64/mm/fault.c ++++ b/arch/arm64/mm/fault.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -290,8 +291,10 @@ retry: + * Handle the "normal" case first - VM_FAULT_MAJOR / VM_FAULT_MINOR + */ + if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | +- VM_FAULT_BADACCESS)))) ++ VM_FAULT_BADACCESS)))) { ++ swap_usaux_page_fault(addr); + return 0; ++ } + + /* + * If we are in kernel mode at this point, we have no context to +diff --git a/fs/exec.c b/fs/exec.c +index 2e83209..6aa8b24 100644 +--- a/fs/exec.c ++++ b/fs/exec.c +@@ -44,6 +44,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -979,6 +980,7 @@ static int de_thread(struct task_struct *tsk) + write_unlock_irq(&tasklist_lock); + threadgroup_change_end(tsk); + ++ swap_usaux_change_leader(leader, tsk); + release_task(leader); + } + +@@ -1049,6 +1051,7 @@ void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec) + strlcpy(tsk->comm, buf, sizeof(tsk->comm)); + task_unlock(tsk); + perf_event_comm(tsk, exec); ++ swap_usaux_set_comm(tsk); + } + + int flush_old_exec(struct linux_binprm * bprm) +diff --git a/include/swap/hook_usaux.h b/include/swap/hook_usaux.h +new file mode 100644 +index 0000000..f6a2ef6 +--- /dev/null ++++ b/include/swap/hook_usaux.h +@@ -0,0 +1,38 @@ ++#ifndef _LINUX_SWAP_HOOK_USAUX_H ++#define _LINUX_SWAP_HOOK_USAUX_H ++ ++ ++static inline void swap_usaux_page_fault(unsigned long addr) ++{ ++} ++ ++static inline void swap_usaux_copy_process_pre(void) ++{ ++} ++ ++static inline void swap_usaux_copy_process_post(struct task_struct *task) ++{ ++} ++ ++static inline void swap_usaux_mm_release(struct task_struct *task) ++{ ++} ++ ++static inline void swap_usaux_munmap(unsigned long start, unsigned long end) ++{ ++} ++ ++static inline void swap_usaux_mmap(struct file *file, unsigned long addr) ++{ ++} ++ ++static inline void swap_usaux_set_comm(struct task_struct *task) ++{ ++} ++ ++static inline void swap_usaux_change_leader(struct task_struct *prev, ++ struct task_struct *next) ++{ ++} ++ ++#endif /* _LINUX_SWAP_HOOK_USAUX_H */ +diff --git a/kernel/fork.c b/kernel/fork.c +index 6ee449f..16c640a 100644 +--- a/kernel/fork.c ++++ b/kernel/fork.c +@@ -60,6 +60,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -811,6 +812,8 @@ static int wait_for_vfork_done(struct task_struct *child, + */ + void mm_release(struct task_struct *tsk, struct mm_struct *mm) + { ++ swap_usaux_mm_release(tsk); ++ + /* Get rid of any futexes when releasing the mm */ + #ifdef CONFIG_FUTEX + if (unlikely(tsk->robust_list)) { +@@ -1669,8 +1672,11 @@ long do_fork(unsigned long clone_flags, + trace = 0; + } + ++ swap_usaux_copy_process_pre(); + p = copy_process(clone_flags, stack_start, stack_size, + child_tidptr, NULL, trace); ++ swap_usaux_copy_process_post(p); ++ + /* + * Do this prior waking up the new thread - the thread pointer + * might get invalid after that point, if the thread exits quickly. +diff --git a/mm/mmap.c b/mm/mmap.c +index f73ff5b..6a9f9c1 100644 +--- a/mm/mmap.c ++++ b/mm/mmap.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1306,8 +1307,10 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, + * that it represents a valid section of the address space. + */ + addr = get_unmapped_area(file, addr, len, pgoff, flags); +- if (addr & ~PAGE_MASK) ++ if (addr & ~PAGE_MASK) { ++ swap_usaux_mmap(file, addr); + return addr; ++ } + + /* Do simple checking here so the lower-level routines won't have + * to. we assume access permissions have been handled by the open +@@ -1408,6 +1411,8 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, + ((vm_flags & VM_LOCKED) || + (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE)) + *populate = len; ++ ++ swap_usaux_mmap(file, addr); + return addr; + } + +@@ -2614,6 +2619,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len) + /* Fix up all other VM information */ + remove_vma_list(mm, vma); + ++ swap_usaux_munmap(start, end); ++ + return 0; + } + +-- +2.1.4 +