From patchwork Tue Feb 11 15:11:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 24466 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 7271B203F3 for ; Tue, 11 Feb 2014 15:12:03 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf34170717oag.4 for ; Tue, 11 Feb 2014 07:12:02 -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=rGC848Bva85/v5YAYyiBWX0B4uZtZfXMAYgshcSd348=; b=OA8FPE83AmPK+RnCnrFk7J9acYRo9a+eRlErdoSe1r6N3uHJY15ZcK4cJ8xLHXQb03 fsJe6JbGHrKR2irHNEtyEdeMS3UQbpH1F4sRPLPe/kqOmWPonBLnoR89jo3gsa22eyhO BNcaNUa5s1aRTmeQkpj2+LUnCXlZ13CmTCUO9cwXKzYsE3h2kNpzkeLtNCjROr7lIstS ql0wqmvdOU2TzH3X9fHqeup1lUc1hYcFTmlE5gYV8BAhEJrIvfNqKnl9Eb/9YCkaDdcs tjUt6XzE8EId74cZfk0NvIdUc8CfD8+zk0fcxEn/rXrLgsrBmh1rZIh8QmcdKlAlfG8g bcFw== X-Gm-Message-State: ALoCoQlfFpeSZFjqJDeF++pvKderpJUkd1vtCIjeyOp37LIVhJ74k0WbLMZrWsFwZQye1mnGL1/a X-Received: by 10.42.196.71 with SMTP id ef7mr8149812icb.24.1392131522162; Tue, 11 Feb 2014 07:12:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.52 with SMTP id j49ls2491439qge.7.gmail; Tue, 11 Feb 2014 07:12:02 -0800 (PST) X-Received: by 10.52.94.77 with SMTP id da13mr24697vdb.55.1392131521969; Tue, 11 Feb 2014 07:12:01 -0800 (PST) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id x3si6018240vcn.9.2014.02.11.07.12.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 07:12:01 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.44; Received: by mail-vb0-f44.google.com with SMTP id f12so6048440vbg.3 for ; Tue, 11 Feb 2014 07:12:01 -0800 (PST) X-Received: by 10.58.252.8 with SMTP id zo8mr22106vec.55.1392131521828; Tue, 11 Feb 2014 07:12:01 -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 u4csp253448vcz; Tue, 11 Feb 2014 07:12:01 -0800 (PST) X-Received: by 10.66.145.199 with SMTP id sw7mr16306459pab.143.1392131518969; Tue, 11 Feb 2014 07:11:58 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8si19341505pbq.59.2014.02.11.07.11.57; Tue, 11 Feb 2014 07:11:57 -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 S1751507AbaBKPLl (ORCPT + 27 others); Tue, 11 Feb 2014 10:11:41 -0500 Received: from mail-la0-f42.google.com ([209.85.215.42]:56086 "EHLO mail-la0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750890AbaBKPLh (ORCPT ); Tue, 11 Feb 2014 10:11:37 -0500 Received: by mail-la0-f42.google.com with SMTP id hr13so6080187lab.1 for ; Tue, 11 Feb 2014 07:11:36 -0800 (PST) X-Received: by 10.112.41.100 with SMTP id e4mr47972lbl.84.1392131496457; Tue, 11 Feb 2014 07:11:36 -0800 (PST) Received: from localhost.localdomain (AToulouse-654-1-479-183.w86-201.abo.wanadoo.fr. [86.201.194.183]) by mx.google.com with ESMTPSA id qx7sm19964004lbb.9.2014.02.11.07.11.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 07:11:35 -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 2/5] cpuidle/idle: Move the cpuidle_idle_call function to idle.c Date: Tue, 11 Feb 2014 16:11:28 +0100 Message-Id: <1392131491-5265-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392131491-5265-1-git-send-email-daniel.lezcano@linaro.org> References: <1392131491-5265-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.212.44 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 --- 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 172ab6a..ae3078b 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -173,43 +173,6 @@ void cpuidle_reflect(struct cpuidle_device *dev, int index) } /** - * 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 bf06f37..0befaff 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); @@ -155,7 +154,6 @@ static inline int cpuidle_enter(struct cpuidle_driver *drv, 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; } diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 14ca434..6963822 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -63,6 +63,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 */