From patchwork Mon Mar 3 07:48: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: 25590 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4CEE220540 for ; Mon, 3 Mar 2014 07:49:42 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id q9sf21039011ykb.3 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=5fM61M1VWtqCLoZ6/JXuIXn+F09kAW9oGc+GCj9mQ/A=; b=Wh43WrHtxglzSNoFFQltV8abFtc+nmGBrL4MR6EOIVxKOf3RgJE+3idMyzMllxaSsA S9/QBIHIJFpxU3jovLmciC0RImAlKIy+YA89p0rmNZTYSKpFQ5i1Wct3uex312WtfRv/ TDLWAORsPgW1pIDiRJOFZygRR25O18HLOaDHouR8IJUdOau28e7M3mH3XXnGvCZ2knVD 8TY9oW7tLI+ouaYDxdiyEk15pFHw8bWdm109Ba2KYW1ieqDHmTI/M7CCuywpeRuryLau mpTNdwN54B1BZJbLrEG4b7vvxH/6qQNKLkOHjhKFlfr1qnRtcrpleD83AafA8nSYhKLV vziw== X-Gm-Message-State: ALoCoQmRLrzCkRxv5EJR5i4sk+8MhxelVNUzn1/BFX46dP2mo/xybgn1kMrCO9ikMQysjUpRpazC X-Received: by 10.52.37.33 with SMTP id v1mr12954554vdj.1.1393832982167; Sun, 02 Mar 2014 23:49:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.43.246 with SMTP id e109ls2085303qga.89.gmail; Sun, 02 Mar 2014 23:49:42 -0800 (PST) X-Received: by 10.52.230.105 with SMTP id sx9mr24840195vdc.10.1393832982003; Sun, 02 Mar 2014 23:49:42 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id tt2si3247097vdc.61.2014.03.02.23.49.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 23:49:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id pa12so3298419veb.15 for ; Sun, 02 Mar 2014 23:49:41 -0800 (PST) X-Received: by 10.58.119.161 with SMTP id kv1mr15975030veb.21.1393832981918; Sun, 02 Mar 2014 23:49:41 -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 u1csp36225vcs; Sun, 2 Mar 2014 23:49:41 -0800 (PST) X-Received: by 10.69.31.43 with SMTP id kj11mr17825386pbd.67.1393832980706; Sun, 02 Mar 2014 23:49:40 -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.39; Sun, 02 Mar 2014 23:49:39 -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 S1753774AbaCCHtV (ORCPT + 26 others); Mon, 3 Mar 2014 02:49:21 -0500 Received: from mail-pb0-f49.google.com ([209.85.160.49]:43073 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753482AbaCCHtR (ORCPT ); Mon, 3 Mar 2014 02:49:17 -0500 Received: by mail-pb0-f49.google.com with SMTP id jt11so3422484pbb.22 for ; Sun, 02 Mar 2014 23:49:16 -0800 (PST) X-Received: by 10.68.189.5 with SMTP id ge5mr18118579pbc.42.1393832956525; Sun, 02 Mar 2014 23:49:16 -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.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 23:49:15 -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 2/5] cpuidle/idle: Move the cpuidle_idle_call function to idle.c Date: Mon, 3 Mar 2014 08:48:51 +0100 Message-Id: <1393832934-11625-2-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.128.170 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 cpuidle_idle_call does nothing more than calling the three individuals function and is no longer used by any arch specific code but only in the cpuidle framework code. We can move this function into the idle task code to ensure better proximity to the scheduler code. Signed-off-by: Daniel Lezcano Acked-by: Nicolas Pitre --- Changelog: V4: * rebased on the top of tip/master --- drivers/cpuidle/cpuidle.c | 49 ---------------------------------------- include/linux/cpuidle.h | 2 - kernel/sched/idle.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 51 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/drivers/cpuidle/cpuidle.c =================================================================== --- cpuidle-next.orig/drivers/cpuidle/cpuidle.c +++ cpuidle-next/drivers/cpuidle/cpuidle.c @@ -173,55 +173,6 @@ void cpuidle_reflect(struct cpuidle_devi } /** - * cpuidle_idle_call - the main idle loop - * - * NOTE: no locks or semaphores should be used here - * return non-zero on failure - */ -int cpuidle_idle_call(void) -{ - struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); - struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); - int next_state, entered_state, ret; - bool broadcast; - - ret = cpuidle_enabled(drv, dev); - if (ret < 0) - return ret; - - /* ask the governor for the next state */ - next_state = cpuidle_select(drv, dev); - - if (need_resched()) { - dev->last_residency = 0; - /* give the governor an opportunity to reflect on the outcome */ - cpuidle_reflect(dev, next_state); - local_irq_enable(); - return 0; - } - - broadcast = !!(drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP); - - if (broadcast && - clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu)) - return -EBUSY; - - trace_cpu_idle_rcuidle(next_state, dev->cpu); - - entered_state = cpuidle_enter(drv, dev, next_state); - - trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); - - if (broadcast) - clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu); - - /* give the governor an opportunity to reflect on the outcome */ - cpuidle_reflect(dev, entered_state); - - return 0; -} - -/** * cpuidle_install_idle_handler - installs the cpuidle idle loop handler */ void cpuidle_install_idle_handler(void) Index: cpuidle-next/include/linux/cpuidle.h =================================================================== --- cpuidle-next.orig/include/linux/cpuidle.h +++ cpuidle-next/include/linux/cpuidle.h @@ -128,7 +128,6 @@ extern int cpuidle_enter(struct cpuidle_ struct cpuidle_device *dev, int index); extern void cpuidle_reflect(struct cpuidle_device *dev, int index); -extern int cpuidle_idle_call(void); extern int cpuidle_register_driver(struct cpuidle_driver *drv); extern struct cpuidle_driver *cpuidle_get_driver(void); extern struct cpuidle_driver *cpuidle_driver_ref(void); @@ -160,7 +159,6 @@ static inline int cpuidle_enter(struct c struct cpuidle_device *dev, int index) {return -ENODEV; } static inline void cpuidle_reflect(struct cpuidle_device *dev, int index) { } -static inline int cpuidle_idle_call(void) { return -ENODEV; } static inline int cpuidle_register_driver(struct cpuidle_driver *drv) {return -ENODEV; } static inline struct cpuidle_driver *cpuidle_get_driver(void) {return NULL; } Index: cpuidle-next/kernel/sched/idle.c =================================================================== --- cpuidle-next.orig/kernel/sched/idle.c +++ cpuidle-next/kernel/sched/idle.c @@ -63,6 +63,62 @@ void __weak arch_cpu_idle(void) local_irq_enable(); } +#ifdef CONFIG_CPU_IDLE +/** + * cpuidle_idle_call - the main idle function + * + * NOTE: no locks or semaphores should be used here + * return non-zero on failure + */ +static int cpuidle_idle_call(void) +{ + struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); + int next_state, entered_state, ret; + bool broadcast; + + ret = cpuidle_enabled(drv, dev); + if (ret < 0) + return ret; + + /* ask the governor for the next state */ + next_state = cpuidle_select(drv, dev); + + if (need_resched()) { + dev->last_residency = 0; + /* give the governor an opportunity to reflect on the outcome */ + cpuidle_reflect(dev, next_state); + local_irq_enable(); + return 0; + } + + broadcast = !!(drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP); + + if (broadcast && + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu)) + return -EBUSY; + + trace_cpu_idle_rcuidle(next_state, dev->cpu); + + entered_state = cpuidle_enter(drv, dev, next_state); + + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); + + if (broadcast) + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu); + + /* give the governor an opportunity to reflect on the outcome */ + cpuidle_reflect(dev, entered_state); + + return 0; +} +#else +static inline int cpuidle_idle_call(void) +{ + return -ENODEV; +} +#endif + /* * Generic idle loop implementation */