From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754146AbcLLGxW (ORCPT ); Mon, 12 Dec 2016 01:53:22 -0500 Received: from terminus.zytor.com ([198.137.202.10]:49636 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752314AbcLLGxU (ORCPT ); Mon, 12 Dec 2016 01:53:20 -0500 Date: Sun, 11 Dec 2016 22:50:46 -0800 From: tip-bot for Vincent Guittot Message-ID: Cc: peterz@infradead.org, morten.rasmussen@arm.com, linux-kernel@vger.kernel.org, matt@codeblueprint.co.uk, torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org, vincent.guittot@linaro.org, tglx@linutronix.de Reply-To: linux-kernel@vger.kernel.org, morten.rasmussen@arm.com, peterz@infradead.org, tglx@linutronix.de, vincent.guittot@linaro.org, mingo@kernel.org, torvalds@linux-foundation.org, matt@codeblueprint.co.uk, hpa@zytor.com In-Reply-To: <1481216215-24651-2-git-send-email-vincent.guittot@linaro.org> References: <1481216215-24651-2-git-send-email-vincent.guittot@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/core: Fix find_idlest_group() for fork Git-Commit-ID: f519a3f1c6b7a990e5aed37a8f853c6ecfdee945 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f519a3f1c6b7a990e5aed37a8f853c6ecfdee945 Gitweb: http://git.kernel.org/tip/f519a3f1c6b7a990e5aed37a8f853c6ecfdee945 Author: Vincent Guittot AuthorDate: Thu, 8 Dec 2016 17:56:53 +0100 Committer: Ingo Molnar CommitDate: Sun, 11 Dec 2016 13:10:56 +0100 sched/core: Fix find_idlest_group() for fork During fork, the utilization of a task is init once the rq has been selected because the current utilization level of the rq is used to set the utilization of the fork task. As the task's utilization is still 0 at this step of the fork sequence, it doesn't make sense to look for some spare capacity that can fit the task's utilization. Furthermore, I can see perf regressions for the test: hackbench -P -g 1 because the least loaded policy is always bypassed and tasks are not spread during fork. With this patch and the fix below, we are back to same performances as for v4.8. The fix below is only a temporary one used for the test until a smarter solution is found because we can't simply remove the test which is useful for others benchmarks | @@ -5708,13 +5708,6 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t | | avg_cost = this_sd->avg_scan_cost; | | - /* | - * Due to large variance we need a large fuzz factor; hackbench in | - * particularly is sensitive here. | - */ | - if ((avg_idle / 512) < avg_cost) | - return -1; | - | time = local_clock(); | | for_each_cpu_wrap(cpu, sched_domain_span(sd), target, wrap) { Tested-by: Matt Fleming Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Matt Fleming Acked-by: Morten Rasmussen Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: dietmar.eggemann@arm.com Cc: kernellwp@gmail.com Cc: umgwanakikbuti@gmail.com Cc: yuyang.du@intel.comc Link: http://lkml.kernel.org/r/1481216215-24651-2-git-send-email-vincent.guittot@linaro.org Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 18d9e75..ebb815f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5473,13 +5473,21 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, * utilized systems if we require spare_capacity > task_util(p), * so we allow for some task stuffing by using * spare_capacity > task_util(p)/2. + * + * Spare capacity can't be used for fork because the utilization has + * not been set yet, we must first select a rq to compute the initial + * utilization. */ + if (sd_flag & SD_BALANCE_FORK) + goto skip_spare; + if (this_spare > task_util(p) / 2 && imbalance*this_spare > 100*most_spare) return NULL; else if (most_spare > task_util(p) / 2) return most_spare_sg; +skip_spare: if (!idlest || 100*this_load < imbalance*min_load) return NULL; return idlest;