From 8c3259605f26b32d443be8c25e86b9a518e08a95 Mon Sep 17 00:00:00 2001 From: Hamad Al Marri Date: Tue, 16 Nov 2021 22:30:28 +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 --- patches/5.15/tt-5.15-r2.patch | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/patches/5.15/tt-5.15-r2.patch b/patches/5.15/tt-5.15-r2.patch index bb5fe67..903cbec 100644 --- a/patches/5.15/tt-5.15-r2.patch +++ b/patches/5.15/tt-5.15-r2.patch @@ -134,10 +134,10 @@ index 978fcfca5871..464b134de739 100644 obj-$(CONFIG_SMP) += cpupri.o cpudeadline.o topology.o stop_task.o pelt.o diff --git a/kernel/sched/bs.c b/kernel/sched/bs.c new file mode 100644 -index 000000000000..758cd410d6e6 +index 000000000000..bbeb0c844325 --- /dev/null +++ b/kernel/sched/bs.c -@@ -0,0 +1,1181 @@ +@@ -0,0 +1,1179 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * TT Scheduler Class (SCHED_NORMAL/SCHED_BATCH) @@ -161,9 +161,6 @@ index 000000000000..758cd410d6e6 +#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) @@ -558,14 +555,15 @@ index 000000000000..758cd410d6e6 + 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); + /* @@ -1321,10 +1319,12 @@ index 000000000000..758cd410d6e6 +} diff --git a/kernel/sched/bs.h b/kernel/sched/bs.h new file mode 100644 -index 000000000000..d413aad1d0a3 +index 000000000000..721eb690abeb --- /dev/null +++ b/kernel/sched/bs.h -@@ -0,0 +1,305 @@ +@@ -0,0 +1,306 @@ ++#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 @@ -1371,13 +1371,12 @@ index 000000000000..d413aad1d0a3 + */ + 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); +} +