Skip to contentSkip to conversation

cpuidle : Add support for pseudo-cpuidle driver

RFC Superseded Abhishek Goel 2 participants 2 messages Sep 21, 2020 – Sep 22, 2020 CPU idle time management framework

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC v2 1/1 cpuidle : Add support for pseudo-cpuidle driver

This option adds support for a testing cpuidle driver, which allows user to define custom idle states with their respective latencies and residencies. This is useful for testing the behaviour of governors on customized set of idle states.

This can be used as of now by hard-coding the customized set of cpuidle states in the driver. Will add the capability of this driver to be used as a module in subsequent patches.

Original idea and discussion for this patch can be found at:
https://lkml.org/lkml/2019/12/17/655

---

v1-> v2 : Includes minor changes adapted from reviews.
Also, there was a divergence from expected behaviour of idle loop in v1. That has been fixed.

 drivers/cpuidle/Kconfig        |   9 ++
 drivers/cpuidle/Makefile       |   1 +
 drivers/cpuidle/cpuidle-test.c | 283 +++++++++++++++++++++++++++++++++
 3 files changed, 293 insertions(+)
 create mode 100644 drivers/cpuidle/cpuidle-test.c
drivers/cpuidle/Kconfig +9 -0
index c0aeedd66f02..1a0f227d61d6 100644
@@ -71,6 +71,15 @@ config HALTPOLL_CPUIDLE
 	 before halting in the guest (more efficient than polling in the
 	 host via halt_poll_ns for some scenarios).
 
+config TEST_CPUIDLE
+	tristate "cpuidle test driver"
+	default n
+	help
+	  This option enables a testing cpuidle driver, which allows the user
+	  to define custom idle states with their respective latencies & residencies.
+	  This is useful for testing the behaviour of governors on different
+	  sets of idle states.
+
 endif
 
 config ARCH_NEEDS_CPU_IDLE_COUPLED
drivers/cpuidle/Makefile +1 -0
index f07800cbb43f..68ea7dc257b5 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
 obj-$(CONFIG_DT_IDLE_STATES)		  += dt_idle_states.o
 obj-$(CONFIG_ARCH_HAS_CPU_RELAX)	  += poll_state.o
 obj-$(CONFIG_HALTPOLL_CPUIDLE)		  += cpuidle-haltpoll.o
+obj-$(CONFIG_TEST_CPUIDLE)		  += cpuidle-test.o
 
 ##################################################################################
 # ARM SoC drivers
drivers/cpuidle/cpuidle-test.c new file +283 -0

283 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Abhishek,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on pm/linux-next]
[also build test WARNING on linux/master linus/master v5.9-rc6 next-20200921] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Abhishek-Goel/cpuidle-Add-support-for-pseudo-cpuidle-driver/20200921-144126
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/cpuidle/cpuidle-test.c: In function 'add_cpuidle_states':

>> drivers/cpuidle/cpuidle-test.c:184:6: warning: variable 'rc' set but not used [-Wunused-but-set-variable]
     184 |  int rc;
         |      ^~

# https://github.com/0day-ci/linux/commit/d9e8ba5bf4c4223e99414f48d2049131f045551d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Abhishek-Goel/cpuidle-Add-support-for-pseudo-cpuidle-driver/20200921-144126 git checkout d9e8ba5bf4c4223e99414f48d2049131f045551d
vim +/rc +184 drivers/cpuidle/cpuidle-test.c

172
173 static int add_cpuidle_states(void)
174 {
175 /* Parse the module param and initialize the idle states here
176 * in cpuidle_state_table.
177 */
178 char *this_param;
179 char *input_name = name;
180 char *input_res = residency_us;
181 char *input_lat = latency_us;
182 int index = 1;
183 long temp;

 > 184		int rc;

185
186 switch (sim_type) {
187 case 1:
188 cpuidle_state_table = cpuidle_states_ppc;
189 return 0;
190 case 2:
191 cpuidle_state_table = cpuidle_states_intel;
192 return 0;
193 case 3:
194 break;
195 default:
196 pr_warn("Sim value out of bound\n");
197 break;
198 }
199
200 if (strnlen(input_name, MAX_PARAM_LENGTH)) {
201 while ((this_param = strsep(&input_name, ",")) && index <= nr_states) {
202 strcpy(cpuidle_states[index].name, this_param);
203 cpuidle_states[index].enter = idle_loop;
204 index++;
205 }
206 }
207
208 if (strnlen(input_res, MAX_PARAM_LENGTH)) {
209 index = 1;
210 while ((this_param = strsep(&input_res, ",")) && index <= nr_states) {
211 rc = kstrtol(this_param, 10, &temp);
212 cpuidle_states[index].target_residency = temp;
213 index++;
214 }
215 }
216
217 if (strnlen(input_lat, MAX_PARAM_LENGTH)) {
218 index = 1;
219 while ((this_param = strsep(&input_lat, ",")) && index <= nr_states) {
220 rc = kstrtol(this_param, 10, &temp);
221 cpuidle_states[index].exit_latency = temp;
222 index++;
223 }
224 }
225
226 cpuidle_state_table = cpuidle_states;
227 return nr_states;
228 }
229

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]