From patchwork Wed Oct 22 13:57:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 39304 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A9596202DB for ; Wed, 22 Oct 2014 13:58:13 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d49sf1679452eek.11 for ; Wed, 22 Oct 2014 06:58:12 -0700 (PDT) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=9FgEllK+ykB0WFj6npINETQWB+9X6hQdCiMhvAmtXss=; b=YdOHV5G7spwK2z28jHuprdI5Z94eHf7mMeaZv3UugSvmWLLl7jJEcKQ+kxjTUu/iwr Zbve1WYRW9Kz6ar9c6ny+iEhpGFIVPVLWzrvHAxZM42zRzUYDqNt8kgeIjifab6qwjHF DUiign5SLupDlw7OBbXB4djayumDWJlMoIdMnHW+BWY2FZk7VU7i83IZ7rHAYzjoJMQr DcbvVe6aLVgiNiRXS5uxfQNzWOwFpJp39ZcT40tP6x6Gwg5/MRoGI71IF2Y8Kfue8vs5 9VXLrBgsclFFeqnFs3hDqO0BIOi1MYxDVBFEYS38/OD2zZvGaYgJUE7KN3ntrOLAGcM+ s1jA== X-Gm-Message-State: ALoCoQnjVevO1LnHlF3iULkXzdBLPKUOF3WgFtE6+1zswXMJiht+oJLNX3Z1+VdOpN/tpbDPn0Cl X-Received: by 10.180.98.165 with SMTP id ej5mr5719153wib.1.1413986292519; Wed, 22 Oct 2014 06:58:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.99 with SMTP id r3ls191423lar.73.gmail; Wed, 22 Oct 2014 06:58:12 -0700 (PDT) X-Received: by 10.152.163.101 with SMTP id yh5mr40734030lab.68.1413986292359; Wed, 22 Oct 2014 06:58:12 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id w4si23430242laj.78.2014.10.22.06.58.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 06:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id s18so3041817lam.9 for ; Wed, 22 Oct 2014 06:58:12 -0700 (PDT) X-Received: by 10.112.14.69 with SMTP id n5mr986909lbc.34.1413986292230; Wed, 22 Oct 2014 06:58:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp76304lbz; Wed, 22 Oct 2014 06:58:11 -0700 (PDT) X-Received: by 10.180.211.206 with SMTP id ne14mr38098745wic.79.1413986291636; Wed, 22 Oct 2014 06:58:11 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com. [209.85.212.169]) by mx.google.com with ESMTPS id dd6si1911735wib.8.2014.10.22.06.58.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 06:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.lezcano@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Received: by mail-wi0-f169.google.com with SMTP id r20so1354790wiv.0 for ; Wed, 22 Oct 2014 06:58:11 -0700 (PDT) X-Received: by 10.194.76.135 with SMTP id k7mr40535820wjw.94.1413986291361; Wed, 22 Oct 2014 06:58:11 -0700 (PDT) Received: from localhost.localdomain (AToulouse-656-1-959-39.w90-50.abo.wanadoo.fr. [90.50.216.39]) by mx.google.com with ESMTPSA id f7sm2030217wiz.13.2014.10.22.06.58.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Oct 2014 06:58:10 -0700 (PDT) From: Daniel Lezcano To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: axboe@kernel.dk, rafael.j.wysocki@intel.com, mingo@kernel.org, peterz@infradead.org, preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com, mturquette@linaro.org, tuukka.tikkanen@linaro.org, nicolas.pitre@linaro.org, patches@linaro.org Subject: [RFD PATCH 07/10] cpuidle: Add a simple select governor Date: Wed, 22 Oct 2014 15:57:50 +0200 Message-Id: <1413986273-28522-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413986273-28522-1-git-send-email-daniel.lezcano@linaro.org> References: <1413986273-28522-1-git-send-email-daniel.lezcano@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This simple governor takes into account the predictable events: the timer sleep duration and the next expected IO sleep duration. By mixing both it deduced what idle state fits better. This governor must be extended to a statistical approach to predict all the other events. The main purpose of this governor is to handle the guessed next events in a categorized way: 1. deterministic events : timers 2. guessed events : IOs 3. predictable events : keystroke, incoming network packet, ... This governor is aimed to be moved later near the scheduler, so this one can inspect/inject more informations and act proactively rather than reactively. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/Kconfig | 4 +++ drivers/cpuidle/governors/Makefile | 1 + drivers/cpuidle/governors/select.c | 55 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 drivers/cpuidle/governors/select.c diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index 32748c3..11e9781 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -25,6 +25,10 @@ config CPU_IDLE_GOV_MENU bool "Menu governor (for tickless system)" default y +config CPU_IDLE_GOV_SELECT + bool "Select governor (for tickless system)" + default y + menu "ARM CPU Idle Drivers" depends on ARM source "drivers/cpuidle/Kconfig.arm" diff --git a/drivers/cpuidle/governors/Makefile b/drivers/cpuidle/governors/Makefile index 1b51272..fa45520 100644 --- a/drivers/cpuidle/governors/Makefile +++ b/drivers/cpuidle/governors/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o +obj-$(CONFIG_CPU_IDLE_GOV_SELECT) += select.o diff --git a/drivers/cpuidle/governors/select.c b/drivers/cpuidle/governors/select.c new file mode 100644 index 0000000..0de7095 --- /dev/null +++ b/drivers/cpuidle/governors/select.c @@ -0,0 +1,55 @@ +/* + * select.c - the select governor + * + * Copyright (C) 2014 Daniel Lezcano + * +*/ + +#include + +static int select(struct cpuidle_driver *drv, struct cpuidle_device *dev, + struct cpuidle_times *times) +{ + int i, index = 0, latency_req = times->latency_req; + unsigned int next_event; + + /* + * If the guessed IO next event is zero, that means there is no IO + * pending, so we ignore it in the equation + */ + next_event = times->next_io_event ? + min(times->next_io_event, times->next_timer_event) : + times->next_timer_event; + + for (i = 0; i < drv->state_count; i++) { + + struct cpuidle_state *s = &drv->states[i]; + struct cpuidle_state_usage *su = &dev->states_usage[i]; + + if (s->disabled || su->disable) + continue; + if (s->target_residency > next_event) + continue; + if (s->exit_latency > latency_req) + continue; + + index = i; + } + + return index; +} + +static struct cpuidle_governor select_governor = { + .name = "select", + .rating = 10, + .select = select, + .owner = THIS_MODULE, +}; + +static int __init select_init(void) +{ + return cpuidle_register_governor(&select_governor); +} + +postcore_initcall(select_init); +