This commit is contained in:
ferrreo 2023-07-26 10:45:05 +01:00
parent 88eaaf7a8a
commit 6e71e0f1db
6 changed files with 3161 additions and 912 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
From d5ebb5aa8f44f2a81002becad5f85b6e70801575 Mon Sep 17 00:00:00 2001
From 5c15cb285591295dbbe5da9d7d957fa36e49db0b Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Tue, 11 Jul 2023 19:27:06 +0200
Date: Wed, 19 Jul 2023 18:55:28 +0200
Subject: [PATCH] EEVDF
Signed-off-by: Peter Jung <admin@ptr1337.dev>
@ -20,7 +20,7 @@ Signed-off-by: Peter Jung <admin@ptr1337.dev>
12 files changed, 733 insertions(+), 658 deletions(-)
diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index e592a9364473..c826ab4e2e1a 100644
index e592a93644739..c826ab4e2e1a1 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -1121,6 +1121,16 @@ All time durations are in microseconds.
@ -41,7 +41,7 @@ index e592a9364473..c826ab4e2e1a 100644
Memory
diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index 7ee7ed5de722..6dbc5a1bf6a8 100644
index 7ee7ed5de7227..6dbc5a1bf6a8c 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -60,6 +60,32 @@ rb_insert_augmented_cached(struct rb_node *node,
@ -78,7 +78,7 @@ index 7ee7ed5de722..6dbc5a1bf6a8 100644
* Template for declaring augmented rbtree callbacks (generic case)
*
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8473324705ca..88c3e7ba8992 100644
index 8473324705caa..88c3e7ba8992e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -550,13 +550,18 @@ struct sched_entity {
@ -110,7 +110,7 @@ index 8473324705ca..88c3e7ba8992 100644
struct sched_entity se;
struct sched_rt_entity rt;
diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h
index 3bac0a8ceab2..b2e932c25be6 100644
index 3bac0a8ceab26..b2e932c25be62 100644
--- a/include/uapi/linux/sched.h
+++ b/include/uapi/linux/sched.h
@@ -132,6 +132,7 @@ struct clone_args {
@ -131,7 +131,7 @@ index 3bac0a8ceab2..b2e932c25be6 100644
#endif /* _UAPI_LINUX_SCHED_H */
diff --git a/include/uapi/linux/sched/types.h b/include/uapi/linux/sched/types.h
index f2c4589d4dbf..db1e8199e8c8 100644
index f2c4589d4dbfe..db1e8199e8c80 100644
--- a/include/uapi/linux/sched/types.h
+++ b/include/uapi/linux/sched/types.h
@@ -10,6 +10,7 @@ struct sched_param {
@ -175,7 +175,7 @@ index f2c4589d4dbf..db1e8199e8c8 100644
#endif /* _UAPI_LINUX_SCHED_TYPES_H */
diff --git a/init/init_task.c b/init/init_task.c
index ff6c4b9bfe6b..511cbcf3510d 100644
index ff6c4b9bfe6b1..511cbcf3510dc 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -78,6 +78,7 @@ struct task_struct init_task
@ -196,7 +196,7 @@ index ff6c4b9bfe6b..511cbcf3510d 100644
.rt = {
.run_list = LIST_HEAD_INIT(init_task.rt.run_list),
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1b971c69d3a2..df2f22a9729c 100644
index 1b971c69d3a2a..df2f22a9729cb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1305,6 +1305,12 @@ static void set_load_weight(struct task_struct *p, bool update_load)
@ -358,7 +358,7 @@ index 1b971c69d3a2..df2f22a9729c 100644
#ifdef CONFIG_CFS_BANDWIDTH
{
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index aeeba46a096b..5c743bcb340d 100644
index aeeba46a096b9..5c743bcb340d2 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -347,10 +347,7 @@ static __init int sched_init_debug(void)
@ -462,7 +462,7 @@ index aeeba46a096b..5c743bcb340d 100644
P(dl.runtime);
P(dl.deadline);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 64cbea29b007..36dcf4770830 100644
index a6205f9e6cb59..15167f12b9cf3 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -47,6 +47,7 @@
@ -1663,7 +1663,7 @@ index 64cbea29b007..36dcf4770830 100644
}
@@ -6241,13 +6335,12 @@ static inline void unthrottle_offline_cfs_rqs(struct rq *rq) {}
@@ -6259,13 +6353,12 @@ static inline void unthrottle_offline_cfs_rqs(struct rq *rq) {}
static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
{
struct sched_entity *se = &p->se;
@ -1678,7 +1678,7 @@ index 64cbea29b007..36dcf4770830 100644
s64 delta = slice - ran;
if (delta < 0) {
@@ -6271,8 +6364,7 @@ static void hrtick_update(struct rq *rq)
@@ -6289,8 +6382,7 @@ static void hrtick_update(struct rq *rq)
if (!hrtick_enabled_fair(rq) || curr->sched_class != &fair_sched_class)
return;
@ -1688,7 +1688,7 @@ index 64cbea29b007..36dcf4770830 100644
}
#else /* !CONFIG_SCHED_HRTICK */
static inline void
@@ -6313,17 +6405,6 @@ static int sched_idle_rq(struct rq *rq)
@@ -6331,17 +6423,6 @@ static int sched_idle_rq(struct rq *rq)
rq->nr_running);
}
@ -1706,7 +1706,7 @@ index 64cbea29b007..36dcf4770830 100644
#ifdef CONFIG_SMP
static int sched_idle_cpu(int cpu)
{
@@ -7809,18 +7890,6 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu)
@@ -7827,18 +7908,6 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu)
{
struct sched_entity *se = &p->se;
@ -1725,7 +1725,7 @@ index 64cbea29b007..36dcf4770830 100644
if (!task_on_rq_migrating(p)) {
remove_entity_load_avg(se);
@@ -7858,66 +7927,6 @@ balance_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
@@ -7876,66 +7945,6 @@ balance_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
}
#endif /* CONFIG_SMP */
@ -1792,7 +1792,7 @@ index 64cbea29b007..36dcf4770830 100644
static void set_next_buddy(struct sched_entity *se)
{
for_each_sched_entity(se) {
@@ -7929,12 +7938,6 @@ static void set_next_buddy(struct sched_entity *se)
@@ -7947,12 +7956,6 @@ static void set_next_buddy(struct sched_entity *se)
}
}
@ -1805,7 +1805,7 @@ index 64cbea29b007..36dcf4770830 100644
/*
* Preempt the current task with a newly woken task if needed:
*/
@@ -7943,7 +7946,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
@@ -7961,7 +7964,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
struct task_struct *curr = rq->curr;
struct sched_entity *se = &curr->se, *pse = &p->se;
struct cfs_rq *cfs_rq = task_cfs_rq(curr);
@ -1813,7 +1813,7 @@ index 64cbea29b007..36dcf4770830 100644
int next_buddy_marked = 0;
int cse_is_idle, pse_is_idle;
@@ -7959,7 +7961,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
@@ -7977,7 +7979,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
if (unlikely(throttled_hierarchy(cfs_rq_of(pse))))
return;
@ -1822,7 +1822,7 @@ index 64cbea29b007..36dcf4770830 100644
set_next_buddy(pse);
next_buddy_marked = 1;
}
@@ -8004,35 +8006,19 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
@@ -8022,35 +8024,19 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
if (cse_is_idle != pse_is_idle)
return;
@ -1865,7 +1865,7 @@ index 64cbea29b007..36dcf4770830 100644
}
#ifdef CONFIG_SMP
@@ -8233,8 +8219,6 @@ static void put_prev_task_fair(struct rq *rq, struct task_struct *prev)
@@ -8251,8 +8237,6 @@ static void put_prev_task_fair(struct rq *rq, struct task_struct *prev)
/*
* sched_yield() is very simple
@ -1874,7 +1874,7 @@ index 64cbea29b007..36dcf4770830 100644
*/
static void yield_task_fair(struct rq *rq)
{
@@ -8250,21 +8234,19 @@ static void yield_task_fair(struct rq *rq)
@@ -8268,21 +8252,19 @@ static void yield_task_fair(struct rq *rq)
clear_buddies(cfs_rq, se);
@ -1908,7 +1908,7 @@ index 64cbea29b007..36dcf4770830 100644
}
static bool yield_to_task_fair(struct rq *rq, struct task_struct *p)
@@ -8512,8 +8494,7 @@ static int task_hot(struct task_struct *p, struct lb_env *env)
@@ -8530,8 +8512,7 @@ static int task_hot(struct task_struct *p, struct lb_env *env)
* Buddy candidates are cache hot:
*/
if (sched_feat(CACHE_HOT_BUDDY) && env->dst_rq->nr_running &&
@ -1918,7 +1918,7 @@ index 64cbea29b007..36dcf4770830 100644
return 1;
if (sysctl_sched_migration_cost == -1)
@@ -12139,8 +12120,8 @@ static void rq_offline_fair(struct rq *rq)
@@ -12157,8 +12138,8 @@ static void rq_offline_fair(struct rq *rq)
static inline bool
__entity_slice_used(struct sched_entity *se, int min_nr_tasks)
{
@ -1928,7 +1928,7 @@ index 64cbea29b007..36dcf4770830 100644
return (rtime * min_nr_tasks > slice);
}
@@ -12296,8 +12277,8 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
@@ -12314,8 +12295,8 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
*/
static void task_fork_fair(struct task_struct *p)
{
@ -1938,7 +1938,7 @@ index 64cbea29b007..36dcf4770830 100644
struct rq *rq = this_rq();
struct rq_flags rf;
@@ -12306,22 +12287,9 @@ static void task_fork_fair(struct task_struct *p)
@@ -12324,22 +12305,9 @@ static void task_fork_fair(struct task_struct *p)
cfs_rq = task_cfs_rq(current);
curr = cfs_rq->curr;
@ -1963,7 +1963,7 @@ index 64cbea29b007..36dcf4770830 100644
rq_unlock(rq, &rf);
}
@@ -12350,34 +12318,6 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio)
@@ -12368,34 +12336,6 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio)
check_preempt_curr(rq, p, 0);
}
@ -1998,7 +1998,7 @@ index 64cbea29b007..36dcf4770830 100644
#ifdef CONFIG_FAIR_GROUP_SCHED
/*
* Propagate the changes of the sched_entity across the tg tree to make it
@@ -12448,16 +12388,6 @@ static void attach_entity_cfs_rq(struct sched_entity *se)
@@ -12466,16 +12406,6 @@ static void attach_entity_cfs_rq(struct sched_entity *se)
static void detach_task_cfs_rq(struct task_struct *p)
{
struct sched_entity *se = &p->se;
@ -2015,7 +2015,7 @@ index 64cbea29b007..36dcf4770830 100644
detach_entity_cfs_rq(se);
}
@@ -12465,12 +12395,8 @@ static void detach_task_cfs_rq(struct task_struct *p)
@@ -12483,12 +12413,8 @@ static void detach_task_cfs_rq(struct task_struct *p)
static void attach_task_cfs_rq(struct task_struct *p)
{
struct sched_entity *se = &p->se;
@ -2028,7 +2028,7 @@ index 64cbea29b007..36dcf4770830 100644
}
static void switched_from_fair(struct rq *rq, struct task_struct *p)
@@ -12581,6 +12507,7 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
@@ -12599,6 +12525,7 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
goto err;
tg->shares = NICE_0_LOAD;
@ -2036,7 +2036,7 @@ index 64cbea29b007..36dcf4770830 100644
init_cfs_bandwidth(tg_cfs_bandwidth(tg));
@@ -12679,6 +12606,9 @@ void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
@@ -12697,6 +12624,9 @@ void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
}
se->my_q = cfs_rq;
@ -2046,7 +2046,7 @@ index 64cbea29b007..36dcf4770830 100644
/* guarantee group entities always have weight */
update_load_set(&se->load, NICE_0_LOAD);
se->parent = parent;
@@ -12809,6 +12739,29 @@ int sched_group_set_idle(struct task_group *tg, long idle)
@@ -12827,6 +12757,29 @@ int sched_group_set_idle(struct task_group *tg, long idle)
return 0;
}
@ -2076,7 +2076,7 @@ index 64cbea29b007..36dcf4770830 100644
#else /* CONFIG_FAIR_GROUP_SCHED */
void free_fair_sched_group(struct task_group *tg) { }
@@ -12835,7 +12788,7 @@ static unsigned int get_rr_interval_fair(struct rq *rq, struct task_struct *task
@@ -12853,7 +12806,7 @@ static unsigned int get_rr_interval_fair(struct rq *rq, struct task_struct *task
* idle runqueue:
*/
if (rq->cfs.load.weight)
@ -2086,7 +2086,7 @@ index 64cbea29b007..36dcf4770830 100644
return rr_interval;
}
diff --git a/kernel/sched/features.h b/kernel/sched/features.h
index 9e390eb82e38..ca95044a7479 100644
index 9e390eb82e384..ca95044a74791 100644
--- a/kernel/sched/features.h
+++ b/kernel/sched/features.h
@@ -1,16 +1,12 @@
@ -2133,7 +2133,7 @@ index 9e390eb82e38..ca95044a7479 100644
-SCHED_FEAT(ALT_PERIOD, true)
-SCHED_FEAT(BASE_SLICE, true)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 0605fb53816d..96b1ae519f20 100644
index a6e814eb84cd8..abf5a48b509c6 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -372,6 +372,8 @@ struct task_group {
@ -2174,7 +2174,7 @@ index 0605fb53816d..96b1ae519f20 100644
#ifdef CONFIG_SCHED_DEBUG
unsigned int nr_spread_over;
@@ -2170,6 +2176,7 @@ extern const u32 sched_prio_to_wmult[40];
@@ -2192,6 +2198,7 @@ extern const u32 sched_prio_to_wmult[40];
#else
#define ENQUEUE_MIGRATED 0x00
#endif
@ -2182,7 +2182,7 @@ index 0605fb53816d..96b1ae519f20 100644
#define RETRY_TASK ((void *)-1UL)
@@ -2474,11 +2481,9 @@ extern void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags);
@@ -2496,11 +2503,9 @@ extern void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags);
extern const_debug unsigned int sysctl_sched_nr_migrate;
extern const_debug unsigned int sysctl_sched_migration_cost;
@ -2196,7 +2196,7 @@ index 0605fb53816d..96b1ae519f20 100644
extern int sysctl_resched_latency_warn_ms;
extern int sysctl_resched_latency_warn_once;
@@ -2491,6 +2496,8 @@ extern unsigned int sysctl_numa_balancing_scan_size;
@@ -2513,6 +2518,8 @@ extern unsigned int sysctl_numa_balancing_scan_size;
extern unsigned int sysctl_numa_balancing_hot_threshold;
#endif
@ -2205,7 +2205,7 @@ index 0605fb53816d..96b1ae519f20 100644
#ifdef CONFIG_SCHED_HRTICK
/*
@@ -3499,4 +3506,7 @@ static inline void task_tick_mm_cid(struct rq *rq, struct task_struct *curr) { }
@@ -3521,4 +3528,7 @@ static inline void task_tick_mm_cid(struct rq *rq, struct task_struct *curr) { }
static inline void init_sched_mm_cid(struct task_struct *t) { }
#endif
@ -2214,7 +2214,7 @@ index 0605fb53816d..96b1ae519f20 100644
+
#endif /* _KERNEL_SCHED_SCHED_H */
diff --git a/tools/include/uapi/linux/sched.h b/tools/include/uapi/linux/sched.h
index 3bac0a8ceab2..b2e932c25be6 100644
index 3bac0a8ceab26..b2e932c25be62 100644
--- a/tools/include/uapi/linux/sched.h
+++ b/tools/include/uapi/linux/sched.h
@@ -132,6 +132,7 @@ struct clone_args {

View File

@ -1,21 +1,21 @@
From 4a346951e2b3c7de65511c95f74fdd7197e3d2e5 Mon Sep 17 00:00:00 2001
From: Peter Jung <admin@ptr1337.dev>
Date: Tue, 11 Jul 2023 19:31:15 +0200
From 06140f2f7a609e07d9fc7d1c79343772ead98dbd Mon Sep 17 00:00:00 2001
From: Piotr Gorski <lucjan.lucjanov@gmail.com>
Date: Sun, 23 Jul 2023 09:44:46 +0200
Subject: [PATCH] bore-eevdf
Signed-off-by: Peter Jung <admin@ptr1337.dev>
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
---
include/linux/sched.h | 10 +++
init/Kconfig | 20 +++++
kernel/sched/core.c | 62 +++++++++++++
include/linux/sched.h | 10 ++
init/Kconfig | 20 ++++
kernel/sched/core.c | 117 +++++++++++++++++++++++
kernel/sched/debug.c | 4 +
kernel/sched/fair.c | 193 ++++++++++++++++++++++++++++++++++++++--
kernel/sched/fair.c | 203 ++++++++++++++++++++++++++++++++++++++--
kernel/sched/features.h | 4 +
kernel/sched/sched.h | 1 +
7 files changed, 286 insertions(+), 8 deletions(-)
7 files changed, 351 insertions(+), 8 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 88c3e7ba8992..6b4c553aea75 100644
index 88c3e7ba8..6b4c553ae 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -560,6 +560,12 @@ struct sched_entity {
@ -43,7 +43,7 @@ index 88c3e7ba8992..6b4c553aea75 100644
/*
* 'ptraced' is the list of tasks this task is using ptrace() on.
diff --git a/init/Kconfig b/init/Kconfig
index b6d38eccca10..e90546df3182 100644
index b6d38eccc..e90546df3 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1277,6 +1277,26 @@ config CHECKPOINT_RESTORE
@ -74,16 +74,17 @@ index b6d38eccca10..e90546df3182 100644
bool "Automatic process group scheduling"
select CGROUPS
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index df2f22a9729c..4995243a2ba4 100644
index df2f22a97..df8b76e2c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4490,6 +4490,57 @@ int wake_up_state(struct task_struct *p, unsigned int state)
@@ -4490,6 +4490,112 @@ int wake_up_state(struct task_struct *p, unsigned int state)
return try_to_wake_up(p, state, 0);
}
+#ifdef CONFIG_SCHED_BORE
+#define CHILD_BURST_CUTOFF_BITS 9
+extern unsigned int sched_burst_cache_lifetime;
+extern unsigned int sched_burst_fork_atavistic;
+
+void __init sched_init_bore(void) {
+ init_task.child_burst_cache = 0;
@ -93,82 +94,136 @@ index df2f22a9729c..4995243a2ba4 100644
+ init_task.se.max_burst_time = 0;
+}
+
+void inline __sched_fork_bore(struct task_struct *p) {
+void inline sched_fork_bore(struct task_struct *p) {
+ p->child_burst_cache = 0;
+ p->child_burst_last_cached = 0;
+ p->se.burst_time = 0;
+}
+
+static inline void update_task_child_burst_time_cache(struct task_struct *p) {
+ u64 sum = 0, avg_burst_time = 0;
+ u32 cnt = 0;
+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;
+}
+
+static inline bool child_burst_cache_expired(struct task_struct *p, u64 now) {
+ return (p->child_burst_last_cached + sched_burst_cache_lifetime < now);
+}
+
+static void __update_child_burst_cache(
+ struct task_struct *p, u32 cnt, u64 sum, u64 now) {
+ u64 avg = 0;
+ if (cnt) avg = div_u64(sum, cnt) << CHILD_BURST_CUTOFF_BITS;
+ p->child_burst_cache = max(avg, p->se.max_burst_time);
+ p->child_burst_last_cached = now;
+}
+
+static void update_child_burst_cache(struct task_struct *p, u64 now) {
+ struct task_struct *child;
+ u32 cnt = 0;
+ u64 sum = 0;
+
+ read_lock(&tasklist_lock);
+ list_for_each_entry(child, &p->children, sibling) {
+ cnt++;
+ sum += child->se.max_burst_time >> CHILD_BURST_CUTOFF_BITS;
+ }
+
+ __update_child_burst_cache(p, cnt, sum, now);
+}
+
+static void update_child_burst_cache_atavistic(
+ struct task_struct *p, u64 now, u32 depth, u32 *acnt, u64 *asum) {
+ struct task_struct *child, *dec;
+ u32 cnt = 0, dcnt = 0;
+ u64 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) {
+ cnt++;
+ sum += dec->se.max_burst_time >> CHILD_BURST_CUTOFF_BITS;
+ } else {
+ if (child_burst_cache_expired(dec, now))
+ update_child_burst_cache_atavistic(dec, now, depth - 1, &cnt, &sum);
+ else {
+ cnt += dcnt;
+ sum += (dec->child_burst_cache >> CHILD_BURST_CUTOFF_BITS) * dcnt;
+ }
+ }
+ }
+
+ __update_child_burst_cache(p, cnt, sum, now);
+ *acnt += cnt;
+ *asum += sum;
+}
+
+static void update_task_initial_burst_time(struct task_struct *p) {
+ struct sched_entity *se = &p->se;
+ struct task_struct *anc = p->real_parent;
+ u64 now = ktime_get_ns();
+ u32 cnt = 0;
+ u64 sum = 0;
+
+ read_lock(&tasklist_lock);
+
+ if (sched_burst_fork_atavistic) {
+ while ((anc->real_parent != anc) && (count_child_tasks(anc) == 1))
+ anc = anc->real_parent;
+ if (child_burst_cache_expired(anc, now))
+ update_child_burst_cache_atavistic(
+ anc, now, sched_burst_fork_atavistic - 1, &cnt, &sum);
+ } else
+ if (child_burst_cache_expired(anc, now))
+ update_child_burst_cache(anc, now);
+
+ read_unlock(&tasklist_lock);
+
+ if (cnt) avg_burst_time = div_u64(sum, cnt) << CHILD_BURST_CUTOFF_BITS;
+ p->child_burst_cache = max(avg_burst_time, p->se.max_burst_time);
+}
+
+static void update_task_initial_burst_time(struct task_struct *task) {
+ struct sched_entity *se = &task->se;
+ struct task_struct *par = task->real_parent;
+ u64 now = ktime_get_ns();
+
+ if (likely(par)) {
+ if (par->child_burst_last_cached + sched_burst_cache_lifetime < now) {
+ par->child_burst_last_cached = now;
+ update_task_child_burst_time_cache(par);
+ }
+ se->prev_burst_time = max(se->prev_burst_time, par->child_burst_cache);
+ }
+
+ se->max_burst_time = se->prev_burst_time;
+ se->max_burst_time = se->prev_burst_time =
+ max(se->prev_burst_time, anc->child_burst_cache);
+}
+#endif // CONFIG_SCHED_BORE
+
/*
* Perform scheduler related setup for a newly forked process p.
* p is forked by current.
@@ -4506,6 +4557,9 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
@@ -4506,6 +4612,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;
+#ifdef CONFIG_SCHED_BORE
+ __sched_fork_bore(p);
+ sched_fork_bore(p);
+#endif // CONFIG_SCHED_BORE
p->se.vlag = 0;
INIT_LIST_HEAD(&p->se.group_node);
@@ -4735,6 +4789,9 @@ late_initcall(sched_core_sysctl_init);
int sched_fork(unsigned long clone_flags, struct task_struct *p)
@@ -4827,6 +4936,9 @@ void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs)
void sched_post_fork(struct task_struct *p)
{
__sched_fork(clone_flags, p);
+#ifdef CONFIG_SCHED_BORE
+ update_task_initial_burst_time(p);
+#endif // CONFIG_SCHED_BORE
/*
* We mark the process as NEW here. This guarantees that
* nobody will actually run it, and a signal or other external
@@ -9968,6 +10025,11 @@ void __init sched_init(void)
uclamp_post_fork(p);
}
@@ -9968,6 +10080,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 2.4.2 by Masahito Suzuki");
+ printk(KERN_INFO "BORE (Burst-Oriented Response Enhancer) CPU Scheduler modification 2.5.3 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 5c743bcb340d..755ef4c8d34b 100644
index 5c743bcb3..755ef4c8d 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -348,6 +348,7 @@ static __init int sched_init_debug(void)
@ -190,7 +245,7 @@ index 5c743bcb340d..755ef4c8d34b 100644
SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
#endif
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 36dcf4770830..30080b227866 100644
index 15167f12b..51f1b7a67 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -19,6 +19,9 @@
@ -226,7 +281,7 @@ index 36dcf4770830..30080b227866 100644
/*
* After fork, child runs first. If set to 0 (default) then
@@ -84,8 +87,75 @@ static unsigned int normalized_sysctl_sched_base_slice = 750000ULL;
@@ -84,8 +87,76 @@ static unsigned int normalized_sysctl_sched_base_slice = 750000ULL;
*/
unsigned int sysctl_sched_child_runs_first __read_mostly;
@ -246,10 +301,11 @@ index 36dcf4770830..30080b227866 100644
+#ifdef CONFIG_SCHED_BORE
+unsigned int __read_mostly sched_bore = 1;
+unsigned int __read_mostly sched_burst_cache_lifetime = 15000000;
+unsigned int __read_mostly sched_burst_penalty_offset = 18;
+unsigned int __read_mostly sched_burst_cache_lifetime = 60000000;
+unsigned int __read_mostly sched_burst_penalty_offset = 12;
+unsigned int __read_mostly sched_burst_penalty_scale = 1292;
+unsigned int __read_mostly sched_burst_smoothness = 1;
+unsigned int __read_mostly sched_burst_smoothness = 2;
+unsigned int __read_mostly sched_burst_fork_atavistic = 2;
+static int three = 3;
+static int sixty_four = 64;
+static int maxval_12_bits = 4095;
@ -279,7 +335,7 @@ index 36dcf4770830..30080b227866 100644
+}
+
+static inline u64 __binary_smooth(u64 new, u64 old, unsigned int smoothness) {
+ return (new + old * ((1 << smoothness) - 1)) >> smoothness;
+ return (new <= old)? new: (new + old * ((1 << smoothness) - 1)) >> smoothness;
+}
+
+void restart_burst(struct sched_entity *se) {
@ -302,7 +358,7 @@ index 36dcf4770830..30080b227866 100644
int sched_thermal_decay_shift;
static int __init setup_sched_thermal_decay_shift(char *str)
{
@@ -145,6 +215,51 @@ static unsigned int sysctl_numa_balancing_promote_rate_limit = 65536;
@@ -145,6 +216,60 @@ static unsigned int sysctl_numa_balancing_promote_rate_limit = 65536;
#ifdef CONFIG_SYSCTL
static struct ctl_table sched_fair_sysctls[] = {
@ -324,6 +380,15 @@ index 36dcf4770830..30080b227866 100644
+ .proc_handler = proc_dointvec,
+ },
+ {
+ .procname = "sched_burst_fork_atavistic",
+ .data = &sched_burst_fork_atavistic,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = &three,
+ },
+ {
+ .procname = "sched_burst_penalty_offset",
+ .data = &sched_burst_penalty_offset,
+ .maxlen = sizeof(unsigned int),
@ -354,7 +419,7 @@ index 36dcf4770830..30080b227866 100644
{
.procname = "sched_child_runs_first",
.data = &sysctl_sched_child_runs_first,
@@ -238,6 +353,7 @@ static void update_sysctl(void)
@@ -238,6 +363,7 @@ static void update_sysctl(void)
#define SET_SYSCTL(name) \
(sysctl_##name = (factor) * normalized_sysctl_##name)
SET_SYSCTL(sched_base_slice);
@ -362,7 +427,7 @@ index 36dcf4770830..30080b227866 100644
#undef SET_SYSCTL
}
@@ -308,11 +424,19 @@ static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight
@@ -308,11 +434,19 @@ static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight
/*
* delta /= w
*/
@ -382,7 +447,7 @@ index 36dcf4770830..30080b227866 100644
return delta;
}
@@ -708,7 +832,11 @@ void update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
@@ -708,7 +842,11 @@ void update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
SCHED_WARN_ON(!se->on_rq);
lag = avg_vruntime(cfs_rq) - se->vruntime;
@ -394,7 +459,7 @@ index 36dcf4770830..30080b227866 100644
se->vlag = clamp(lag, -limit, limit);
}
@@ -946,6 +1074,7 @@ int sched_update_scaling(void)
@@ -946,6 +1084,7 @@ int sched_update_scaling(void)
#define WRT_SYSCTL(name) \
(normalized_sysctl_##name = sysctl_##name / (factor))
WRT_SYSCTL(sched_base_slice);
@ -402,7 +467,7 @@ index 36dcf4770830..30080b227866 100644
#undef WRT_SYSCTL
return 0;
@@ -1123,6 +1252,11 @@ static void update_curr(struct cfs_rq *cfs_rq)
@@ -1123,6 +1262,11 @@ static void update_curr(struct cfs_rq *cfs_rq)
curr->sum_exec_runtime += delta_exec;
schedstat_add(cfs_rq->exec_clock, delta_exec);
@ -414,7 +479,7 @@ index 36dcf4770830..30080b227866 100644
curr->vruntime += calc_delta_fair(delta_exec, curr);
update_deadline(cfs_rq, curr);
update_min_vruntime(cfs_rq);
@@ -5237,6 +5371,9 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
@@ -5237,6 +5381,9 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
se->prev_sum_exec_runtime = se->sum_exec_runtime;
}
@ -424,7 +489,7 @@ index 36dcf4770830..30080b227866 100644
/*
* Pick the next process, keeping these things in mind, in this order:
* 1) keep things fair between processes/task groups
@@ -5247,14 +5384,16 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
@@ -5247,14 +5394,16 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
static struct sched_entity *
pick_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *curr)
{
@ -443,7 +508,7 @@ index 36dcf4770830..30080b227866 100644
}
static bool check_cfs_rq_runtime(struct cfs_rq *cfs_rq);
@@ -6504,6 +6643,38 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
@@ -6522,6 +6671,38 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
hrtick_update(rq);
}
@ -482,7 +547,7 @@ index 36dcf4770830..30080b227866 100644
static void set_next_buddy(struct sched_entity *se);
/*
@@ -6522,6 +6693,9 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
@@ -6540,6 +6721,9 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
util_est_dequeue(&rq->cfs, p);
for_each_sched_entity(se) {
@ -492,7 +557,7 @@ index 36dcf4770830..30080b227866 100644
cfs_rq = cfs_rq_of(se);
dequeue_entity(cfs_rq, se, flags);
@@ -8012,7 +8186,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
@@ -8030,7 +8214,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
/*
* XXX pick_eevdf(cfs_rq) != se ?
*/
@ -501,7 +566,7 @@ index 36dcf4770830..30080b227866 100644
goto preempt;
return;
@@ -8225,6 +8399,9 @@ static void yield_task_fair(struct rq *rq)
@@ -8243,6 +8427,9 @@ static void yield_task_fair(struct rq *rq)
struct task_struct *curr = rq->curr;
struct cfs_rq *cfs_rq = task_cfs_rq(curr);
struct sched_entity *se = &curr->se;
@ -512,7 +577,7 @@ index 36dcf4770830..30080b227866 100644
/*
* Are we the only task in the tree?
diff --git a/kernel/sched/features.h b/kernel/sched/features.h
index ca95044a7479..a7d34d1b28c5 100644
index ca95044a7..a7d34d1b2 100644
--- a/kernel/sched/features.h
+++ b/kernel/sched/features.h
@@ -13,7 +13,11 @@ SCHED_FEAT(PLACE_DEADLINE_INITIAL, true)
@ -528,10 +593,10 @@ index ca95044a7479..a7d34d1b28c5 100644
/*
* Consider buddies to be cache hot, decreases the likeliness of a
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 96b1ae519f20..cc0a17fb23c2 100644
index abf5a48b5..a9f9e80a1 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2482,6 +2482,7 @@ extern const_debug unsigned int sysctl_sched_nr_migrate;
@@ -2504,6 +2504,7 @@ 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;
@ -540,4 +605,4 @@ index 96b1ae519f20..cc0a17fb23c2 100644
#ifdef CONFIG_SCHED_DEBUG
extern int sysctl_resched_latency_warn_ms;
--
2.41.0
2.41.0.159.g0bfa463d37

File diff suppressed because it is too large Load Diff

View File

@ -2,4 +2,4 @@
echo "Pika Kernel - Building"
make -j`nproc` bindeb-pkg LOCALVERSION=-pikaos KDEB_PKGVERSION=$(make kernelversion)-24
make -j`nproc` bindeb-pkg LOCALVERSION=-pikaos KDEB_PKGVERSION=$(make kernelversion)-1

View File

@ -2,7 +2,7 @@
echo "Pika Kernel - Getting source"
wget -nv https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.3.tar.gz
tar -xf ./linux-6.4.3.tar.gz
wget -nv https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.4.6.tar.gz
tar -xf ./linux-6.4.6.tar.gz
cd linux-6.4.3
cd linux-6.4.6