diff options
Diffstat (limited to 'SOURCES/cachy-bore.patch')
-rw-r--r-- | SOURCES/cachy-bore.patch | 178 |
1 files changed, 113 insertions, 65 deletions
diff --git a/SOURCES/cachy-bore.patch b/SOURCES/cachy-bore.patch index c321203..7421807 100644 --- a/SOURCES/cachy-bore.patch +++ b/SOURCES/cachy-bore.patch @@ -1,22 +1,21 @@ -From 699662da34346e7dfea9523fb4ae2b18287f527c Mon Sep 17 00:00:00 2001 -From: Piotr Gorski <lucjan.lucjanov@gmail.com> -Date: Thu, 4 Jul 2024 21:28:26 +0200 +From 3816495f5635104fae1dda21b743f750c2914196 Mon Sep 17 00:00:00 2001 +From: Eric Naim <dnaim@proton.me> +Date: Sat, 3 Aug 2024 15:23:30 +0700 Subject: [PATCH] bore -Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com> --- include/linux/sched.h | 10 ++ init/Kconfig | 17 +++ - kernel/Kconfig.hz | 16 +++ - kernel/sched/core.c | 143 +++++++++++++++++++++ - kernel/sched/debug.c | 60 ++++++++- - kernel/sched/fair.c | 275 +++++++++++++++++++++++++++++++++++++--- - kernel/sched/features.h | 28 +++- + kernel/Kconfig.hz | 16 ++ + kernel/sched/core.c | 143 ++++++++++++++++++ + kernel/sched/debug.c | 60 +++++++- + kernel/sched/fair.c | 322 ++++++++++++++++++++++++++++++++++++++-- + kernel/sched/features.h | 22 ++- kernel/sched/sched.h | 7 + - 8 files changed, 538 insertions(+), 18 deletions(-) + 8 files changed, 583 insertions(+), 14 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h -index 3c2abbc58..e7bf3a034 100644 +index 76214d7c8..9f65d367b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -547,6 +547,16 @@ struct sched_entity { @@ -37,10 +36,10 @@ index 3c2abbc58..e7bf3a034 100644 u64 slice; diff --git a/init/Kconfig b/init/Kconfig -index 459f44ef7..17385c859 100644 +index febdea2af..171b5d995 100644 --- a/init/Kconfig +++ b/init/Kconfig -@@ -1279,6 +1279,23 @@ config CHECKPOINT_RESTORE +@@ -1283,6 +1283,23 @@ config CHECKPOINT_RESTORE If unsure, say N here. @@ -91,10 +90,10 @@ index 38ef6d068..5f6eecd1e 100644 config SCHED_HRTICK def_bool HIGH_RES_TIMERS diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index d211d40a2..b6b2aa707 100644 +index ebf21373f..5d1c97612 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -4516,6 +4516,138 @@ int wake_up_state(struct task_struct *p, unsigned int state) +@@ -4512,6 +4512,138 @@ int wake_up_state(struct task_struct *p, unsigned int state) return try_to_wake_up(p, state, 0); } @@ -233,7 +232,7 @@ index d211d40a2..b6b2aa707 100644 /* * Perform scheduler related setup for a newly forked process p. * p is forked by current. -@@ -4532,6 +4664,9 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p) +@@ -4528,6 +4660,9 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p) p->se.prev_sum_exec_runtime = 0; p->se.nr_migrations = 0; p->se.vruntime = 0; @@ -243,7 +242,7 @@ index d211d40a2..b6b2aa707 100644 p->se.vlag = 0; p->se.slice = sysctl_sched_base_slice; INIT_LIST_HEAD(&p->se.group_node); -@@ -4848,6 +4983,9 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs) +@@ -4843,6 +4978,9 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs) void sched_post_fork(struct task_struct *p) { @@ -253,20 +252,20 @@ index d211d40a2..b6b2aa707 100644 uclamp_post_fork(p); } -@@ -9931,6 +10069,11 @@ void __init sched_init(void) +@@ -9930,6 +10068,11 @@ void __init sched_init(void) BUG_ON(&dl_sched_class != &stop_sched_class + 1); #endif +#ifdef CONFIG_SCHED_BORE + sched_init_bore(); -+ printk(KERN_INFO "BORE (Burst-Oriented Response Enhancer) CPU Scheduler modification 5.2.4 by Masahito Suzuki"); ++ printk(KERN_INFO "BORE (Burst-Oriented Response Enhancer) CPU Scheduler modification 5.2.8 by Masahito Suzuki"); +#endif // CONFIG_SCHED_BORE + wait_bit_init(); #ifdef CONFIG_FAIR_GROUP_SCHED diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c -index 8d5d98a58..b17861261 100644 +index c1eb9a1af..e2da8d773 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -167,7 +167,52 @@ static const struct file_operations sched_feat_fops = { @@ -352,7 +351,7 @@ index 8d5d98a58..b17861261 100644 debugfs_create_u32("migration_cost_ns", 0644, debugfs_sched, &sysctl_sched_migration_cost); debugfs_create_u32("nr_migrate", 0644, debugfs_sched, &sysctl_sched_nr_migrate); -@@ -595,6 +647,9 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) +@@ -596,6 +648,9 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) SPLIT_NS(schedstat_val_or_zero(p->stats.sum_sleep_runtime)), SPLIT_NS(schedstat_val_or_zero(p->stats.sum_block_runtime))); @@ -362,7 +361,7 @@ index 8d5d98a58..b17861261 100644 #ifdef CONFIG_NUMA_BALANCING SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p)); #endif -@@ -1068,6 +1123,9 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, +@@ -1069,6 +1124,9 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, P(se.load.weight); #ifdef CONFIG_SMP @@ -373,7 +372,7 @@ index 8d5d98a58..b17861261 100644 P(se.avg.runnable_sum); P(se.avg.util_sum); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index 213c94d02..6dffa3419 100644 +index 483c137b9..4c8d7fbd5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -19,6 +19,9 @@ @@ -386,7 +385,7 @@ index 213c94d02..6dffa3419 100644 */ #include <linux/energy_model.h> #include <linux/mmap_lock.h> -@@ -64,20 +67,125 @@ +@@ -64,20 +67,146 @@ * SCHED_TUNABLESCALING_LOG - scaled logarithmical, *1+ilog(ncpus) * SCHED_TUNABLESCALING_LINEAR - scaled linear, *ncpus * @@ -420,12 +419,17 @@ index 213c94d02..6dffa3419 100644 +#ifdef CONFIG_SCHED_BORE +u8 __read_mostly sched_bore = 1; ++u8 __read_mostly sched_burst_exclude_kthreads = 1; +u8 __read_mostly sched_burst_smoothness_long = 1; +u8 __read_mostly sched_burst_smoothness_short = 0; +u8 __read_mostly sched_burst_fork_atavistic = 2; +u8 __read_mostly sched_burst_penalty_offset = 22; +uint __read_mostly sched_burst_penalty_scale = 1280; +uint __read_mostly sched_burst_cache_lifetime = 60000000; ++uint __read_mostly sched_deadline_boost_mask = ENQUEUE_INITIAL ++ | ENQUEUE_WAKEUP; ++uint __read_mostly sched_deadline_preserve_mask = ENQUEUE_RESTORE ++ | ENQUEUE_MIGRATED; +static int __maybe_unused sixty_four = 64; +static int __maybe_unused maxval_12_bits = 4095; + @@ -461,7 +465,19 @@ index 213c94d02..6dffa3419 100644 + return __unscale_slice(delta, se->burst_score); +} + -+void reweight_task(struct task_struct *p, int prio); ++static void reweight_entity( ++ struct cfs_rq *cfs_rq, struct sched_entity *se, unsigned long weight); ++ ++static void renice_task(struct task_struct *p, int prio) ++{ ++ struct sched_entity *se = &p->se; ++ struct cfs_rq *cfs_rq = cfs_rq_of(se); ++ struct load_weight *load = &se->load; ++ unsigned long weight = scale_load(sched_prio_to_weight[prio]); ++ ++ reweight_entity(cfs_rq, se, weight); ++ load->inv_weight = sched_prio_to_wmult[prio]; ++} + +static void update_burst_score(struct sched_entity *se) { + if (!entity_is_task(se)) return; @@ -469,11 +485,15 @@ index 213c94d02..6dffa3419 100644 + u8 prio = p->static_prio - MAX_RT_PRIO; + u8 prev_prio = min(39, prio + se->burst_score); + -+ se->burst_score = se->burst_penalty >> 2; ++ u8 burst_score = 0; ++ if (!(sched_burst_exclude_kthreads && (p->flags & PF_KTHREAD))) ++ burst_score = se->burst_penalty >> 2; ++ ++ se->burst_score = burst_score; + + u8 new_prio = min(39, prio + se->burst_score); + if (new_prio != prev_prio) -+ reweight_task(p, new_prio); ++ renice_task(p, new_prio); +} + +static void update_burst_penalty(struct sched_entity *se) { @@ -511,10 +531,10 @@ index 213c94d02..6dffa3419 100644 +} +#endif // CONFIG_SCHED_BORE + - int sched_thermal_decay_shift; static int __init setup_sched_thermal_decay_shift(char *str) { -@@ -137,6 +245,69 @@ static unsigned int sysctl_numa_balancing_promote_rate_limit = 65536; + pr_warn("Ignoring the deprecated sched_thermal_decay_shift= option\n"); +@@ -131,6 +260,92 @@ static unsigned int sysctl_numa_balancing_promote_rate_limit = 65536; #ifdef CONFIG_SYSCTL static struct ctl_table sched_fair_sysctls[] = { @@ -529,6 +549,15 @@ index 213c94d02..6dffa3419 100644 + .extra2 = SYSCTL_ONE, + }, + { ++ .procname = "sched_burst_exclude_kthreads", ++ .data = &sched_burst_exclude_kthreads, ++ .maxlen = sizeof(u8), ++ .mode = 0644, ++ .proc_handler = proc_dou8vec_minmax, ++ .extra1 = SYSCTL_ZERO, ++ .extra2 = SYSCTL_ONE, ++ }, ++ { + .procname = "sched_burst_smoothness_long", + .data = &sched_burst_smoothness_long, + .maxlen = sizeof(u8), @@ -580,11 +609,25 @@ index 213c94d02..6dffa3419 100644 + .mode = 0644, + .proc_handler = proc_douintvec, + }, ++ { ++ .procname = "sched_deadline_boost_mask", ++ .data = &sched_deadline_boost_mask, ++ .maxlen = sizeof(uint), ++ .mode = 0644, ++ .proc_handler = proc_douintvec, ++ }, ++ { ++ .procname = "sched_deadline_preserve_mask", ++ .data = &sched_deadline_preserve_mask, ++ .maxlen = sizeof(uint), ++ .mode = 0644, ++ .proc_handler = proc_douintvec, ++ }, +#endif // CONFIG_SCHED_BORE #ifdef CONFIG_CFS_BANDWIDTH { .procname = "sched_cfs_bandwidth_slice_us", -@@ -195,6 +366,13 @@ static inline void update_load_set(struct load_weight *lw, unsigned long w) +@@ -188,6 +403,13 @@ static inline void update_load_set(struct load_weight *lw, unsigned long w) * * This idea comes from the SD scheduler of Con Kolivas: */ @@ -598,7 +641,7 @@ index 213c94d02..6dffa3419 100644 static unsigned int get_update_sysctl_factor(void) { unsigned int cpus = min_t(unsigned int, num_online_cpus(), 8); -@@ -225,6 +403,7 @@ static void update_sysctl(void) +@@ -218,6 +440,7 @@ static void update_sysctl(void) SET_SYSCTL(sched_base_slice); #undef SET_SYSCTL } @@ -606,7 +649,7 @@ index 213c94d02..6dffa3419 100644 void __init sched_init_granularity(void) { -@@ -702,6 +881,9 @@ static s64 entity_lag(u64 avruntime, struct sched_entity *se) +@@ -695,6 +918,9 @@ static s64 entity_lag(u64 avruntime, struct sched_entity *se) vlag = avruntime - se->vruntime; limit = calc_delta_fair(max_t(u64, 2*se->slice, TICK_NSEC), se); @@ -616,7 +659,7 @@ index 213c94d02..6dffa3419 100644 return clamp(vlag, -limit, limit); } -@@ -862,6 +1044,39 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq) +@@ -855,6 +1081,39 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq) return __node_2_se(left); } @@ -656,7 +699,7 @@ index 213c94d02..6dffa3419 100644 /* * Earliest Eligible Virtual Deadline First * -@@ -881,28 +1096,27 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq) +@@ -874,28 +1133,27 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq) * * Which allows tree pruning through eligibility. */ @@ -692,7 +735,7 @@ index 213c94d02..6dffa3419 100644 return curr; /* Pick the leftmost entity if it's eligible */ -@@ -961,6 +1175,7 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) +@@ -954,6 +1212,7 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) * Scheduling class statistics methods: */ #ifdef CONFIG_SMP @@ -700,7 +743,7 @@ index 213c94d02..6dffa3419 100644 int sched_update_scaling(void) { unsigned int factor = get_update_sysctl_factor(); -@@ -972,6 +1187,7 @@ int sched_update_scaling(void) +@@ -965,6 +1224,7 @@ int sched_update_scaling(void) return 0; } @@ -708,7 +751,7 @@ index 213c94d02..6dffa3419 100644 #endif #endif -@@ -1171,7 +1387,13 @@ static void update_curr(struct cfs_rq *cfs_rq) +@@ -1165,7 +1425,13 @@ static void update_curr(struct cfs_rq *cfs_rq) if (unlikely(delta_exec <= 0)) return; @@ -722,7 +765,19 @@ index 213c94d02..6dffa3419 100644 update_deadline(cfs_rq, curr); update_min_vruntime(cfs_rq); -@@ -5183,6 +5405,9 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) +@@ -5179,6 +5445,11 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) + s64 lag = 0; + + se->slice = sysctl_sched_base_slice; ++#ifdef CONFIG_SCHED_BORE ++ if (flags & ~sched_deadline_boost_mask & sched_deadline_preserve_mask) ++ vslice = se->deadline - se->vruntime; ++ else ++#endif // CONFIG_SCHED_BORE + vslice = calc_delta_fair(se->slice, se); + + /* +@@ -5189,6 +5460,9 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) * * EEVDF: placement strategy #1 / #2 */ @@ -732,17 +787,19 @@ index 213c94d02..6dffa3419 100644 if (sched_feat(PLACE_LAG) && cfs_rq->nr_running) { struct sched_entity *curr = cfs_rq->curr; unsigned long load; -@@ -5258,7 +5483,8 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) +@@ -5264,7 +5538,11 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) * on average, halfway through their slice, as such start tasks * off with half a slice to ease into the competition. */ -- if (sched_feat(PLACE_DEADLINE_INITIAL) && (flags & ENQUEUE_INITIAL)) -+ if ((sched_feat(PLACE_DEADLINE_INITIAL) && (flags & ENQUEUE_INITIAL)) || -+ (sched_feat(PLACE_DEADLINE_WAKEUP) && (flags & ENQUEUE_WAKEUP))) ++#if !defined(CONFIG_SCHED_BORE) + if (sched_feat(PLACE_DEADLINE_INITIAL) && (flags & ENQUEUE_INITIAL)) ++#else // CONFIG_SCHED_BORE ++ if (flags & sched_deadline_boost_mask) ++#endif // CONFIG_SCHED_BORE vslice /= 2; /* -@@ -5472,7 +5698,7 @@ pick_next_entity(struct cfs_rq *cfs_rq) +@@ -5478,7 +5756,7 @@ pick_next_entity(struct cfs_rq *cfs_rq) cfs_rq->next && entity_eligible(cfs_rq, cfs_rq->next)) return cfs_rq->next; @@ -751,7 +808,7 @@ index 213c94d02..6dffa3419 100644 } static bool check_cfs_rq_runtime(struct cfs_rq *cfs_rq); -@@ -6835,6 +7061,14 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) +@@ -6846,6 +7124,14 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) bool was_sched_idle = sched_idle_rq(rq); util_est_dequeue(&rq->cfs, p); @@ -766,19 +823,16 @@ index 213c94d02..6dffa3419 100644 for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); -@@ -8369,10 +8603,7 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int - cfs_rq = cfs_rq_of(se); - update_curr(cfs_rq); - -- /* -- * XXX pick_eevdf(cfs_rq) != se ? -- */ +@@ -8414,7 +8700,7 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int + /* + * XXX pick_eevdf(cfs_rq) != se ? + */ - if (pick_eevdf(cfs_rq) == pse) + if (pick_eevdf(cfs_rq, pse) == pse) goto preempt; return; -@@ -8590,16 +8821,25 @@ static void yield_task_fair(struct rq *rq) +@@ -8632,16 +8918,25 @@ static void yield_task_fair(struct rq *rq) /* * Are we the only task in the tree? */ @@ -804,7 +858,7 @@ index 213c94d02..6dffa3419 100644 /* * Tell update_rq_clock() that we've just updated, * so we don't do microscopic update in schedule() -@@ -12660,6 +12900,9 @@ static void task_fork_fair(struct task_struct *p) +@@ -12709,6 +13004,9 @@ static void task_fork_fair(struct task_struct *p) curr = cfs_rq->curr; if (curr) update_curr(cfs_rq); @@ -815,25 +869,19 @@ index 213c94d02..6dffa3419 100644 rq_unlock(rq, &rf); } diff --git a/kernel/sched/features.h b/kernel/sched/features.h -index 143f55df8..9ad25e4e7 100644 +index 143f55df8..3aad8900c 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h -@@ -5,8 +5,34 @@ +@@ -5,8 +5,28 @@ * sleep+wake cycles. EEVDF placement strategy #1, #2 if disabled. */ SCHED_FEAT(PLACE_LAG, true) +/* + * Give new tasks half a slice to ease into the competition. + */ ++#if !defined(CONFIG_SCHED_BORE) SCHED_FEAT(PLACE_DEADLINE_INITIAL, true) -SCHED_FEAT(RUN_TO_PARITY, true) -+/* -+ * Give waken tasks half a slice to ease into the competition. -+ */ -+#ifdef CONFIG_SCHED_BORE -+SCHED_FEAT(PLACE_DEADLINE_WAKEUP, true) -+#else // !CONFIG_SCHED_BORE -+SCHED_FEAT(PLACE_DEADLINE_WAKEUP, false) +#endif // CONFIG_SCHED_BORE +/* + * Inhibit (wakeup) preemption until the current task has exhausted its slice. @@ -855,10 +903,10 @@ index 143f55df8..9ad25e4e7 100644 /* * Prefer to schedule the task we woke last (assuming it failed diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h -index ae50f2127..8c976d27f 100644 +index 38aeedd8a..aa0ae3fb9 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h -@@ -1967,7 +1967,11 @@ static inline void dirty_sched_domain_sysctl(int cpu) +@@ -1969,7 +1969,11 @@ static inline void dirty_sched_domain_sysctl(int cpu) } #endif @@ -881,5 +929,5 @@ index ae50f2127..8c976d27f 100644 #ifdef CONFIG_SCHED_DEBUG extern int sysctl_resched_latency_warn_ms; -- -2.45.2.606.g9005149a4a +2.46.0 |