From patchwork Mon Mar 3 07:48:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 25592 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C87D820E7B for ; Mon, 3 Mar 2014 07:49:43 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id fp1sf3942930pdb.8 for ; Sun, 02 Mar 2014 23:49:42 -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=Wla8u7oNFARCeK8W8FcFW/YbHniVolTGqeh1ZhTrDAQ=; b=ZqdJPH0x+wbaRQOzqcriJTjxQotTQwhGz7YHD9xxhS8Siwr++fITEfm5SE+r3v9OXy +PlS7GsAe+Su/fIA80DAJxGmTVy2ozWCUvZcvg8cGR4lPOL/JJ9AidvGPJEc9nHaS9s2 GIksSs0Iu53z2Y6UYd8dfcgePTo6r3zvWXWDkLHdYiCTt3IbyIpzr/oqr2BTh4eIxhvp jLXKc8yLN2jQi+DwuQn9JxnABbJM2VHjaKYVsrWv0imUM3ZYvX0NaBMBSEhzD+qaAVbx yw7irvfsQe+kwDgDZmVm++Hd38Y0BJqGqmLeADbIHUA/QQJsvvi1kNzxg6PZNIZbaEjd DkyQ== X-Gm-Message-State: ALoCoQlsU2XcdCZm2XYJVwGjFgD+YfFZnO75yynKjXcW+KF+YenMPHlcgdYXwzSAyIl/iCc0gKkW X-Received: by 10.66.65.109 with SMTP id w13mr7738576pas.21.1393832982926; Sun, 02 Mar 2014 23:49:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.100.146 with SMTP id s18ls2014176qge.8.gmail; Sun, 02 Mar 2014 23:49:42 -0800 (PST) X-Received: by 10.52.81.66 with SMTP id y2mr24722432vdx.23.1393832982809; Sun, 02 Mar 2014 23:49:42 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id eb8si3230843vdb.138.2014.03.02.23.49.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 23:49:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 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.180; Received: by mail-vc0-f180.google.com with SMTP id ks9so3184676vcb.39 for ; Sun, 02 Mar 2014 23:49:42 -0800 (PST) X-Received: by 10.58.209.36 with SMTP id mj4mr10313vec.47.1393832982723; Sun, 02 Mar 2014 23:49:42 -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.130.193 with SMTP id u1csp36226vcs; Sun, 2 Mar 2014 23:49:42 -0800 (PST) X-Received: by 10.68.163.3 with SMTP id ye3mr18280602pbb.78.1393832981746; Sun, 02 Mar 2014 23:49:41 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yo5si9699256pab.63.2014.03.02.23.49.40; Sun, 02 Mar 2014 23:49:40 -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 S1753871AbaCCHt1 (ORCPT + 26 others); Mon, 3 Mar 2014 02:49:27 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:64323 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753798AbaCCHtY (ORCPT ); Mon, 3 Mar 2014 02:49:24 -0500 Received: by mail-pa0-f48.google.com with SMTP id kx10so3463760pab.7 for ; Sun, 02 Mar 2014 23:49:24 -0800 (PST) X-Received: by 10.67.22.38 with SMTP id hp6mr18096384pad.53.1393832962469; Sun, 02 Mar 2014 23:49:22 -0800 (PST) Received: from localhost.localdomain (z88l218.static.ctm.net. [202.175.88.218]) by mx.google.com with ESMTPSA id os1sm78855252pac.20.2014.03.02.23.49.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 23:49:21 -0800 (PST) From: Daniel Lezcano To: peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de, rjw@rjwysocki.net Cc: nicolas.pitre@linaro.org, preeti@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org Subject: [PATCH V4 3/5] idle: Reorganize the idle loop Date: Mon, 3 Mar 2014 08:48:52 +0100 Message-Id: <1393832934-11625-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393832934-11625-1-git-send-email-daniel.lezcano@linaro.org> References: <20140228125604.GN27965@twins.programming.kicks-ass.net> <1393832934-11625-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.180 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: V4: * no changes V3: * no changes 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; } broadcast = !!(drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP); @@ -109,15 +113,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 @@ -150,14 +154,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(); }