From: Josh Don <joshdon@google.com>
To: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
linux-kernel@vger.kernel.org, Paul Turner <pjt@google.com>,
Josh Don <joshdon@google.com>
Subject: [PATCH v2] sched/fair: Do not set skip buddy up the sched hierarchy
Date: Wed, 6 Nov 2019 14:14:48 -0800 [thread overview]
Message-ID: <20191106221448.225183-1-joshdon@google.com> (raw)
In-Reply-To: <CAKfTPtDeMevgn0JFxjzUWhp4dS10T2MQSA9P82nOGX73xUjXoA@mail.gmail.com>
From: Venkatesh Pallipadi <venki@google.com>
Setting skip buddy all the way up the hierarchy does not play well
with intra-cgroup yield. One typical usecase of yield is when a
thread in a cgroup wants to yield CPU to another thread within the
same cgroup. For such a case, setting the skip buddy all the way up
the hierarchy is counter-productive, as that results in CPU being
yielded to a task in some other cgroup.
So, limit the skip effect only to the task requesting it.
Signed-off-by: Josh Don <joshdon@google.com>
---
Changelog since v1:
- As an optimization, skip clearing the skip buddy up the hierarchy
- Due to the above, it makes sense to inline __clear_buddies_skip; while
we're at it, inline the other __clear_buddies* functions as well.
kernel/sched/fair.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 682a754ea3e1..dbac30e3cc08 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4010,7 +4010,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
}
}
-static void __clear_buddies_last(struct sched_entity *se)
+static inline void __clear_buddies_last(struct sched_entity *se)
{
for_each_sched_entity(se) {
struct cfs_rq *cfs_rq = cfs_rq_of(se);
@@ -4021,7 +4021,7 @@ static void __clear_buddies_last(struct sched_entity *se)
}
}
-static void __clear_buddies_next(struct sched_entity *se)
+static inline void __clear_buddies_next(struct sched_entity *se)
{
for_each_sched_entity(se) {
struct cfs_rq *cfs_rq = cfs_rq_of(se);
@@ -4032,15 +4032,12 @@ static void __clear_buddies_next(struct sched_entity *se)
}
}
-static void __clear_buddies_skip(struct sched_entity *se)
+static inline void __clear_buddies_skip(struct sched_entity *se)
{
- for_each_sched_entity(se) {
- struct cfs_rq *cfs_rq = cfs_rq_of(se);
- if (cfs_rq->skip != se)
- break;
+ struct cfs_rq *cfs_rq = cfs_rq_of(se);
+ if (cfs_rq->skip == se)
cfs_rq->skip = NULL;
- }
}
static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
@@ -4051,8 +4048,7 @@ static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
if (cfs_rq->next == se)
__clear_buddies_next(se);
- if (cfs_rq->skip == se)
- __clear_buddies_skip(se);
+ __clear_buddies_skip(se);
}
static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq);
@@ -6647,8 +6643,15 @@ static void set_next_buddy(struct sched_entity *se)
static void set_skip_buddy(struct sched_entity *se)
{
- for_each_sched_entity(se)
- cfs_rq_of(se)->skip = se;
+ /*
+ * One typical usecase of yield is when a thread in a cgroup
+ * wants to yield CPU to another thread within the same cgroup.
+ * For such a case, setting the skip buddy all the way up the
+ * hierarchy is counter-productive, as that results in CPU being
+ * yielded to a task in some other cgroup. So, only set skip
+ * for the task requesting it.
+ */
+ cfs_rq_of(se)->skip = se;
}
/*
--
2.24.0.rc1.363.gb1bccd3e3d-goog
next prev parent reply other threads:[~2019-11-06 22:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 18:45 [PATCH] sched/fair: Do not set skip buddy up the sched hierarchy Josh Don
2019-11-04 14:54 ` Vincent Guittot
2019-11-06 22:14 ` Josh Don [this message]
2019-12-04 20:06 [PATCH v2] " Josh Don
2019-12-06 7:57 ` Vincent Guittot
2019-12-06 22:13 ` Josh Don
2019-12-09 9:18 ` Dietmar Eggemann
2019-12-12 22:19 ` Josh Don
2019-12-18 11:36 ` Dietmar Eggemann
2019-12-18 20:02 ` Josh Don
2019-12-12 8:05 ` Vincent Guittot
2019-12-17 19:58 ` Josh Don
2019-12-17 20:42 ` Peter Zijlstra
2019-12-17 21:00 ` Greg Kroah-Hartman
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=20191106221448.225183-1-joshdon@google.com \
--to=joshdon@google.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).