diff options
| -rwxr-xr-x | SOURCE/module/kernel/load.c | 17 | ||||
| -rw-r--r-- | SOURCE/module/kernel/mutex.c | 23 | ||||
| -rwxr-xr-x | SOURCE/module/kernel/sys_delay.c | 22 | ||||
| -rwxr-xr-x | SOURCE/module/misc.c | 3 | ||||
| -rw-r--r-- | SOURCE/module/mm/memcg_stats.c | 5 | ||||
| -rw-r--r-- | SOURCE/module/net/tcp_retrans.c | 3 | ||||
| -rw-r--r-- | SOURCE/module/pmu/pmu.c | 38 | ||||
| -rwxr-xr-x | SOURCE/module/symbol.c | 4 |
8 files changed, 107 insertions, 8 deletions
diff --git a/SOURCE/module/kernel/load.c b/SOURCE/module/kernel/load.c index ce34668..9226117 100755 --- a/SOURCE/module/kernel/load.c +++ b/SOURCE/module/kernel/load.c @@ -27,6 +27,7 @@ #include <linux/rbtree.h> #include <linux/cpu.h> #include <linux/syscalls.h> +#include <asm-generic/rwonce.h> // for READ_ONCE(x) #include <asm/irq_regs.h> @@ -79,6 +80,12 @@ void diag_load_timer(struct diag_percpu_context *context) } #else +// https://www.spinics.net/lists/kernel/msg3582022.html +// fun remove from 5.8.rc3, just for build to add it here +#define task_contributes_to_load2(task) ((READ_ONCE(task->__state) & TASK_UNINTERRUPTIBLE) != 0 && \ + (task->flags & PF_FROZEN) == 0 && \ + (READ_ONCE(task->__state) & TASK_NOLOAD) == 0) + static void load_monitor_ipi(void *ignore) { struct load_monitor_cpu_run *cpu_run; @@ -144,7 +151,7 @@ void diag_load_timer(struct diag_percpu_context *context) rcu_read_lock(); do_each_thread(g, p) { - if (task_contributes_to_load(p)) + if (task_contributes_to_load2(p)) nr_uninterrupt++; } while_each_thread(g, p); @@ -206,8 +213,12 @@ void diag_load_timer(struct diag_percpu_context *context) diag_variant_buffer_seal(&load_monitor_variant_buffer); diag_variant_buffer_spin_unlock(&load_monitor_variant_buffer, flags); do_each_thread(g, p) { - if ((p->state == TASK_RUNNING) - || task_contributes_to_load(p)) { +// [[PATCH v2 7/7] sched: Change task_struct::state](https://lore.kernel.org/all/[email protected]/#r) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) + if ((p->state == TASK_RUNNING) || task_contributes_to_load2(p)) { +#else + if ((p->__state == TASK_RUNNING) || task_contributes_to_load2(p)) { +#endif tsk_info.et_type = et_load_monitor_task; tsk_info.id = event_id; tsk_info.tv = detail.tv; diff --git a/SOURCE/module/kernel/mutex.c b/SOURCE/module/kernel/mutex.c index 8ee8b97..5143765 100644 --- a/SOURCE/module/kernel/mutex.c +++ b/SOURCE/module/kernel/mutex.c @@ -430,13 +430,22 @@ static int __activate_mutex_monitor(void) hook_tracepoint("sched_process_exit", trace_sched_process_exit_hit, NULL); } //get_argv_processes(&mm_tree); - +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) get_online_cpus(); +#else + cpus_read_lock(); +#endif new_mutex_lock(orig_text_mutex); JUMP_INSTALL(mutex_lock); JUMP_INSTALL(mutex_unlock); new_mutex_unlock(orig_text_mutex); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif return 1; out_variant_buffer: @@ -452,14 +461,24 @@ static void __deactivate_mutex_monitor(void) unhook_tracepoint("sched_process_exit", trace_sched_process_exit_hit, NULL); } +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) get_online_cpus(); +#else + cpus_read_lock(); +#endif new_mutex_lock(orig_text_mutex); JUMP_REMOVE(mutex_lock); JUMP_REMOVE(mutex_unlock); new_mutex_unlock(orig_text_mutex); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif clean_data(); @@ -633,6 +652,8 @@ static int lookup_syms(void) if (orig___mutex_unlock_slowpath == NULL) orig___mutex_unlock_slowpath = (void *)diag_kallsyms_lookup_name("__mutex_unlock_slowpath.isra.19"); if (orig___mutex_unlock_slowpath == NULL) + orig___mutex_unlock_slowpath = (void *)diag_kallsyms_lookup_name("__mutex_unlock_slowpath.isra.24"); + if (orig___mutex_unlock_slowpath == NULL) orig___mutex_unlock_slowpath = (void *)diag_kallsyms_lookup_name("__mutex_unlock_slowpath"); if (orig___mutex_unlock_slowpath == NULL) orig___mutex_unlock_slowpath = (void *)diag_kallsyms_lookup_name("__mutex_unlock_slowpath.constprop.0"); diff --git a/SOURCE/module/kernel/sys_delay.c b/SOURCE/module/kernel/sys_delay.c index daa915f..8ea674c 100755 --- a/SOURCE/module/kernel/sys_delay.c +++ b/SOURCE/module/kernel/sys_delay.c @@ -326,11 +326,21 @@ static int __activate_sys_delay(void) } //get_argv_processes(&mm_tree); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) get_online_cpus(); +#else + cpus_read_lock(); +#endif mutex_lock(orig_text_mutex); JUMP_INSTALL(_cond_resched); mutex_unlock(orig_text_mutex); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif return 1; out_variant_buffer: @@ -362,11 +372,21 @@ static void __deactivate_sys_delay(void) unhook_tracepoint("sched_process_exit", trace_sched_process_exit_hit, NULL); } +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) get_online_cpus(); +#else + cpus_read_lock(); +#endif mutex_lock(orig_text_mutex); JUMP_REMOVE(_cond_resched); mutex_unlock(orig_text_mutex); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif synchronize_sched(); msleep(10); @@ -507,7 +527,7 @@ long diag_ioctl_sys_delay(unsigned int cmd, unsigned long arg) static int lookup_syms(void) { - LOOKUP_SYMS(_cond_resched); + // LOOKUP_SYMS(_cond_resched); #if KERNEL_VERSION(4, 4, 0) <= LINUX_VERSION_CODE LOOKUP_SYMS(__schedule); #else diff --git a/SOURCE/module/misc.c b/SOURCE/module/misc.c index 220b9de..bf5a709 100755 --- a/SOURCE/module/misc.c +++ b/SOURCE/module/misc.c @@ -89,7 +89,7 @@ int need_dump(int delay_threshold_ms, u64 *max_delay_ms, u64 base) return ret; } - +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0) static char *bdevt_str(dev_t devt, char *buf) { if (MAJOR(devt) <= 0xff && MINOR(devt) <= 0xff) { @@ -101,6 +101,7 @@ static char *bdevt_str(dev_t devt, char *buf) return buf; } +#endif /* * print a full list of all partitions - intended for places where the root diff --git a/SOURCE/module/mm/memcg_stats.c b/SOURCE/module/mm/memcg_stats.c index 6f1eb2f..ed380b6 100644 --- a/SOURCE/module/mm/memcg_stats.c +++ b/SOURCE/module/mm/memcg_stats.c @@ -245,8 +245,11 @@ static void diag_memcg_build_inode_stats(struct mem_cgroup *memcg, struct page *page, *n; struct lruvec *lruvec; enum lru_list lru; - +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id); +#else + mz = memcg->nodeinfo[pgdat->node_id]; +#endif if (!mz) continue; diff --git a/SOURCE/module/net/tcp_retrans.c b/SOURCE/module/net/tcp_retrans.c index f71a21a..fe196e6 100644 --- a/SOURCE/module/net/tcp_retrans.c +++ b/SOURCE/module/net/tcp_retrans.c @@ -90,8 +90,9 @@ struct diag_tcp_retrans { int syncack_count; int skb_count; }; - +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 3, 0) static struct diag_variant_buffer tcp_retrans_variant_buffer; +#endif __maybe_unused static void clean_data(void) { diff --git a/SOURCE/module/pmu/pmu.c b/SOURCE/module/pmu/pmu.c index 8495dcd..1732451 100644 --- a/SOURCE/module/pmu/pmu.c +++ b/SOURCE/module/pmu/pmu.c @@ -347,10 +347,20 @@ void pmu_destroy_all_events(void) { unsigned int cpu; +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) get_online_cpus(); +#else + cpus_read_lock(); +#endif for_each_online_cpu(cpu) pmu_destroy_counter(cpu); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif } int pmu_create_all_events(void) @@ -358,17 +368,32 @@ int pmu_create_all_events(void) int cpu; int ret; +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) get_online_cpus(); +#else + cpus_read_lock(); +#endif for_each_online_cpu(cpu) { ret = pmu_create_core_events(cpu); if (ret) { +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif goto err_out; } } +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif return 0; @@ -382,6 +407,8 @@ struct cpuacct_impl { char internal[0]; }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) && LINUX_VERSION_CODE <= KERNEL_VERSION(5,16,0) + static struct cpuacct * cb_attach_cpuacct_cgrp(struct cpuacct *acct, void *data) { struct cpuacct_impl *impl; @@ -415,6 +442,7 @@ void pmu_detach_all_cgroups(void) { cpuacct_cgroup_walk_tree(cb_detach_cpuacct_cgrp, NULL); } +#endif static void pmu_walk_pmu_cgroup_tree(void (*callback)(struct pmu_cgroup *)) { @@ -544,7 +572,12 @@ static void dump_pmu_all(void) return; atomic64_inc_return(&pmu_nr_running); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) get_online_cpus(); +#else + cpus_read_lock(); +#endif for_each_online_cpu(cpu) queue_work_on(cpu, system_wq, per_cpu_ptr(&dump_pmu_works, cpu)); @@ -552,7 +585,12 @@ static void dump_pmu_all(void) for_each_online_cpu(cpu) flush_work(per_cpu_ptr(&dump_pmu_works, cpu)); +//https://lore.kernel.org/lkml/[email protected]/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) put_online_cpus(); +#else + cpus_read_unlock(); +#endif atomic64_dec_return(&pmu_nr_running); } diff --git a/SOURCE/module/symbol.c b/SOURCE/module/symbol.c index 10cf509..ace68dc 100755 --- a/SOURCE/module/symbol.c +++ b/SOURCE/module/symbol.c @@ -168,10 +168,14 @@ static int lookup_syms(void) //LOOKUP_SYMS(__do_page_fault); LOOKUP_SYMS(block_class); LOOKUP_SYMS(disk_type); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) LOOKUP_SYMS(disk_name); +#endif LOOKUP_SYMS(access_remote_vm); LOOKUP_SYMS(idle_task); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0) LOOKUP_SYMS(get_files_struct); +#endif LOOKUP_SYMS(put_files_struct); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) LOOKUP_SYMS(follow_page); |
