aboutsummaryrefslogtreecommitdiff
path: root/SOURCES/cachy-bore.patch
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2024-05-04 16:09:57 +0200
committerJan200101 <sentrycraft123@gmail.com>2024-05-04 16:09:57 +0200
commit8d155e9c8872d1ed636a154fe6e60c859215fbed (patch)
treeed5eea5d6fdb12c164c4575c65982da83eaf2621 /SOURCES/cachy-bore.patch
parent4fc30561591a268fc993f3f56cd5c5043d1c1eac (diff)
downloadkernel-fsync-8d155e9c8872d1ed636a154fe6e60c859215fbed.tar.gz
kernel-fsync-8d155e9c8872d1ed636a154fe6e60c859215fbed.zip
kernel 6.8.9
Diffstat (limited to 'SOURCES/cachy-bore.patch')
-rw-r--r--SOURCES/cachy-bore.patch191
1 files changed, 151 insertions, 40 deletions
diff --git a/SOURCES/cachy-bore.patch b/SOURCES/cachy-bore.patch
index 711ded8..4437383 100644
--- a/SOURCES/cachy-bore.patch
+++ b/SOURCES/cachy-bore.patch
@@ -1,18 +1,18 @@
-From c75c12077f2f8dfa7c763f434f746727b8a3b9e6 Mon Sep 17 00:00:00 2001
+From eadef3d0f478dc82de92a71a2a5c9cd1874ea4e8 Mon Sep 17 00:00:00 2001
From: Piotr Gorski <lucjan.lucjanov@gmail.com>
-Date: Tue, 26 Mar 2024 08:10:41 +0100
+Date: Mon, 29 Apr 2024 21:26:00 +0200
Subject: [PATCH] bore
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
---
include/linux/sched.h | 10 ++
- init/Kconfig | 17 ++++
- kernel/sched/core.c | 144 ++++++++++++++++++++++++++
- kernel/sched/debug.c | 60 ++++++++++-
- kernel/sched/fair.c | 218 +++++++++++++++++++++++++++++++++++++++-
- kernel/sched/features.h | 4 +
+ init/Kconfig | 17 +++
+ kernel/sched/core.c | 143 +++++++++++++++++++++
+ kernel/sched/debug.c | 60 ++++++++-
+ kernel/sched/fair.c | 272 +++++++++++++++++++++++++++++++++++++---
+ kernel/sched/features.h | 20 ++-
kernel/sched/sched.h | 7 ++
- 7 files changed, 457 insertions(+), 3 deletions(-)
+ 7 files changed, 512 insertions(+), 17 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ffe8f618a..0ab0b0424 100644
@@ -36,7 +36,7 @@ index ffe8f618a..0ab0b0424 100644
u64 slice;
diff --git a/init/Kconfig b/init/Kconfig
-index bee58f746..13427dbb4 100644
+index c8a155cf7..874bd0158 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1279,6 +1279,23 @@ config CHECKPOINT_RESTORE
@@ -64,15 +64,14 @@ index bee58f746..13427dbb4 100644
bool "Automatic process group scheduling"
select CGROUPS
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 9116bcc90..fc3d7b48e 100644
+index 9116bcc90..a38919fe8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -4507,6 +4507,139 @@ int wake_up_state(struct task_struct *p, unsigned int state)
+@@ -4507,6 +4507,138 @@ int wake_up_state(struct task_struct *p, unsigned int state)
return try_to_wake_up(p, state, 0);
}
+#ifdef CONFIG_SCHED_BORE
-+extern bool sched_bore;
+extern u8 sched_burst_fork_atavistic;
+extern uint sched_burst_cache_lifetime;
+
@@ -207,7 +206,7 @@ index 9116bcc90..fc3d7b48e 100644
/*
* Perform scheduler related setup for a newly forked process p.
* p is forked by current.
-@@ -4523,6 +4656,9 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
+@@ -4523,6 +4655,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;
@@ -217,7 +216,7 @@ index 9116bcc90..fc3d7b48e 100644
p->se.vlag = 0;
p->se.slice = sysctl_sched_base_slice;
INIT_LIST_HEAD(&p->se.group_node);
-@@ -4839,6 +4975,9 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs)
+@@ -4839,6 +4974,9 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs)
void sched_post_fork(struct task_struct *p)
{
@@ -227,13 +226,13 @@ index 9116bcc90..fc3d7b48e 100644
uclamp_post_fork(p);
}
-@@ -9910,6 +10049,11 @@ void __init sched_init(void)
+@@ -9910,6 +10048,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.0.3 by Masahito Suzuki");
++ printk(KERN_INFO "BORE (Burst-Oriented Response Enhancer) CPU Scheduler modification 5.2.0 by Masahito Suzuki");
+#endif // CONFIG_SCHED_BORE
+
wait_bit_init();
@@ -347,7 +346,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 533547e3c..ae55f46a8 100644
+index aee5e7a70..d6824d030 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -19,6 +19,9 @@
@@ -360,7 +359,7 @@ index 533547e3c..ae55f46a8 100644
*/
#include <linux/energy_model.h>
#include <linux/mmap_lock.h>
-@@ -64,20 +67,126 @@
+@@ -64,20 +67,125 @@
* SCHED_TUNABLESCALING_LOG - scaled logarithmical, *1+ilog(ncpus)
* SCHED_TUNABLESCALING_LINEAR - scaled linear, *ncpus
*
@@ -400,7 +399,6 @@ index 533547e3c..ae55f46a8 100644
+u8 __read_mostly sched_burst_penalty_offset = 22;
+uint __read_mostly sched_burst_penalty_scale = 1280;
+uint __read_mostly sched_burst_cache_lifetime = 60000000;
-+static int __maybe_unused thirty_two = 32;
+static int __maybe_unused sixty_four = 64;
+static int __maybe_unused maxval_12_bits = 4095;
+
@@ -489,7 +487,7 @@ index 533547e3c..ae55f46a8 100644
int sched_thermal_decay_shift;
static int __init setup_sched_thermal_decay_shift(char *str)
{
-@@ -137,6 +246,69 @@ static unsigned int sysctl_numa_balancing_promote_rate_limit = 65536;
+@@ -137,6 +245,69 @@ static unsigned int sysctl_numa_balancing_promote_rate_limit = 65536;
#ifdef CONFIG_SYSCTL
static struct ctl_table sched_fair_sysctls[] = {
@@ -559,7 +557,7 @@ index 533547e3c..ae55f46a8 100644
#ifdef CONFIG_CFS_BANDWIDTH
{
.procname = "sched_cfs_bandwidth_slice_us",
-@@ -195,6 +367,13 @@ static inline void update_load_set(struct load_weight *lw, unsigned long w)
+@@ -195,6 +366,13 @@ static inline void update_load_set(struct load_weight *lw, unsigned long w)
*
* This idea comes from the SD scheduler of Con Kolivas:
*/
@@ -573,7 +571,7 @@ index 533547e3c..ae55f46a8 100644
static unsigned int get_update_sysctl_factor(void)
{
unsigned int cpus = min_t(unsigned int, num_online_cpus(), 8);
-@@ -225,6 +404,7 @@ static void update_sysctl(void)
+@@ -225,6 +403,7 @@ static void update_sysctl(void)
SET_SYSCTL(sched_base_slice);
#undef SET_SYSCTL
}
@@ -581,17 +579,93 @@ index 533547e3c..ae55f46a8 100644
void __init sched_init_granularity(void)
{
-@@ -704,6 +884,9 @@ static void update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
- lag = avg_vruntime(cfs_rq) - se->vruntime;
+@@ -702,6 +881,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);
+#ifdef CONFIG_SCHED_BORE
+ limit >>= 1;
+#endif // CONFIG_SCHED_BORE
- se->vlag = clamp(lag, -limit, limit);
+
+ return clamp(vlag, -limit, limit);
+ }
+@@ -862,6 +1044,39 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
+ return __node_2_se(left);
}
-@@ -955,6 +1138,7 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
++static inline bool pick_curr(struct cfs_rq *cfs_rq,
++ struct sched_entity *curr, struct sched_entity *wakee)
++{
++ /*
++ * Nothing to preserve...
++ */
++ if (!curr || !sched_feat(RESPECT_SLICE))
++ return false;
++
++ /*
++ * Allow preemption at the 0-lag point -- even if not all of the slice
++ * is consumed. Note: placement of positive lag can push V left and render
++ * @curr instantly ineligible irrespective the time on-cpu.
++ */
++ if (sched_feat(RUN_TO_PARITY) && !entity_eligible(cfs_rq, curr))
++ return false;
++
++ /*
++ * Don't preserve @curr when the @wakee has a shorter slice and earlier
++ * deadline. IOW, explicitly allow preemption.
++ */
++ if (sched_feat(PREEMPT_SHORT) && wakee &&
++ wakee->slice < curr->slice &&
++ (s64)(wakee->deadline - curr->deadline) < 0)
++ return false;
++
++ /*
++ * Preserve @curr to allow it to finish its first slice.
++ * See the HACK in set_next_entity().
++ */
++ return curr->vlag == curr->deadline;
++}
++
+ /*
+ * Earliest Eligible Virtual Deadline First
+ *
+@@ -881,28 +1096,27 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
+ *
+ * Which allows tree pruning through eligibility.
+ */
+-static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
++static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *wakee)
+ {
+ struct rb_node *node = cfs_rq->tasks_timeline.rb_root.rb_node;
+ struct sched_entity *se = __pick_first_entity(cfs_rq);
+ struct sched_entity *curr = cfs_rq->curr;
+ struct sched_entity *best = NULL;
+
++ if (curr && !curr->on_rq)
++ curr = NULL;
++
+ /*
+ * We can safely skip eligibility check if there is only one entity
+ * in this cfs_rq, saving some cycles.
+ */
+ if (cfs_rq->nr_running == 1)
+- return curr && curr->on_rq ? curr : se;
+-
+- if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr)))
+- curr = NULL;
++ return curr ?: se;
+
+ /*
+- * Once selected, run a task until it either becomes non-eligible or
+- * until it gets a new slice. See the HACK in set_next_entity().
++ * Preserve @curr to let it finish its slice.
+ */
+- if (sched_feat(RUN_TO_PARITY) && curr && curr->vlag == curr->deadline)
++ if (pick_curr(cfs_rq, curr, wakee))
+ 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)
* Scheduling class statistics methods:
*/
#ifdef CONFIG_SMP
@@ -599,7 +673,7 @@ index 533547e3c..ae55f46a8 100644
int sched_update_scaling(void)
{
unsigned int factor = get_update_sysctl_factor();
-@@ -966,6 +1150,7 @@ int sched_update_scaling(void)
+@@ -972,6 +1187,7 @@ int sched_update_scaling(void)
return 0;
}
@@ -607,7 +681,7 @@ index 533547e3c..ae55f46a8 100644
#endif
#endif
-@@ -1165,7 +1350,13 @@ static void update_curr(struct cfs_rq *cfs_rq)
+@@ -1171,7 +1387,13 @@ static void update_curr(struct cfs_rq *cfs_rq)
if (unlikely(delta_exec <= 0))
return;
@@ -621,7 +695,7 @@ index 533547e3c..ae55f46a8 100644
update_deadline(cfs_rq, curr);
update_min_vruntime(cfs_rq);
-@@ -5171,6 +5362,9 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
+@@ -5177,6 +5399,9 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
*
* EEVDF: placement strategy #1 / #2
*/
@@ -631,7 +705,16 @@ index 533547e3c..ae55f46a8 100644
if (sched_feat(PLACE_LAG) && cfs_rq->nr_running) {
struct sched_entity *curr = cfs_rq->curr;
unsigned long load;
-@@ -6803,6 +6997,14 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
+@@ -5466,7 +5691,7 @@ pick_next_entity(struct cfs_rq *cfs_rq)
+ cfs_rq->next && entity_eligible(cfs_rq, cfs_rq->next))
+ return cfs_rq->next;
+
+- return pick_eevdf(cfs_rq);
++ return pick_eevdf(cfs_rq, NULL);
+ }
+
+ static bool check_cfs_rq_runtime(struct cfs_rq *cfs_rq);
+@@ -6809,6 +7034,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);
@@ -646,7 +729,19 @@ index 533547e3c..ae55f46a8 100644
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
-@@ -8552,16 +8754,25 @@ static void yield_task_fair(struct rq *rq)
+@@ -8343,10 +8576,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 ?
+- */
+- if (pick_eevdf(cfs_rq) == pse)
++ if (pick_eevdf(cfs_rq, pse) == pse)
+ goto preempt;
+
+ return;
+@@ -8564,16 +8794,25 @@ static void yield_task_fair(struct rq *rq)
/*
* Are we the only task in the tree?
*/
@@ -672,7 +767,7 @@ index 533547e3c..ae55f46a8 100644
/*
* Tell update_rq_clock() that we've just updated,
* so we don't do microscopic update in schedule()
-@@ -12651,6 +12862,9 @@ static void task_fork_fair(struct task_struct *p)
+@@ -12663,6 +12902,9 @@ static void task_fork_fair(struct task_struct *p)
curr = cfs_rq->curr;
if (curr)
update_curr(cfs_rq);
@@ -683,26 +778,42 @@ index 533547e3c..ae55f46a8 100644
rq_unlock(rq, &rf);
}
diff --git a/kernel/sched/features.h b/kernel/sched/features.h
-index 143f55df8..3f0fe409f 100644
+index 143f55df8..bfeb9f653 100644
--- a/kernel/sched/features.h
+++ b/kernel/sched/features.h
-@@ -6,7 +6,11 @@
+@@ -5,8 +5,26 @@
+ * 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.
++ */
SCHED_FEAT(PLACE_DEADLINE_INITIAL, true)
+-SCHED_FEAT(RUN_TO_PARITY, true)
++/*
++ * Inhibit (wakeup) preemption until the current task has exhausted its slice.
++ */
+#ifdef CONFIG_SCHED_BORE
-+SCHED_FEAT(RUN_TO_PARITY, false)
++SCHED_FEAT(RESPECT_SLICE, false)
+#else // !CONFIG_SCHED_BORE
- SCHED_FEAT(RUN_TO_PARITY, true)
++SCHED_FEAT(RESPECT_SLICE, true)
+#endif // CONFIG_SCHED_BORE
++/*
++ * Relax RESPECT_SLICE to allow preemption once current has reached 0-lag.
++ */
++SCHED_FEAT(RUN_TO_PARITY, false)
++/*
++ * Allow tasks with a shorter slice to disregard RESPECT_SLICE
++ */
++SCHED_FEAT(PREEMPT_SHORT, true)
/*
* Prefer to schedule the task we woke last (assuming it failed
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
-index 001fe047b..da3ad1d4e 100644
+index 8c817d0a9..05c0a1157 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
-@@ -1965,7 +1965,11 @@ static inline void dirty_sched_domain_sysctl(int cpu)
+@@ -1967,7 +1967,11 @@ static inline void dirty_sched_domain_sysctl(int cpu)
}
#endif
@@ -714,7 +825,7 @@ index 001fe047b..da3ad1d4e 100644
static inline const struct cpumask *task_user_cpus(struct task_struct *p)
{
-@@ -2552,6 +2556,9 @@ extern const_debug unsigned int sysctl_sched_nr_migrate;
+@@ -2554,6 +2558,9 @@ extern const_debug unsigned int sysctl_sched_nr_migrate;
extern const_debug unsigned int sysctl_sched_migration_cost;
extern unsigned int sysctl_sched_base_slice;
@@ -725,5 +836,5 @@ index 001fe047b..da3ad1d4e 100644
#ifdef CONFIG_SCHED_DEBUG
extern int sysctl_resched_latency_warn_ms;
--
-2.43.0.232.ge79552d197
+2.44.0.325.g11c821f2f2