From patchwork Thu Jan 30 14:09:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 23925 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 738B920341 for ; Thu, 30 Jan 2014 14:09:40 +0000 (UTC) Received: by mail-yk0-f198.google.com with SMTP id 131sf17067009ykp.1 for ; Thu, 30 Jan 2014 06:09:39 -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=3wVXH2tf4JHihqJvuWWf/xfVu1evBSrTcAcVqW9k6JM=; b=m5P9CrKT6G90eAd1YK2Zc1LyQMv6MsgAxBcvo4xB//GNptS7Piqvq/N6Bj1kchgF/+ 2gX/Zx7KabXiN8IRc/531naf/bCMPTyHFeL1wktwxFm5W8RN2tYOWHrUx3tWWlE3UGZj 3x8hbT/Oj7TB4UXtOa4Q6jcGbtt5EIteVBC5HZU9dQPrbb7zOotG+cQjnrJHsL6pkysL hrq4a4ReiQmbUg/LC/GGOTSBX/e7kMz+casqOcVOMhK2YLCVMMov3J80KLzISbT+Mn3Q 58LlzsX6cTih5n8gF+PirN1mgeVG4ZVolleAnwKusbR3p6IAt8lSVFpF+k+BIXXTkrs3 sMiQ== X-Gm-Message-State: ALoCoQkUDAt49fQuaNzQsp56Nb04CClucVMtnNW2mKFXrBqA6lc64ijFSYntR3vrcUFWtYg+3qTD X-Received: by 10.58.179.101 with SMTP id df5mr4515310vec.38.1391090979641; Thu, 30 Jan 2014 06:09:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.135 with SMTP id r7ls615670qgr.25.gmail; Thu, 30 Jan 2014 06:09:39 -0800 (PST) X-Received: by 10.52.227.193 with SMTP id sc1mr9840412vdc.1.1391090976953; Thu, 30 Jan 2014 06:09:36 -0800 (PST) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id dq5si2105255vcb.99.2014.01.30.06.09.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 06:09:36 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.179 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.179; Received: by mail-vc0-f179.google.com with SMTP id lh14so2083486vcb.38 for ; Thu, 30 Jan 2014 06:09:36 -0800 (PST) X-Received: by 10.52.189.33 with SMTP id gf1mr6372082vdc.26.1391090976854; Thu, 30 Jan 2014 06:09:36 -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 u4csp15303vcz; Thu, 30 Jan 2014 06:09:36 -0800 (PST) X-Received: by 10.68.197.99 with SMTP id it3mr14451966pbc.37.1391090975919; Thu, 30 Jan 2014 06:09:35 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4si6618700pad.141.2014.01.30.06.09.35; Thu, 30 Jan 2014 06:09:35 -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 S1753638AbaA3OJa (ORCPT + 27 others); Thu, 30 Jan 2014 09:09:30 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:42060 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753129AbaA3OJ1 (ORCPT ); Thu, 30 Jan 2014 09:09:27 -0500 Received: by mail-ee0-f45.google.com with SMTP id b15so1608909eek.32 for ; Thu, 30 Jan 2014 06:09:26 -0800 (PST) X-Received: by 10.15.76.130 with SMTP id n2mr13481196eey.48.1391090966332; Thu, 30 Jan 2014 06:09:26 -0800 (PST) Received: from localhost.localdomain (AToulouse-654-1-350-230.w90-55.abo.wanadoo.fr. [90.55.189.230]) by mx.google.com with ESMTPSA id m9sm9603594eeh.3.2014.01.30.06.09.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 06:09:25 -0800 (PST) From: Daniel Lezcano To: nicolas.pitre@linaro.org, peterz@infradead.org, mingo@redhat.com, tglx@linutronix.de, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org Subject: [RFC PATCH 2/3] cpuidle: move the cpuidle_idle_call function to idle.c Date: Thu, 30 Jan 2014 15:09:21 +0100 Message-Id: <1391090962-15032-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391090962-15032-1-git-send-email-daniel.lezcano@linaro.org> References: <1391090962-15032-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.179 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 the cpuidle_idle_call does nothing more than calling the three individuals function, 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 --- drivers/cpuidle/cpuidle.c | 37 ------------------------------------- include/linux/cpuidle.h | 2 -- kernel/sched/idle.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 39 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index a8fbb28..a039344 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -176,43 +176,6 @@ void cpuidle_reflect(struct cpuidle_device *dev, int index) EXPORT_SYMBOL(cpuidle_reflect); /** - * 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; - - /* ask the governor for the next state */ - next_state = cpuidle_select(drv, dev); - if (next_state < 0) - return next_state; - - 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; - } - - 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); - - /* 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) diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 1ebe9ff..74cdfc9 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -126,7 +126,6 @@ extern int cpuidle_enter(struct cpuidle_driver *drv, 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); @@ -148,7 +147,6 @@ extern int cpuidle_play_dead(void); extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); #else static inline void disable_cpuidle(void) { } -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; } diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 65d0427..3e85d38 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -62,6 +62,50 @@ 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; + + /* ask the governor for the next state */ + next_state = cpuidle_select(drv, dev); + if (next_state < 0) + return next_state; + + 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; + } + + 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); + + /* 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 */