From patchwork Tue Feb 25 08:08:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 25236 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 075F420543 for ; Tue, 25 Feb 2014 08:09:17 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf156653oag.0 for ; Tue, 25 Feb 2014 00:09:17 -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=oldJLpiVhQD678hsT00vz3SvdN+8+k/Kj/0CK3cdMRY=; b=OpO/0rlvHElypd6+ghE3B5vISZVOAotuimOi/2T9MAa5o9UtA9hJNDk3344Dq17yi7 CNJ1dG6LjPJcnkRz2n9ogiy5/vht5y3UmZsMs41shX+jvbHD0P6bBYIW6XWYBeq1wkBm 8HkUbKr6ilCZQh+sikelZDLpAk+m35U00/bgb/b9x14MHhQ5hdJsxXkSeTCWJ8y4AKBD QqTKupHo1216ftC4pwizTOR5rMG2YMHBi2JaHQh84+2wxz7vzDKNAhcTVHKsYS3MPyjG rSW46Gkce9h3XgpybeWgCVgjQGFl4WADQBQHSJk5yJwUapK4wyfj/4LsqaPr171vNr3s YFRA== X-Gm-Message-State: ALoCoQmnDA63nOAP2eHDKrzwePuntJE6725B55764oHsKIDIRTGOrVw1/L/A28swlVRARWaMPRzc X-Received: by 10.182.65.168 with SMTP id y8mr49632obs.38.1393315757286; Tue, 25 Feb 2014 00:09:17 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.69 with SMTP id n63ls2435074qge.96.gmail; Tue, 25 Feb 2014 00:09:17 -0800 (PST) X-Received: by 10.58.77.37 with SMTP id p5mr48968vew.62.1393315757059; Tue, 25 Feb 2014 00:09:17 -0800 (PST) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id w5si6620335vcn.101.2014.02.25.00.09.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 00:09:17 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.177 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.177; Received: by mail-vc0-f177.google.com with SMTP id if11so6750560vcb.22 for ; Tue, 25 Feb 2014 00:09:17 -0800 (PST) X-Received: by 10.221.26.10 with SMTP id rk10mr92450vcb.0.1393315756955; Tue, 25 Feb 2014 00:09:16 -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 u4csp120135vcz; Tue, 25 Feb 2014 00:09:16 -0800 (PST) X-Received: by 10.66.146.229 with SMTP id tf5mr241340pab.50.1393315755699; Tue, 25 Feb 2014 00:09:15 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gk3si19854339pac.118.2014.02.25.00.09.14; Tue, 25 Feb 2014 00:09:14 -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 S1751746AbaBYIJB (ORCPT + 26 others); Tue, 25 Feb 2014 03:09:01 -0500 Received: from mail-wi0-f178.google.com ([209.85.212.178]:52368 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708AbaBYII5 (ORCPT ); Tue, 25 Feb 2014 03:08:57 -0500 Received: by mail-wi0-f178.google.com with SMTP id cc10so298325wib.11 for ; Tue, 25 Feb 2014 00:08:56 -0800 (PST) X-Received: by 10.180.105.65 with SMTP id gk1mr18262509wib.12.1393315736087; Tue, 25 Feb 2014 00:08:56 -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.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 00:08:55 -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 3/5] idle: Reorganize the idle loop Date: Tue, 25 Feb 2014 09:08:51 +0100 Message-Id: <1393315733-32321-3-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.177 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: , Now that we have the main cpuidle function in idle.c, move some code from the idle mainloop to this function for the sake of clarity. That removes if then else indentation difficult to follow when looking at the code. This patch does not change the current behavior. Signed-off-by: Daniel Lezcano Acked-by: Nicolas Pitre --- Changelog: V2: * fixed type in patch's description --- include/linux/cpuidle.h | 2 ++ kernel/sched/idle.c | 33 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 18 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/include/linux/cpuidle.h =================================================================== --- cpuidle-next.orig/include/linux/cpuidle.h +++ cpuidle-next/include/linux/cpuidle.h @@ -180,6 +180,8 @@ static inline int cpuidle_enable_device( {return -ENODEV; } static inline void cpuidle_disable_device(struct cpuidle_device *dev) { } static inline int cpuidle_play_dead(void) {return -ENODEV; } +static inline struct cpuidle_driver *cpuidle_get_cpu_driver( + struct cpuidle_device *dev) {return NULL; } #endif #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED Index: cpuidle-next/kernel/sched/idle.c =================================================================== --- cpuidle-next.orig/kernel/sched/idle.c +++ cpuidle-next/kernel/sched/idle.c @@ -63,7 +63,6 @@ void __weak arch_cpu_idle(void) local_irq_enable(); } -#ifdef CONFIG_CPU_IDLE /** * cpuidle_idle_call - the main idle function * @@ -77,9 +76,14 @@ static int cpuidle_idle_call(void) int next_state, entered_state, ret; bool broadcast; + stop_critical_timings(); + rcu_idle_enter(); + ret = cpuidle_enabled(drv, dev); - if (ret < 0) - return ret; + if (ret < 0) { + arch_cpu_idle(); + goto out; + } /* ask the governor for the next state */ next_state = cpuidle_select(drv, dev); @@ -89,7 +93,7 @@ static int cpuidle_idle_call(void) /* give the governor an opportunity to reflect on the outcome */ cpuidle_reflect(dev, next_state); local_irq_enable(); - return 0; + goto out; } trace_cpu_idle_rcuidle(next_state, dev->cpu); @@ -108,15 +112,15 @@ static int cpuidle_idle_call(void) /* give the governor an opportunity to reflect on the outcome */ cpuidle_reflect(dev, entered_state); +out: + if (WARN_ON_ONCE(irqs_disabled())) + local_irq_enable(); + + rcu_idle_exit(); + start_critical_timings(); return 0; } -#else -static inline int cpuidle_idle_call(void) -{ - return -ENODEV; -} -#endif /* * Generic idle loop implementation @@ -149,14 +153,7 @@ static void cpu_idle_loop(void) cpu_idle_poll(); } else { if (!current_clr_polling_and_test()) { - stop_critical_timings(); - rcu_idle_enter(); - if (cpuidle_idle_call()) - arch_cpu_idle(); - if (WARN_ON_ONCE(irqs_disabled())) - local_irq_enable(); - rcu_idle_exit(); - start_critical_timings(); + cpuidle_idle_call(); } else { local_irq_enable(); }