diff --git a/patches/CacULE/v5.13/rdb-5.13.patch b/patches/CacULE/v5.13/rdb-5.13.patch index 428cd6414..56d4c6810 100644 --- a/patches/CacULE/v5.13/rdb-5.13.patch +++ b/patches/CacULE/v5.13/rdb-5.13.patch @@ -64,10 +64,10 @@ index 089e3bfe5dbc..7c46008e5a7b 100644 This option optimizes the scheduler for common desktop workloads by automatically creating and populating task groups. This separation diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index 6d75473d05f0..abef21dc9500 100644 +index bdedde199504..18d2b5d41b36 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -8111,8 +8111,11 @@ void __init sched_init(void) +@@ -8129,8 +8129,11 @@ void __init sched_init(void) BUG_ON(&dl_sched_class + 1 != &stop_sched_class); #endif @@ -82,10 +82,10 @@ index 6d75473d05f0..abef21dc9500 100644 wait_bit_init(); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index 162395e3fda2..3ca2fedc1cd0 100644 +index ddb9e65b0381..d85baba422d3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c -@@ -786,6 +786,10 @@ static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *_se) +@@ -791,6 +791,10 @@ static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *_se) cfs_rq->head = NULL; cfs_rq->tail = NULL; @@ -96,7 +96,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } else if (se == cfs_rq->head) { // if it is the head cfs_rq->head = cfs_rq->head->next; -@@ -1158,6 +1162,7 @@ static void update_curr_fair(struct rq *rq) +@@ -1163,6 +1167,7 @@ static void update_curr_fair(struct rq *rq) static inline void update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se) { @@ -104,7 +104,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 u64 wait_start, prev_wait_start; if (!schedstat_enabled()) -@@ -1171,11 +1176,13 @@ update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se) +@@ -1176,11 +1181,13 @@ update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se) wait_start -= prev_wait_start; __schedstat_set(se->statistics.wait_start, wait_start); @@ -118,7 +118,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 struct task_struct *p; u64 delta; -@@ -1212,11 +1219,13 @@ update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se) +@@ -1217,11 +1224,13 @@ update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se) __schedstat_inc(se->statistics.wait_count); __schedstat_add(se->statistics.wait_sum, delta); __schedstat_set(se->statistics.wait_start, 0); @@ -132,7 +132,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 struct task_struct *tsk = NULL; u64 sleep_start, block_start; -@@ -1280,6 +1289,7 @@ update_stats_enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) +@@ -1285,6 +1294,7 @@ update_stats_enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) account_scheduler_latency(tsk, delta >> 10, 0); } } @@ -140,7 +140,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } /* -@@ -1288,6 +1298,7 @@ update_stats_enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) +@@ -1293,6 +1303,7 @@ update_stats_enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) static inline void update_stats_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) { @@ -148,7 +148,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 if (!schedstat_enabled()) return; -@@ -1300,11 +1311,13 @@ update_stats_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) +@@ -1305,11 +1316,13 @@ update_stats_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) if (flags & ENQUEUE_WAKEUP) update_stats_enqueue_sleeper(cfs_rq, se); @@ -162,7 +162,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 if (!schedstat_enabled()) return; -@@ -1325,6 +1338,7 @@ update_stats_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) +@@ -1330,6 +1343,7 @@ update_stats_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) __schedstat_set(se->statistics.block_start, rq_clock(rq_of(cfs_rq))); } @@ -170,7 +170,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } /* -@@ -3355,15 +3369,19 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se) +@@ -3360,15 +3374,19 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se) static inline void enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { @@ -190,7 +190,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } #else static inline void -@@ -3664,6 +3682,7 @@ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq) +@@ -3669,6 +3687,7 @@ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq) void set_task_rq_fair(struct sched_entity *se, struct cfs_rq *prev, struct cfs_rq *next) { @@ -198,7 +198,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 u64 p_last_update_time; u64 n_last_update_time; -@@ -3703,6 +3722,7 @@ void set_task_rq_fair(struct sched_entity *se, +@@ -3708,6 +3727,7 @@ void set_task_rq_fair(struct sched_entity *se, #endif __update_load_avg_blocked_se(p_last_update_time, se); se->avg.last_update_time = n_last_update_time; @@ -206,7 +206,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } -@@ -3981,6 +4001,9 @@ static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum +@@ -3986,6 +4006,9 @@ static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) { @@ -216,7 +216,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 unsigned long removed_load = 0, removed_util = 0, removed_runnable = 0; struct sched_avg *sa = &cfs_rq->avg; int decayed = 0; -@@ -4026,8 +4049,10 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) +@@ -4031,8 +4054,10 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) #endif return decayed; @@ -227,7 +227,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /** * attach_entity_load_avg - attach this entity to its cfs_rq load avg * @cfs_rq: cfs_rq to attach to -@@ -4111,6 +4136,7 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s +@@ -4116,6 +4141,7 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s trace_pelt_cfs_tp(cfs_rq); } @@ -235,15 +235,17 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * Optional action to be done while updating the load average -@@ -4122,6 +4148,7 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s +@@ -4127,6 +4153,9 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s /* Update task and its cfs_rq load average */ static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) { -+#if !defined(CONFIG_CACULE_RDB) ++#ifdef CONFIG_CACULE_RDB ++ cfs_rq_util_change(cfs_rq, 0); ++#else u64 now = cfs_rq_clock_pelt(cfs_rq); int decayed; -@@ -4153,8 +4180,10 @@ static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s +@@ -4158,8 +4187,10 @@ static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s if (flags & UPDATE_TG) update_tg_load_avg(cfs_rq); } @@ -254,7 +256,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 #ifndef CONFIG_64BIT static inline u64 cfs_rq_last_update_time(struct cfs_rq *cfs_rq) { -@@ -4175,6 +4204,7 @@ static inline u64 cfs_rq_last_update_time(struct cfs_rq *cfs_rq) +@@ -4180,6 +4211,7 @@ static inline u64 cfs_rq_last_update_time(struct cfs_rq *cfs_rq) return cfs_rq->avg.last_update_time; } #endif @@ -262,7 +264,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * Synchronize entity load avg of dequeued entity without locking -@@ -4182,11 +4212,13 @@ static inline u64 cfs_rq_last_update_time(struct cfs_rq *cfs_rq) +@@ -4187,11 +4219,13 @@ static inline u64 cfs_rq_last_update_time(struct cfs_rq *cfs_rq) */ static void sync_entity_load_avg(struct sched_entity *se) { @@ -276,7 +278,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } /* -@@ -4195,6 +4227,7 @@ static void sync_entity_load_avg(struct sched_entity *se) +@@ -4200,6 +4234,7 @@ static void sync_entity_load_avg(struct sched_entity *se) */ static void remove_entity_load_avg(struct sched_entity *se) { @@ -284,7 +286,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 struct cfs_rq *cfs_rq = cfs_rq_of(se); unsigned long flags; -@@ -4212,6 +4245,7 @@ static void remove_entity_load_avg(struct sched_entity *se) +@@ -4217,6 +4252,7 @@ static void remove_entity_load_avg(struct sched_entity *se) cfs_rq->removed.load_avg += se->avg.load_avg; cfs_rq->removed.runnable_avg += se->avg.runnable_avg; raw_spin_unlock_irqrestore(&cfs_rq->removed.lock, flags); @@ -292,7 +294,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } static inline unsigned long cfs_rq_runnable_avg(struct cfs_rq *cfs_rq) -@@ -4505,10 +4539,13 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) +@@ -4510,10 +4546,13 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) } #endif /* CONFIG_CACULE_SCHED */ @@ -306,7 +308,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 #ifdef CONFIG_SCHEDSTATS if (schedstat_enabled()) return; -@@ -4525,6 +4562,7 @@ static inline void check_schedstat_required(void) +@@ -4530,6 +4569,7 @@ static inline void check_schedstat_required(void) "kernel.sched_schedstats=1\n"); } #endif @@ -314,7 +316,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } static inline bool cfs_bandwidth_used(void); -@@ -4614,6 +4652,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) +@@ -4619,6 +4659,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) __enqueue_entity(cfs_rq, se); se->on_rq = 1; @@ -322,7 +324,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * When bandwidth control is enabled, cfs might have been removed * because of a parent been throttled but cfs->nr_running > 1. Try to -@@ -4624,6 +4663,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) +@@ -4629,6 +4670,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) if (cfs_rq->nr_running == 1) check_enqueue_throttle(cfs_rq); @@ -330,7 +332,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } #if !defined(CONFIG_CACULE_SCHED) -@@ -5154,6 +5194,9 @@ static int tg_throttle_down(struct task_group *tg, void *data) +@@ -5159,6 +5201,9 @@ static int tg_throttle_down(struct task_group *tg, void *data) static bool throttle_cfs_rq(struct cfs_rq *cfs_rq) { @@ -340,7 +342,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 struct rq *rq = rq_of(cfs_rq); struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg); struct sched_entity *se; -@@ -5231,10 +5274,12 @@ static bool throttle_cfs_rq(struct cfs_rq *cfs_rq) +@@ -5236,10 +5281,12 @@ static bool throttle_cfs_rq(struct cfs_rq *cfs_rq) cfs_rq->throttled = 1; cfs_rq->throttled_clock = rq_clock(rq); return true; @@ -353,7 +355,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 struct rq *rq = rq_of(cfs_rq); struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg); struct sched_entity *se; -@@ -5316,6 +5361,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) +@@ -5321,6 +5368,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) /* Determine whether we need to wake up potentially idle CPU: */ if (rq->curr == rq->idle && rq->cfs.nr_running) resched_curr(rq); @@ -361,7 +363,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 } static void distribute_cfs_runtime(struct cfs_bandwidth *cfs_b) -@@ -5768,7 +5814,11 @@ static inline bool cfs_bandwidth_used(void) +@@ -5773,7 +5821,11 @@ static inline bool cfs_bandwidth_used(void) static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) {} static bool check_cfs_rq_runtime(struct cfs_rq *cfs_rq) { return false; } @@ -373,17 +375,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static inline void sync_throttle(struct task_group *tg, int cpu) {} static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq) {} -@@ -5899,7 +5949,9 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) - { - struct cfs_rq *cfs_rq; - struct sched_entity *se = &p->se; -+#if !defined(CONFIG_CACULE_RDB) - int idle_h_nr_running = task_has_idle_policy(p); -+#endif - int task_new = !(flags & ENQUEUE_WAKEUP); - - /* -@@ -5918,6 +5970,13 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) +@@ -5923,6 +5975,15 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) if (p->in_iowait) cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT); @@ -392,12 +384,14 @@ index 162395e3fda2..3ca2fedc1cd0 100644 + cfs_rq = cfs_rq_of(se); + enqueue_entity(cfs_rq, se, flags); + cfs_rq->h_nr_running++; ++ cfs_rq->idle_h_nr_running += idle_h_nr_running; ++ update_load_avg(cfs_rq, se, UPDATE_TG); + } +#else for_each_sched_entity(se) { if (se->on_rq) break; -@@ -5955,6 +6014,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) +@@ -5960,6 +6021,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) if (throttled_hierarchy(cfs_rq)) list_add_leaf_cfs_rq(cfs_rq); } @@ -405,7 +399,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* At this point se is NULL and we are at root level*/ add_nr_running(rq, 1); -@@ -5976,6 +6036,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) +@@ -5981,6 +6043,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) if (!task_new) update_overutilized_status(rq); @@ -413,7 +407,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 enqueue_throttle: if (cfs_bandwidth_used()) { /* -@@ -5991,6 +6052,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) +@@ -5996,6 +6059,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) break; } } @@ -421,7 +415,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 assert_list_leaf_cfs_rq(rq); -@@ -6011,6 +6073,12 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) +@@ -6016,6 +6080,12 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) struct cfs_rq *cfs_rq; struct sched_entity *se = &p->se; int task_sleep = flags & DEQUEUE_SLEEP; @@ -434,7 +428,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 int idle_h_nr_running = task_has_idle_policy(p); bool was_sched_idle = sched_idle_rq(rq); -@@ -6059,15 +6127,18 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) +@@ -6064,15 +6134,18 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) goto dequeue_throttle; } @@ -453,7 +447,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 util_est_update(&rq->cfs, p, task_sleep); hrtick_update(rq); } -@@ -6203,6 +6274,7 @@ static int wake_wide(struct task_struct *p) +@@ -6208,6 +6281,7 @@ static int wake_wide(struct task_struct *p) } #endif /* CONFIG_CACULE_SCHED */ @@ -461,7 +455,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * The purpose of wake_affine() is to quickly determine on which CPU we can run * soonest. For the purpose of speed we only consider the waking and previous -@@ -6304,6 +6376,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, +@@ -6309,6 +6383,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, schedstat_inc(p->se.statistics.nr_wakeups_affine); return target; } @@ -469,7 +463,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static struct sched_group * find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu); -@@ -7221,13 +7294,15 @@ find_least_IS_cpu(struct task_struct *p) +@@ -7231,13 +7306,15 @@ find_least_IS_cpu(struct task_struct *p) static int select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) { @@ -486,7 +480,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 #ifdef CONFIG_CACULE_SCHED struct sched_entity *se = &p->se; -@@ -7248,7 +7323,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) +@@ -7258,7 +7335,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) new_cpu = prev_cpu; cfs_way: @@ -495,7 +489,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 if (wake_flags & WF_TTWU) { record_wakee(p); -@@ -7263,6 +7338,9 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) +@@ -7273,6 +7350,9 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) } #endif /* CONFIG_CACULE_SCHED */ @@ -505,7 +499,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 rcu_read_lock(); for_each_domain(cpu, tmp) { /* -@@ -7297,9 +7375,12 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) +@@ -7307,9 +7387,12 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) rcu_read_unlock(); return new_cpu; @@ -518,7 +512,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * Called immediately before a task is migrated to a new CPU; task_cpu(p) and -@@ -7336,6 +7417,7 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) +@@ -7346,6 +7429,7 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) } #endif /* CONFIG_CACULE_SCHED */ @@ -526,7 +520,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 if (p->on_rq == TASK_ON_RQ_MIGRATING) { /* * In case of TASK_ON_RQ_MIGRATING we in fact hold the 'old' -@@ -7355,6 +7437,7 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) +@@ -7365,6 +7449,7 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) */ remove_entity_load_avg(&p->se); } @@ -534,7 +528,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* Tell new CPU we are migrated */ p->se.avg.last_update_time = 0; -@@ -7654,11 +7737,23 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf +@@ -7664,11 +7749,23 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf if (prev) put_prev_task(rq, prev); @@ -558,7 +552,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 p = task_of(se); -@@ -7680,6 +7775,10 @@ done: __maybe_unused; +@@ -7690,6 +7787,10 @@ done: __maybe_unused; return p; idle: @@ -569,7 +563,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 if (!rf) return NULL; -@@ -7986,6 +8085,7 @@ struct lb_env { +@@ -7996,6 +8097,7 @@ struct lb_env { struct list_head tasks; }; @@ -577,7 +571,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * Is this task likely cache-hot: */ -@@ -8407,6 +8507,7 @@ static void attach_tasks(struct lb_env *env) +@@ -8417,6 +8519,7 @@ static void attach_tasks(struct lb_env *env) rq_unlock(env->dst_rq, &rf); } @@ -585,7 +579,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 #ifdef CONFIG_NO_HZ_COMMON static inline bool cfs_rq_has_blocked(struct cfs_rq *cfs_rq) -@@ -8456,6 +8557,7 @@ static inline void update_blocked_load_tick(struct rq *rq) {} +@@ -8466,6 +8569,7 @@ static inline void update_blocked_load_tick(struct rq *rq) {} static inline void update_blocked_load_status(struct rq *rq, bool has_blocked) {} #endif @@ -593,7 +587,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static bool __update_blocked_others(struct rq *rq, bool *done) { const struct sched_class *curr_class; -@@ -8481,6 +8583,7 @@ static bool __update_blocked_others(struct rq *rq, bool *done) +@@ -8491,6 +8595,7 @@ static bool __update_blocked_others(struct rq *rq, bool *done) return decayed; } @@ -601,7 +595,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 #ifdef CONFIG_FAIR_GROUP_SCHED -@@ -8571,6 +8674,7 @@ static unsigned long task_h_load(struct task_struct *p) +@@ -8581,6 +8686,7 @@ static unsigned long task_h_load(struct task_struct *p) cfs_rq_load_avg(cfs_rq) + 1); } #else @@ -609,7 +603,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static bool __update_blocked_fair(struct rq *rq, bool *done) { struct cfs_rq *cfs_rq = &rq->cfs; -@@ -8582,6 +8686,7 @@ static bool __update_blocked_fair(struct rq *rq, bool *done) +@@ -8592,6 +8698,7 @@ static bool __update_blocked_fair(struct rq *rq, bool *done) return decayed; } @@ -617,7 +611,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static unsigned long task_h_load(struct task_struct *p) { -@@ -8589,6 +8694,7 @@ static unsigned long task_h_load(struct task_struct *p) +@@ -8599,6 +8706,7 @@ static unsigned long task_h_load(struct task_struct *p) } #endif @@ -625,7 +619,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static void update_blocked_averages(int cpu) { bool decayed = false, done = true; -@@ -8607,6 +8713,7 @@ static void update_blocked_averages(int cpu) +@@ -8617,6 +8725,7 @@ static void update_blocked_averages(int cpu) cpufreq_update_util(rq, 0); rq_unlock_irqrestore(rq, &rf); } @@ -633,7 +627,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /********** Helpers for find_busiest_group ************************/ -@@ -9710,6 +9817,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s +@@ -9720,6 +9829,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s * different in groups. */ @@ -641,7 +635,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /** * find_busiest_group - Returns the busiest group within the sched_domain * if there is an imbalance. -@@ -9978,6 +10086,7 @@ static struct rq *find_busiest_queue(struct lb_env *env, +@@ -9988,6 +10098,7 @@ static struct rq *find_busiest_queue(struct lb_env *env, return busiest; } @@ -649,7 +643,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * Max backoff if we encounter pinned tasks. Pretty arbitrary value, but -@@ -10014,6 +10123,7 @@ imbalanced_active_balance(struct lb_env *env) +@@ -10024,6 +10135,7 @@ imbalanced_active_balance(struct lb_env *env) return 0; } @@ -657,7 +651,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static int need_active_balance(struct lb_env *env) { struct sched_domain *sd = env->sd; -@@ -10346,6 +10456,7 @@ static int load_balance(int this_cpu, struct rq *this_rq, +@@ -10356,6 +10468,7 @@ static int load_balance(int this_cpu, struct rq *this_rq, out: return ld_moved; } @@ -665,7 +659,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static inline unsigned long get_sd_balance_interval(struct sched_domain *sd, int cpu_busy) -@@ -10384,6 +10495,7 @@ update_next_balance(struct sched_domain *sd, unsigned long *next_balance) +@@ -10394,6 +10507,7 @@ update_next_balance(struct sched_domain *sd, unsigned long *next_balance) *next_balance = next; } @@ -673,7 +667,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * active_load_balance_cpu_stop is run by the CPU stopper. It pushes * running tasks off the busiest CPU onto idle CPUs. It requires at -@@ -10469,6 +10581,7 @@ static int active_load_balance_cpu_stop(void *data) +@@ -10479,6 +10593,7 @@ static int active_load_balance_cpu_stop(void *data) } static DEFINE_SPINLOCK(balancing); @@ -681,7 +675,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * Scale the max load_balance interval with the number of CPUs in the system. -@@ -10479,6 +10592,7 @@ void update_max_interval(void) +@@ -10489,6 +10604,7 @@ void update_max_interval(void) max_load_balance_interval = HZ*num_online_cpus()/10; } @@ -689,7 +683,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * It checks each scheduling domain to see if it is due to be balanced, * and initiates a balancing operation if so. -@@ -10571,6 +10685,7 @@ static void rebalance_domains(struct rq *rq, enum cpu_idle_type idle) +@@ -10581,6 +10697,7 @@ static void rebalance_domains(struct rq *rq, enum cpu_idle_type idle) rq->next_balance = next_balance; } @@ -697,7 +691,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static inline int on_null_domain(struct rq *rq) { -@@ -10604,6 +10719,7 @@ static inline int find_new_ilb(void) +@@ -10614,6 +10731,7 @@ static inline int find_new_ilb(void) return nr_cpu_ids; } @@ -705,7 +699,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * Kick a CPU to do the nohz balancing, if it is time for it. We pick any * idle CPU in the HK_FLAG_MISC housekeeping set (if there is one). -@@ -10754,6 +10870,7 @@ static void nohz_balancer_kick(struct rq *rq) +@@ -10764,6 +10882,7 @@ static void nohz_balancer_kick(struct rq *rq) if (flags) kick_ilb(flags); } @@ -713,26 +707,61 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static void set_cpu_sd_state_busy(int cpu) { -@@ -10861,6 +10978,7 @@ void nohz_balance_enter_idle(int cpu) - WRITE_ONCE(nohz.has_blocked, 1); +@@ -10884,11 +11003,17 @@ static bool update_nohz_stats(struct rq *rq) + if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick))) + return true; + ++#if !defined(CONFIG_CACULE_RDB) + update_blocked_averages(cpu); ++#endif + + return rq->has_blocked_load; } ++#ifdef CONFIG_CACULE_RDB ++static int idle_try_pull_any(struct cfs_rq *cfs_rq); ++#endif ++ + /* + * Internal function that runs load balance for all idle cpus. The load balance + * can be a simple update of blocked load or a complete load balance with +@@ -10958,7 +11083,11 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags, + rq_unlock_irqrestore(rq, &rf); + + if (flags & NOHZ_BALANCE_KICK) +#if !defined(CONFIG_CACULE_RDB) - static bool update_nohz_stats(struct rq *rq) - { - unsigned int cpu = rq->cpu; -@@ -11041,8 +11159,10 @@ static void nohz_newidle_balance(struct rq *this_rq) - */ - atomic_or(NOHZ_NEWILB_KICK, nohz_flags(this_cpu)); + rebalance_domains(rq, CPU_IDLE); ++#else ++ idle_try_pull_any(&rq->cfs); ++#endif + } + + if (time_after(next_balance, rq->next_balance)) { +@@ -10984,6 +11113,7 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags, + WRITE_ONCE(nohz.has_blocked, 1); + } + ++#if !defined(CONFIG_CACULE_RDB) + /* + * In CONFIG_NO_HZ_COMMON case, the idle balance kickee will do the + * rebalancing for all the cpus for whom scheduler ticks are stopped. +@@ -11004,6 +11134,7 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) + + return true; } +#endif + /* + * Check if we need to run the ILB for updating blocked load before entering +@@ -11053,6 +11184,7 @@ static void nohz_newidle_balance(struct rq *this_rq) + } + #else /* !CONFIG_NO_HZ_COMMON */ +#if !defined(CONFIG_CACULE_RDB) static inline void nohz_balancer_kick(struct rq *rq) { } static inline bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) -@@ -11051,8 +11171,130 @@ static inline bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle +@@ -11061,8 +11193,130 @@ static inline bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle } static inline void nohz_newidle_balance(struct rq *this_rq) { } @@ -812,8 +841,8 @@ index 162395e3fda2..3ca2fedc1cd0 100644 +{ + struct rq *tmp_rq, *max_rq = NULL; + int cpu; -+ u32 max_IS = cfs_rq->IS_head; -+ u32 local_IS; ++ unsigned int max_IS = cfs_rq->IS_head; ++ unsigned int local_IS; + + // find max hrrn + for_each_online_cpu(cpu) { @@ -863,7 +892,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 /* * newidle_balance is called by schedule() if this_cpu is about to become * idle. Attempts to pull tasks from other CPUs. -@@ -11063,6 +11305,105 @@ static inline void nohz_newidle_balance(struct rq *this_rq) { } +@@ -11073,6 +11327,107 @@ static inline void nohz_newidle_balance(struct rq *this_rq) { } * > 0 - success, new (fair) tasks present */ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) @@ -959,6 +988,8 @@ index 162395e3fda2..3ca2fedc1cd0 100644 + + if (pulled_task) + this_rq->idle_stamp = 0; ++ else ++ nohz_newidle_balance(this_rq); + + rq_repin_lock(this_rq, rf); + @@ -969,7 +1000,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 { unsigned long next_balance = jiffies + HZ; int this_cpu = this_rq->cpu; -@@ -11219,6 +11560,214 @@ void trigger_load_balance(struct rq *rq) +@@ -11229,6 +11584,214 @@ void trigger_load_balance(struct rq *rq) nohz_balancer_kick(rq); } @@ -1184,7 +1215,7 @@ index 162395e3fda2..3ca2fedc1cd0 100644 static void rq_online_fair(struct rq *rq) { -@@ -11397,9 +11946,12 @@ static void propagate_entity_cfs_rq(struct sched_entity *se) +@@ -11407,24 +11970,32 @@ static void propagate_entity_cfs_rq(struct sched_entity *se) } } #else @@ -1193,57 +1224,41 @@ index 162395e3fda2..3ca2fedc1cd0 100644 #endif +#endif -+#if !defined(CONFIG_CACULE_RDB) static void detach_entity_cfs_rq(struct sched_entity *se) { struct cfs_rq *cfs_rq = cfs_rq_of(se); -@@ -11410,9 +11962,11 @@ static void detach_entity_cfs_rq(struct sched_entity *se) + ++#if !defined(CONFIG_CACULE_RDB) + /* Catch up with the cfs_rq and remove our load when we leave */ + update_load_avg(cfs_rq, se, 0); + detach_entity_load_avg(cfs_rq, se); update_tg_load_avg(cfs_rq); propagate_entity_cfs_rq(se); - } ++ ++#else ++ cfs_rq_util_change(cfs_rq, 0); +#endif + } static void attach_entity_cfs_rq(struct sched_entity *se) { -+#if !defined(CONFIG_CACULE_RDB) struct cfs_rq *cfs_rq = cfs_rq_of(se); ++#if !defined(CONFIG_CACULE_RDB) #ifdef CONFIG_FAIR_GROUP_SCHED -@@ -11428,10 +11982,12 @@ static void attach_entity_cfs_rq(struct sched_entity *se) + /* + * Since the real-depth could have been changed (only FAIR +@@ -11438,6 +12009,9 @@ static void attach_entity_cfs_rq(struct sched_entity *se) attach_entity_load_avg(cfs_rq, se); update_tg_load_avg(cfs_rq); propagate_entity_cfs_rq(se); ++#else ++ cfs_rq_util_change(cfs_rq, 0); +#endif } static void detach_task_cfs_rq(struct task_struct *p) - { -+#if !defined(CONFIG_CACULE_RDB) - struct sched_entity *se = &p->se; - - #if !defined(CONFIG_CACULE_SCHED) -@@ -11448,10 +12004,12 @@ static void detach_task_cfs_rq(struct task_struct *p) - #endif - - detach_entity_cfs_rq(se); -+#endif - } - - static void attach_task_cfs_rq(struct task_struct *p) - { -+#if !defined(CONFIG_CACULE_RDB) - struct sched_entity *se = &p->se; - - #if !defined(CONFIG_CACULE_SCHED) -@@ -11464,6 +12022,7 @@ static void attach_task_cfs_rq(struct task_struct *p) - if (!vruntime_normalized(p)) - se->vruntime += cfs_rq->min_vruntime; - #endif -+#endif - } - - static void switched_from_fair(struct rq *rq, struct task_struct *p) -@@ -11859,7 +12418,9 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m) +@@ -11869,7 +12443,9 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m) __init void init_sched_fair_class(void) { #ifdef CONFIG_SMP