From 2f7a9034c411aea690cec743d6d6796a6e88e9aa Mon Sep 17 00:00:00 2001 From: yuiiio Date: Sat, 21 Nov 2020 05:15:19 +0900 Subject: [PATCH] Update Project C v5.9-r2 (#124) --- PKGBUILD | 4 +- linux-tkg-config/prepare | 10 +- ..._v5.9-r1.patch => 0009-prjc_v5.9-r2.patch} | 208 +++++++----------- 3 files changed, 86 insertions(+), 136 deletions(-) rename linux-tkg-patches/5.9/{0009-prjc_v5.9-r1.patch => 0009-prjc_v5.9-r2.patch} (98%) diff --git a/PKGBUILD b/PKGBUILD index 6b1c10b..aadd866 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -254,7 +254,7 @@ case $_basever in 0008-5.9-bcachefs.patch 0009-glitched-ondemand-bmq.patch 0009-glitched-bmq.patch - 0009-prjc_v5.9-r1.patch + 0009-prjc_v5.9-r2.patch 0011-ZFS-fix.patch #0012-linux-hardened.patch 0012-misc-additions.patch @@ -281,7 +281,7 @@ case $_basever in '7aba0a625404ed78e73c57860871af3b52610ae5196407286811322e3cd76aa3' '9fad4a40449e09522899955762c8928ae17f4cdaa16e01239fd12592e9d58177' 'a557b342111849a5f920bbe1c129f3ff1fc1eff62c6bd6685e0972fc88e39911' - 'a5149d7220457d30e03e6999f35a050bce46acafc6230bfe6b4d4994c523516d' + '11d2343174e5486e8ea1a1e98f9f6f1a1625043f6547484f5a729a83f94336eb' '49262ce4a8089fa70275aad742fc914baa28d9c384f710c9a62f64796d13e104' '433b919e6a0be26784fb4304c43b1811a28f12ad3de9e26c0af827f64c0c316e') ;; diff --git a/linux-tkg-config/prepare b/linux-tkg-config/prepare index 3dffcd3..f1f0da3 100644 --- a/linux-tkg-config/prepare +++ b/linux-tkg-config/prepare @@ -226,7 +226,7 @@ _tkg_initscript() { read -rp "`echo $' > N/y : '`" _fallback; fi if [[ "$_fallback" =~ [yY] ]] || [ "$_nofallback" = "true" ]; then - echo "_compiler_name=" >> "${_path}"/compilerset + echo "_compiler_name=" >> "${_path}"/compilerset fi if [ ! -e "${_path}"/compilerset ]; then error "Exiting..." @@ -367,7 +367,7 @@ _tkg_srcprep() { if [ "$_basever" = "58" ] || [ "$_basever" = "57" ]; then rev=3 elif [ "$_basever" = "59" ]; then - rev=1 + rev=2 else rev=0 fi @@ -468,7 +468,7 @@ _tkg_srcprep() { echo "CONFIG_CMDLINE=\"${_custom_commandline}\"" >> ./.config echo "# CONFIG_CMDLINE_OVERRIDE is not set" >> ./.config echo "# CONFIG_X86_P6_NOP is not set" >> ./.config - + # openrgb echo "CONFIG_I2C_NCT6775=m" >> ./.config @@ -1060,7 +1060,7 @@ _tkg_srcprep() { tkgpatch="$srcdir/0011-ZFS-fix.patch" && _tkg_patcher fi fi - + # Anbox modules if [ "$_basever" > "56" ]; then if [ -z "$_anbox" ]; then @@ -1070,7 +1070,7 @@ _tkg_srcprep() { read -rp "`echo $' > N/y : '`" CONDITION12; fi if [[ "$CONDITION12" =~ [yY] ]] || [ "$_zfsfix" = "true" ]; then - echo "CONFIG_ASHMEM=y" >> ./.config + echo "CONFIG_ASHMEM=y" >> ./.config echo "CONFIG_ANDROID=y" >> ./.config echo "CONFIG_ANDROID_BINDER_IPC=y" >> ./.config echo "CONFIG_ANDROID_BINDERFS=y" >>./.config diff --git a/linux-tkg-patches/5.9/0009-prjc_v5.9-r1.patch b/linux-tkg-patches/5.9/0009-prjc_v5.9-r2.patch similarity index 98% rename from linux-tkg-patches/5.9/0009-prjc_v5.9-r1.patch rename to linux-tkg-patches/5.9/0009-prjc_v5.9-r2.patch index c06313d..3110c3b 100644 --- a/linux-tkg-patches/5.9/0009-prjc_v5.9-r1.patch +++ b/linux-tkg-patches/5.9/0009-prjc_v5.9-r2.patch @@ -345,10 +345,10 @@ index e5af028c08b4..0a7565d0d3cf 100644 diff --git a/include/linux/skip_list.h b/include/linux/skip_list.h new file mode 100644 -index 000000000000..47ca955a451d +index 000000000000..2a8fc7c1a04f --- /dev/null +++ b/include/linux/skip_list.h -@@ -0,0 +1,177 @@ +@@ -0,0 +1,175 @@ +/* + * Copyright (C) 2016 Alfred Chen. + * @@ -401,7 +401,7 @@ index 000000000000..47ca955a451d + +#include + -+#define NUM_SKIPLIST_LEVEL (8) ++#define NUM_SKIPLIST_LEVEL (4) + +struct skiplist_node { + int level; /* Levels in this node */ @@ -410,10 +410,8 @@ index 000000000000..47ca955a451d +}; + +#define SKIPLIST_NODE_INIT(name) { 0,\ -+ {&name, &name, &name, &name,\ -+ &name, &name, &name, &name},\ -+ {&name, &name, &name, &name,\ -+ &name, &name, &name, &name},\ ++ {&name, &name, &name, &name},\ ++ {&name, &name, &name, &name},\ + } + +static inline void INIT_SKIPLIST_NODE(struct skiplist_node *node) @@ -827,10 +825,10 @@ index 5fc9c9b70862..eb6d7d87779f 100644 obj-$(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) += cpufreq_schedutil.o diff --git a/kernel/sched/alt_core.c b/kernel/sched/alt_core.c new file mode 100644 -index 000000000000..fa0ba0d55503 +index 000000000000..e485c76b1668 --- /dev/null +++ b/kernel/sched/alt_core.c -@@ -0,0 +1,6418 @@ +@@ -0,0 +1,6369 @@ +/* + * kernel/sched/alt_core.c + * @@ -885,7 +883,7 @@ index 000000000000..fa0ba0d55503 + */ +EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_irq_tp); + -+#define ALT_SCHED_VERSION "v5.9-r1" ++#define ALT_SCHED_VERSION "v5.9-r2" + +/* rt_prio(prio) defined in include/linux/sched/rt.h */ +#define rt_task(p) rt_prio((p)->prio) @@ -923,8 +921,9 @@ index 000000000000..fa0ba0d55503 +#ifdef CONFIG_SMP +static cpumask_t sched_rq_pending_mask ____cacheline_aligned_in_smp; + -+DEFINE_PER_CPU(cpumask_t [NR_CPU_AFFINITY_CHK_LEVEL], sched_cpu_affinity_masks); ++DEFINE_PER_CPU(cpumask_t [NR_CPU_AFFINITY_LEVELS], sched_cpu_affinity_masks); +DEFINE_PER_CPU(cpumask_t *, sched_cpu_affinity_end_mask); ++DEFINE_PER_CPU(cpumask_t *, sched_cpu_llc_mask); + +#ifdef CONFIG_SCHED_SMT +DEFINE_STATIC_KEY_FALSE(sched_smt_present); @@ -937,59 +936,6 @@ index 000000000000..fa0ba0d55503 + * domain, see cpus_share_cache(). + */ +DEFINE_PER_CPU(int, sd_llc_id); -+ -+enum { -+ LLC_LEVEL = 1, -+ NR_BEST_CPU_LEVEL -+}; -+ -+#define NR_BEST_CPU_MASK (1 << (NR_BEST_CPU_LEVEL - 1)) -+ -+static cpumask_t -+sched_best_cpu_masks[NR_CPUS][NR_BEST_CPU_MASK] ____cacheline_aligned_in_smp; -+ -+#if NR_CPUS <= 64 -+static inline unsigned int sched_cpumask_first_and(const struct cpumask *srcp, -+ const struct cpumask *andp) -+{ -+ unsigned long t = srcp->bits[0] & andp->bits[0]; -+ -+ if (t) -+ return __ffs(t); -+ -+ return nr_cpu_ids; -+} -+ -+static inline unsigned int sched_best_cpu(const unsigned int cpu, -+ const struct cpumask *m) -+{ -+ cpumask_t *chk = sched_best_cpu_masks[cpu]; -+ unsigned long t; -+ -+ while ((t = chk->bits[0] & m->bits[0]) == 0UL) -+ chk++; -+ -+ return __ffs(t); -+} -+#else -+static inline unsigned int sched_cpumask_first_and(const struct cpumask *srcp, -+ const struct cpumask *andp) -+{ -+ return cpumask_first_and(srcp, andp); -+} -+ -+static inline unsigned int sched_best_cpu(const unsigned int cpu, -+ const struct cpumask *m) -+{ -+ cpumask_t t, *chk = sched_best_cpu_masks[cpu]; -+ -+ while (!cpumask_and(&t, chk, m)) -+ chk++; -+ -+ return cpumask_any(t); -+} -+#endif -+ +#endif /* CONFIG_SMP */ + +static DEFINE_MUTEX(sched_hotcpu_mutex); @@ -1685,7 +1631,7 @@ index 000000000000..fa0ba0d55503 + default_cpu = cpu; + } + -+ for (mask = per_cpu(sched_cpu_affinity_masks, cpu); ++ for (mask = &(per_cpu(sched_cpu_affinity_masks, cpu)[0]); + mask < per_cpu(sched_cpu_affinity_end_mask, cpu); mask++) + for_each_cpu_and(i, mask, housekeeping_cpumask(HK_FLAG_TIMER)) + if (!idle_cpu(i)) @@ -2405,9 +2351,9 @@ index 000000000000..fa0ba0d55503 + cpumask_and(&tmp, &chk_mask, &sched_rq_watermark[IDLE_WM]) || + cpumask_and(&tmp, &chk_mask, + &sched_rq_watermark[task_sched_prio(p, rq) + 1])) -+ return sched_best_cpu(task_cpu(p), &tmp); ++ return best_mask_cpu(task_cpu(p), &tmp); + -+ return sched_best_cpu(task_cpu(p), &chk_mask); ++ return best_mask_cpu(task_cpu(p), &chk_mask); +} + +void sched_set_stop_task(int cpu, struct task_struct *stop) @@ -3979,8 +3925,8 @@ index 000000000000..fa0ba0d55503 +{ + struct rq *rq = this_rq(); + struct task_struct *p = data; ++ cpumask_t tmp; + unsigned long flags; -+ int dcpu; + + local_irq_save(flags); + @@ -3990,9 +3936,12 @@ index 000000000000..fa0ba0d55503 + rq->active_balance = 0; + /* _something_ may have changed the task, double check again */ + if (task_on_rq_queued(p) && task_rq(p) == rq && -+ (dcpu = sched_cpumask_first_and(p->cpus_ptr, &sched_sg_idle_mask)) < -+ nr_cpu_ids) ++ cpumask_and(&tmp, p->cpus_ptr, &sched_sg_idle_mask)) { ++ int cpu = cpu_of(rq); ++ int dcpu = __best_mask_cpu(cpu, &tmp, ++ per_cpu(sched_cpu_llc_mask, cpu)); + rq = move_queued_task(rq, p, dcpu); ++ } + + raw_spin_unlock(&rq->lock); + raw_spin_unlock(&p->pi_lock); @@ -4406,7 +4355,7 @@ index 000000000000..fa0ba0d55503 + if (cpumask_empty(&sched_rq_pending_mask)) + return 0; + -+ affinity_mask = per_cpu(sched_cpu_affinity_masks, cpu); ++ affinity_mask = &(per_cpu(sched_cpu_affinity_masks, cpu)[0]); + end_mask = per_cpu(sched_cpu_affinity_end_mask, cpu); + do { + int i; @@ -6749,18 +6698,16 @@ index 000000000000..fa0ba0d55503 + cpumask_t *tmp; + + for_each_possible_cpu(cpu) { -+ for (level = 0; level < NR_CPU_AFFINITY_CHK_LEVEL; level++) { ++ for (level = 0; level < NR_CPU_AFFINITY_LEVELS; level++) { + tmp = &(per_cpu(sched_cpu_affinity_masks, cpu)[level]); + cpumask_copy(tmp, cpu_possible_mask); + cpumask_clear_cpu(cpu, tmp); + } ++ per_cpu(sched_cpu_llc_mask, cpu) = ++ &(per_cpu(sched_cpu_affinity_masks, cpu)[0]); + per_cpu(sched_cpu_affinity_end_mask, cpu) = + &(per_cpu(sched_cpu_affinity_masks, cpu)[1]); + /*per_cpu(sd_llc_id, cpu) = cpu;*/ -+ -+ for (level = 0; level < NR_BEST_CPU_MASK; level++) -+ cpumask_copy(&sched_best_cpu_masks[cpu][level], -+ cpu_possible_mask); + } +} + @@ -6782,11 +6729,14 @@ index 000000000000..fa0ba0d55503 + + chk = &(per_cpu(sched_cpu_affinity_masks, cpu)[0]); + ++ cpumask_copy(chk++, cpumask_of(cpu)); ++ + cpumask_complement(chk, cpumask_of(cpu)); +#ifdef CONFIG_SCHED_SMT + TOPOLOGY_CPUMASK(smt, topology_sibling_cpumask(cpu), false); +#endif + per_cpu(sd_llc_id, cpu) = cpumask_first(cpu_coregroup_mask(cpu)); ++ per_cpu(sched_cpu_llc_mask, cpu) = chk; + TOPOLOGY_CPUMASK(coregroup, cpu_coregroup_mask(cpu), false); + + TOPOLOGY_CPUMASK(core, topology_core_cpumask(cpu), false); @@ -6794,11 +6744,10 @@ index 000000000000..fa0ba0d55503 + TOPOLOGY_CPUMASK(others, cpu_online_mask, true); + + per_cpu(sched_cpu_affinity_end_mask, cpu) = chk; -+ printk(KERN_INFO "sched: cpu#%02d llc_id = %d\n", -+ cpu, per_cpu(sd_llc_id, cpu)); -+ -+ cpumask_copy(sched_best_cpu_masks[cpu], -+ cpu_coregroup_mask(cpu)); ++ printk(KERN_INFO "sched: cpu#%02d llc_id = %d, llc_mask idx = %d\n", ++ cpu, per_cpu(sd_llc_id, cpu), ++ (int) (per_cpu(sched_cpu_llc_mask, cpu) - ++ &(per_cpu(sched_cpu_affinity_masks, cpu)[0]))); + } +} +#endif @@ -7288,10 +7237,10 @@ index 000000000000..1212a031700e +{} diff --git a/kernel/sched/alt_sched.h b/kernel/sched/alt_sched.h new file mode 100644 -index 000000000000..fee65eeb1405 +index 000000000000..4698d6d16a2d --- /dev/null +++ b/kernel/sched/alt_sched.h -@@ -0,0 +1,545 @@ +@@ -0,0 +1,572 @@ +#ifndef ALT_SCHED_H +#define ALT_SCHED_H + @@ -7507,17 +7456,44 @@ index 000000000000..fee65eeb1405 +extern bool sched_smp_initialized; + +enum { -+ BASE_CPU_AFFINITY_CHK_LEVEL = 1, ++ ITSELF_LEVEL_SPACE_HOLDER, +#ifdef CONFIG_SCHED_SMT -+ SMT_CPU_AFFINITY_CHK_LEVEL_SPACE_HOLDER, ++ SMT_LEVEL_SPACE_HOLDER, +#endif -+#ifdef CONFIG_SCHED_MC -+ MC_CPU_AFFINITY_CHK_LEVEL_SPACE_HOLDER, -+#endif -+ NR_CPU_AFFINITY_CHK_LEVEL ++ COREGROUP_LEVEL_SPACE_HOLDER, ++ CORE_LEVEL_SPACE_HOLDER, ++ OTHER_LEVEL_SPACE_HOLDER, ++ NR_CPU_AFFINITY_LEVELS +}; + -+DECLARE_PER_CPU(cpumask_t [NR_CPU_AFFINITY_CHK_LEVEL], sched_cpu_affinity_masks); ++DECLARE_PER_CPU(cpumask_t [NR_CPU_AFFINITY_LEVELS], sched_cpu_affinity_masks); ++ ++static inline int __best_mask_cpu(int cpu, const cpumask_t *cpumask, ++ const cpumask_t *mask) ++{ ++#if NR_CPUS <= 64 ++ unsigned long t; ++ ++ while ((t = cpumask->bits[0] & mask->bits[0]) == 0UL) ++ mask++; ++ ++ return __ffs(t); ++#else ++ while ((cpu = cpumask_any_and(cpumask, mask)) >= nr_cpu_ids) ++ mask++; ++ return cpu; ++#endif ++} ++ ++static inline int best_mask_cpu(int cpu, const cpumask_t *cpumask) ++{ ++#if NR_CPUS <= 64 ++ return __best_mask_cpu(cpu, cpumask, per_cpu(sched_cpu_affinity_masks, cpu)); ++#else ++ return cpumask_test_cpu(cpu, cpumask) ? cpu: ++ __best_mask_cpu(cpu, cpumask, per_cpu(sched_cpu_affinity_masks, cpu) + 1); ++#endif ++} + +extern void flush_smp_call_function_from_idle(void); + @@ -8205,10 +8181,10 @@ index 000000000000..7fdeace7e8a5 +#endif diff --git a/kernel/sched/pds_imp.h b/kernel/sched/pds_imp.h new file mode 100644 -index 000000000000..e1f98a83cfcb +index 000000000000..bd3b84cbafa7 --- /dev/null +++ b/kernel/sched/pds_imp.h -@@ -0,0 +1,257 @@ +@@ -0,0 +1,252 @@ +#define ALT_SCHED_VERSION_MSG "sched/pds: PDS CPU Scheduler "ALT_SCHED_VERSION" by Alfred Chen.\n" + +static const u64 user_prio2deadline[NICE_WIDTH] = { @@ -8379,22 +8355,17 @@ index 000000000000..e1f98a83cfcb + +static inline bool sched_task_need_requeue(struct task_struct *p, struct rq *rq) +{ -+ struct skiplist_node *node = p->sl_node.prev[0]; ++ struct skiplist_node *node; + -+ if (node != &rq->sl_header) { -+ struct task_struct *t = skiplist_entry(node, struct task_struct, sl_node); -+ -+ if (t->priodl > p->priodl) -+ return true; -+ } ++ node = p->sl_node.prev[0]; ++ if (node != &rq->sl_header && ++ skiplist_entry(node, struct task_struct, sl_node)->priodl > p->priodl) ++ return true; + + node = p->sl_node.next[0]; -+ if (node != &rq->sl_header) { -+ struct task_struct *t = skiplist_entry(node, struct task_struct, sl_node); -+ -+ if (t->priodl < p->priodl) -+ return true; -+ } ++ if (node != &rq->sl_header && ++ skiplist_entry(node, struct task_struct, sl_node)->priodl < p->priodl) ++ return true; + + return false; +} @@ -8595,7 +8566,7 @@ index 750fb3c67eed..108422ebc7bf 100644 } return 0; diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c -index 1bd7e3af904f..bbd96ce88008 100644 +index 1bd7e3af904f..cc946a9bd550 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -4,6 +4,7 @@ @@ -8633,7 +8604,7 @@ index 1bd7e3af904f..bbd96ce88008 100644 #ifdef CONFIG_NUMA static const struct cpumask *sd_numa_mask(int cpu) -@@ -2316,3 +2321,25 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], +@@ -2316,3 +2321,17 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], partition_sched_domains_locked(ndoms_new, doms_new, dattr_new); mutex_unlock(&sched_domains_mutex); } @@ -8647,15 +8618,7 @@ index 1bd7e3af904f..bbd96ce88008 100644 + +int sched_numa_find_closest(const struct cpumask *cpus, int cpu) +{ -+ const cpumask_t *mask; -+ -+ if (cpumask_test_cpu(cpu, cpus)) -+ return cpu; -+ -+ mask = per_cpu(sched_cpu_affinity_masks, cpu); -+ while ((cpu = cpumask_any_and(cpus, mask)) >= nr_cpu_ids) -+ mask++; -+ return cpu; ++ return best_mask_cpu(cpu, cpus); +} +#endif /* CONFIG_NUMA */ +#endif @@ -8812,16 +8775,3 @@ index b5e3496cf803..65f60c77bc50 100644 }; struct wakeup_test_data *x = data; -diff --git a/kernel/sched/alt_core.c b/kernel/sched/alt_core.c -index fa0ba0d55503ba7116fc4e2ec870e2b7e27517b5..edba089affc00bf5e84652d3e6f6004e5294b197 100644 ---- a/kernel/sched/alt_core.c -+++ b/kernel/sched/alt_core.c -@@ -153,7 +153,7 @@ static inline unsigned int sched_best_cpu(const unsigned int cpu, - while (!cpumask_and(&t, chk, m)) - chk++; - -- return cpumask_any(t); -+ return cpumask_any(&t); - } - #endif -