Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1791119ybx; Thu, 7 Nov 2019 17:26:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxSFOeedRNTHerBxcgncSZAeQzkl0hvJWVOIFaNdr+NpvabSw4PQGhjU3AtzPaVHBBrL+xR X-Received: by 2002:a17:906:74d7:: with SMTP id z23mr4349888ejl.1.1573176402023; Thu, 07 Nov 2019 17:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573176402; cv=none; d=google.com; s=arc-20160816; b=hojNrv4O5/82yeADuJGw9l1FNgdycqEAc4CTWxKCVRna03QDOeTgRhfbCoHFkwqqAR lAAXNqZQUNsSzlcuBAqjNmwZWxQWwKkSd2mIJzb90i+13gbd66DdBxBzBvHxbHIwH8rF 55OPLfCyrDXrYhpFV/lIpl2Aru4wrEgVL+X128tnTTvZBtFt1Gm+oy4nHf+quBA82ck2 B2ul+nVYr5DJOW7kH39kKu34NpGn93IEF0a16jVMC/O2rL3AMAYkaCLNiswiN9EyxQ8p ey7bC2zvd/hQVBotCsLvfcv6ApuQiSOJ2o4vLn7Si1fmevpjRJhwJtKO1SiRS8c5lOeZ JcWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UzIUVDVdqlEvJDF4js6TVsszrTo73GTH0mVr66Dab+k=; b=jL9TjcU5oVtkhRhIsI3sd0qdBMZQI9IA03xyZVDQH1G9oCHvqvI4ps+3vkO6uU8dWn RdhR2xe0Od3MRjv/WvGtoDc0MR3o5WnpKpLyUx/lTl05htnsF6E0QDyhwbj2co9p4MFa 3f4//06qC4HSrsi2oI+Po0Z2k7wm/8SJKxkj7+8kzF1r+XOANlswgtx+XdJqur/MQHo4 Bx3WUOVhODUeGji5d+USkb6prlFIT58lzcY8G1KylE/Xq2kckXDfSHKYv43QQ/BMIO3q SgQbEvqxm3UXRu9WLsPcws2cHMJFU5SFwMbOvFBB27w7jZLROfZgGIGaZ3jSp54AWFmF 3YGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x17si2580770ejs.178.2019.11.07.17.26.19; Thu, 07 Nov 2019 17:26:42 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728466AbfKHBZB (ORCPT + 99 others); Thu, 7 Nov 2019 20:25:01 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:60962 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbfKHBZA (ORCPT ); Thu, 7 Nov 2019 20:25:00 -0500 Received: from 79.184.254.83.ipv4.supernova.orange.pl (79.184.254.83) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.292) id 9a94e20a5dd8eaf8; Fri, 8 Nov 2019 02:24:58 +0100 From: "Rafael J. Wysocki" To: Daniel Lezcano Cc: mathieu.poirier@linaro.org, mingo@redhat.com, peterz@infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org Subject: Re: [PATCH V6 3/3] powercap/drivers/idle_inject: Specify the idle state to inject Date: Fri, 08 Nov 2019 02:24:58 +0100 Message-ID: <9716500.oJdd2kxadQ@kreacher> In-Reply-To: <20191030075141.1039-3-daniel.lezcano@linaro.org> References: <20191030075141.1039-1-daniel.lezcano@linaro.org> <20191030075141.1039-3-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, October 30, 2019 8:51:41 AM CET Daniel Lezcano wrote: > 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 > Acked-by: Mathieu Poirier > Reviewed-by: Ulf Hansson > --- > V6: > - Rename variable name 'state' -> 'state_idx': > https://lkml.org/lkml/2019/10/28/874 > --- > drivers/powercap/idle_inject.c | 14 +++++++++++++- > include/linux/idle_inject.h | 3 +++ > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c > index 233c878cbf46..2607d3e9afc5 100644 > --- a/drivers/powercap/idle_inject.c > +++ b/drivers/powercap/idle_inject.c > @@ -66,6 +66,7 @@ struct idle_inject_thread { > */ > struct idle_inject_device { > struct hrtimer timer; > + int state_idx; > unsigned int idle_duration_us; > unsigned int run_duration_us; > unsigned long int cpumask[0]; > @@ -140,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_idx)); > } > > /** > @@ -171,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 index) > +{ > + if (index >= CPUIDLE_STATE_NOUSE && index < CPUIDLE_STATE_MAX) > + WRITE_ONCE(ii_dev->state_idx, index); > +} So whoever uses this interface, needs to know the idle states list as provided by the cpuidle driver for the given CPU, but what really needs to be specified here is the exit latency limit (which can be provided as a number in us or ns without knowing the state index).