linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] sched/fair: Do not set skip buddy up the sched hierarchy
@ 2019-12-04 20:06 Josh Don
  2019-12-06  7:57 ` Vincent Guittot
  0 siblings, 1 reply; 15+ messages in thread
From: Josh Don @ 2019-12-04 20:06 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	linux-kernel, Paul Turner, Josh Don

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>
---
v2: Only clear skip buddy on the current cfs_rq

 kernel/sched/fair.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 08a233e97a01..0b7a1958ad52 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4051,13 +4051,10 @@ static void __clear_buddies_next(struct sched_entity *se)
 
 static 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)
@@ -6552,8 +6549,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.393.g34dc348eaf-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* Re: [PATCH] sched/fair: Do not set skip buddy up the sched hierarchy
@ 2019-11-04 14:54 Vincent Guittot
  2019-11-06 22:14 ` [PATCH v2] " Josh Don
  0 siblings, 1 reply; 15+ messages in thread
From: Vincent Guittot @ 2019-11-04 14:54 UTC (permalink / raw)
  To: Josh Don
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Paul Turner, Mel Gorman,
	linux-kernel, Venkatesh Pallipadi

On Thu, 31 Oct 2019 at 19:45, Josh Don <joshdon@google.com> wrote:
>
> 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>
> ---
>  kernel/sched/fair.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 682a754ea3e1..52ab06585d7f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6647,8 +6647,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;
>  }

You should also update __clear_buddies_skip  to only clear this skip

>
>  /*
> --
> 2.23.0.700.g56cf767bdb-goog
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-02-25  1:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04 20:06 [PATCH v2] sched/fair: Do not set skip buddy up the sched hierarchy 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-19  0:14             ` [PATCH v3] " Josh Don
2019-12-26 15:05               ` Vincent Guittot
2020-02-25  1:50                 ` Josh Don
2019-12-12  8:05     ` [PATCH v2] " Vincent Guittot
2019-12-17 19:58       ` Josh Don
2019-12-17 20:42         ` Peter Zijlstra
2019-12-17 21:00           ` Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2019-11-04 14:54 [PATCH] " Vincent Guittot
2019-11-06 22:14 ` [PATCH v2] " Josh Don

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).