From patchwork Mon Sep 7 15:37:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 53246 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id AE8B522B05 for ; Mon, 7 Sep 2015 15:37:56 +0000 (UTC) Received: by lamp12 with SMTP id p12sf27397798lam.2 for ; Mon, 07 Sep 2015 08:37:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:subject:to:references:cc:from :message-id:date:user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=LjHpCH2S00HTNZgUEwRsff7LLQAmJgzYRd4gcaRFCJ0=; b=A8Cyk1ofuqQ8tlGQshQ+HgAdbvep5Xhg1o9vS+uG7MVSULt/De0b7eAntPYDYdzXLH QcoQL6aEJ77EPSicQOhckO/irxlYySDTGxvH7YsgIO6cwcXuePlBoANJlFLYBkP5Cgwv LAiV7Smg4YVfAaBOXT5Rax/eAG/RMzbPfVM7NexTIHeACPSvu1RuDt4MKBPpJMjcKOU6 UYGE4MWRyzvBLVf+f32VHa2Kio2wV1WDRHhIX8mkA/5AC0cRTnQukqFcJ3MNoAf6o1mh U/m+IrGf74LqBMXcdSkPfSulZ0Mgw4HFoALp7FcrHMxC6+ai5IDLHHYV8C5KOmWeGKDg +aUQ== X-Gm-Message-State: ALoCoQnI9Yk4lpg/cEWYeZRP+hlkzVnfLWRnq0X2aoeAS923Yy4Y4oXGUx2gGj1QgDAdF6/XJxvM X-Received: by 10.194.115.135 with SMTP id jo7mr5154466wjb.7.1441640275008; Mon, 07 Sep 2015 08:37:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.69 with SMTP id yg5ls597249lab.5.gmail; Mon, 07 Sep 2015 08:37:54 -0700 (PDT) X-Received: by 10.112.161.232 with SMTP id xv8mr17389029lbb.123.1441640274778; Mon, 07 Sep 2015 08:37:54 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id r8si299212lbh.7.2015.09.07.08.37.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2015 08:37:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagj9 with SMTP id j9so54505326lag.2 for ; Mon, 07 Sep 2015 08:37:54 -0700 (PDT) X-Received: by 10.152.198.140 with SMTP id jc12mr17463276lac.19.1441640274332; Mon, 07 Sep 2015 08:37:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp444921lbq; Mon, 7 Sep 2015 08:37:53 -0700 (PDT) X-Received: by 10.107.166.136 with SMTP id p130mr29325753ioe.163.1441640272237; Mon, 07 Sep 2015 08:37:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ml10si320295pdb.137.2015.09.07.08.37.49; Mon, 07 Sep 2015 08:37:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753915AbbIGPhs (ORCPT + 28 others); Mon, 7 Sep 2015 11:37:48 -0400 Received: from eu-smtp-delivery-143.mimecast.com ([207.82.80.143]:26578 "EHLO eu-smtp-delivery-143.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751252AbbIGPhn convert rfc822-to-8bit (ORCPT ); Mon, 7 Sep 2015 11:37:43 -0400 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-2-jBULFga3RBGiDWpNnc1Jmg-1; Mon, 07 Sep 2015 16:37:40 +0100 Received: from [10.2.131.51] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 7 Sep 2015 16:37:39 +0100 Subject: Re: [PATCH 5/6] sched/fair: Get rid of scaling utilization by capacity_orig To: Steve Muckle , Morten Rasmussen References: <1439569394-11974-1-git-send-email-morten.rasmussen@arm.com> <1439569394-11974-6-git-send-email-morten.rasmussen@arm.com> <55E8DD00.2030706@linaro.org> Cc: "peterz@infradead.org" , "mingo@redhat.com" , "vincent.guittot@linaro.org" , "daniel.lezcano@linaro.org" , "yuyang.du@intel.com" , "mturquette@baylibre.com" , "rjw@rjwysocki.net" , Juri Lelli , "sgurrappadi@nvidia.com" , "pang.xunlei@zte.com.cn" , "linux-kernel@vger.kernel.org" From: Dietmar Eggemann Message-ID: <55EDAF43.30500@arm.com> Date: Mon, 7 Sep 2015 16:37:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E8DD00.2030706@linaro.org> X-OriginalArrivalTime: 07 Sep 2015 15:37:39.0752 (UTC) FILETIME=[21022280:01D0E983] X-MC-Unique: jBULFga3RBGiDWpNnc1Jmg-1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dietmar.eggemann@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 04/09/15 00:51, Steve Muckle wrote: > Hi Morten, Dietmar, > > On 08/14/2015 09:23 AM, Morten Rasmussen wrote: > ... >> + * cfs_rq.avg.util_avg is the sum of running time of runnable tasks plus the >> + * recent utilization of currently non-runnable tasks on a CPU. It represents >> + * the amount of utilization of a CPU in the range [0..capacity_orig] where > > I see util_sum is scaled by SCHED_LOAD_SHIFT at the end of > __update_load_avg(). If there is now an assumption that util_avg may be > used directly as a capacity value, should it be changed to > SCHED_CAPACITY_SHIFT? These are equal right now, not sure if they will > always be or if they can be combined. You're referring to the code line 2647 sa->util_avg = (sa->util_sum << SCHED_LOAD_SHIFT) / LOAD_AVG_MAX; in __update_load_avg()? Here we actually scale by 'SCHED_LOAD_SCALE/LOAD_AVG_MAX' so both values are load related. LOAD (UTIL) and CAPACITY have the same SCALE and SHIFT values because SCHED_LOAD_RESOLUTION is always defined to 0. scale_load() and scale_load_down() are also NOPs so this area is probably worth a separate clean-up. Beyond that, I'm not sure if the current functionality is broken if we use different SCALE and SHIFT values for LOAD and CAPACITY? > >> + * capacity_orig is the cpu_capacity available at * the highest frequency > > spurious * > > thanks, > Steve > Fixed. Thanks, -- Dietmar -- >8 -- From: Dietmar Eggemann Date: Fri, 14 Aug 2015 17:23:13 +0100 Subject: [PATCH] sched/fair: Get rid of scaling utilization by capacity_orig Utilization is currently scaled by capacity_orig, but since we now have frequency and cpu invariant cfs_rq.avg.util_avg, frequency and cpu scaling now happens as part of the utilization tracking itself. So cfs_rq.avg.util_avg should no longer be scaled in cpu_util(). Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Dietmar Eggemann Signed-off-by: Morten Rasmussen --- kernel/sched/fair.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2074d45a67c2..a73ece2372f5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4824,33 +4824,39 @@ static int select_idle_sibling(struct task_struct *p, int target) done: return target; } + /* * cpu_util returns the amount of capacity of a CPU that is used by CFS * tasks. The unit of the return value must be the one of capacity so we can * compare the utilization with the capacity of the CPU that is available for * CFS task (ie cpu_capacity). - * cfs.avg.util_avg is the sum of running time of runnable tasks on a - * CPU. It represents the amount of utilization of a CPU in the range - * [0..SCHED_LOAD_SCALE]. The utilization of a CPU can't be higher than the - * full capacity of the CPU because it's about the running time on this CPU. - * Nevertheless, cfs.avg.util_avg can be higher than SCHED_LOAD_SCALE - * because of unfortunate rounding in util_avg or just - * after migrating tasks until the average stabilizes with the new running - * time. So we need to check that the utilization stays into the range - * [0..cpu_capacity_orig] and cap if necessary. - * Without capping the utilization, a group could be seen as overloaded (CPU0 - * utilization at 121% + CPU1 utilization at 80%) whereas CPU1 has 20% of - * available capacity. + * + * cfs_rq.avg.util_avg is the sum of running time of runnable tasks plus the + * recent utilization of currently non-runnable tasks on a CPU. It represents + * the amount of utilization of a CPU in the range [0..capacity_orig] where + * capacity_orig is the cpu_capacity available at the highest frequency + * (arch_scale_freq_capacity()). + * The utilization of a CPU converges towards a sum equal to or less than the + * current capacity (capacity_curr <= capacity_orig) of the CPU because it is + * the running time on this CPU scaled by capacity_curr. + * + * Nevertheless, cfs_rq.avg.util_avg can be higher than capacity_curr or even + * higher than capacity_orig because of unfortunate rounding in + * cfs.avg.util_avg or just after migrating tasks and new task wakeups until + * the average stabilizes with the new running time. We need to check that the + * utilization stays within the range of [0..capacity_orig] and cap it if + * necessary. Without utilization capping, a group could be seen as overloaded + * (CPU0 utilization at 121% + CPU1 utilization at 80%) whereas CPU1 has 20% of + * available capacity. We allow utilization to overshoot capacity_curr (but not + * capacity_orig) as it useful for predicting the capacity required after task + * migrations (scheduler-driven DVFS). */ static int cpu_util(int cpu) { unsigned long util = cpu_rq(cpu)->cfs.avg.util_avg; unsigned long capacity = capacity_orig_of(cpu); - if (util >= SCHED_LOAD_SCALE) - return capacity; - - return (util * capacity) >> SCHED_LOAD_SHIFT; + return (util >= capacity) ? capacity : util; } /*