Update patches/0002-bore-cachy.patch
This commit is contained in:
parent
2a1e73528d
commit
12b1c9732b
@ -1,9 +1,9 @@
|
|||||||
From f88ecfd06f1641c3b03ad36b5ed0e3f62aa6972d Mon Sep 17 00:00:00 2001
|
From edce20799f90ec9d9fb19b4733ad1ff48fa58450 Mon Sep 17 00:00:00 2001
|
||||||
From: Piotr Gorski <lucjan.lucjanov@gmail.com>
|
From: Eric Naim <dnaim@cachyos.org>
|
||||||
Date: Thu, 5 Dec 2024 22:52:18 +0100
|
Date: Fri, 6 Dec 2024 12:24:07 +0800
|
||||||
Subject: [PATCH] bore-cachy
|
Subject: [PATCH] bore-cachy-5.8
|
||||||
|
|
||||||
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
|
Signed-off-by: Eric Naim <dnaim@cachyos.org>
|
||||||
---
|
---
|
||||||
include/linux/sched.h | 17 ++
|
include/linux/sched.h | 17 ++
|
||||||
include/linux/sched/bore.h | 40 ++++
|
include/linux/sched/bore.h | 40 ++++
|
||||||
@ -11,17 +11,17 @@ Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
|
|||||||
kernel/Kconfig.hz | 17 ++
|
kernel/Kconfig.hz | 17 ++
|
||||||
kernel/fork.c | 5 +
|
kernel/fork.c | 5 +
|
||||||
kernel/sched/Makefile | 1 +
|
kernel/sched/Makefile | 1 +
|
||||||
kernel/sched/bore.c | 410 +++++++++++++++++++++++++++++++++++++
|
kernel/sched/bore.c | 426 +++++++++++++++++++++++++++++++++++++
|
||||||
kernel/sched/core.c | 6 +
|
kernel/sched/core.c | 6 +
|
||||||
kernel/sched/debug.c | 61 +++++-
|
kernel/sched/debug.c | 61 +++++-
|
||||||
kernel/sched/fair.c | 88 ++++++--
|
kernel/sched/fair.c | 88 ++++++--
|
||||||
kernel/sched/sched.h | 9 +
|
kernel/sched/sched.h | 9 +
|
||||||
11 files changed, 653 insertions(+), 18 deletions(-)
|
11 files changed, 669 insertions(+), 18 deletions(-)
|
||||||
create mode 100644 include/linux/sched/bore.h
|
create mode 100644 include/linux/sched/bore.h
|
||||||
create mode 100644 kernel/sched/bore.c
|
create mode 100644 kernel/sched/bore.c
|
||||||
|
|
||||||
diff --git a/include/linux/sched.h b/include/linux/sched.h
|
diff --git a/include/linux/sched.h b/include/linux/sched.h
|
||||||
index bb343136d..c86185f87 100644
|
index bb343136ddd0..c86185f87e7b 100644
|
||||||
--- a/include/linux/sched.h
|
--- a/include/linux/sched.h
|
||||||
+++ b/include/linux/sched.h
|
+++ b/include/linux/sched.h
|
||||||
@@ -538,6 +538,14 @@ struct sched_statistics {
|
@@ -538,6 +538,14 @@ struct sched_statistics {
|
||||||
@ -57,7 +57,7 @@ index bb343136d..c86185f87 100644
|
|||||||
|
|
||||||
diff --git a/include/linux/sched/bore.h b/include/linux/sched/bore.h
|
diff --git a/include/linux/sched/bore.h b/include/linux/sched/bore.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 000000000..14d8f260a
|
index 000000000000..c3db800bd6e3
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/include/linux/sched/bore.h
|
+++ b/include/linux/sched/bore.h
|
||||||
@@ -0,0 +1,40 @@
|
@@ -0,0 +1,40 @@
|
||||||
@ -67,7 +67,7 @@ index 000000000..14d8f260a
|
|||||||
+
|
+
|
||||||
+#ifndef _LINUX_SCHED_BORE_H
|
+#ifndef _LINUX_SCHED_BORE_H
|
||||||
+#define _LINUX_SCHED_BORE_H
|
+#define _LINUX_SCHED_BORE_H
|
||||||
+#define SCHED_BORE_VERSION "5.7.8"
|
+#define SCHED_BORE_VERSION "5.8.10"
|
||||||
+
|
+
|
||||||
+#ifdef CONFIG_SCHED_BORE
|
+#ifdef CONFIG_SCHED_BORE
|
||||||
+extern u8 __read_mostly sched_bore;
|
+extern u8 __read_mostly sched_bore;
|
||||||
@ -102,7 +102,7 @@ index 000000000..14d8f260a
|
|||||||
+#endif // CONFIG_SCHED_BORE
|
+#endif // CONFIG_SCHED_BORE
|
||||||
+#endif // _LINUX_SCHED_BORE_H
|
+#endif // _LINUX_SCHED_BORE_H
|
||||||
diff --git a/init/Kconfig b/init/Kconfig
|
diff --git a/init/Kconfig b/init/Kconfig
|
||||||
index 857869dbc..9bd4551a7 100644
|
index 857869dbc22c..9bd4551a7c3a 100644
|
||||||
--- a/init/Kconfig
|
--- a/init/Kconfig
|
||||||
+++ b/init/Kconfig
|
+++ b/init/Kconfig
|
||||||
@@ -1361,6 +1361,23 @@ config CHECKPOINT_RESTORE
|
@@ -1361,6 +1361,23 @@ config CHECKPOINT_RESTORE
|
||||||
@ -130,7 +130,7 @@ index 857869dbc..9bd4551a7 100644
|
|||||||
bool "Automatic process group scheduling"
|
bool "Automatic process group scheduling"
|
||||||
select CGROUPS
|
select CGROUPS
|
||||||
diff --git a/kernel/Kconfig.hz b/kernel/Kconfig.hz
|
diff --git a/kernel/Kconfig.hz b/kernel/Kconfig.hz
|
||||||
index 0f78364ef..83a6b919a 100644
|
index 0f78364efd4f..83a6b919ab29 100644
|
||||||
--- a/kernel/Kconfig.hz
|
--- a/kernel/Kconfig.hz
|
||||||
+++ b/kernel/Kconfig.hz
|
+++ b/kernel/Kconfig.hz
|
||||||
@@ -79,5 +79,22 @@ config HZ
|
@@ -79,5 +79,22 @@ config HZ
|
||||||
@ -157,7 +157,7 @@ index 0f78364ef..83a6b919a 100644
|
|||||||
config SCHED_HRTICK
|
config SCHED_HRTICK
|
||||||
def_bool HIGH_RES_TIMERS
|
def_bool HIGH_RES_TIMERS
|
||||||
diff --git a/kernel/fork.c b/kernel/fork.c
|
diff --git a/kernel/fork.c b/kernel/fork.c
|
||||||
index e97e527ce..d40105f4b 100644
|
index e97e527cec69..d40105f4b177 100644
|
||||||
--- a/kernel/fork.c
|
--- a/kernel/fork.c
|
||||||
+++ b/kernel/fork.c
|
+++ b/kernel/fork.c
|
||||||
@@ -117,6 +117,8 @@
|
@@ -117,6 +117,8 @@
|
||||||
@ -180,7 +180,7 @@ index e97e527ce..d40105f4b 100644
|
|||||||
retval = perf_event_init_task(p, clone_flags);
|
retval = perf_event_init_task(p, clone_flags);
|
||||||
if (retval)
|
if (retval)
|
||||||
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile
|
diff --git a/kernel/sched/Makefile b/kernel/sched/Makefile
|
||||||
index 976092b7b..293aad675 100644
|
index 976092b7bd45..293aad675444 100644
|
||||||
--- a/kernel/sched/Makefile
|
--- a/kernel/sched/Makefile
|
||||||
+++ b/kernel/sched/Makefile
|
+++ b/kernel/sched/Makefile
|
||||||
@@ -32,3 +32,4 @@ obj-y += core.o
|
@@ -32,3 +32,4 @@ obj-y += core.o
|
||||||
@ -190,15 +190,17 @@ index 976092b7b..293aad675 100644
|
|||||||
+obj-y += bore.o
|
+obj-y += bore.o
|
||||||
diff --git a/kernel/sched/bore.c b/kernel/sched/bore.c
|
diff --git a/kernel/sched/bore.c b/kernel/sched/bore.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 000000000..e3e7ef8ea
|
index 000000000000..94517f26ca60
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/kernel/sched/bore.c
|
+++ b/kernel/sched/bore.c
|
||||||
@@ -0,0 +1,410 @@
|
@@ -0,0 +1,426 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Burst-Oriented Response Enhancer (BORE) CPU Scheduler
|
+ * Burst-Oriented Response Enhancer (BORE) CPU Scheduler
|
||||||
+ * Copyright (C) 2021-2024 Masahito Suzuki <firelzrd@gmail.com>
|
+ * Copyright (C) 2021-2024 Masahito Suzuki <firelzrd@gmail.com>
|
||||||
+ */
|
+ */
|
||||||
+#include <linux/cpuset.h>
|
+#include <linux/cpuset.h>
|
||||||
|
+#include <linux/rculist.h>
|
||||||
|
+#include <linux/rcupdate.h>
|
||||||
+#include <linux/sched/task.h>
|
+#include <linux/sched/task.h>
|
||||||
+#include <linux/sched/bore.h>
|
+#include <linux/sched/bore.h>
|
||||||
+#include "sched.h"
|
+#include "sched.h"
|
||||||
@ -212,7 +214,7 @@ index 000000000..e3e7ef8ea
|
|||||||
+u8 __read_mostly sched_burst_parity_threshold = 2;
|
+u8 __read_mostly sched_burst_parity_threshold = 2;
|
||||||
+u8 __read_mostly sched_burst_penalty_offset = 24;
|
+u8 __read_mostly sched_burst_penalty_offset = 24;
|
||||||
+uint __read_mostly sched_burst_penalty_scale = 1280;
|
+uint __read_mostly sched_burst_penalty_scale = 1280;
|
||||||
+uint __read_mostly sched_burst_cache_stop_count = 20;
|
+uint __read_mostly sched_burst_cache_stop_count = 64;
|
||||||
+uint __read_mostly sched_burst_cache_lifetime = 75000000;
|
+uint __read_mostly sched_burst_cache_lifetime = 75000000;
|
||||||
+uint __read_mostly sched_deadline_boost_mask = ENQUEUE_INITIAL
|
+uint __read_mostly sched_deadline_boost_mask = ENQUEUE_INITIAL
|
||||||
+ | ENQUEUE_WAKEUP;
|
+ | ENQUEUE_WAKEUP;
|
||||||
@ -347,7 +349,8 @@ index 000000000..e3e7ef8ea
|
|||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+#define for_each_child(p, t) \
|
+#define for_each_child(p, t) \
|
||||||
+ list_for_each_entry(t, &(p)->children, sibling)
|
+ list_for_each_entry_rcu(t, &(p)->children, sibling, \
|
||||||
|
+ lockdep_is_held(&tasklist_lock))
|
||||||
+
|
+
|
||||||
+static u32 count_children_max2(struct task_struct *p) {
|
+static u32 count_children_max2(struct task_struct *p) {
|
||||||
+ u32 cnt = 0;
|
+ u32 cnt = 0;
|
||||||
@ -356,6 +359,22 @@ index 000000000..e3e7ef8ea
|
|||||||
+ return cnt;
|
+ return cnt;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
+static u32 count_children_max2_head(
|
||||||
|
+ struct task_struct *p, struct task_struct **first) {
|
||||||
|
+ struct list_head *head = &p->children;
|
||||||
|
+ struct task_struct *cursor;
|
||||||
|
+ u32 cnt = 0;
|
||||||
|
+ *first = cursor = list_first_or_null_rcu(head, struct task_struct, sibling);
|
||||||
|
+ if (cursor) {
|
||||||
|
+ cnt++;
|
||||||
|
+ list_for_each_entry_continue_rcu(cursor, head, sibling) {
|
||||||
|
+ cnt++;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return cnt;
|
||||||
|
+}
|
||||||
|
+
|
||||||
+static inline bool burst_cache_expired(struct sched_burst_cache *bc, u64 now)
|
+static inline bool burst_cache_expired(struct sched_burst_cache *bc, u64 now)
|
||||||
+{return (s64)(bc->timestamp + sched_burst_cache_lifetime - now) < 0;}
|
+{return (s64)(bc->timestamp + sched_burst_cache_lifetime - now) < 0;}
|
||||||
+
|
+
|
||||||
@ -375,7 +394,6 @@ index 000000000..e3e7ef8ea
|
|||||||
+ if (!task_is_bore_eligible(child)) continue;
|
+ if (!task_is_bore_eligible(child)) continue;
|
||||||
+ cnt++;
|
+ cnt++;
|
||||||
+ sum += child->se.burst_penalty;
|
+ sum += child->se.burst_penalty;
|
||||||
+ if (unlikely(sched_burst_cache_stop_count <= cnt)) break;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ update_burst_cache(&p->se.child_burst, p, cnt, sum, now);
|
+ update_burst_cache(&p->se.child_burst, p, cnt, sum, now);
|
||||||
@ -392,18 +410,16 @@ index 000000000..e3e7ef8ea
|
|||||||
+static void update_child_burst_topological(
|
+static void update_child_burst_topological(
|
||||||
+ struct task_struct *p, u64 now, u32 depth, u32 *acnt, u32 *asum) {
|
+ struct task_struct *p, u64 now, u32 depth, u32 *acnt, u32 *asum) {
|
||||||
+ u32 cnt = 0, dcnt = 0, sum = 0;
|
+ u32 cnt = 0, dcnt = 0, sum = 0;
|
||||||
+ struct task_struct *child, *dec;
|
+ struct task_struct *child, *dec, *next;
|
||||||
+
|
+
|
||||||
+ for_each_child(p, child) {
|
+ for_each_child(p, child) {
|
||||||
+ dec = child;
|
+ dec = child;
|
||||||
+ while ((dcnt = count_children_max2(dec)) == 1)
|
+ while ((dcnt = count_children_max2_head(dec, &next)) == 1) {dec = next;}
|
||||||
+ dec = list_first_entry(&dec->children, struct task_struct, sibling);
|
|
||||||
+
|
+
|
||||||
+ if (!dcnt || !depth) {
|
+ if (!dcnt || !depth) {
|
||||||
+ if (!task_is_bore_eligible(dec)) continue;
|
+ if (!task_is_bore_eligible(dec)) continue;
|
||||||
+ cnt++;
|
+ cnt++;
|
||||||
+ sum += dec->se.burst_penalty;
|
+ sum += dec->se.burst_penalty;
|
||||||
+ if (unlikely(sched_burst_cache_stop_count <= cnt)) break;
|
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ if (!burst_cache_expired(&dec->se.child_burst, now)) {
|
+ if (!burst_cache_expired(&dec->se.child_burst, now)) {
|
||||||
@ -425,7 +441,8 @@ index 000000000..e3e7ef8ea
|
|||||||
+ u32 cnt = 0, sum = 0;
|
+ u32 cnt = 0, sum = 0;
|
||||||
+
|
+
|
||||||
+ for (struct task_struct *next;
|
+ for (struct task_struct *next;
|
||||||
+ anc != (next = anc->real_parent) && count_children_max2(anc) <= 1;
|
+ anc != (next = rcu_dereference(anc->real_parent)) &&
|
||||||
|
+ count_children_max2(anc) <= 1;
|
||||||
+ anc = next) {}
|
+ anc = next) {}
|
||||||
+
|
+
|
||||||
+ if (burst_cache_expired(&anc->se.child_burst, now))
|
+ if (burst_cache_expired(&anc->se.child_burst, now))
|
||||||
@ -443,7 +460,6 @@ index 000000000..e3e7ef8ea
|
|||||||
+ if (!task_is_bore_eligible(task)) continue;
|
+ if (!task_is_bore_eligible(task)) continue;
|
||||||
+ cnt++;
|
+ cnt++;
|
||||||
+ sum += task->se.burst_penalty;
|
+ sum += task->se.burst_penalty;
|
||||||
+ if (unlikely(sched_burst_cache_stop_count <= cnt)) break;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ update_burst_cache(&p->se.group_burst, p, cnt, sum, now);
|
+ update_burst_cache(&p->se.group_burst, p, cnt, sum, now);
|
||||||
@ -464,7 +480,7 @@ index 000000000..e3e7ef8ea
|
|||||||
+
|
+
|
||||||
+ if (!task_is_bore_eligible(p)) return;
|
+ if (!task_is_bore_eligible(p)) return;
|
||||||
+
|
+
|
||||||
+ read_lock(&tasklist_lock);
|
+ rcu_read_lock();
|
||||||
+ now = jiffies_to_nsecs(jiffies);
|
+ now = jiffies_to_nsecs(jiffies);
|
||||||
+ if (clone_flags & CLONE_THREAD) {
|
+ if (clone_flags & CLONE_THREAD) {
|
||||||
+ penalty = inherit_burst_tg(parent, now);
|
+ penalty = inherit_burst_tg(parent, now);
|
||||||
@ -475,7 +491,7 @@ index 000000000..e3e7ef8ea
|
|||||||
+ inherit_burst_topological(parent, now):
|
+ inherit_burst_topological(parent, now):
|
||||||
+ inherit_burst_direct(parent, now);
|
+ inherit_burst_direct(parent, now);
|
||||||
+ }
|
+ }
|
||||||
+ read_unlock(&tasklist_lock);
|
+ rcu_read_unlock();
|
||||||
+
|
+
|
||||||
+ struct sched_entity *se = &p->se;
|
+ struct sched_entity *se = &p->se;
|
||||||
+ revolve_burst_penalty(se);
|
+ revolve_burst_penalty(se);
|
||||||
@ -605,7 +621,7 @@ index 000000000..e3e7ef8ea
|
|||||||
+#endif // CONFIG_SYSCTL
|
+#endif // CONFIG_SYSCTL
|
||||||
+#endif // CONFIG_SCHED_BORE
|
+#endif // CONFIG_SCHED_BORE
|
||||||
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
|
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
|
||||||
index a1c353a62..4dc0c98c1 100644
|
index a1c353a62c56..4dc0c98c1afd 100644
|
||||||
--- a/kernel/sched/core.c
|
--- a/kernel/sched/core.c
|
||||||
+++ b/kernel/sched/core.c
|
+++ b/kernel/sched/core.c
|
||||||
@@ -97,6 +97,8 @@
|
@@ -97,6 +97,8 @@
|
||||||
@ -629,7 +645,7 @@ index a1c353a62..4dc0c98c1 100644
|
|||||||
|
|
||||||
#ifdef CONFIG_FAIR_GROUP_SCHED
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
||||||
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
|
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
|
||||||
index f4035c7a0..0edb3a216 100644
|
index f4035c7a0fa1..0edb3a216f5d 100644
|
||||||
--- a/kernel/sched/debug.c
|
--- a/kernel/sched/debug.c
|
||||||
+++ b/kernel/sched/debug.c
|
+++ b/kernel/sched/debug.c
|
||||||
@@ -167,7 +167,53 @@ static const struct file_operations sched_feat_fops = {
|
@@ -167,7 +167,53 @@ static const struct file_operations sched_feat_fops = {
|
||||||
@ -678,9 +694,9 @@ index f4035c7a0..0edb3a216 100644
|
|||||||
+ .llseek = seq_lseek, \
|
+ .llseek = seq_lseek, \
|
||||||
+ .release = single_release, \
|
+ .release = single_release, \
|
||||||
+};
|
+};
|
||||||
+
|
|
||||||
+DEFINE_SYSCTL_SCHED_FUNC(min_base_slice, min_base_slice)
|
|
||||||
|
|
||||||
|
+DEFINE_SYSCTL_SCHED_FUNC(min_base_slice, min_base_slice)
|
||||||
|
+
|
||||||
+#undef DEFINE_SYSCTL_SCHED_FUNC
|
+#undef DEFINE_SYSCTL_SCHED_FUNC
|
||||||
+#else // !CONFIG_SCHED_BORE
|
+#else // !CONFIG_SCHED_BORE
|
||||||
static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
|
static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
|
||||||
@ -737,7 +753,7 @@ index f4035c7a0..0edb3a216 100644
|
|||||||
P(se.avg.runnable_sum);
|
P(se.avg.runnable_sum);
|
||||||
P(se.avg.util_sum);
|
P(se.avg.util_sum);
|
||||||
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
|
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
|
||||||
index 54e7c4c3e..94c54154a 100644
|
index 54e7c4c3e2c5..94c54154a175 100644
|
||||||
--- a/kernel/sched/fair.c
|
--- a/kernel/sched/fair.c
|
||||||
+++ b/kernel/sched/fair.c
|
+++ b/kernel/sched/fair.c
|
||||||
@@ -55,6 +55,8 @@
|
@@ -55,6 +55,8 @@
|
||||||
@ -971,7 +987,7 @@ index 54e7c4c3e..94c54154a 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
|
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
|
||||||
index c5d601279..ce3804c6f 100644
|
index c5d6012794de..ce3804c6fa5c 100644
|
||||||
--- a/kernel/sched/sched.h
|
--- a/kernel/sched/sched.h
|
||||||
+++ b/kernel/sched/sched.h
|
+++ b/kernel/sched/sched.h
|
||||||
@@ -2075,7 +2075,11 @@ static inline void update_sched_domain_debugfs(void) { }
|
@@ -2075,7 +2075,11 @@ static inline void update_sched_domain_debugfs(void) { }
|
||||||
@ -1001,4 +1017,3 @@ index c5d601279..ce3804c6f 100644
|
|||||||
extern int sysctl_resched_latency_warn_ms;
|
extern int sysctl_resched_latency_warn_ms;
|
||||||
--
|
--
|
||||||
2.47.1
|
2.47.1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user