From: Tim Chen <tim.c.chen@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Ingo Molnar <mingo@elte.hu>, Juri Lelli <juri.lelli@redhat.com>
Cc: Yu Chen <yu.c.chen@intel.com>,
Walter Mack <walter.mack@intel.com>, Mel Gorman <mgorman@suse.de>,
linux-kernel@vger.kernel.org,
Tim Chen <tim.c.chen@linux.intel.com>
Subject: [PATCH 1/2] sched/fair: Don't rely on ->exec_start for migration
Date: Fri, 25 Mar 2022 15:54:16 -0700 [thread overview]
Message-ID: <68832dfbb60fda030540b5f4e39c5801942689b1.1648228023.git.tim.c.chen@linux.intel.com> (raw)
In-Reply-To: <cover.1648228023.git.tim.c.chen@linux.intel.com>
From: Peter Zijlstra <peterz@infradead.org>
From: Peter Zijlstra (Intel) <peterz@infradead.org>
Currently migrate_task_rq_fair() (ab)uses se->exec_start to make
task_hot() fail. In order to preserve ->exec_start, add a ->migrated
flag to sched_entity.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
include/linux/sched.h | 1 +
kernel/sched/fair.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 75ba8aa60248..0edf16b4d40a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -541,6 +541,7 @@ struct sched_entity {
struct rb_node run_node;
struct list_head group_node;
unsigned int on_rq;
+ unsigned int migrated;
u64 exec_start;
u64 sum_exec_runtime;
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5146163bfabb..2498e97804fd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1004,6 +1004,7 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
/*
* We are starting a new run period:
*/
+ se->migrated = 0;
se->exec_start = rq_clock_task(rq_of(cfs_rq));
}
@@ -6979,7 +6980,7 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu)
p->se.avg.last_update_time = 0;
/* We have migrated, no longer consider this task hot */
- p->se.exec_start = 0;
+ p->se.migrated = 1;
update_scan_period(p, new_cpu);
}
@@ -7665,6 +7666,9 @@ static int task_hot(struct task_struct *p, struct lb_env *env)
if (sysctl_sched_migration_cost == 0)
return 0;
+ if (p->se.migrated)
+ return 0;
+
delta = rq_clock_task(env->src_rq) - p->se.exec_start;
return delta < (s64)sysctl_sched_migration_cost;
--
2.32.0
next prev parent reply other threads:[~2022-03-25 23:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 22:54 [PATCH 0/2] sched/fair: Fix starvation caused by task migration Tim Chen
2022-03-25 22:54 ` Tim Chen [this message]
2022-03-25 22:54 ` [PATCH 2/2] sched/fair: Simple runqueue order on migrate Tim Chen
2022-03-29 9:03 ` Vincent Guittot
2022-03-31 11:47 ` Peter Zijlstra
2022-03-31 12:15 ` Vincent Guittot
2022-03-29 10:09 ` Abel Wu
2022-03-29 14:26 ` Tim Chen
2022-03-30 9:46 ` [sched/fair] ddb3b1126f: hackbench.throughput -25.9% regression kernel test robot
2022-03-30 23:48 ` Tim Chen
2022-04-01 18:04 ` Chen Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68832dfbb60fda030540b5f4e39c5801942689b1.1648228023.git.tim.c.chen@linux.intel.com \
--to=tim.c.chen@linux.intel.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=vincent.guittot@linaro.org \
--cc=walter.mack@intel.com \
--cc=yu.c.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®