From patchwork Tue Feb 11 15:11:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 24467 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A1B7920967 for ; Tue, 11 Feb 2014 15:12:08 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf17746979pab.7 for ; Tue, 11 Feb 2014 07:12:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=4M8aJW03BD59NP5pFU7X/MFSOQP5zgvyigP4FOa1rcA=; b=J7YtSWvruquioIGLNgoGlqwHjXyGt6PUNGhi99aw0iHwYtVPtG3Ucq53dFpQyku2XQ iKZQiAgCDvyrcWxmLjzGhycI2vwryJ2uRaEdjxL69wbl2h1WhzCuU6ut/wGYmGshPORm bk2uou4SDvy4RQ1ccOB7O/87eINKDfBUCUwZcxPKCMmI4DUTIBM0MeKmmyyYijCZmTG2 0+ERx/9QKmLbAOJSYwMXN/O5PbNltZU9UiBSlVOtAJTGBBKv9ymf46joJXzlGf5+u500 h8fq+SeL99HygrXxbZ6c+SGU/+OIPHP6P5gOi+QcvqqTx7eUm+tn8VuEnCiKeHeCjD+F 7kMQ== X-Gm-Message-State: ALoCoQm+TdmdJ1Q0mtJgpYrtL5OQ9SULAuxVqfEI2C5ognMHn4qorSJsEOvDTiKOemcjSvIKgOfC X-Received: by 10.66.146.65 with SMTP id ta1mr11499640pab.19.1392131523386; Tue, 11 Feb 2014 07:12:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.137 with SMTP id l9ls2481228qgf.40.gmail; Tue, 11 Feb 2014 07:12:03 -0800 (PST) X-Received: by 10.52.68.106 with SMTP id v10mr21074vdt.59.1392131523164; Tue, 11 Feb 2014 07:12:03 -0800 (PST) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id x16si6016172vct.30.2014.02.11.07.12.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 07:12:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.45 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.45; Received: by mail-vb0-f45.google.com with SMTP id m10so5856715vbh.4 for ; Tue, 11 Feb 2014 07:12:03 -0800 (PST) X-Received: by 10.220.89.4 with SMTP id c4mr25839vcm.53.1392131523031; Tue, 11 Feb 2014 07:12:03 -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 u4csp253449vcz; Tue, 11 Feb 2014 07:12:02 -0800 (PST) X-Received: by 10.68.237.99 with SMTP id vb3mr44665360pbc.76.1392131519819; Tue, 11 Feb 2014 07:11:59 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8si19341505pbq.59.2014.02.11.07.11.59; Tue, 11 Feb 2014 07:11:59 -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 S1751790AbaBKPLx (ORCPT + 27 others); Tue, 11 Feb 2014 10:11:53 -0500 Received: from mail-lb0-f177.google.com ([209.85.217.177]:52255 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbaBKPLo (ORCPT ); Tue, 11 Feb 2014 10:11:44 -0500 Received: by mail-lb0-f177.google.com with SMTP id 10so4411263lbg.8 for ; Tue, 11 Feb 2014 07:11:43 -0800 (PST) X-Received: by 10.152.143.231 with SMTP id sh7mr26922035lab.26.1392131503249; Tue, 11 Feb 2014 07:11:43 -0800 (PST) Received: from localhost.localdomain (AToulouse-654-1-479-183.w86-201.abo.wanadoo.fr. [86.201.194.183]) by mx.google.com with ESMTPSA id qx7sm19964004lbb.9.2014.02.11.07.11.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 07:11:42 -0800 (PST) From: Daniel Lezcano To: mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, rjw@rjwysocki.net Cc: nicolas.pitre@linaro.org, preeti@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] idle: Add more comments to the code Date: Tue, 11 Feb 2014 16:11:31 +0100 Message-Id: <1392131491-5265-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392131491-5265-1-git-send-email-daniel.lezcano@linaro.org> References: <1392131491-5265-1-git-send-email-daniel.lezcano@linaro.org> 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.45 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: , The idle main function is a complex and a critical function. Added more comments to the code. Signed-off-by: Daniel Lezcano Acked-by: Nicolas Pitre --- kernel/sched/idle.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 72b5926..36ff1a7 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -86,19 +86,34 @@ static int cpuidle_idle_call(void) if (cpu_idle_force_poll || tick_check_broadcast_expired()) return cpu_idle_poll(); + /* + * Check if the idle task must rescheduled. If it is the case, + * exit the function after re-enabling the local irq and set + * again the polling flag + */ if (current_clr_polling_and_test()) { local_irq_enable(); __current_set_polling(); return 0; } + /* + * During the idle period, stop measuring the disabled irqs + * critical sections latencies + */ stop_critical_timings(); + + /* + * Tell the RCU framework we are entering an idle section, + * so no more rcu read side critical sections and one more + * step to the grace period + */ rcu_idle_enter(); - /* Ask the governor for the next state, this call can fail for - * different reasons: cpuidle is not enabled or an idle state - * fulfilling the constraints was not found. In this case, we fall - * back to the default idle function + /* + * Ask the governor to choose an idle state it thinks it is + * convenient to go to. There is *always* a convenient idle + * state but the call could fail if cpuidle is not enabled */ next_state = cpuidle_select(drv, dev); if (next_state < 0) { @@ -106,6 +121,10 @@ static int cpuidle_idle_call(void) goto out; } + /* + * The idle task must be scheduled, it is pointless to go to idle, + * just update no idle residency and get out of this function + */ if (need_resched()) { dev->last_residency = 0; /* give the governor an opportunity to reflect on the outcome */ @@ -116,6 +135,12 @@ static int cpuidle_idle_call(void) trace_cpu_idle_rcuidle(next_state, dev->cpu); + /* + * Enter the idle state previously returned by the governor + * decision. This function will block until an interrupt + * occurs and will take care of re-enabling the local + * interrupts + */ entered_state = cpuidle_enter(drv, dev, next_state); trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); @@ -152,6 +177,10 @@ static void cpu_idle_loop(void) local_irq_disable(); arch_cpu_idle_enter(); + /* + * It is up to the underlying functions to + * enable the local interrupts again + */ cpuidle_idle_call(); arch_cpu_idle_exit();