From patchwork Thu Jan 30 14:09:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 23926 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 652F920341 for ; Thu, 30 Jan 2014 14:09:57 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id w17sf7122845vbj.9 for ; Thu, 30 Jan 2014 06:09:56 -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=BLxQWrVjuM3n9AN9hBxTL6PycckkXg0IR0Vs5wEXhAA=; b=T4FvUBoBJUs+aJfy8KrxWXfgf+xi+JOx+6KWhLgZpCvUiUyd6MqsQnYEj+sPLRqAFi kS68JmtjftLZGnH8pqxfK0W6IX6MJVCcjmktK/K8Lx5cE1qaTi0gqUjnjURM03fBY8pm 6dEeyYbkDcXCwDFDs3vsd1NQhLZRp3QjtyCdzwVL2isXCWFjHAKOJs1+ji8As8Wyo97t Yw7AhKeFRocYTrjo8J3tpo3BTPAToCAP6OcXHWy9io+rKWg98ZaI5o4dim599EmjZ58J qHYuiRY+ITrX4UFOtGLnqPu1FPil/yQXmxM46WQBs98YZPv/6EPKE4bRDhQaDX9cZbqk T6BA== X-Gm-Message-State: ALoCoQmc4FhkD+Y6tUFaoshRaY1Nl3lsoRKldpYujXXzcpXqfcgv1ohcXVloDK/P3ScbI/wjB+3g X-Received: by 10.236.73.164 with SMTP id v24mr4816753yhd.24.1391090996515; Thu, 30 Jan 2014 06:09:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.139 with SMTP id f11ls532534qgf.71.gmail; Thu, 30 Jan 2014 06:09:56 -0800 (PST) X-Received: by 10.220.76.201 with SMTP id d9mr290507vck.33.1391090996300; Thu, 30 Jan 2014 06:09:56 -0800 (PST) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id sg4si2112440vdc.1.2014.01.30.06.09.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 06:09:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.173 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.173; Received: by mail-vc0-f173.google.com with SMTP id ld13so2137384vcb.32 for ; Thu, 30 Jan 2014 06:09:56 -0800 (PST) X-Received: by 10.52.227.193 with SMTP id sc1mr9841493vdc.1.1391090996209; Thu, 30 Jan 2014 06:09:56 -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 u4csp15329vcz; Thu, 30 Jan 2014 06:09:55 -0800 (PST) X-Received: by 10.68.209.193 with SMTP id mo1mr14840164pbc.38.1391090994655; Thu, 30 Jan 2014 06:09:54 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id to9si6602978pbc.275.2014.01.30.06.09.54; Thu, 30 Jan 2014 06:09:54 -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 S1753669AbaA3OJq (ORCPT + 27 others); Thu, 30 Jan 2014 09:09:46 -0500 Received: from mail-ee0-f44.google.com ([74.125.83.44]:57564 "EHLO mail-ee0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753195AbaA3OJ3 (ORCPT ); Thu, 30 Jan 2014 09:09:29 -0500 Received: by mail-ee0-f44.google.com with SMTP id c13so1645900eek.3 for ; Thu, 30 Jan 2014 06:09:28 -0800 (PST) X-Received: by 10.15.64.69 with SMTP id n45mr758422eex.106.1391090968027; Thu, 30 Jan 2014 06:09:28 -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.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 06:09:27 -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 3/3] idle: store the idle state index in the struct rq Date: Thu, 30 Jan 2014 15:09:22 +0100 Message-Id: <1391090962-15032-4-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.173 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 main cpuidle function is part of the idle.c and this one belongs to the sched directory, allowing to integration the private structure used by the scheduler. We can store the idle index where the cpu is and reuse it in the scheduler to do better decision regarding balancing and idlest cpu. Signed-off-by: Daniel Lezcano --- kernel/sched/idle.c | 9 +++++++++ kernel/sched/sched.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 3e85d38..eeb9f60 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -12,6 +12,8 @@ #include +#include "sched.h" + static int __read_mostly cpu_idle_force_poll; void cpu_idle_poll_ctrl(bool enable) @@ -73,6 +75,7 @@ static int cpuidle_idle_call(void) { struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); + struct rq *rq = this_rq(); int next_state, entered_state; /* ask the governor for the next state */ @@ -80,6 +83,9 @@ static int cpuidle_idle_call(void) if (next_state < 0) return next_state; + /* let know the scheduler in which idle state the cpu will be */ + rq->idle_index = next_state; + if (need_resched()) { dev->last_residency = 0; /* give the governor an opportunity to reflect on the outcome */ @@ -97,6 +103,9 @@ static int cpuidle_idle_call(void) /* give the governor an opportunity to reflect on the outcome */ cpuidle_reflect(dev, entered_state); + /* we exited the idle state, let the scheduler know */ + rq->idle_index = -1; + return 0; } #else diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 90aef084..130debf 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -654,6 +654,9 @@ struct rq { #endif struct sched_avg avg; +#ifdef CONFIG_CPU_IDLE + int idle_index; +#endif }; static inline int cpu_of(struct rq *rq)