2024-04-03 18:43:13 +02:00
|
|
|
From 37fd243d8f075b558f54a36fc85887269310709c Mon Sep 17 00:00:00 2001
|
2023-12-12 12:10:53 +01:00
|
|
|
From: Piotr Gorski <lucjan.lucjanov@gmail.com>
|
2024-04-03 18:43:13 +02:00
|
|
|
Date: Tue, 26 Mar 2024 08:11:18 +0100
|
2023-11-04 20:11:33 +01:00
|
|
|
Subject: [PATCH] bore-cachy
|
|
|
|
|
2023-12-12 12:10:53 +01:00
|
|
|
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
|
2023-11-04 20:11:33 +01:00
|
|
|
---
|
2024-04-03 18:43:13 +02:00
|
|
|
include/linux/sched.h | 10 ++
|
|
|
|
init/Kconfig | 17 +++
|
|
|
|
kernel/sched/core.c | 144 +++++++++++++++++++++++++
|
|
|
|
kernel/sched/debug.c | 60 ++++++++++-
|
|
|
|
kernel/sched/fair.c | 231 +++++++++++++++++++++++++++++++++++++---
|
2023-12-12 12:10:53 +01:00
|
|
|
kernel/sched/features.h | 4 +
|
2024-04-03 18:43:13 +02:00
|
|
|
kernel/sched/sched.h | 7 ++
|
|
|
|
7 files changed, 457 insertions(+), 16 deletions(-)
|
2023-11-04 20:11:33 +01:00
|
|
|
|
|
|
|
diff --git a/include/linux/sched.h b/include/linux/sched.h
|
2024-04-03 18:43:13 +02:00
|
|
|
index ffe8f618a..0ab0b0424 100644
|
2023-11-04 20:11:33 +01:00
|
|
|
--- a/include/linux/sched.h
|
|
|
|
+++ b/include/linux/sched.h
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -547,6 +547,16 @@ struct sched_entity {
|
2023-11-04 20:11:33 +01:00
|
|
|
u64 sum_exec_runtime;
|
|
|
|
u64 prev_sum_exec_runtime;
|
|
|
|
u64 vruntime;
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ u64 burst_time;
|
2023-12-12 12:10:53 +01:00
|
|
|
+ u8 prev_burst_penalty;
|
|
|
|
+ u8 curr_burst_penalty;
|
|
|
|
+ u8 burst_penalty;
|
2024-02-29 17:17:15 +01:00
|
|
|
+ u8 burst_score;
|
2023-12-12 12:10:53 +01:00
|
|
|
+ u8 child_burst;
|
2024-02-29 17:17:15 +01:00
|
|
|
+ u32 child_burst_cnt;
|
2023-12-12 12:10:53 +01:00
|
|
|
+ u64 child_burst_last_cached;
|
2023-11-04 20:11:33 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
s64 vlag;
|
|
|
|
u64 slice;
|
|
|
|
|
|
|
|
diff --git a/init/Kconfig b/init/Kconfig
|
2024-04-03 18:43:13 +02:00
|
|
|
index 9ea39297f..f9bb5401f 100644
|
2023-11-04 20:11:33 +01:00
|
|
|
--- a/init/Kconfig
|
|
|
|
+++ b/init/Kconfig
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -1299,6 +1299,23 @@ config CHECKPOINT_RESTORE
|
2023-11-04 20:11:33 +01:00
|
|
|
|
|
|
|
If unsure, say N here.
|
|
|
|
|
|
|
|
+config SCHED_BORE
|
|
|
|
+ bool "Burst-Oriented Response Enhancer"
|
|
|
|
+ default y
|
|
|
|
+ help
|
|
|
|
+ In Desktop and Mobile computing, one might prefer interactive
|
|
|
|
+ tasks to keep responsive no matter what they run in the background.
|
|
|
|
+
|
|
|
|
+ Enabling this kernel feature modifies the scheduler to discriminate
|
|
|
|
+ tasks by their burst time (runtime since it last went sleeping or
|
|
|
|
+ yielding state) and prioritize those that run less bursty.
|
|
|
|
+ Such tasks usually include window compositor, widgets backend,
|
|
|
|
+ terminal emulator, video playback, games and so on.
|
|
|
|
+ With a little impact to scheduling fairness, it may improve
|
|
|
|
+ responsiveness especially under heavy background workload.
|
|
|
|
+
|
2023-12-12 12:10:53 +01:00
|
|
|
+ If unsure, say Y here.
|
2023-11-04 20:11:33 +01:00
|
|
|
+
|
|
|
|
config SCHED_AUTOGROUP
|
|
|
|
bool "Automatic process group scheduling"
|
|
|
|
select CGROUPS
|
|
|
|
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
|
2024-04-03 18:43:13 +02:00
|
|
|
index 9116bcc90..fc3d7b48e 100644
|
2023-11-04 20:11:33 +01:00
|
|
|
--- a/kernel/sched/core.c
|
|
|
|
+++ b/kernel/sched/core.c
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -4507,6 +4507,139 @@ int wake_up_state(struct task_struct *p, unsigned int state)
|
2023-11-04 20:11:33 +01:00
|
|
|
return try_to_wake_up(p, state, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2023-12-12 12:10:53 +01:00
|
|
|
+extern bool sched_bore;
|
|
|
|
+extern u8 sched_burst_fork_atavistic;
|
|
|
|
+extern uint sched_burst_cache_lifetime;
|
2023-11-04 20:11:33 +01:00
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static void __init sched_init_bore(void) {
|
2023-11-04 20:11:33 +01:00
|
|
|
+ init_task.se.burst_time = 0;
|
|
|
|
+ init_task.se.prev_burst_penalty = 0;
|
|
|
|
+ init_task.se.curr_burst_penalty = 0;
|
|
|
|
+ init_task.se.burst_penalty = 0;
|
2024-02-29 17:17:15 +01:00
|
|
|
+ init_task.se.burst_score = 0;
|
2023-12-12 12:10:53 +01:00
|
|
|
+ init_task.se.child_burst_last_cached = 0;
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void inline sched_fork_bore(struct task_struct *p) {
|
|
|
|
+ p->se.burst_time = 0;
|
|
|
|
+ p->se.curr_burst_penalty = 0;
|
2024-02-29 17:17:15 +01:00
|
|
|
+ p->se.burst_score = 0;
|
2023-12-12 12:10:53 +01:00
|
|
|
+ p->se.child_burst_last_cached = 0;
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static u32 count_child_tasks(struct task_struct *p) {
|
|
|
|
+ struct task_struct *child;
|
|
|
|
+ u32 cnt = 0;
|
|
|
|
+ list_for_each_entry(child, &p->children, sibling) {cnt++;}
|
|
|
|
+ return cnt;
|
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static inline bool task_is_inheritable(struct task_struct *p) {
|
|
|
|
+ return (p->sched_class == &fair_sched_class);
|
|
|
|
+}
|
|
|
|
+
|
2023-11-04 20:11:33 +01:00
|
|
|
+static inline bool child_burst_cache_expired(struct task_struct *p, u64 now) {
|
2024-02-29 17:17:15 +01:00
|
|
|
+ u64 expiration_time =
|
|
|
|
+ p->se.child_burst_last_cached + sched_burst_cache_lifetime;
|
|
|
|
+ return ((s64)(expiration_time - now) < 0);
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void __update_child_burst_cache(
|
|
|
|
+ struct task_struct *p, u32 cnt, u32 sum, u64 now) {
|
2023-12-12 12:10:53 +01:00
|
|
|
+ u8 avg = 0;
|
2023-11-04 20:11:33 +01:00
|
|
|
+ if (cnt) avg = sum / cnt;
|
2023-12-12 12:10:53 +01:00
|
|
|
+ p->se.child_burst = max(avg, p->se.burst_penalty);
|
|
|
|
+ p->se.child_burst_cnt = cnt;
|
|
|
|
+ p->se.child_burst_last_cached = now;
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static inline void update_child_burst_direct(struct task_struct *p, u64 now) {
|
2023-11-04 20:11:33 +01:00
|
|
|
+ struct task_struct *child;
|
|
|
|
+ u32 cnt = 0;
|
|
|
|
+ u32 sum = 0;
|
|
|
|
+
|
|
|
|
+ list_for_each_entry(child, &p->children, sibling) {
|
2024-02-29 17:17:15 +01:00
|
|
|
+ if (!task_is_inheritable(child)) continue;
|
2023-11-04 20:11:33 +01:00
|
|
|
+ cnt++;
|
|
|
|
+ sum += child->se.burst_penalty;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ __update_child_burst_cache(p, cnt, sum, now);
|
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static inline u8 __inherit_burst_direct(struct task_struct *p, u64 now) {
|
|
|
|
+ struct task_struct *parent = p->real_parent;
|
|
|
|
+ if (child_burst_cache_expired(parent, now))
|
|
|
|
+ update_child_burst_direct(parent, now);
|
|
|
|
+
|
|
|
|
+ return parent->se.child_burst;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void update_child_burst_topological(
|
2023-11-04 20:11:33 +01:00
|
|
|
+ struct task_struct *p, u64 now, u32 depth, u32 *acnt, u32 *asum) {
|
|
|
|
+ struct task_struct *child, *dec;
|
|
|
|
+ u32 cnt = 0, dcnt = 0;
|
|
|
|
+ u32 sum = 0;
|
|
|
|
+
|
|
|
|
+ list_for_each_entry(child, &p->children, sibling) {
|
|
|
|
+ dec = child;
|
|
|
|
+ while ((dcnt = count_child_tasks(dec)) == 1)
|
|
|
|
+ dec = list_first_entry(&dec->children, struct task_struct, sibling);
|
|
|
|
+
|
|
|
|
+ if (!dcnt || !depth) {
|
2024-02-29 17:17:15 +01:00
|
|
|
+ if (!task_is_inheritable(dec)) continue;
|
2023-11-04 20:11:33 +01:00
|
|
|
+ cnt++;
|
|
|
|
+ sum += dec->se.burst_penalty;
|
2023-12-12 12:10:53 +01:00
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (!child_burst_cache_expired(dec, now)) {
|
|
|
|
+ cnt += dec->se.child_burst_cnt;
|
|
|
|
+ sum += (u32)dec->se.child_burst * dec->se.child_burst_cnt;
|
|
|
|
+ continue;
|
2023-11-04 20:11:33 +01:00
|
|
|
+ }
|
2024-02-29 17:17:15 +01:00
|
|
|
+ update_child_burst_topological(dec, now, depth - 1, &cnt, &sum);
|
2023-11-04 20:11:33 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ __update_child_burst_cache(p, cnt, sum, now);
|
|
|
|
+ *acnt += cnt;
|
|
|
|
+ *asum += sum;
|
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static inline u8 __inherit_burst_topological(struct task_struct *p, u64 now) {
|
|
|
|
+ struct task_struct *anc = p->real_parent;
|
|
|
|
+ u32 cnt = 0, sum = 0;
|
|
|
|
+
|
|
|
|
+ while (anc->real_parent != anc && count_child_tasks(anc) == 1)
|
|
|
|
+ anc = anc->real_parent;
|
|
|
|
+
|
|
|
|
+ if (child_burst_cache_expired(anc, now))
|
|
|
|
+ update_child_burst_topological(
|
|
|
|
+ anc, now, sched_burst_fork_atavistic - 1, &cnt, &sum);
|
|
|
|
+
|
|
|
|
+ return anc->se.child_burst;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline void inherit_burst(struct task_struct *p) {
|
2023-12-12 12:10:53 +01:00
|
|
|
+ u8 burst_cache;
|
2024-02-29 17:17:15 +01:00
|
|
|
+ u64 now = ktime_get_ns();
|
2023-11-04 20:11:33 +01:00
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+ read_lock(&tasklist_lock);
|
|
|
|
+ burst_cache = likely(sched_burst_fork_atavistic)?
|
|
|
|
+ __inherit_burst_topological(p, now):
|
|
|
|
+ __inherit_burst_direct(p, now);
|
|
|
|
+ read_unlock(&tasklist_lock);
|
|
|
|
+
|
|
|
|
+ p->se.prev_burst_penalty = max(p->se.prev_burst_penalty, burst_cache);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void sched_post_fork_bore(struct task_struct *p) {
|
2024-04-03 18:43:13 +02:00
|
|
|
+ if (p->sched_class == &fair_sched_class)
|
2024-02-29 17:17:15 +01:00
|
|
|
+ inherit_burst(p);
|
|
|
|
+ p->se.burst_penalty = p->se.prev_burst_penalty;
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* Perform scheduler related setup for a newly forked process p.
|
|
|
|
* p is forked by current.
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -4523,6 +4656,9 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
|
2023-11-04 20:11:33 +01:00
|
|
|
p->se.prev_sum_exec_runtime = 0;
|
|
|
|
p->se.nr_migrations = 0;
|
|
|
|
p->se.vruntime = 0;
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ sched_fork_bore(p);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
p->se.vlag = 0;
|
2023-12-12 12:10:53 +01:00
|
|
|
p->se.slice = sysctl_sched_base_slice;
|
2023-11-04 20:11:33 +01:00
|
|
|
INIT_LIST_HEAD(&p->se.group_node);
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -4839,6 +4975,9 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs)
|
2023-11-04 20:11:33 +01:00
|
|
|
|
|
|
|
void sched_post_fork(struct task_struct *p)
|
|
|
|
{
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2023-12-12 12:10:53 +01:00
|
|
|
+ sched_post_fork_bore(p);
|
2023-11-04 20:11:33 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
uclamp_post_fork(p);
|
|
|
|
}
|
|
|
|
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -9910,6 +10049,11 @@ void __init sched_init(void)
|
2023-11-04 20:11:33 +01:00
|
|
|
BUG_ON(&dl_sched_class != &stop_sched_class + 1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ sched_init_bore();
|
2024-04-03 18:43:13 +02:00
|
|
|
+ printk(KERN_INFO "BORE (Burst-Oriented Response Enhancer) CPU Scheduler modification 5.0.3 by Masahito Suzuki");
|
2023-11-04 20:11:33 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
+
|
|
|
|
wait_bit_init();
|
|
|
|
|
|
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
|
|
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
|
2024-04-03 18:43:13 +02:00
|
|
|
index 8d5d98a58..b17861261 100644
|
2023-11-04 20:11:33 +01:00
|
|
|
--- a/kernel/sched/debug.c
|
|
|
|
+++ b/kernel/sched/debug.c
|
2024-02-29 17:17:15 +01:00
|
|
|
@@ -167,7 +167,52 @@ static const struct file_operations sched_feat_fops = {
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+static ssize_t sched_min_base_slice_write(struct file *filp, const char __user *ubuf,
|
|
|
|
+ size_t cnt, loff_t *ppos)
|
|
|
|
+{
|
|
|
|
+ char buf[16];
|
|
|
|
+ unsigned int value;
|
|
|
|
+
|
|
|
|
+ if (cnt > 15)
|
|
|
|
+ cnt = 15;
|
|
|
|
+
|
|
|
|
+ if (copy_from_user(&buf, ubuf, cnt))
|
|
|
|
+ return -EFAULT;
|
|
|
|
+ buf[cnt] = '\0';
|
|
|
|
+
|
|
|
|
+ if (kstrtouint(buf, 10, &value))
|
|
|
|
+ return -EINVAL;
|
|
|
|
|
|
|
|
+ if (!value)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ sysctl_sched_min_base_slice = value;
|
|
|
|
+ sched_update_min_base_slice();
|
|
|
|
+
|
|
|
|
+ *ppos += cnt;
|
|
|
|
+ return cnt;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int sched_min_base_slice_show(struct seq_file *m, void *v)
|
|
|
|
+{
|
|
|
|
+ seq_printf(m, "%d\n", sysctl_sched_min_base_slice);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int sched_min_base_slice_open(struct inode *inode, struct file *filp)
|
|
|
|
+{
|
|
|
|
+ return single_open(filp, sched_min_base_slice_show, NULL);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static const struct file_operations sched_min_base_slice_fops = {
|
|
|
|
+ .open = sched_min_base_slice_open,
|
|
|
|
+ .write = sched_min_base_slice_write,
|
|
|
|
+ .read = seq_read,
|
|
|
|
+ .llseek = seq_lseek,
|
|
|
|
+ .release = single_release,
|
|
|
|
+};
|
|
|
|
+#else // !CONFIG_SCHED_BORE
|
|
|
|
static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
|
|
|
|
size_t cnt, loff_t *ppos)
|
|
|
|
{
|
|
|
|
@@ -213,7 +258,7 @@ static const struct file_operations sched_scaling_fops = {
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
-
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
#endif /* SMP */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PREEMPT_DYNAMIC
|
|
|
|
@@ -347,13 +392,20 @@ static __init int sched_init_debug(void)
|
|
|
|
debugfs_create_file("preempt", 0644, debugfs_sched, NULL, &sched_dynamic_fops);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ debugfs_create_file("min_base_slice_ns", 0644, debugfs_sched, NULL, &sched_min_base_slice_fops);
|
|
|
|
+ debugfs_create_u32("base_slice_ns", 0400, debugfs_sched, &sysctl_sched_base_slice);
|
|
|
|
+#else // !CONFIG_SCHED_BORE
|
|
|
|
debugfs_create_u32("base_slice_ns", 0644, debugfs_sched, &sysctl_sched_base_slice);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
|
|
|
debugfs_create_u32("latency_warn_ms", 0644, debugfs_sched, &sysctl_resched_latency_warn_ms);
|
|
|
|
debugfs_create_u32("latency_warn_once", 0644, debugfs_sched, &sysctl_resched_latency_warn_once);
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
+#if !defined(CONFIG_SCHED_BORE)
|
|
|
|
debugfs_create_file("tunable_scaling", 0644, debugfs_sched, NULL, &sched_scaling_fops);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
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)
|
2023-11-04 20:11:33 +01:00
|
|
|
SPLIT_NS(schedstat_val_or_zero(p->stats.sum_sleep_runtime)),
|
|
|
|
SPLIT_NS(schedstat_val_or_zero(p->stats.sum_block_runtime)));
|
|
|
|
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2024-02-29 17:17:15 +01:00
|
|
|
+ SEQ_printf(m, " %2d", p->se.burst_score);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
2023-11-04 20:11:33 +01:00
|
|
|
#ifdef CONFIG_NUMA_BALANCING
|
|
|
|
SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
|
|
|
|
#endif
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -1068,6 +1123,9 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
|
2024-03-16 11:46:26 +01:00
|
|
|
|
|
|
|
P(se.load.weight);
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ P(se.burst_score);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
P(se.avg.load_sum);
|
|
|
|
P(se.avg.runnable_sum);
|
|
|
|
P(se.avg.util_sum);
|
2023-11-04 20:11:33 +01:00
|
|
|
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
|
2024-04-03 18:43:13 +02:00
|
|
|
index fc0a9de42..ae55f46a8 100644
|
2023-11-04 20:11:33 +01:00
|
|
|
--- a/kernel/sched/fair.c
|
|
|
|
+++ b/kernel/sched/fair.c
|
|
|
|
@@ -19,6 +19,9 @@
|
|
|
|
*
|
|
|
|
* Adaptive scheduling granularity, math enhancements by Peter Zijlstra
|
|
|
|
* Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra
|
|
|
|
+ *
|
|
|
|
+ * Burst-Oriented Response Enhancer (BORE) CPU Scheduler
|
2024-02-29 17:17:15 +01:00
|
|
|
+ * Copyright (C) 2021-2024 Masahito Suzuki <firelzrd@gmail.com>
|
2023-11-04 20:11:33 +01:00
|
|
|
*/
|
|
|
|
#include <linux/energy_model.h>
|
|
|
|
#include <linux/mmap_lock.h>
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -64,28 +67,125 @@
|
2023-11-04 20:11:33 +01:00
|
|
|
* SCHED_TUNABLESCALING_LOG - scaled logarithmical, *1+ilog(ncpus)
|
|
|
|
* SCHED_TUNABLESCALING_LINEAR - scaled linear, *ncpus
|
|
|
|
*
|
|
|
|
- * (default SCHED_TUNABLESCALING_LOG = *(1+ilog(ncpus))
|
|
|
|
+ * (BORE default SCHED_TUNABLESCALING_NONE = *1 constant)
|
|
|
|
+ * (EEVDF default SCHED_TUNABLESCALING_LOG = *(1+ilog(ncpus))
|
|
|
|
*/
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+unsigned int sysctl_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
|
2024-02-29 17:17:15 +01:00
|
|
|
+#else // !CONFIG_SCHED_BORE
|
2023-11-04 20:11:33 +01:00
|
|
|
unsigned int sysctl_sched_tunable_scaling = SCHED_TUNABLESCALING_LOG;
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Minimal preemption granularity for CPU-bound tasks:
|
|
|
|
*
|
|
|
|
- * (default: 0.75 msec * (1 + ilog(ncpus)), units: nanoseconds)
|
2024-02-29 17:17:15 +01:00
|
|
|
+ * (BORE default: max(1 sec / HZ, min_base_slice) constant, units: nanoseconds)
|
2023-11-04 20:11:33 +01:00
|
|
|
+ * (EEVDF default: 0.75 msec * (1 + ilog(ncpus)), units: nanoseconds)
|
|
|
|
*/
|
2024-02-29 17:17:15 +01:00
|
|
|
-#ifdef CONFIG_CACHY
|
|
|
|
-unsigned int sysctl_sched_base_slice = 350000ULL;
|
|
|
|
-static unsigned int normalized_sysctl_sched_base_slice = 350000ULL;
|
|
|
|
-#else
|
2023-11-04 20:11:33 +01:00
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2024-02-29 17:17:15 +01:00
|
|
|
+unsigned int sysctl_sched_base_slice = 1000000000ULL / HZ;
|
|
|
|
+static unsigned int configured_sched_base_slice = 1000000000ULL / HZ;
|
|
|
|
+unsigned int sysctl_sched_min_base_slice = 2000000ULL;
|
|
|
|
+#else // !CONFIG_SCHED_BORE
|
2023-11-04 20:11:33 +01:00
|
|
|
unsigned int sysctl_sched_base_slice = 750000ULL;
|
|
|
|
static unsigned int normalized_sysctl_sched_base_slice = 750000ULL;
|
2024-02-29 17:17:15 +01:00
|
|
|
-#endif
|
2023-11-04 20:11:33 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
2024-02-29 17:17:15 +01:00
|
|
|
-#ifdef CONFIG_CACHY
|
|
|
|
-const_debug unsigned int sysctl_sched_migration_cost = 300000UL;
|
|
|
|
-#else
|
2023-11-04 20:11:33 +01:00
|
|
|
const_debug unsigned int sysctl_sched_migration_cost = 500000UL;
|
2024-02-29 17:17:15 +01:00
|
|
|
-#endif
|
|
|
|
+
|
2023-11-04 20:11:33 +01:00
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2024-02-29 17:17:15 +01:00
|
|
|
+u8 __read_mostly sched_bore = 1;
|
|
|
|
+u8 __read_mostly sched_burst_smoothness_long = 1;
|
|
|
|
+u8 __read_mostly sched_burst_smoothness_short = 0;
|
2023-12-12 12:10:53 +01:00
|
|
|
+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;
|
2024-03-16 11:46:26 +01:00
|
|
|
+static int __maybe_unused thirty_two = 32;
|
2024-02-29 17:17:15 +01:00
|
|
|
+static int __maybe_unused sixty_four = 64;
|
|
|
|
+static int __maybe_unused maxval_12_bits = 4095;
|
2023-12-12 12:10:53 +01:00
|
|
|
+
|
|
|
|
+#define MAX_BURST_PENALTY (39U <<2)
|
2023-11-04 20:11:33 +01:00
|
|
|
+
|
|
|
|
+static inline u32 log2plus1_u64_u32f8(u64 v) {
|
2023-12-12 12:10:53 +01:00
|
|
|
+ u32 msb = fls64(v);
|
|
|
|
+ s32 excess_bits = msb - 9;
|
|
|
|
+ u8 fractional = (0 <= excess_bits)? v >> excess_bits: v << -excess_bits;
|
|
|
|
+ return msb << 8 | fractional;
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline u32 calc_burst_penalty(u64 burst_time) {
|
|
|
|
+ u32 greed, tolerance, penalty, scaled_penalty;
|
|
|
|
+
|
|
|
|
+ greed = log2plus1_u64_u32f8(burst_time);
|
|
|
|
+ tolerance = sched_burst_penalty_offset << 8;
|
|
|
|
+ penalty = max(0, (s32)greed - (s32)tolerance);
|
2023-12-12 12:10:53 +01:00
|
|
|
+ scaled_penalty = penalty * sched_burst_penalty_scale >> 16;
|
2023-11-04 20:11:33 +01:00
|
|
|
+
|
|
|
|
+ return min(MAX_BURST_PENALTY, scaled_penalty);
|
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static inline u64 scale_slice(u64 delta, struct sched_entity *se) {
|
|
|
|
+ return mul_u64_u32_shr(delta, sched_prio_to_wmult[se->burst_score], 22);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline u64 __unscale_slice(u64 delta, u8 score) {
|
|
|
|
+ return mul_u64_u32_shr(delta, sched_prio_to_weight[score], 10);
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static inline u64 unscale_slice(u64 delta, struct sched_entity *se) {
|
|
|
|
+ return __unscale_slice(delta, se->burst_score);
|
|
|
|
+}
|
|
|
|
+
|
2024-04-03 18:43:13 +02:00
|
|
|
+void reweight_task(struct task_struct *p, int prio);
|
2024-02-29 17:17:15 +01:00
|
|
|
+
|
|
|
|
+static void update_burst_score(struct sched_entity *se) {
|
2024-04-03 18:43:13 +02:00
|
|
|
+ if (!entity_is_task(se)) return;
|
|
|
|
+ struct task_struct *p = task_of(se);
|
|
|
|
+ u8 prio = p->static_prio - MAX_RT_PRIO;
|
|
|
|
+ u8 prev_prio = min(39, prio + se->burst_score);
|
2024-02-29 17:17:15 +01:00
|
|
|
+
|
2024-04-03 18:43:13 +02:00
|
|
|
+ se->burst_score = se->burst_penalty >> 2;
|
|
|
|
+
|
|
|
|
+ u8 new_prio = min(39, prio + se->burst_score);
|
|
|
|
+ if (new_prio != prev_prio)
|
|
|
|
+ reweight_task(p, new_prio);
|
2023-12-12 12:10:53 +01:00
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static void update_burst_penalty(struct sched_entity *se) {
|
|
|
|
+ se->curr_burst_penalty = calc_burst_penalty(se->burst_time);
|
|
|
|
+ se->burst_penalty = max(se->prev_burst_penalty, se->curr_burst_penalty);
|
|
|
|
+ update_burst_score(se);
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline u32 binary_smooth(u32 new, u32 old) {
|
|
|
|
+ int increment = new - old;
|
|
|
|
+ return (0 <= increment)?
|
2023-12-12 12:10:53 +01:00
|
|
|
+ old + ( increment >> (int)sched_burst_smoothness_long):
|
|
|
|
+ old - (-increment >> (int)sched_burst_smoothness_short);
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void restart_burst(struct sched_entity *se) {
|
|
|
|
+ se->burst_penalty = se->prev_burst_penalty =
|
|
|
|
+ binary_smooth(se->curr_burst_penalty, se->prev_burst_penalty);
|
|
|
|
+ se->curr_burst_penalty = 0;
|
|
|
|
+ se->burst_time = 0;
|
2024-02-29 17:17:15 +01:00
|
|
|
+ update_burst_score(se);
|
2023-11-04 20:11:33 +01:00
|
|
|
+}
|
|
|
|
+
|
2024-02-29 17:17:15 +01:00
|
|
|
+static void restart_burst_rescale_deadline(struct sched_entity *se) {
|
|
|
|
+ s64 vscaled, wremain, vremain = se->deadline - se->vruntime;
|
|
|
|
+ u8 prev_score = se->burst_score;
|
|
|
|
+ restart_burst(se);
|
|
|
|
+ if (prev_score > se->burst_score) {
|
|
|
|
+ wremain = __unscale_slice(abs(vremain), prev_score);
|
|
|
|
+ vscaled = scale_slice(wremain, se);
|
|
|
|
+ if (unlikely(vremain < 0))
|
|
|
|
+ vscaled = -vscaled;
|
|
|
|
+ se->deadline = se->vruntime + vscaled;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
2023-11-04 20:11:33 +01:00
|
|
|
int sched_thermal_decay_shift;
|
|
|
|
static int __init setup_sched_thermal_decay_shift(char *str)
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -136,12 +236,8 @@ int __weak arch_asym_cpu_priority(int cpu)
|
2024-02-29 17:17:15 +01:00
|
|
|
*
|
|
|
|
* (default: 5 msec, units: microseconds)
|
|
|
|
*/
|
|
|
|
-#ifdef CONFIG_CACHY
|
|
|
|
-static unsigned int sysctl_sched_cfs_bandwidth_slice = 3000UL;
|
|
|
|
-#else
|
|
|
|
static unsigned int sysctl_sched_cfs_bandwidth_slice = 5000UL;
|
|
|
|
#endif
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NUMA_BALANCING
|
|
|
|
/* Restrict the NUMA promotion throughput (MB/s) for each target node. */
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -150,6 +246,69 @@ static unsigned int sysctl_numa_balancing_promote_rate_limit = 65536;
|
2023-11-04 20:11:33 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
static struct ctl_table sched_fair_sysctls[] = {
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ {
|
|
|
|
+ .procname = "sched_bore",
|
|
|
|
+ .data = &sched_bore,
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .maxlen = sizeof(u8),
|
2023-11-04 20:11:33 +01:00
|
|
|
+ .mode = 0644,
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .proc_handler = proc_dou8vec_minmax,
|
2024-04-03 18:43:13 +02:00
|
|
|
+ .extra1 = SYSCTL_ONE,
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .extra2 = SYSCTL_ONE,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ .procname = "sched_burst_smoothness_long",
|
|
|
|
+ .data = &sched_burst_smoothness_long,
|
|
|
|
+ .maxlen = sizeof(u8),
|
|
|
|
+ .mode = 0644,
|
|
|
|
+ .proc_handler = proc_dou8vec_minmax,
|
|
|
|
+ .extra1 = SYSCTL_ZERO,
|
|
|
|
+ .extra2 = SYSCTL_ONE,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ .procname = "sched_burst_smoothness_short",
|
|
|
|
+ .data = &sched_burst_smoothness_short,
|
|
|
|
+ .maxlen = sizeof(u8),
|
|
|
|
+ .mode = 0644,
|
|
|
|
+ .proc_handler = proc_dou8vec_minmax,
|
|
|
|
+ .extra1 = SYSCTL_ZERO,
|
|
|
|
+ .extra2 = SYSCTL_ONE,
|
2023-11-04 20:11:33 +01:00
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ .procname = "sched_burst_fork_atavistic",
|
|
|
|
+ .data = &sched_burst_fork_atavistic,
|
2023-12-12 12:10:53 +01:00
|
|
|
+ .maxlen = sizeof(u8),
|
2023-11-04 20:11:33 +01:00
|
|
|
+ .mode = 0644,
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .proc_handler = proc_dou8vec_minmax,
|
2023-11-04 20:11:33 +01:00
|
|
|
+ .extra1 = SYSCTL_ZERO,
|
2023-12-12 12:10:53 +01:00
|
|
|
+ .extra2 = SYSCTL_THREE,
|
2023-11-04 20:11:33 +01:00
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ .procname = "sched_burst_penalty_offset",
|
|
|
|
+ .data = &sched_burst_penalty_offset,
|
2023-12-12 12:10:53 +01:00
|
|
|
+ .maxlen = sizeof(u8),
|
2023-11-04 20:11:33 +01:00
|
|
|
+ .mode = 0644,
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .proc_handler = proc_dou8vec_minmax,
|
2023-11-04 20:11:33 +01:00
|
|
|
+ .extra1 = SYSCTL_ZERO,
|
|
|
|
+ .extra2 = &sixty_four,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ .procname = "sched_burst_penalty_scale",
|
|
|
|
+ .data = &sched_burst_penalty_scale,
|
2023-12-12 12:10:53 +01:00
|
|
|
+ .maxlen = sizeof(uint),
|
2023-11-04 20:11:33 +01:00
|
|
|
+ .mode = 0644,
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .proc_handler = proc_douintvec_minmax,
|
2023-11-04 20:11:33 +01:00
|
|
|
+ .extra1 = SYSCTL_ZERO,
|
|
|
|
+ .extra2 = &maxval_12_bits,
|
|
|
|
+ },
|
|
|
|
+ {
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .procname = "sched_burst_cache_lifetime",
|
|
|
|
+ .data = &sched_burst_cache_lifetime,
|
|
|
|
+ .maxlen = sizeof(uint),
|
2023-12-12 12:10:53 +01:00
|
|
|
+ .mode = 0644,
|
2024-02-29 17:17:15 +01:00
|
|
|
+ .proc_handler = proc_douintvec,
|
2023-11-04 20:11:33 +01:00
|
|
|
+ },
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
2024-02-29 17:17:15 +01:00
|
|
|
#ifdef CONFIG_CFS_BANDWIDTH
|
2023-11-04 20:11:33 +01:00
|
|
|
{
|
2024-02-29 17:17:15 +01:00
|
|
|
.procname = "sched_cfs_bandwidth_slice_us",
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -208,6 +367,13 @@ static inline void update_load_set(struct load_weight *lw, unsigned long w)
|
2024-02-29 17:17:15 +01:00
|
|
|
*
|
|
|
|
* This idea comes from the SD scheduler of Con Kolivas:
|
|
|
|
*/
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+static void update_sysctl(void) {
|
|
|
|
+ sysctl_sched_base_slice =
|
|
|
|
+ max(sysctl_sched_min_base_slice, configured_sched_base_slice);
|
|
|
|
+}
|
|
|
|
+void sched_update_min_base_slice(void) { update_sysctl(); }
|
|
|
|
+#else // !CONFIG_SCHED_BORE
|
|
|
|
static unsigned int get_update_sysctl_factor(void)
|
|
|
|
{
|
|
|
|
unsigned int cpus = min_t(unsigned int, num_online_cpus(), 8);
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -238,6 +404,7 @@ static void update_sysctl(void)
|
2024-02-29 17:17:15 +01:00
|
|
|
SET_SYSCTL(sched_base_slice);
|
|
|
|
#undef SET_SYSCTL
|
|
|
|
}
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
|
|
|
void __init sched_init_granularity(void)
|
|
|
|
{
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -717,6 +884,9 @@ static void update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
|
2024-02-29 17:17:15 +01:00
|
|
|
lag = avg_vruntime(cfs_rq) - se->vruntime;
|
|
|
|
|
|
|
|
limit = calc_delta_fair(max_t(u64, 2*se->slice, TICK_NSEC), se);
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2024-04-03 18:43:13 +02:00
|
|
|
+ limit >>= 1;
|
2024-02-29 17:17:15 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
se->vlag = clamp(lag, -limit, limit);
|
2023-11-04 20:11:33 +01:00
|
|
|
}
|
|
|
|
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -968,6 +1138,7 @@ struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
|
2023-11-04 20:11:33 +01:00
|
|
|
* Scheduling class statistics methods:
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_SMP
|
2024-02-29 17:17:15 +01:00
|
|
|
+#if !defined(CONFIG_SCHED_BORE)
|
2023-11-04 20:11:33 +01:00
|
|
|
int sched_update_scaling(void)
|
|
|
|
{
|
2024-02-29 17:17:15 +01:00
|
|
|
unsigned int factor = get_update_sysctl_factor();
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -979,6 +1150,7 @@ int sched_update_scaling(void)
|
2024-02-29 17:17:15 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2023-12-12 12:10:53 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
2024-02-29 17:17:15 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
2023-12-12 12:10:53 +01:00
|
|
|
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -1178,7 +1350,13 @@ static void update_curr(struct cfs_rq *cfs_rq)
|
2024-02-29 17:17:15 +01:00
|
|
|
if (unlikely(delta_exec <= 0))
|
|
|
|
return;
|
2023-11-04 20:11:33 +01:00
|
|
|
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ curr->burst_time += delta_exec;
|
|
|
|
+ update_burst_penalty(curr);
|
|
|
|
+ curr->vruntime += max(1ULL, calc_delta_fair(delta_exec, curr));
|
2024-02-29 17:17:15 +01:00
|
|
|
+#else // !CONFIG_SCHED_BORE
|
|
|
|
curr->vruntime += calc_delta_fair(delta_exec, curr);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
2023-11-04 20:11:33 +01:00
|
|
|
update_deadline(cfs_rq, curr);
|
|
|
|
update_min_vruntime(cfs_rq);
|
|
|
|
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -5184,6 +5362,9 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
|
2024-03-16 11:46:26 +01:00
|
|
|
*
|
|
|
|
* EEVDF: placement strategy #1 / #2
|
2024-02-29 17:17:15 +01:00
|
|
|
*/
|
2023-12-12 12:10:53 +01:00
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2024-04-03 18:43:13 +02:00
|
|
|
+ if (se->vlag)
|
2023-12-12 12:10:53 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
2024-03-16 11:46:26 +01:00
|
|
|
if (sched_feat(PLACE_LAG) && cfs_rq->nr_running) {
|
|
|
|
struct sched_entity *curr = cfs_rq->curr;
|
|
|
|
unsigned long load;
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -6816,6 +6997,14 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
|
2023-12-12 12:10:53 +01:00
|
|
|
bool was_sched_idle = sched_idle_rq(rq);
|
2023-11-04 20:11:33 +01:00
|
|
|
|
2023-12-12 12:10:53 +01:00
|
|
|
util_est_dequeue(&rq->cfs, p);
|
2023-11-04 20:11:33 +01:00
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2023-12-12 12:10:53 +01:00
|
|
|
+ if (task_sleep) {
|
2024-02-29 17:17:15 +01:00
|
|
|
+ cfs_rq = cfs_rq_of(se);
|
|
|
|
+ if (cfs_rq->curr == se)
|
|
|
|
+ update_curr(cfs_rq);
|
2023-12-12 12:10:53 +01:00
|
|
|
+ restart_burst(se);
|
|
|
|
+ }
|
2023-11-04 20:11:33 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
2023-12-12 12:10:53 +01:00
|
|
|
for_each_sched_entity(se) {
|
|
|
|
cfs_rq = cfs_rq_of(se);
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -8565,16 +8754,25 @@ static void yield_task_fair(struct rq *rq)
|
2023-11-04 20:11:33 +01:00
|
|
|
/*
|
|
|
|
* Are we the only task in the tree?
|
|
|
|
*/
|
2024-02-29 17:17:15 +01:00
|
|
|
+#if !defined(CONFIG_SCHED_BORE)
|
|
|
|
if (unlikely(rq->nr_running == 1))
|
2023-11-04 20:11:33 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
clear_buddies(cfs_rq, se);
|
2024-02-29 17:17:15 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
2023-11-04 20:11:33 +01:00
|
|
|
|
2024-02-29 17:17:15 +01:00
|
|
|
update_rq_clock(rq);
|
|
|
|
/*
|
2023-11-04 20:11:33 +01:00
|
|
|
* Update run-time statistics of the 'current'.
|
|
|
|
*/
|
|
|
|
update_curr(cfs_rq);
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
2024-02-29 17:17:15 +01:00
|
|
|
+ restart_burst_rescale_deadline(se);
|
|
|
|
+ if (unlikely(rq->nr_running == 1))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ clear_buddies(cfs_rq, se);
|
2023-11-04 20:11:33 +01:00
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
/*
|
|
|
|
* Tell update_rq_clock() that we've just updated,
|
|
|
|
* so we don't do microscopic update in schedule()
|
2024-04-03 18:43:13 +02:00
|
|
|
@@ -12664,6 +12862,9 @@ static void task_fork_fair(struct task_struct *p)
|
2024-02-29 17:17:15 +01:00
|
|
|
curr = cfs_rq->curr;
|
|
|
|
if (curr)
|
|
|
|
update_curr(cfs_rq);
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+ update_burst_score(se);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
place_entity(cfs_rq, se, ENQUEUE_INITIAL);
|
|
|
|
rq_unlock(rq, &rf);
|
|
|
|
}
|
2023-11-04 20:11:33 +01:00
|
|
|
diff --git a/kernel/sched/features.h b/kernel/sched/features.h
|
2024-02-29 17:17:15 +01:00
|
|
|
index 143f55df8..3f0fe409f 100644
|
2023-11-04 20:11:33 +01:00
|
|
|
--- a/kernel/sched/features.h
|
|
|
|
+++ b/kernel/sched/features.h
|
|
|
|
@@ -6,7 +6,11 @@
|
|
|
|
*/
|
|
|
|
SCHED_FEAT(PLACE_LAG, true)
|
|
|
|
SCHED_FEAT(PLACE_DEADLINE_INITIAL, true)
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+SCHED_FEAT(RUN_TO_PARITY, false)
|
2024-02-29 17:17:15 +01:00
|
|
|
+#else // !CONFIG_SCHED_BORE
|
2023-11-04 20:11:33 +01:00
|
|
|
SCHED_FEAT(RUN_TO_PARITY, true)
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prefer to schedule the task we woke last (assuming it failed
|
2024-02-29 17:17:15 +01:00
|
|
|
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
|
|
|
|
index ed5c758c7..9d62372ae 100644
|
|
|
|
--- a/kernel/sched/sched.h
|
|
|
|
+++ b/kernel/sched/sched.h
|
|
|
|
@@ -1965,7 +1965,11 @@ static inline void dirty_sched_domain_sysctl(int cpu)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+extern void sched_update_min_base_slice(void);
|
|
|
|
+#else // !CONFIG_SCHED_BORE
|
|
|
|
extern int sched_update_scaling(void);
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
|
|
|
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;
|
|
|
|
extern const_debug unsigned int sysctl_sched_migration_cost;
|
|
|
|
|
|
|
|
extern unsigned int sysctl_sched_base_slice;
|
|
|
|
+#ifdef CONFIG_SCHED_BORE
|
|
|
|
+extern unsigned int sysctl_sched_min_base_slice;
|
|
|
|
+#endif // CONFIG_SCHED_BORE
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_DEBUG
|
|
|
|
extern int sysctl_resched_latency_warn_ms;
|
2023-11-04 20:11:33 +01:00
|
|
|
--
|
2024-02-29 17:17:15 +01:00
|
|
|
2.43.0.232.ge79552d197
|