From patchwork Thu Jan 23 14:39:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 23624 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 54F08203BE for ; Thu, 23 Jan 2014 14:39:50 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf7361993oag.0 for ; Thu, 23 Jan 2014 06:39:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=tBPH8XUyoLxKuTOH8yYxB5D1FuXo/qdW6J7Jodge4cg=; b=D6qmApt8wi5hVZH+IsTAGBxaAHphSvzPZhV1PL1PTCO8OKH3rFUpiF/ml6G0JdcNKM h+ApGLzHKD6/1Igv2KVBrel9lipZtLv8ePzhPOoIe9jS9H5RWt72YjeuWiC/+bSLIKGa rxNnk6dY7I0FWEpkhScRoLBU34mNElGmY0ycEkUrVLsSFhCJpi0VeDLD8F6hWlsX2e3z IlnNs+XRliuOoTlTkenr6iSQsBT1lDzMHbZTbR1qK3eMz26wZkzLET+tTyCsNYCpFGm3 5dha3wKOC91G9Ie1Z5KQvoegI5VAOu7oO3PK3kVu/M1ftZ1erB4cOuRs4wtSJF82FhGa AzFw== X-Gm-Message-State: ALoCoQmaLLiszv3YjoIrF+LWVUqj1MGIFO0Q10ojk/8KjfH1ej9RiBFCcSE6M7PWvI7+y7/ZNvb6 X-Received: by 10.182.126.137 with SMTP id my9mr3170542obb.13.1390487989391; Thu, 23 Jan 2014 06:39:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.16 with SMTP id e16ls289862qgd.63.gmail; Thu, 23 Jan 2014 06:39:49 -0800 (PST) X-Received: by 10.220.247.68 with SMTP id mb4mr293136vcb.37.1390487989239; Thu, 23 Jan 2014 06:39:49 -0800 (PST) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id wm4si2743828vcb.79.2014.01.23.06.39.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 06:39:49 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.44; Received: by mail-vb0-f44.google.com with SMTP id f12so1083766vbg.17 for ; Thu, 23 Jan 2014 06:39:49 -0800 (PST) X-Received: by 10.58.86.230 with SMTP id s6mr4754129vez.16.1390487989127; Thu, 23 Jan 2014 06:39:49 -0800 (PST) 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.220.174.196 with SMTP id u4csp31146vcz; Thu, 23 Jan 2014 06:39:46 -0800 (PST) X-Received: by 10.68.162.131 with SMTP id ya3mr8453366pbb.102.1390487985428; Thu, 23 Jan 2014 06:39:45 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id to9si14436334pbc.5.2014.01.23.06.39.44; Thu, 23 Jan 2014 06:39:44 -0800 (PST) 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 S1754154AbaAWOji (ORCPT + 27 others); Thu, 23 Jan 2014 09:39:38 -0500 Received: from mail-wg0-f43.google.com ([74.125.82.43]:61211 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752225AbaAWOjh (ORCPT ); Thu, 23 Jan 2014 09:39:37 -0500 Received: by mail-wg0-f43.google.com with SMTP id y10so1590224wgg.22 for ; Thu, 23 Jan 2014 06:39:36 -0800 (PST) X-Received: by 10.180.80.103 with SMTP id q7mr25018833wix.14.1390487976256; Thu, 23 Jan 2014 06:39:36 -0800 (PST) Received: from [192.168.1.150] (AToulouse-654-1-414-93.w82-125.abo.wanadoo.fr. [82.125.161.93]) by mx.google.com with ESMTPSA id uc9sm28351016wib.2.2014.01.23.06.39.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 06:39:35 -0800 (PST) Message-ID: <52E129A8.5050503@linaro.org> Date: Thu, 23 Jan 2014 15:39:36 +0100 From: Daniel Lezcano User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Peter Zijlstra , linux-kernel@vger.kernel.org CC: mingo@kernel.org, pjt@google.com, bsegall@google.com, Jason Low Subject: Re: [PATCH 3/9] sched: Move idle_stamp up to the core References: <20140121111754.580142558@infradead.org> <20140121112258.410353740@infradead.org> <20140123125822.GX31570@twins.programming.kicks-ass.net> In-Reply-To: <20140123125822.GX31570@twins.programming.kicks-ass.net> 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: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=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 01/23/2014 01:58 PM, Peter Zijlstra wrote: > On Tue, Jan 21, 2014 at 12:17:57PM +0100, Peter Zijlstra wrote: >> From: Daniel Lezcano >> >> The idle_balance modifies the idle_stamp field of the rq, making this >> information to be shared across core.c and fair.c. As we can know if the >> cpu is going to idle or not with the previous patch, let's encapsulate the >> idle_stamp information in core.c by moving it up to the caller. The >> idle_balance function returns true in case a balancing occured and the cpu >> won't be idle, false if no balance happened and the cpu is going idle. >> >> Cc: alex.shi@linaro.org >> Cc: peterz@infradead.org >> Cc: mingo@kernel.org >> Signed-off-by: Daniel Lezcano >> Signed-off-by: Peter Zijlstra >> Link: http://lkml.kernel.org/r/1389949444-14821-3-git-send-email-daniel.lezcano@linaro.org >> --- >> kernel/sched/core.c | 2 +- >> kernel/sched/fair.c | 14 ++++++-------- >> kernel/sched/sched.h | 2 +- >> 3 files changed, 8 insertions(+), 10 deletions(-) >> >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -2680,7 +2680,7 @@ static void __sched __schedule(void) >> pre_schedule(rq, prev); >> >> if (unlikely(!rq->nr_running)) >> - idle_balance(rq); >> + rq->idle_stamp = idle_balance(rq) ? 0 : rq_clock(rq); > > OK, spotted a problem here.. > > So previously idle_stamp was set _before_ actually doing idle_balance(), > and that was RIGHT, because that way we include the cost of actually > doing idle_balance() into the idle time. > > By not including the cost of idle_balance() you underestimate the 'idle' > time in that if idle_balance() filled the entire idle time we account 0 > idle, even though we had 'plenty' of time to run the entire thing. > > This leads to not running idle_balance() even though we have the time > for it. Good catch. How did you notice that ? > So we very much want something like: > > > if (!rq->nr_running) > rq->idle_stamp = rq_clock(rq); > > p = pick_next_task(rq, prev); > > if (!is_idle_task(p)) > rq->idle_stamp = 0; Is this code assuming idle_balance() is in pick_next_task ? For this specific patch 3/9, will be ok the following ? + if (unlikely(!rq->nr_running)) { + rq->idle_stamp = rq_clock(rq); + if (idle_balance(rq)) + rq->idle_stamp = 0; + } So the patch 9/9 is wrong also because it does not fill idle_stamp before idle_balance, the fix would be. kernel/sched/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > Index: cpuidle-next/kernel/sched/core.c =================================================================== --- cpuidle-next.orig/kernel/sched/core.c +++ cpuidle-next/kernel/sched/core.c @@ -2579,15 +2579,17 @@ again: } } + rq->idle_stamp = rq_clock(rq); + /* * If there is a task balanced on this cpu, pick the next task, * otherwise fall in the optimization by picking the idle task * directly. */ - if (idle_balance(rq)) + if (idle_balance(rq)) { + rq->idle_stamp = 0; goto again; - - rq->idle_stamp = rq_clock(rq); + } return idle_sched_class.pick_next_task(rq, prev); }