From: Vincent Guittot <vincent.guittot@linaro.org>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de,
linux-kernel@vger.kernel.org
Cc: pauld@redhat.com, parth@linux.ibm.com,
valentin.schneider@arm.com, hdanton@sina.com,
Vincent Guittot <vincent.guittot@linaro.org>
Subject: [PATCH v2 1/5] sched/fair: Reorder enqueue/dequeue_task_fair path
Date: Fri, 14 Feb 2020 16:27:25 +0100 [thread overview]
Message-ID: <20200214152729.6059-2-vincent.guittot@linaro.org> (raw)
In-Reply-To: <20200214152729.6059-1-vincent.guittot@linaro.org>
The walk through the cgroup hierarchy during the enqueue/dequeue of a task
is split in 2 distinct parts for throttled cfs_rq without any added value
but making code less readable.
Change the code ordering such that everything related to a cfs_rq
(throttled or not) will be done in the same loop.
In addition, the same steps ordering is used when updating a cfs_rq:
- update_load_avg
- update_cfs_group
- update *h_nr_running
No functional and performance changes are expected and have been noticed
during tests.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
kernel/sched/fair.c | 42 ++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a7e11b1bb64c..27450c4ddc81 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5259,32 +5259,31 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
cfs_rq = cfs_rq_of(se);
enqueue_entity(cfs_rq, se, flags);
- /*
- * end evaluation on encountering a throttled cfs_rq
- *
- * note: in the case of encountering a throttled cfs_rq we will
- * post the final h_nr_running increment below.
- */
- if (cfs_rq_throttled(cfs_rq))
- break;
cfs_rq->h_nr_running++;
cfs_rq->idle_h_nr_running += idle_h_nr_running;
+ /* end evaluation on encountering a throttled cfs_rq */
+ if (cfs_rq_throttled(cfs_rq))
+ goto enqueue_throttle;
+
flags = ENQUEUE_WAKEUP;
}
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
- cfs_rq->h_nr_running++;
- cfs_rq->idle_h_nr_running += idle_h_nr_running;
+ /* end evaluation on encountering a throttled cfs_rq */
if (cfs_rq_throttled(cfs_rq))
- break;
+ goto enqueue_throttle;
update_load_avg(cfs_rq, se, UPDATE_TG);
update_cfs_group(se);
+
+ cfs_rq->h_nr_running++;
+ cfs_rq->idle_h_nr_running += idle_h_nr_running;
}
+enqueue_throttle:
if (!se) {
add_nr_running(rq, 1);
/*
@@ -5345,17 +5344,13 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
cfs_rq = cfs_rq_of(se);
dequeue_entity(cfs_rq, se, flags);
- /*
- * end evaluation on encountering a throttled cfs_rq
- *
- * note: in the case of encountering a throttled cfs_rq we will
- * post the final h_nr_running decrement below.
- */
- if (cfs_rq_throttled(cfs_rq))
- break;
cfs_rq->h_nr_running--;
cfs_rq->idle_h_nr_running -= idle_h_nr_running;
+ /* end evaluation on encountering a throttled cfs_rq */
+ if (cfs_rq_throttled(cfs_rq))
+ goto dequeue_throttle;
+
/* Don't dequeue parent if it has other entities besides us */
if (cfs_rq->load.weight) {
/* Avoid re-evaluating load for this entity: */
@@ -5373,16 +5368,19 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
for_each_sched_entity(se) {
cfs_rq = cfs_rq_of(se);
- cfs_rq->h_nr_running--;
- cfs_rq->idle_h_nr_running -= idle_h_nr_running;
+ /* end evaluation on encountering a throttled cfs_rq */
if (cfs_rq_throttled(cfs_rq))
- break;
+ goto dequeue_throttle;
update_load_avg(cfs_rq, se, UPDATE_TG);
update_cfs_group(se);
+
+ cfs_rq->h_nr_running--;
+ cfs_rq->idle_h_nr_running -= idle_h_nr_running;
}
+dequeue_throttle:
if (!se)
sub_nr_running(rq, 1);
--
2.17.1
next prev parent reply other threads:[~2020-02-14 15:27 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 15:27 [PATCH v2 0/5] remove runnable_load_avg and improve group_classify Vincent Guittot
2020-02-14 15:27 ` Vincent Guittot [this message]
2020-02-18 12:37 ` [PATCH v2 1/5] sched/fair: Reorder enqueue/dequeue_task_fair path Dietmar Eggemann
2020-02-18 13:22 ` Peter Zijlstra
2020-02-18 14:15 ` Vincent Guittot
2020-02-19 11:07 ` Dietmar Eggemann
2020-02-19 16:26 ` Vincent Guittot
2020-02-20 13:38 ` Dietmar Eggemann
[not found] ` <20200222152541.GA11669@geo.homenetwork>
2020-02-26 16:30 ` Vincent Guittot
2020-02-14 15:27 ` [PATCH v2 2/5] sched/numa: Replace runnable_load_avg by load_avg Vincent Guittot
2020-02-18 12:37 ` Dietmar Eggemann
2020-02-18 13:50 ` Mel Gorman
2020-02-18 14:17 ` Vincent Guittot
2020-02-18 14:42 ` Dietmar Eggemann
2020-02-18 14:54 ` Valentin Schneider
2020-02-18 15:33 ` Vincent Guittot
2020-02-18 15:38 ` Mel Gorman
2020-02-18 16:50 ` Valentin Schneider
2020-02-18 17:41 ` Mel Gorman
2020-02-18 17:54 ` Valentin Schneider
2020-02-18 16:51 ` Vincent Guittot
2020-02-14 15:27 ` [PATCH v2 3/5] sched/pelt: Remove unused runnable load average Vincent Guittot
2020-02-21 9:57 ` Dietmar Eggemann
2020-02-21 11:56 ` Vincent Guittot
2020-02-14 15:27 ` [PATCH v2 4/5] sched/pelt: Add a new runnable average signal Vincent Guittot
2020-02-18 14:54 ` Valentin Schneider
2020-02-18 15:12 ` Peter Zijlstra
2020-02-18 15:28 ` Vincent Guittot
2020-02-18 16:30 ` Valentin Schneider
2020-02-18 21:19 ` Valentin Schneider
2020-02-19 9:02 ` Vincent Guittot
2020-02-19 9:08 ` Mel Gorman
2020-02-19 12:55 ` [PATCH v3 " Vincent Guittot
2020-02-19 14:02 ` Mel Gorman
2020-02-19 20:10 ` Valentin Schneider
2020-02-20 14:36 ` Vincent Guittot
2020-02-20 16:11 ` Valentin Schneider
2020-02-21 8:56 ` Vincent Guittot
2020-02-24 15:57 ` Valentin Schneider
2020-02-21 9:04 ` Mel Gorman
2020-02-21 9:25 ` Vincent Guittot
2020-02-21 10:40 ` Mel Gorman
2020-02-21 13:28 ` Vincent Guittot
2020-02-20 15:04 ` Dietmar Eggemann
2020-02-21 9:44 ` Dietmar Eggemann
2020-02-21 11:47 ` Vincent Guittot
2020-02-14 15:27 ` [PATCH v2 5/5] sched/fair: Take into account runnable_avg to classify group Vincent Guittot
2020-02-15 21:58 ` [PATCH v2 0/5] remove runnable_load_avg and improve group_classify Mel Gorman
2020-02-21 9:58 ` Dietmar Eggemann
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=20200214152729.6059-2-vincent.guittot@linaro.org \
--to=vincent.guittot@linaro.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=hdanton@sina.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=parth@linux.ibm.com \
--cc=pauld@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=valentin.schneider@arm.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®