From patchwork Tue Feb 25 08:08:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 25240 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3FB9C20543 for ; Tue, 25 Feb 2014 08:10:11 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id hq11sf13658002vcb.4 for ; Tue, 25 Feb 2014 00:10:10 -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=TO5Aa87qIsEnEOr8l6QPMCSljXj7zzkiBWaOZROIQ8A=; b=Uvkjrk4QtILIm3a/6hCNFuxwzK4KhFNeh/vi5lmDmo61AswtitS0BmZ33ejWSeJVRU 2Umx/PLdh4z7WMK5S6itWm1ouIo5r74dcsShPbarN9IOJDjlF4T6mHQhIsTrlxqtf/gu E7e5D2bVPU9WPdDZ7VpmKNovsDg2p6qdxxEhUW09csI2GoQSbflkgvPrZC3Hl152AdpU lgpXx8pKVZ5SmiKySXB6hAnROkKusUIbbsZi7Tb9dsYS35r4oEfkR16F7c6r2PILvOiB vD/YeIlTPKSe6qIBQ6iDV+CmEXFzm//YPPzB0ZlZPqBjqe9LPmqHInmDV8AAF1f0qU7M nJdw== X-Gm-Message-State: ALoCoQkHc82YqNSvrITDzIkJOOeEs6mrnPTKXDNaU4L6lN8LQQDEJBrscoam0DDJ1nWROnZEDD7E X-Received: by 10.236.17.161 with SMTP id j21mr1272432yhj.55.1393315810958; Tue, 25 Feb 2014 00:10:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.169 with SMTP id o38ls1508910qge.37.gmail; Tue, 25 Feb 2014 00:10:10 -0800 (PST) X-Received: by 10.52.248.138 with SMTP id ym10mr61624vdc.18.1393315810827; Tue, 25 Feb 2014 00:10:10 -0800 (PST) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id yb7si6631616vec.39.2014.02.25.00.10.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 00:10:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ld13so6906982vcb.18 for ; Tue, 25 Feb 2014 00:10:10 -0800 (PST) X-Received: by 10.58.211.8 with SMTP id my8mr41899vec.80.1393315810741; Tue, 25 Feb 2014 00:10:10 -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 u4csp120191vcz; Tue, 25 Feb 2014 00:10:10 -0800 (PST) X-Received: by 10.66.27.48 with SMTP id q16mr134641pag.9.1393315809158; Tue, 25 Feb 2014 00:10:09 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ki1si2710467pbc.325.2014.02.25.00.10.08; Tue, 25 Feb 2014 00:10:08 -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 S1752464AbaBYIJn (ORCPT + 26 others); Tue, 25 Feb 2014 03:09:43 -0500 Received: from mail-wg0-f46.google.com ([74.125.82.46]:58256 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751505AbaBYIJA (ORCPT ); Tue, 25 Feb 2014 03:09:00 -0500 Received: by mail-wg0-f46.google.com with SMTP id z12so40833wgg.17 for ; Tue, 25 Feb 2014 00:08:59 -0800 (PST) X-Received: by 10.194.91.232 with SMTP id ch8mr1129590wjb.13.1393315739027; Tue, 25 Feb 2014 00:08:59 -0800 (PST) Received: from localhost.localdomain (AToulouse-654-1-343-25.w90-55.abo.wanadoo.fr. [90.55.62.25]) by mx.google.com with ESMTPSA id ga20sm31710399wic.0.2014.02.25.00.08.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 00:08:58 -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 V3 5/5] idle: Add more comments to the code Date: Tue, 25 Feb 2014 09:08:53 +0100 Message-Id: <1393315733-32321-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393315733-32321-1-git-send-email-daniel.lezcano@linaro.org> References: <1393315733-32321-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.220.173 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 --- Changelog: V2: * fixed typo in comment --- kernel/sched/idle.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 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/idle.c =================================================================== --- cpuidle-next.orig/kernel/sched/idle.c +++ cpuidle-next/kernel/sched/idle.c @@ -76,20 +76,48 @@ static int cpuidle_idle_call(void) int next_state, entered_state; bool broadcast; + /* + * Check if the idle task must be 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(); + /* + * Check if the cpuidle framework is ready, otherwise fallback + * to the default arch specific idle method + */ if (cpuidle_enabled(drv, dev) == 0) { - /* ask the governor for the next state */ + /* + * Ask the governor to choose an idle state it thinks + * it is convenient to go to. There is *always* a + * convenient idle state + */ next_state = cpuidle_select(drv, dev); + /* + * 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 (current_clr_polling_and_test()) { dev->last_residency = 0; entered_state = next_state; @@ -104,7 +132,13 @@ static int cpuidle_idle_call(void) clockevents_notify( CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &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); if (broadcast) @@ -164,6 +198,11 @@ static void cpu_idle_loop(void) if (cpu_idle_force_poll || tick_check_broadcast_expired()) cpu_idle_poll(); else + /* + * It is up to the underlying + * functions to enable the local + * interrupts again + */ cpuidle_idle_call(); arch_cpu_idle_exit();