From 11c50e29b9d19a22c5296697bcc1531a47327c4a Mon Sep 17 00:00:00 2001 From: Hamad Al Marri Date: Tue, 16 Nov 2021 22:05:05 +0300 Subject: [PATCH] Initial work to https://github.com/hamadmarri/TT-CPU-Scheduler/issues/6 `YIELD_MARK` only applies if `cfs_rq->h_nr_running > 1` `YIELD_UNMARK` on migrate_task --- kernel/sched/bs.c | 8 +++----- kernel/sched/bs.h | 7 ++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/sched/bs.c b/kernel/sched/bs.c index 758cd410d6e6d..bbeb0c8443251 100644 --- a/kernel/sched/bs.c +++ b/kernel/sched/bs.c @@ -21,9 +21,6 @@ unsigned int __read_mostly tt_max_lifetime = 22000; // in ms #define RACE_TIME 40000000 #define FACTOR (RACE_TIME / HZ_PERIOD) -#define YIELD_MARK(ttn) ((ttn)->vruntime |= 0x8000000000000000ULL) -#define YIELD_UNMARK(ttn) ((ttn)->vruntime &= 0x7FFFFFFFFFFFFFFFULL) - #define IS_REALTIME(ttn) ((ttn)->task_type == TT_REALTIME) #define IS_INTERACTIVE(ttn) ((ttn)->task_type == TT_INTERACTIVE) #define IS_NO_TYPE(ttn) ((ttn)->task_type == TT_NO_TYPE) @@ -418,14 +415,15 @@ static void yield_task_fair(struct rq *rq) struct task_struct *curr = rq->curr; struct cfs_rq *cfs_rq = task_cfs_rq(curr); - YIELD_MARK(&curr->se.tt_node); - /* * Are we the only task in the tree? */ if (unlikely(rq->nr_running == 1)) return; + if (cfs_rq->h_nr_running > 1) + YIELD_MARK(&curr->se.tt_node); + if (curr->policy != SCHED_BATCH) { update_rq_clock(rq); /* diff --git a/kernel/sched/bs.h b/kernel/sched/bs.h index d413aad1d0a37..721eb690abeb2 100644 --- a/kernel/sched/bs.h +++ b/kernel/sched/bs.h @@ -1,3 +1,5 @@ +#define YIELD_MARK(ttn) ((ttn)->vruntime |= 0x8000000000000000ULL) +#define YIELD_UNMARK(ttn) ((ttn)->vruntime &= 0x7FFFFFFFFFFFFFFFULL) /* * After fork, child runs first. If set to 0 (default) then @@ -44,13 +46,12 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) */ remove_entity_load_avg(&p->se); } - - /* We have migrated, no longer consider this task hot */ - p->se.exec_start = 0; #endif /* Tell new CPU we are migrated */ p->se.avg.last_update_time = 0; + YIELD_UNMARK(&p->se.tt_node); + update_scan_period(p, new_cpu); }