From patchwork Mon Aug 5 17:02:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 11077593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BAD614E5 for ; Mon, 5 Aug 2019 17:02:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88C0528950 for ; Mon, 5 Aug 2019 17:02:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D11A28960; Mon, 5 Aug 2019 17:02:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFD3C28950 for ; Mon, 5 Aug 2019 17:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729001AbfHERCb (ORCPT ); Mon, 5 Aug 2019 13:02:31 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51108 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729780AbfHERCb (ORCPT ); Mon, 5 Aug 2019 13:02:31 -0400 Received: by mail-wm1-f66.google.com with SMTP id v15so75465540wml.0 for ; Mon, 05 Aug 2019 10:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=+IiyIv/QVlUWmx804ezFK4A4Fw8LXcM/x4rGCJj+JDM=; b=WVPkyn0n5tb9CV7ZaunY6rCfNEDplgh1SISnuZcsRAd6+CwHMooFSdKdPV4FZWkP5i /bPMWNWAXWvsmwOdsp/ekVvEUO02IPM3PHegVGgzc6xAvr9V0VBnarnVM696ZHF5k095 pO1BzDnCrQHrMtGcJD5M3U8bnaXZAKl/9AxbqnfwVupxSbPqscXt4Qm6Q+vSZLJfN8kB hpAYA6Zripmsc2Q98gFZQ35I6USKZsWvxN5Lz+ggcYuPypXUJl/xEVAOFAlhPCD0q8rh Jey7ftL9jsk2A63nd0drlaZ7mzT003RS2Y3OEN8/tRxfWo2XYC1ombPkQyHL8uFSeFi+ Oz1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+IiyIv/QVlUWmx804ezFK4A4Fw8LXcM/x4rGCJj+JDM=; b=dfaKU7n7WEGL4gKbP64NB6SHwVBwh3fOXcw1TtlrdxoLgmaWcXfWLwgujAcTFDs7qg DnIAVoxU5XqyHuHMtNjtHtWQEzs8QE3AVFd41xlKz2Lr5HQe3hAhcx8w5444iSJpQQF2 uceSlXAYgBMIOCndEIEHggYYc6f2B6643Xz6BCorj6R4BH6Dp0RC67FN0+CESLO2g1Ga ycOCgQwnuyk2JvxTd3aamumfr2hEhbQraoOrMYlLi1ucvu6S4vib2sMdzAaT+1Dy+AZ+ iIO5uO5Qk+0cgz21FKN2k8G0ZFgnuxeKdNVHKopQEqIqEWEeUhtf0JfgMvWCQ1pC2Mlb qczw== X-Gm-Message-State: APjAAAXj2cwie0qNSEgZLh++ZKeUGZMEwHbXPliiDP9v1PKVKCvaiFvj vdo/FSHqtnrgeLyDD1FqMZJlqQ== X-Google-Smtp-Source: APXvYqzw/80pNXBne/sIiLOxE2KOrY5gRuvPAWkv5eFPOkE6QGcw7WFLB8aA/q+l2eIOYRP5G1TDkg== X-Received: by 2002:a7b:c106:: with SMTP id w6mr20717489wmi.80.1565024548256; Mon, 05 Aug 2019 10:02:28 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:e5cb:2287:9bbb:b7eb]) by smtp.gmail.com with ESMTPSA id v29sm28893685wrv.74.2019.08.05.10.02.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 10:02:27 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/3] cpuidle: play_idle: Make play_idle more flexible Date: Mon, 5 Aug 2019 19:02:06 +0200 Message-Id: <20190805170208.26873-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The play_idle function has two users, the intel powerclamp and the idle_injection. The idle injection cooling device uses the function via the idle_injection powercap's APIs. Unfortunately, play_idle is currently limited by the idle state depth, by default the deepest idle state is selected. On the ARM[64] platforms, most of the time it is the cluster idle state, the exit latency and the residency can be very high. That reduces the scope of the idle injection usage because the impact on the performances can be very significant and the idle injection would make sense only if the frequency scaling fails to cool down the CPU by dropping the static leakage and force the CPU to regain part of its thermal capacity. If the idle injection cycles are done with a shallow state like a retention state, the cooling effect can give similar results than the cpufreq cooling device. In order to prepare the function to receive an idle state parameter, let's replace the 'use_deepest_state' boolean field with 'use_state' and use this value to enter the specific idle state. The current code keeps the default behavior which is go to the deepest idle state. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 21 +++++++++++---------- include/linux/cpuidle.h | 12 +++++------- kernel/sched/idle.c | 9 ++++----- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 0895b988fa92..86fcf7278c1a 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -99,31 +99,31 @@ static int find_deepest_state(struct cpuidle_driver *drv, } /** - * cpuidle_use_deepest_state - Set/clear governor override flag. - * @enable: New value of the flag. + * cpuidle_use_state - Force the cpuidle framework to enter an idle state. + * @state: An integer for an idle state * - * Set/unset the current CPU to use the deepest idle state (override governors - * going forward if set). + * Specify an idle state the cpuidle framework must step in and bypass + * the idle state selection process. */ -void cpuidle_use_deepest_state(bool enable) +void cpuidle_use_state(int state) { struct cpuidle_device *dev; preempt_disable(); dev = cpuidle_get_device(); if (dev) - dev->use_deepest_state = enable; + dev->use_state = state; preempt_enable(); } /** * cpuidle_find_deepest_state - Find the deepest available idle state. - * @drv: cpuidle driver for the given CPU. - * @dev: cpuidle device for the given CPU. */ -int cpuidle_find_deepest_state(struct cpuidle_driver *drv, - struct cpuidle_device *dev) +int cpuidle_find_deepest_state(void) { + struct cpuidle_device *dev = cpuidle_get_device(); + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); + return find_deepest_state(drv, dev, UINT_MAX, 0, false); } @@ -554,6 +554,7 @@ static void __cpuidle_unregister_device(struct cpuidle_device *dev) static void __cpuidle_device_init(struct cpuidle_device *dev) { memset(dev->states_usage, 0, sizeof(dev->states_usage)); + dev->use_state = -1; dev->last_residency = 0; dev->next_hrtimer = 0; } diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 1a9f54eb3aa1..6c58e71a9995 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -80,9 +80,9 @@ struct cpuidle_driver_kobj; struct cpuidle_device { unsigned int registered:1; unsigned int enabled:1; - unsigned int use_deepest_state:1; unsigned int poll_time_limit:1; unsigned int cpu; + unsigned int use_state; ktime_t next_hrtimer; int last_state_idx; @@ -200,19 +200,17 @@ static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; } #endif #ifdef CONFIG_CPU_IDLE -extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv, - struct cpuidle_device *dev); +extern int cpuidle_find_deepest_state(void); extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev); -extern void cpuidle_use_deepest_state(bool enable); +extern void cpuidle_use_state(int state); #else -static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv, - struct cpuidle_device *dev) +static inline int cpuidle_find_deepest_state(void) {return -ENODEV; } static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev) {return -ENODEV; } -static inline void cpuidle_use_deepest_state(bool enable) +static inline void cpuidle_use_state(int state) { } #endif diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index b98283fc6914..c102e03dee6e 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -165,7 +165,7 @@ static void cpuidle_idle_call(void) * until a proper wakeup interrupt happens. */ - if (idle_should_enter_s2idle() || dev->use_deepest_state) { + if (idle_should_enter_s2idle() || dev->use_state != -1) { if (idle_should_enter_s2idle()) { rcu_idle_enter(); @@ -181,8 +181,7 @@ static void cpuidle_idle_call(void) tick_nohz_idle_stop_tick(); rcu_idle_enter(); - next_state = cpuidle_find_deepest_state(drv, dev); - call_cpuidle(drv, dev, next_state); + call_cpuidle(drv, dev, dev->use_state); } else { bool stop_tick = true; @@ -328,7 +327,7 @@ void play_idle(unsigned long duration_us) rcu_sleep_check(); preempt_disable(); current->flags |= PF_IDLE; - cpuidle_use_deepest_state(true); + cpuidle_use_state(cpuidle_find_deepest_state()); it.done = 0; hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); @@ -339,7 +338,7 @@ void play_idle(unsigned long duration_us) while (!READ_ONCE(it.done)) do_idle(); - cpuidle_use_deepest_state(false); + cpuidle_use_state(-1); current->flags &= ~PF_IDLE; preempt_fold_need_resched(); From patchwork Mon Aug 5 17:02:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 11077603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D5CC14E5 for ; Mon, 5 Aug 2019 17:02:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A8A628950 for ; Mon, 5 Aug 2019 17:02:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BF8028968; Mon, 5 Aug 2019 17:02:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D896E28956 for ; Mon, 5 Aug 2019 17:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729973AbfHERCl (ORCPT ); Mon, 5 Aug 2019 13:02:41 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39403 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729914AbfHERCl (ORCPT ); Mon, 5 Aug 2019 13:02:41 -0400 Received: by mail-wm1-f66.google.com with SMTP id u25so63360893wmc.4 for ; Mon, 05 Aug 2019 10:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wTiqcN9ans0X8+b6FfQH+5cUMosgyj2ws3IXTgtGmS8=; b=KQ0cEdMQ7CsmbkTG8v83WQ8idHQcpy1o6EqRpdVIr6T/mKjdwyQyFobXC7ej0BsWmz +4hk4IBZlp0q6fwXr+b2VG5jG7xI0/JO6MYkxepVK2S2dq2oNl7TDkGiCmjj9MgvEC8X gwhZn8+PbYoEeNTEMBT1XyqAx2ikdgyZLf+Vwbu7v8duiat9g1olSU/E5sSpTY+7hbZP wIEd6ysvglzS9f7w5BG4LGuvZRZyIJD8lowKn0tEuhP7xX3s2S885dyADWLPbUCfTGSs 3u66m7CFthV0uuXWVDUCRjvx/9eixE0/bFzMvfTJMJK4iHjFL6zSUEDqeglbj86zW8r7 RhqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wTiqcN9ans0X8+b6FfQH+5cUMosgyj2ws3IXTgtGmS8=; b=SUjUDm33N+3LNBPP6F3w0iUgyIH/5AZYUI86se8ZLp4kPqVXn8qrktQPQdk1TTyeQS GkAo1i4eogTTCRpHOwk5jpjZeQSoaDUorbHJ3M/o3savP2IgfQBS42vWuRH9DxIZqpve 87Q4gjujYfwOfangQRrbKpTfYqDxdga8q+YRby/VNK7LkXqyJA01NmtB3D/XNYivZyJu ls5gZkCSxY6uxZPZbnFNtDhpFhN/uhqfjj5hlen4elUPn12d9iG1j4Ar0XkSUlNr8K3b xdtITVwcZp5rRbh+YIlYs6pRn7lPfEzrjDW5O390vvkSv2uiGUOx2U+qtivunc6tnO5h yLQw== X-Gm-Message-State: APjAAAX1fPvrsj7QNvjfuq8uVZR999XzKalNgbxiklxB4KiCaiIS9FI6 51Cc6Bmo4f7CunfSDgGbffDAiA== X-Google-Smtp-Source: APXvYqwsGaz1BOvp3kYprODq82cWSaGikSyiwtR6lbRCKmQF5G0TU8NEWUwCMNRTwnJNficS0uI/AQ== X-Received: by 2002:a05:600c:c4:: with SMTP id u4mr19728181wmm.96.1565024558987; Mon, 05 Aug 2019 10:02:38 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:e5cb:2287:9bbb:b7eb]) by smtp.gmail.com with ESMTPSA id v29sm28893685wrv.74.2019.08.05.10.02.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 10:02:38 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, Zhang Rui , Eduardo Valentin , Ingo Molnar , Peter Zijlstra , Greg Kroah-Hartman , Thomas Gleixner , Luc Van Oostenryck , Finn Thain , Amit Kucheria , Josh Poimboeuf , Nicholas Piggin , Jiri Kosina , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/3] cpuidle: play_idle: Specify play_idle with an idle state Date: Mon, 5 Aug 2019 19:02:07 +0200 Message-Id: <20190805170208.26873-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805170208.26873-1-daniel.lezcano@linaro.org> References: <20190805170208.26873-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the play_idle function does not allow to tell which idle state we want to go. Improve this by passing the idle state as parameter to the function. Signed-off-by: Daniel Lezcano --- drivers/powercap/idle_inject.c | 3 ++- drivers/thermal/intel/intel_powerclamp.c | 4 +++- include/linux/cpu.h | 2 +- kernel/sched/idle.c | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c index cd1270614cc6..9b18667b9f26 100644 --- a/drivers/powercap/idle_inject.c +++ b/drivers/powercap/idle_inject.c @@ -138,7 +138,8 @@ static void idle_inject_fn(unsigned int cpu) */ iit->should_run = 0; - play_idle(READ_ONCE(ii_dev->idle_duration_us)); + play_idle(READ_ONCE(ii_dev->idle_duration_us), + cpuidle_find_deepest_state()); } /** diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c index 53216dcbe173..b55786c169ae 100644 --- a/drivers/thermal/intel/intel_powerclamp.c +++ b/drivers/thermal/intel/intel_powerclamp.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -430,7 +431,8 @@ static void clamp_idle_injection_func(struct kthread_work *work) if (should_skip) goto balance; - play_idle(jiffies_to_usecs(w_data->duration_jiffies)); + play_idle(jiffies_to_usecs(w_data->duration_jiffies), + cpuidle_find_deepest_state()); balance: if (clamping && w_data->clamping && cpu_online(w_data->cpu)) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 88dc0c653925..76e3038b63ce 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -179,7 +179,7 @@ void arch_cpu_idle_dead(void); int cpu_report_state(int cpu); int cpu_check_up_prepare(int cpu); void cpu_set_state_online(int cpu); -void play_idle(unsigned long duration_us); +void play_idle(unsigned long duration_us, int state); #ifdef CONFIG_HOTPLUG_CPU bool cpu_wait_death(unsigned int cpu, int seconds); diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index c102e03dee6e..f9773dd55ab9 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -310,7 +310,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer) return HRTIMER_NORESTART; } -void play_idle(unsigned long duration_us) +void play_idle(unsigned long duration_us, int state) { struct idle_timer it; @@ -327,7 +327,7 @@ void play_idle(unsigned long duration_us) rcu_sleep_check(); preempt_disable(); current->flags |= PF_IDLE; - cpuidle_use_state(cpuidle_find_deepest_state()); + cpuidle_use_state(state); it.done = 0; hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); From patchwork Mon Aug 5 17:02:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 11077607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7374C1399 for ; Mon, 5 Aug 2019 17:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B92528950 for ; Mon, 5 Aug 2019 17:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FBD828961; Mon, 5 Aug 2019 17:02:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAD7F28950 for ; Mon, 5 Aug 2019 17:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730024AbfHERCq (ORCPT ); Mon, 5 Aug 2019 13:02:46 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52258 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730011AbfHERCq (ORCPT ); Mon, 5 Aug 2019 13:02:46 -0400 Received: by mail-wm1-f68.google.com with SMTP id s3so75435231wms.2 for ; Mon, 05 Aug 2019 10:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8seUtniCWRwFTJq4JInJW6atX1NHBdkEw579O8M2U9c=; b=rZuWM93zis34ydR/ncwm9ywfu2puMq373eHZDdgwqmtjXJXB1PEM9wVVrN1dGDB+Ey VV2wbneQrvNNZxmOELIEn9K+wnBS6lcBwOldd8Ic/DHqfynnRkVfUsKNa4KOKnetFmsS ZFYK5/OmE6emlTxZZ/UJkEjx6X1LwwrAhN+Eoss6ERTPRQ78FTgRpf3jCWG+R7dG2hay CbfdNRQanY9NIos3Zo17BWvTT8pmxSTIK7LMpKEa6FuMbCZtFj7iKiYQ2MoSAx1QM4LH oK1DzgT1Xm1vrsCLu7rfRFb/hZGZeCd+OAZMvD0K+14jUH4vIefXM50yCm35Q2lR92Ok RAeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8seUtniCWRwFTJq4JInJW6atX1NHBdkEw579O8M2U9c=; b=AH4PGjyygE+bsYtUsOs/250qU/5DbSprJ/BZ7RreMSYSGlLYgru4HYgLWYUl8VgtbC h2VQJ7A1RDlzLPXB+JpKJnrss45Juk/lQ4hpDcR6NE15RVKxkk7c3Zyr7t/aQodZ5m/P slALjoCcpoGtD5vzhVWipJziRo9x4U8dJ8oJ1LDYojW+uPXCwZqWoulO60V6ayyMEu3p dSRiEkAzfOE0N0vNOUoOofjP3QdJglnYMWNpGw85k31n/1UJmPhFgf0DRtsebsLg1VEc 6q22kHS9KUGdc0gyIJ5oZgFqPib2UWQFMapP09AgAfqNz63sXCrbQru/FWvdQg0uxAdE 0m1w== X-Gm-Message-State: APjAAAV2FUbzBV/6UVIP0o8RNG6i0DBmSFDDPOrsbD6INJO1+knjvLZO 2zUnjafvem/zgw8MDNTwnb3xuU489uI= X-Google-Smtp-Source: APXvYqwNMG6nkRMSEbp8tcPVmOdfLttrjljhraM67lgOekaFbI3CEyHmigGc/TLZS7gq3QrWAxIbgA== X-Received: by 2002:a1c:a8c9:: with SMTP id r192mr20084425wme.43.1565024564444; Mon, 05 Aug 2019 10:02:44 -0700 (PDT) Received: from localhost.localdomain ([2a01:e34:ed2f:f020:e5cb:2287:9bbb:b7eb]) by smtp.gmail.com with ESMTPSA id v29sm28893685wrv.74.2019.08.05.10.02.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 10:02:44 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/3] powercap/drivers/idle_inject: Specify the idle state to inject Date: Mon, 5 Aug 2019 19:02:08 +0200 Message-Id: <20190805170208.26873-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805170208.26873-1-daniel.lezcano@linaro.org> References: <20190805170208.26873-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the idle injection framework only allows to inject the deepest idle state available on the system. Give the opportunity to specify which idle state we want to inject by adding a new function helper to set the state and use it when calling play_idle(). Signed-off-by: Daniel Lezcano --- drivers/powercap/idle_inject.c | 15 ++++++++++++++- include/linux/idle_inject.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c index 9b18667b9f26..a94ebab9ee21 100644 --- a/drivers/powercap/idle_inject.c +++ b/drivers/powercap/idle_inject.c @@ -38,6 +38,7 @@ #define pr_fmt(fmt) "ii_dev: " fmt #include +#include #include #include #include @@ -65,6 +66,7 @@ struct idle_inject_thread { */ struct idle_inject_device { struct hrtimer timer; + int state; unsigned int idle_duration_us; unsigned int run_duration_us; unsigned long int cpumask[0]; @@ -139,7 +141,7 @@ static void idle_inject_fn(unsigned int cpu) iit->should_run = 0; play_idle(READ_ONCE(ii_dev->idle_duration_us), - cpuidle_find_deepest_state()); + READ_ONCE(ii_dev->state)); } /** @@ -170,6 +172,16 @@ void idle_inject_get_duration(struct idle_inject_device *ii_dev, *idle_duration_us = READ_ONCE(ii_dev->idle_duration_us); } +/** + * idle_inject_set_state - set the idle state to inject + * @state: an integer for the idle state to inject + */ +void idle_inject_set_state(struct idle_inject_device *ii_dev, int state) +{ + if (state >= -1 && state < CPUIDLE_STATE_MAX) + WRITE_ONCE(ii_dev->state, state); +} + /** * idle_inject_start - start idle injections * @ii_dev: idle injection control device structure @@ -298,6 +310,7 @@ struct idle_inject_device *idle_inject_register(struct cpumask *cpumask) cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask); hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); ii_dev->timer.function = idle_inject_timer_fn; + ii_dev->state = cpuidle_find_deepest_state(); for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) { diff --git a/include/linux/idle_inject.h b/include/linux/idle_inject.h index a445cd1a36c5..e2b26b9ccd34 100644 --- a/include/linux/idle_inject.h +++ b/include/linux/idle_inject.h @@ -26,4 +26,7 @@ void idle_inject_set_duration(struct idle_inject_device *ii_dev, void idle_inject_get_duration(struct idle_inject_device *ii_dev, unsigned int *run_duration_us, unsigned int *idle_duration_us); + +void idle_inject_set_state(struct idle_inject_device *ii_dev, int state); + #endif /* __IDLE_INJECT_H__ */