summaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 22:15:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 22:15:14 -0400
commit77dcfe2b9edc98286cf18e03c243c9b999f955d9 (patch)
tree0ba3c4002b6c26c715bf03fac81d63de13c01d96 /drivers/cpuidle
parent04cbfba6208592999d7bfe6609ec01dc3fde73f5 (diff)
parentfc6763a2d7e0a7f49ccec97a46e92e9fb1f3f9dd (diff)
Merge tag 'pm-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management updates from Rafael Wysocki: "These include a rework of the main suspend-to-idle code flow (related to the handling of spurious wakeups), a switch over of several users of cpufreq notifiers to QoS-based limits, a new devfreq driver for Tegra20, a new cpuidle driver and governor for virtualized guests, an extension of the wakeup sources framework to expose wakeup sources as device objects in sysfs, and more. Specifics: - Rework the main suspend-to-idle control flow to avoid repeating "noirq" device resume and suspend operations in case of spurious wakeups from the ACPI EC and decouple the ACPI EC wakeups support from the LPS0 _DSM support (Rafael Wysocki). - Extend the wakeup sources framework to expose wakeup sources as device objects in sysfs (Tri Vo, Stephen Boyd). - Expose system suspend statistics in sysfs (Kalesh Singh). - Introduce a new haltpoll cpuidle driver and a new matching governor for virtualized guests wanting to do guest-side polling in the idle loop (Marcelo Tosatti, Joao Martins, Wanpeng Li, Stephen Rothwell). - Fix the menu and teo cpuidle governors to allow the scheduler tick to be stopped if PM QoS is used to limit the CPU idle state exit latency in some cases (Rafael Wysocki). - Increase the resolution of the play_idle() argument to microseconds for more fine-grained injection of CPU idle cycles (Daniel Lezcano). - Switch over some users of cpuidle notifiers to the new QoS-based frequency limits and drop the CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier events (Viresh Kumar). - Add new cpufreq driver based on nvmem for sun50i (Yangtao Li). - Add support for MT8183 and MT8516 to the mediatek cpufreq driver (Andrew-sh.Cheng, Fabien Parent). - Add i.MX8MN support to the imx-cpufreq-dt cpufreq driver (Anson Huang). - Add qcs404 to cpufreq-dt-platdev blacklist (Jorge Ramirez-Ortiz). - Update the qcom cpufreq driver (among other things, to make it easier to extend and to use kryo cpufreq for other nvmem-based SoCs) and add qcs404 support to it (Niklas Cassel, Douglas RAILLARD, Sibi Sankar, Sricharan R). - Fix assorted issues and make assorted minor improvements in the cpufreq code (Colin Ian King, Douglas RAILLARD, Florian Fainelli, Gustavo Silva, Hariprasad Kelam). - Add new devfreq driver for NVidia Tegra20 (Dmitry Osipenko, Arnd Bergmann). - Add new Exynos PPMU events to devfreq events and extend that mechanism (Lukasz Luba). - Fix and clean up the exynos-bus devfreq driver (Kamil Konieczny). - Improve devfreq documentation and governor code, fix spelling typos in devfreq (Ezequiel Garcia, Krzysztof Kozlowski, Leonard Crestez, MyungJoo Ham, Gaël PORTAY). - Add regulators enable and disable to the OPP (operating performance points) framework (Kamil Konieczny). - Update the OPP framework to support multiple opp-suspend properties (Anson Huang). - Fix assorted issues and make assorted minor improvements in the OPP code (Niklas Cassel, Viresh Kumar, Yue Hu). - Clean up the generic power domains (genpd) framework (Ulf Hansson). - Clean up assorted pieces of power management code and documentation (Akinobu Mita, Amit Kucheria, Chuhong Yuan). - Update the pm-graph tool to version 5.5 including multiple fixes and improvements (Todd Brandt). - Update the cpupower utility (Benjamin Weis, Geert Uytterhoeven, Sébastien Szymanski)" * tag 'pm-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (126 commits) cpuidle-haltpoll: Enable kvm guest polling when dedicated physical CPUs are available cpuidle-haltpoll: do not set an owner to allow modunload cpuidle-haltpoll: return -ENODEV on modinit failure cpuidle-haltpoll: set haltpoll as preferred governor cpuidle: allow governor switch on cpuidle_register_driver() PM: runtime: Documentation: add runtime_status ABI document pm-graph: make setVal unbuffered again for python2 and python3 powercap: idle_inject: Use higher resolution for idle injection cpuidle: play_idle: Increase the resolution to usec cpuidle-haltpoll: vcpu hotplug support cpufreq: Add qcs404 to cpufreq-dt-platdev blacklist cpufreq: qcom: Add support for qcs404 on nvmem driver cpufreq: qcom: Refactor the driver to make it easier to extend cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem based qcom socs dt-bindings: opp: Add qcom-opp bindings with properties needed for CPR dt-bindings: opp: qcom-nvmem: Support pstates provided by a power domain Documentation: cpufreq: Update policy notifier documentation cpufreq: Remove CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier events PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_state() PM / Domains: Simplify genpd_lookup_dev() ...
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/Kconfig20
-rw-r--r--drivers/cpuidle/Makefile1
-rw-r--r--drivers/cpuidle/cpuidle-haltpoll.c134
-rw-r--r--drivers/cpuidle/cpuidle.c30
-rw-r--r--drivers/cpuidle/cpuidle.h2
-rw-r--r--drivers/cpuidle/driver.c25
-rw-r--r--drivers/cpuidle/governor.c7
-rw-r--r--drivers/cpuidle/governors/Makefile1
-rw-r--r--drivers/cpuidle/governors/haltpoll.c150
-rw-r--r--drivers/cpuidle/governors/ladder.c21
-rw-r--r--drivers/cpuidle/governors/menu.c21
-rw-r--r--drivers/cpuidle/governors/teo.c60
-rw-r--r--drivers/cpuidle/poll_state.c11
-rw-r--r--drivers/cpuidle/sysfs.c7
14 files changed, 419 insertions, 71 deletions
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index a4ac31e4a58c..88727b7c0d59 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -33,6 +33,17 @@ config CPU_IDLE_GOV_TEO
33 Some workloads benefit from using it and it generally should be safe 33 Some workloads benefit from using it and it generally should be safe
34 to use. Say Y here if you are not happy with the alternatives. 34 to use. Say Y here if you are not happy with the alternatives.
35 35
36config CPU_IDLE_GOV_HALTPOLL
37 bool "Haltpoll governor (for virtualized systems)"
38 depends on KVM_GUEST
39 help
40 This governor implements haltpoll idle state selection, to be
41 used in conjunction with the haltpoll cpuidle driver, allowing
42 for polling for a certain amount of time before entering idle
43 state.
44
45 Some virtualized workloads benefit from using it.
46
36config DT_IDLE_STATES 47config DT_IDLE_STATES
37 bool 48 bool
38 49
@@ -51,6 +62,15 @@ depends on PPC
51source "drivers/cpuidle/Kconfig.powerpc" 62source "drivers/cpuidle/Kconfig.powerpc"
52endmenu 63endmenu
53 64
65config HALTPOLL_CPUIDLE
66 tristate "Halt poll cpuidle driver"
67 depends on X86 && KVM_GUEST
68 default y
69 help
70 This option enables halt poll cpuidle driver, which allows to poll
71 before halting in the guest (more efficient than polling in the
72 host via halt_poll_ns for some scenarios).
73
54endif 74endif
55 75
56config ARCH_NEEDS_CPU_IDLE_COUPLED 76config ARCH_NEEDS_CPU_IDLE_COUPLED
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 40d016339b29..ee70d5cc5b99 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -7,6 +7,7 @@ obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
7obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o 7obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
8obj-$(CONFIG_DT_IDLE_STATES) += dt_idle_states.o 8obj-$(CONFIG_DT_IDLE_STATES) += dt_idle_states.o
9obj-$(CONFIG_ARCH_HAS_CPU_RELAX) += poll_state.o 9obj-$(CONFIG_ARCH_HAS_CPU_RELAX) += poll_state.o
10obj-$(CONFIG_HALTPOLL_CPUIDLE) += cpuidle-haltpoll.o
10 11
11################################################################################## 12##################################################################################
12# ARM SoC drivers 13# ARM SoC drivers
diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c
new file mode 100644
index 000000000000..932390b028f1
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-haltpoll.c
@@ -0,0 +1,134 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * cpuidle driver for haltpoll governor.
4 *
5 * Copyright 2019 Red Hat, Inc. and/or its affiliates.
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level directory.
9 *
10 * Authors: Marcelo Tosatti <mtosatti@redhat.com>
11 */
12
13#include <linux/init.h>
14#include <linux/cpu.h>
15#include <linux/cpuidle.h>
16#include <linux/module.h>
17#include <linux/sched/idle.h>
18#include <linux/kvm_para.h>
19#include <linux/cpuidle_haltpoll.h>
20
21static struct cpuidle_device __percpu *haltpoll_cpuidle_devices;
22static enum cpuhp_state haltpoll_hp_state;
23
24static int default_enter_idle(struct cpuidle_device *dev,
25 struct cpuidle_driver *drv, int index)
26{
27 if (current_clr_polling_and_test()) {
28 local_irq_enable();
29 return index;
30 }
31 default_idle();
32 return index;
33}
34
35static struct cpuidle_driver haltpoll_driver = {
36 .name = "haltpoll",
37 .governor = "haltpoll",
38 .states = {
39 { /* entry 0 is for polling */ },
40 {
41 .enter = default_enter_idle,
42 .exit_latency = 1,
43 .target_residency = 1,
44 .power_usage = -1,
45 .name = "haltpoll idle",
46 .desc = "default architecture idle",
47 },
48 },
49 .safe_state_index = 0,
50 .state_count = 2,
51};
52
53static int haltpoll_cpu_online(unsigned int cpu)
54{
55 struct cpuidle_device *dev;
56
57 dev = per_cpu_ptr(haltpoll_cpuidle_devices, cpu);
58 if (!dev->registered) {
59 dev->cpu = cpu;
60 if (cpuidle_register_device(dev)) {
61 pr_notice("cpuidle_register_device %d failed!\n", cpu);
62 return -EIO;
63 }
64 arch_haltpoll_enable(cpu);
65 }
66
67 return 0;
68}
69
70static int haltpoll_cpu_offline(unsigned int cpu)
71{
72 struct cpuidle_device *dev;
73
74 dev = per_cpu_ptr(haltpoll_cpuidle_devices, cpu);
75 if (dev->registered) {
76 arch_haltpoll_disable(cpu);
77 cpuidle_unregister_device(dev);
78 }
79
80 return 0;
81}
82
83static void haltpoll_uninit(void)
84{
85 if (haltpoll_hp_state)
86 cpuhp_remove_state(haltpoll_hp_state);
87 cpuidle_unregister_driver(&haltpoll_driver);
88
89 free_percpu(haltpoll_cpuidle_devices);
90 haltpoll_cpuidle_devices = NULL;
91}
92
93static int __init haltpoll_init(void)
94{
95 int ret;
96 struct cpuidle_driver *drv = &haltpoll_driver;
97
98 cpuidle_poll_state_init(drv);
99
100 if (!kvm_para_available() ||
101 !kvm_para_has_hint(KVM_HINTS_REALTIME))
102 return -ENODEV;
103
104 ret = cpuidle_register_driver(drv);
105 if (ret < 0)
106 return ret;
107
108 haltpoll_cpuidle_devices = alloc_percpu(struct cpuidle_device);
109 if (haltpoll_cpuidle_devices == NULL) {
110 cpuidle_unregister_driver(drv);
111 return -ENOMEM;
112 }
113
114 ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "cpuidle/haltpoll:online",
115 haltpoll_cpu_online, haltpoll_cpu_offline);
116 if (ret < 0) {
117 haltpoll_uninit();
118 } else {
119 haltpoll_hp_state = ret;
120 ret = 0;
121 }
122
123 return ret;
124}
125
126static void __exit haltpoll_exit(void)
127{
128 haltpoll_uninit();
129}
130
131module_init(haltpoll_init);
132module_exit(haltpoll_exit);
133MODULE_LICENSE("GPL");
134MODULE_AUTHOR("Marcelo Tosatti <mtosatti@redhat.com>");
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 0f4b7c45df3e..0895b988fa92 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -362,6 +362,36 @@ void cpuidle_reflect(struct cpuidle_device *dev, int index)
362} 362}
363 363
364/** 364/**
365 * cpuidle_poll_time - return amount of time to poll for,
366 * governors can override dev->poll_limit_ns if necessary
367 *
368 * @drv: the cpuidle driver tied with the cpu
369 * @dev: the cpuidle device
370 *
371 */
372u64 cpuidle_poll_time(struct cpuidle_driver *drv,
373 struct cpuidle_device *dev)
374{
375 int i;
376 u64 limit_ns;
377
378 if (dev->poll_limit_ns)
379 return dev->poll_limit_ns;
380
381 limit_ns = TICK_NSEC;
382 for (i = 1; i < drv->state_count; i++) {
383 if (drv->states[i].disabled || dev->states_usage[i].disable)
384 continue;
385
386 limit_ns = (u64)drv->states[i].target_residency * NSEC_PER_USEC;
387 }
388
389 dev->poll_limit_ns = limit_ns;
390
391 return dev->poll_limit_ns;
392}
393
394/**
365 * cpuidle_install_idle_handler - installs the cpuidle idle loop handler 395 * cpuidle_install_idle_handler - installs the cpuidle idle loop handler
366 */ 396 */
367void cpuidle_install_idle_handler(void) 397void cpuidle_install_idle_handler(void)
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index d6613101af92..9f336af17fa6 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -9,6 +9,7 @@
9/* For internal use only */ 9/* For internal use only */
10extern char param_governor[]; 10extern char param_governor[];
11extern struct cpuidle_governor *cpuidle_curr_governor; 11extern struct cpuidle_governor *cpuidle_curr_governor;
12extern struct cpuidle_governor *cpuidle_prev_governor;
12extern struct list_head cpuidle_governors; 13extern struct list_head cpuidle_governors;
13extern struct list_head cpuidle_detected_devices; 14extern struct list_head cpuidle_detected_devices;
14extern struct mutex cpuidle_lock; 15extern struct mutex cpuidle_lock;
@@ -22,6 +23,7 @@ extern void cpuidle_install_idle_handler(void);
22extern void cpuidle_uninstall_idle_handler(void); 23extern void cpuidle_uninstall_idle_handler(void);
23 24
24/* governors */ 25/* governors */
26extern struct cpuidle_governor *cpuidle_find_governor(const char *str);
25extern int cpuidle_switch_governor(struct cpuidle_governor *gov); 27extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
26 28
27/* sysfs */ 29/* sysfs */
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index dc32f34e68d9..80c1a830d991 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -254,12 +254,25 @@ static void __cpuidle_unregister_driver(struct cpuidle_driver *drv)
254 */ 254 */
255int cpuidle_register_driver(struct cpuidle_driver *drv) 255int cpuidle_register_driver(struct cpuidle_driver *drv)
256{ 256{
257 struct cpuidle_governor *gov;
257 int ret; 258 int ret;
258 259
259 spin_lock(&cpuidle_driver_lock); 260 spin_lock(&cpuidle_driver_lock);
260 ret = __cpuidle_register_driver(drv); 261 ret = __cpuidle_register_driver(drv);
261 spin_unlock(&cpuidle_driver_lock); 262 spin_unlock(&cpuidle_driver_lock);
262 263
264 if (!ret && !strlen(param_governor) && drv->governor &&
265 (cpuidle_get_driver() == drv)) {
266 mutex_lock(&cpuidle_lock);
267 gov = cpuidle_find_governor(drv->governor);
268 if (gov) {
269 cpuidle_prev_governor = cpuidle_curr_governor;
270 if (cpuidle_switch_governor(gov) < 0)
271 cpuidle_prev_governor = NULL;
272 }
273 mutex_unlock(&cpuidle_lock);
274 }
275
263 return ret; 276 return ret;
264} 277}
265EXPORT_SYMBOL_GPL(cpuidle_register_driver); 278EXPORT_SYMBOL_GPL(cpuidle_register_driver);
@@ -274,9 +287,21 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver);
274 */ 287 */
275void cpuidle_unregister_driver(struct cpuidle_driver *drv) 288void cpuidle_unregister_driver(struct cpuidle_driver *drv)
276{ 289{
290 bool enabled = (cpuidle_get_driver() == drv);
291
277 spin_lock(&cpuidle_driver_lock); 292 spin_lock(&cpuidle_driver_lock);
278 __cpuidle_unregister_driver(drv); 293 __cpuidle_unregister_driver(drv);
279 spin_unlock(&cpuidle_driver_lock); 294 spin_unlock(&cpuidle_driver_lock);
295
296 if (!enabled)
297 return;
298
299 mutex_lock(&cpuidle_lock);
300 if (cpuidle_prev_governor) {
301 if (!cpuidle_switch_governor(cpuidle_prev_governor))
302 cpuidle_prev_governor = NULL;
303 }
304 mutex_unlock(&cpuidle_lock);
280} 305}
281EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); 306EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);
282 307
diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
index 2e3e14192bee..e9801f26c732 100644
--- a/drivers/cpuidle/governor.c
+++ b/drivers/cpuidle/governor.c
@@ -20,14 +20,15 @@ char param_governor[CPUIDLE_NAME_LEN];
20 20
21LIST_HEAD(cpuidle_governors); 21LIST_HEAD(cpuidle_governors);
22struct cpuidle_governor *cpuidle_curr_governor; 22struct cpuidle_governor *cpuidle_curr_governor;
23struct cpuidle_governor *cpuidle_prev_governor;
23 24
24/** 25/**
25 * __cpuidle_find_governor - finds a governor of the specified name 26 * cpuidle_find_governor - finds a governor of the specified name
26 * @str: the name 27 * @str: the name
27 * 28 *
28 * Must be called with cpuidle_lock acquired. 29 * Must be called with cpuidle_lock acquired.
29 */ 30 */
30static struct cpuidle_governor * __cpuidle_find_governor(const char *str) 31struct cpuidle_governor *cpuidle_find_governor(const char *str)
31{ 32{
32 struct cpuidle_governor *gov; 33 struct cpuidle_governor *gov;
33 34
@@ -87,7 +88,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
87 return -ENODEV; 88 return -ENODEV;
88 89
89 mutex_lock(&cpuidle_lock); 90 mutex_lock(&cpuidle_lock);
90 if (__cpuidle_find_governor(gov->name) == NULL) { 91 if (cpuidle_find_governor(gov->name) == NULL) {
91 ret = 0; 92 ret = 0;
92 list_add_tail(&gov->governor_list, &cpuidle_governors); 93 list_add_tail(&gov->governor_list, &cpuidle_governors);
93 if (!cpuidle_curr_governor || 94 if (!cpuidle_curr_governor ||
diff --git a/drivers/cpuidle/governors/Makefile b/drivers/cpuidle/governors/Makefile
index 42f44cc610dd..63abb5393a4d 100644
--- a/drivers/cpuidle/governors/Makefile
+++ b/drivers/cpuidle/governors/Makefile
@@ -6,3 +6,4 @@
6obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o 6obj-$(CONFIG_CPU_IDLE_GOV_LADDER) += ladder.o
7obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o 7obj-$(CONFIG_CPU_IDLE_GOV_MENU) += menu.o
8obj-$(CONFIG_CPU_IDLE_GOV_TEO) += teo.o 8obj-$(CONFIG_CPU_IDLE_GOV_TEO) += teo.o
9obj-$(CONFIG_CPU_IDLE_GOV_HALTPOLL) += haltpoll.o
diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c
new file mode 100644
index 000000000000..7a703d2e0064
--- /dev/null
+++ b/drivers/cpuidle/governors/haltpoll.c
@@ -0,0 +1,150 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * haltpoll.c - haltpoll idle governor
4 *
5 * Copyright 2019 Red Hat, Inc. and/or its affiliates.
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level directory.
9 *
10 * Authors: Marcelo Tosatti <mtosatti@redhat.com>
11 */
12
13#include <linux/kernel.h>
14#include <linux/cpuidle.h>
15#include <linux/time.h>
16#include <linux/ktime.h>
17#include <linux/hrtimer.h>
18#include <linux/tick.h>
19#include <linux/sched.h>
20#include <linux/module.h>
21#include <linux/kvm_para.h>
22
23static unsigned int guest_halt_poll_ns __read_mostly = 200000;
24module_param(guest_halt_poll_ns, uint, 0644);
25
26/* division factor to shrink halt_poll_ns */
27static unsigned int guest_halt_poll_shrink __read_mostly = 2;
28module_param(guest_halt_poll_shrink, uint, 0644);
29
30/* multiplication factor to grow per-cpu poll_limit_ns */
31static unsigned int guest_halt_poll_grow __read_mostly = 2;
32module_param(guest_halt_poll_grow, uint, 0644);
33
34/* value in us to start growing per-cpu halt_poll_ns */
35static unsigned int guest_halt_poll_grow_start __read_mostly = 50000;
36module_param(guest_halt_poll_grow_start, uint, 0644);
37
38/* allow shrinking guest halt poll */
39static bool guest_halt_poll_allow_shrink __read_mostly = true;
40module_param(guest_halt_poll_allow_shrink, bool, 0644);
41
42/**
43 * haltpoll_select - selects the next idle state to enter
44 * @drv: cpuidle driver containing state data
45 * @dev: the CPU
46 * @stop_tick: indication on whether or not to stop the tick
47 */
48static int haltpoll_select(struct cpuidle_driver *drv,
49 struct cpuidle_device *dev,
50 bool *stop_tick)
51{
52 int latency_req = cpuidle_governor_latency_req(dev->cpu);
53
54 if (!drv->state_count || latency_req == 0) {
55 *stop_tick = false;
56 return 0;
57 }
58
59 if (dev->poll_limit_ns == 0)
60 return 1;
61
62 /* Last state was poll? */
63 if (dev->last_state_idx == 0) {
64 /* Halt if no event occurred on poll window */
65 if (dev->poll_time_limit == true)
66 return 1;
67
68 *stop_tick = false;
69 /* Otherwise, poll again */
70 return 0;
71 }
72
73 *stop_tick = false;
74 /* Last state was halt: poll */
75 return 0;
76}
77
78static void adjust_poll_limit(struct cpuidle_device *dev, unsigned int block_us)
79{
80 unsigned int val;
81 u64 block_ns = block_us*NSEC_PER_USEC;
82
83 /* Grow cpu_halt_poll_us if
84 * cpu_halt_poll_us < block_ns < guest_halt_poll_us
85 */
86 if (block_ns > dev->poll_limit_ns && block_ns <= guest_halt_poll_ns) {
87 val = dev->poll_limit_ns * guest_halt_poll_grow;
88
89 if (val < guest_halt_poll_grow_start)
90 val = guest_halt_poll_grow_start;
91 if (val > guest_halt_poll_ns)
92 val = guest_halt_poll_ns;
93
94 dev->poll_limit_ns = val;
95 } else if (block_ns > guest_halt_poll_ns &&
96 guest_halt_poll_allow_shrink) {
97 unsigned int shrink = guest_halt_poll_shrink;
98
99 val = dev->poll_limit_ns;
100 if (shrink == 0)
101 val = 0;
102 else
103 val /= shrink;
104 dev->poll_limit_ns = val;
105 }
106}
107
108/**
109 * haltpoll_reflect - update variables and update poll time
110 * @dev: the CPU
111 * @index: the index of actual entered state
112 */
113static void haltpoll_reflect(struct cpuidle_device *dev, int index)
114{
115 dev->last_state_idx = index;
116
117 if (index != 0)
118 adjust_poll_limit(dev, dev->last_residency);
119}
120
121/**
122 * haltpoll_enable_device - scans a CPU's states and does setup
123 * @drv: cpuidle driver
124 * @dev: the CPU
125 */
126static int haltpoll_enable_device(struct cpuidle_driver *drv,
127 struct cpuidle_device *dev)
128{
129 dev->poll_limit_ns = 0;
130
131 return 0;
132}
133
134static struct cpuidle_governor haltpoll_governor = {
135 .name = "haltpoll",
136 .rating = 9,
137 .enable = haltpoll_enable_device,
138 .select = haltpoll_select,
139 .reflect = haltpoll_reflect,
140};
141
142static int __init init_haltpoll(void)
143{
144 if (kvm_para_available())
145 return cpuidle_register_governor(&haltpoll_governor);
146
147 return 0;
148}
149
150postcore_initcall(init_haltpoll);
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index f0dddc66af26..428eeb832fe7 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -38,7 +38,6 @@ struct ladder_device_state {
38 38
39struct ladder_device { 39struct ladder_device {
40 struct ladder_device_state states[CPUIDLE_STATE_MAX]; 40 struct ladder_device_state states[CPUIDLE_STATE_MAX];
41 int last_state_idx;
42}; 41};
43 42
44static DEFINE_PER_CPU(struct ladder_device, ladder_devices); 43static DEFINE_PER_CPU(struct ladder_device, ladder_devices);
@@ -49,12 +48,13 @@ static DEFINE_PER_CPU(struct ladder_device, ladder_devices);
49 * @old_idx: the current state index 48 * @old_idx: the current state index
50 * @new_idx: the new target state index 49 * @new_idx: the new target state index
51 */ 50 */
52static inline void ladder_do_selection(struct ladder_device *ldev, 51static inline void ladder_do_selection(struct cpuidle_device *dev,
52 struct ladder_device *ldev,
53 int old_idx, int new_idx) 53 int old_idx, int new_idx)
54{ 54{
55 ldev->states[old_idx].stats.promotion_count = 0; 55 ldev->states[old_idx].stats.promotion_count = 0;
56 ldev->states[old_idx].stats.demotion_count = 0; 56 ldev->states[old_idx].stats.demotion_count = 0;
57 ldev->last_state_idx = new_idx; 57 dev->last_state_idx = new_idx;
58} 58}
59 59
60/** 60/**
@@ -68,13 +68,13 @@ static int ladder_select_state(struct cpuidle_driver *drv,
68{ 68{
69 struct ladder_device *ldev = this_cpu_ptr(&ladder_devices); 69 struct ladder_device *ldev = this_cpu_ptr(&ladder_devices);
70 struct ladder_device_state *last_state; 70 struct ladder_device_state *last_state;
71 int last_residency, last_idx = ldev->last_state_idx; 71 int last_residency, last_idx = dev->last_state_idx;
72 int first_idx = drv->states[0].flags & CPUIDLE_FLAG_POLLING ? 1 : 0; 72 int first_idx = drv->states[0].flags & CPUIDLE_FLAG_POLLING ? 1 : 0;
73 int latency_req = cpuidle_governor_latency_req(dev->cpu); 73 int latency_req = cpuidle_governor_latency_req(dev->cpu);
74 74
75 /* Special case when user has set very strict latency requirement */ 75 /* Special case when user has set very strict latency requirement */
76 if (unlikely(latency_req == 0)) { 76 if (unlikely(latency_req == 0)) {
77 ladder_do_selection(ldev, last_idx, 0); 77 ladder_do_selection(dev, ldev, last_idx, 0);
78 return 0; 78 return 0;
79 } 79 }
80 80
@@ -91,7 +91,7 @@ static int ladder_select_state(struct cpuidle_driver *drv,
91 last_state->stats.promotion_count++; 91 last_state->stats.promotion_count++;
92 last_state->stats.demotion_count = 0; 92 last_state->stats.demotion_count = 0;
93 if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) { 93 if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) {
94 ladder_do_selection(ldev, last_idx, last_idx + 1); 94 ladder_do_selection(dev, ldev, last_idx, last_idx + 1);
95 return last_idx + 1; 95 return last_idx + 1;
96 } 96 }
97 } 97 }
@@ -107,7 +107,7 @@ static int ladder_select_state(struct cpuidle_driver *drv,
107 if (drv->states[i].exit_latency <= latency_req) 107 if (drv->states[i].exit_latency <= latency_req)
108 break; 108 break;
109 } 109 }
110 ladder_do_selection(ldev, last_idx, i); 110 ladder_do_selection(dev, ldev, last_idx, i);
111 return i; 111 return i;
112 } 112 }
113 113
@@ -116,7 +116,7 @@ static int ladder_select_state(struct cpuidle_driver *drv,
116 last_state->stats.demotion_count++; 116 last_state->stats.demotion_count++;
117 last_state->stats.promotion_count = 0; 117 last_state->stats.promotion_count = 0;
118 if (last_state->stats.demotion_count >= last_state->threshold.demotion_count) { 118 if (last_state->stats.demotion_count >= last_state->threshold.demotion_count) {
119 ladder_do_selection(ldev, last_idx, last_idx - 1); 119 ladder_do_selection(dev, ldev, last_idx, last_idx - 1);
120 return last_idx - 1; 120 return last_idx - 1;
121 } 121 }
122 } 122 }
@@ -139,7 +139,7 @@ static int ladder_enable_device(struct cpuidle_driver *drv,
139 struct ladder_device_state *lstate; 139 struct ladder_device_state *lstate;
140 struct cpuidle_state *state; 140 struct cpuidle_state *state;
141 141
142 ldev->last_state_idx = first_idx; 142 dev->last_state_idx = first_idx;
143 143
144 for (i = first_idx; i < drv->state_count; i++) { 144 for (i = first_idx; i < drv->state_count; i++) {
145 state = &drv->states[i]; 145 state = &drv->states[i];
@@ -167,9 +167,8 @@ static int ladder_enable_device(struct cpuidle_driver *drv,
167 */ 167 */
168static void ladder_reflect(struct cpuidle_device *dev, int index) 168static void ladder_reflect(struct cpuidle_device *dev, int index)
169{ 169{
170 struct ladder_device *ldev = this_cpu_ptr(&ladder_devices);
171 if (index > 0) 170 if (index > 0)
172 ldev->last_state_idx = index; 171 dev->last_state_idx = index;
173} 172}
174 173
175static struct cpuidle_governor ladder_governor = { 174static struct cpuidle_governor ladder_governor = {
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index e9a28c7846d6..e5a5d0c8d66b 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -117,7 +117,6 @@
117 */ 117 */
118 118
119struct menu_device { 119struct menu_device {
120 int last_state_idx;
121 int needs_update; 120 int needs_update;
122 int tick_wakeup; 121 int tick_wakeup;
123 122
@@ -302,9 +301,10 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
302 !drv->states[0].disabled && !dev->states_usage[0].disable)) { 301 !drv->states[0].disabled && !dev->states_usage[0].disable)) {
303 /* 302 /*
304 * In this case state[0] will be used no matter what, so return 303 * In this case state[0] will be used no matter what, so return
305 * it right away and keep the tick running. 304 * it right away and keep the tick running if state[0] is a
305 * polling one.
306 */ 306 */
307 *stop_tick = false; 307 *stop_tick = !(drv->states[0].flags & CPUIDLE_FLAG_POLLING);
308 return 0; 308 return 0;
309 } 309 }
310 310
@@ -395,16 +395,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
395 395
396 return idx; 396 return idx;
397 } 397 }
398 if (s->exit_latency > latency_req) { 398 if (s->exit_latency > latency_req)
399 /*
400 * If we break out of the loop for latency reasons, use
401 * the target residency of the selected state as the
402 * expected idle duration so that the tick is retained
403 * as long as that target residency is low enough.
404 */
405 predicted_us = drv->states[idx].target_residency;
406 break; 399 break;
407 } 400
408 idx = i; 401 idx = i;
409 } 402 }
410 403
@@ -455,7 +448,7 @@ static void menu_reflect(struct cpuidle_device *dev, int index)
455{ 448{
456 struct menu_device *data = this_cpu_ptr(&menu_devices); 449 struct menu_device *data = this_cpu_ptr(&menu_devices);
457 450
458 data->last_state_idx = index; 451 dev->last_state_idx = index;
459 data->needs_update = 1; 452 data->needs_update = 1;
460 data->tick_wakeup = tick_nohz_idle_got_tick(); 453 data->tick_wakeup = tick_nohz_idle_got_tick();
461} 454}
@@ -468,7 +461,7 @@ static void menu_reflect(struct cpuidle_device *dev, int index)
468static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) 461static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
469{ 462{
470 struct menu_device *data = this_cpu_ptr(&menu_devices); 463 struct menu_device *data = this_cpu_ptr(&menu_devices);
471 int last_idx = data->last_state_idx; 464 int last_idx = dev->last_state_idx;
472 struct cpuidle_state *target = &drv->states[last_idx]; 465 struct cpuidle_state *target = &drv->states[last_idx];
473 unsigned int measured_us; 466 unsigned int measured_us;
474 unsigned int new_factor; 467 unsigned int new_factor;
diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index 7d05efdbd3c6..b5a0e498f798 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -96,7 +96,6 @@ struct teo_idle_state {
96 * @time_span_ns: Time between idle state selection and post-wakeup update. 96 * @time_span_ns: Time between idle state selection and post-wakeup update.
97 * @sleep_length_ns: Time till the closest timer event (at the selection time). 97 * @sleep_length_ns: Time till the closest timer event (at the selection time).
98 * @states: Idle states data corresponding to this CPU. 98 * @states: Idle states data corresponding to this CPU.
99 * @last_state: Idle state entered by the CPU last time.
100 * @interval_idx: Index of the most recent saved idle interval. 99 * @interval_idx: Index of the most recent saved idle interval.
101 * @intervals: Saved idle duration values. 100 * @intervals: Saved idle duration values.
102 */ 101 */
@@ -104,7 +103,6 @@ struct teo_cpu {
104 u64 time_span_ns; 103 u64 time_span_ns;
105 u64 sleep_length_ns; 104 u64 sleep_length_ns;
106 struct teo_idle_state states[CPUIDLE_STATE_MAX]; 105 struct teo_idle_state states[CPUIDLE_STATE_MAX];
107 int last_state;
108 int interval_idx; 106 int interval_idx;
109 unsigned int intervals[INTERVALS]; 107 unsigned int intervals[INTERVALS];
110}; 108};
@@ -125,12 +123,15 @@ static void teo_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
125 123
126 if (cpu_data->time_span_ns >= cpu_data->sleep_length_ns) { 124 if (cpu_data->time_span_ns >= cpu_data->sleep_length_ns) {
127 /* 125 /*
128 * One of the safety nets has triggered or this was a timer 126 * One of the safety nets has triggered or the wakeup was close
129 * wakeup (or equivalent). 127 * enough to the closest timer event expected at the idle state
128 * selection time to be discarded.
130 */ 129 */
131 measured_us = sleep_length_us; 130 measured_us = UINT_MAX;
132 } else { 131 } else {
133 unsigned int lat = drv->states[cpu_data->last_state].exit_latency; 132 unsigned int lat;
133
134 lat = drv->states[dev->last_state_idx].exit_latency;
134 135
135 measured_us = ktime_to_us(cpu_data->time_span_ns); 136 measured_us = ktime_to_us(cpu_data->time_span_ns);
136 /* 137 /*
@@ -189,15 +190,6 @@ static void teo_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
189 } 190 }
190 191
191 /* 192 /*
192 * If the total time span between idle state selection and the "reflect"
193 * callback is greater than or equal to the sleep length determined at
194 * the idle state selection time, the wakeup is likely to be due to a
195 * timer event.
196 */
197 if (cpu_data->time_span_ns >= cpu_data->sleep_length_ns)
198 measured_us = UINT_MAX;
199
200 /*
201 * Save idle duration values corresponding to non-timer wakeups for 193 * Save idle duration values corresponding to non-timer wakeups for
202 * pattern detection. 194 * pattern detection.
203 */ 195 */
@@ -242,12 +234,12 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
242 struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu); 234 struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu);
243 int latency_req = cpuidle_governor_latency_req(dev->cpu); 235 int latency_req = cpuidle_governor_latency_req(dev->cpu);
244 unsigned int duration_us, count; 236 unsigned int duration_us, count;
245 int max_early_idx, idx, i; 237 int max_early_idx, constraint_idx, idx, i;
246 ktime_t delta_tick; 238 ktime_t delta_tick;
247 239
248 if (cpu_data->last_state >= 0) { 240 if (dev->last_state_idx >= 0) {
249 teo_update(drv, dev); 241 teo_update(drv, dev);
250 cpu_data->last_state = -1; 242 dev->last_state_idx = -1;
251 } 243 }
252 244
253 cpu_data->time_span_ns = local_clock(); 245 cpu_data->time_span_ns = local_clock();
@@ -257,6 +249,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
257 249
258 count = 0; 250 count = 0;
259 max_early_idx = -1; 251 max_early_idx = -1;
252 constraint_idx = drv->state_count;
260 idx = -1; 253 idx = -1;
261 254
262 for (i = 0; i < drv->state_count; i++) { 255 for (i = 0; i < drv->state_count; i++) {
@@ -286,16 +279,8 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
286 if (s->target_residency > duration_us) 279 if (s->target_residency > duration_us)
287 break; 280 break;
288 281
289 if (s->exit_latency > latency_req) { 282 if (s->exit_latency > latency_req && constraint_idx > i)
290 /* 283 constraint_idx = i;
291 * If we break out of the loop for latency reasons, use
292 * the target residency of the selected state as the
293 * expected idle duration to avoid stopping the tick
294 * as long as that target residency is low enough.
295 */
296 duration_us = drv->states[idx].target_residency;
297 goto refine;
298 }
299 284
300 idx = i; 285 idx = i;
301 286
@@ -321,7 +306,13 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
321 duration_us = drv->states[idx].target_residency; 306 duration_us = drv->states[idx].target_residency;
322 } 307 }
323 308
324refine: 309 /*
310 * If there is a latency constraint, it may be necessary to use a
311 * shallower idle state than the one selected so far.
312 */
313 if (constraint_idx < idx)
314 idx = constraint_idx;
315
325 if (idx < 0) { 316 if (idx < 0) {
326 idx = 0; /* No states enabled. Must use 0. */ 317 idx = 0; /* No states enabled. Must use 0. */
327 } else if (idx > 0) { 318 } else if (idx > 0) {
@@ -331,13 +322,12 @@ refine:
331 322
332 /* 323 /*
333 * Count and sum the most recent idle duration values less than 324 * Count and sum the most recent idle duration values less than
334 * the target residency of the state selected so far, find the 325 * the current expected idle duration value.
335 * max.
336 */ 326 */
337 for (i = 0; i < INTERVALS; i++) { 327 for (i = 0; i < INTERVALS; i++) {
338 unsigned int val = cpu_data->intervals[i]; 328 unsigned int val = cpu_data->intervals[i];
339 329
340 if (val >= drv->states[idx].target_residency) 330 if (val >= duration_us)
341 continue; 331 continue;
342 332
343 count++; 333 count++;
@@ -356,8 +346,10 @@ refine:
356 * would be too shallow. 346 * would be too shallow.
357 */ 347 */
358 if (!(tick_nohz_tick_stopped() && avg_us < TICK_USEC)) { 348 if (!(tick_nohz_tick_stopped() && avg_us < TICK_USEC)) {
359 idx = teo_find_shallower_state(drv, dev, idx, avg_us);
360 duration_us = avg_us; 349 duration_us = avg_us;
350 if (drv->states[idx].target_residency > avg_us)
351 idx = teo_find_shallower_state(drv, dev,
352 idx, avg_us);
361 } 353 }
362 } 354 }
363 } 355 }
@@ -394,7 +386,7 @@ static void teo_reflect(struct cpuidle_device *dev, int state)
394{ 386{
395 struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu); 387 struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu);
396 388
397 cpu_data->last_state = state; 389 dev->last_state_idx = state;
398 /* 390 /*
399 * If the wakeup was not "natural", but triggered by one of the safety 391 * If the wakeup was not "natural", but triggered by one of the safety
400 * nets, assume that the CPU might have been idle for the entire sleep 392 * nets, assume that the CPU might have been idle for the entire sleep
diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c
index 02b9315a9e96..c8fa5f41dfc4 100644
--- a/drivers/cpuidle/poll_state.c
+++ b/drivers/cpuidle/poll_state.c
@@ -20,16 +20,9 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
20 local_irq_enable(); 20 local_irq_enable();
21 if (!current_set_polling_and_test()) { 21 if (!current_set_polling_and_test()) {
22 unsigned int loop_count = 0; 22 unsigned int loop_count = 0;
23 u64 limit = TICK_NSEC; 23 u64 limit;
24 int i;
25 24
26 for (i = 1; i < drv->state_count; i++) { 25 limit = cpuidle_poll_time(drv, dev);
27 if (drv->states[i].disabled || dev->states_usage[i].disable)
28 continue;
29
30 limit = (u64)drv->states[i].target_residency * NSEC_PER_USEC;
31 break;
32 }
33 26
34 while (!need_resched()) { 27 while (!need_resched()) {
35 cpu_relax(); 28 cpu_relax();
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index eb20adb5de23..2bb2683b493c 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -334,6 +334,7 @@ struct cpuidle_state_kobj {
334 struct cpuidle_state_usage *state_usage; 334 struct cpuidle_state_usage *state_usage;
335 struct completion kobj_unregister; 335 struct completion kobj_unregister;
336 struct kobject kobj; 336 struct kobject kobj;
337 struct cpuidle_device *device;
337}; 338};
338 339
339#ifdef CONFIG_SUSPEND 340#ifdef CONFIG_SUSPEND
@@ -391,6 +392,7 @@ static inline void cpuidle_remove_s2idle_attr_group(struct cpuidle_state_kobj *k
391#define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) 392#define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj)
392#define kobj_to_state(k) (kobj_to_state_obj(k)->state) 393#define kobj_to_state(k) (kobj_to_state_obj(k)->state)
393#define kobj_to_state_usage(k) (kobj_to_state_obj(k)->state_usage) 394#define kobj_to_state_usage(k) (kobj_to_state_obj(k)->state_usage)
395#define kobj_to_device(k) (kobj_to_state_obj(k)->device)
394#define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) 396#define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr)
395 397
396static ssize_t cpuidle_state_show(struct kobject *kobj, struct attribute *attr, 398static ssize_t cpuidle_state_show(struct kobject *kobj, struct attribute *attr,
@@ -414,10 +416,14 @@ static ssize_t cpuidle_state_store(struct kobject *kobj, struct attribute *attr,
414 struct cpuidle_state *state = kobj_to_state(kobj); 416 struct cpuidle_state *state = kobj_to_state(kobj);
415 struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj); 417 struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj);
416 struct cpuidle_state_attr *cattr = attr_to_stateattr(attr); 418 struct cpuidle_state_attr *cattr = attr_to_stateattr(attr);
419 struct cpuidle_device *dev = kobj_to_device(kobj);
417 420
418 if (cattr->store) 421 if (cattr->store)
419 ret = cattr->store(state, state_usage, buf, size); 422 ret = cattr->store(state, state_usage, buf, size);
420 423
424 /* reset poll time cache */
425 dev->poll_limit_ns = 0;
426
421 return ret; 427 return ret;
422} 428}
423 429
@@ -468,6 +474,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device)
468 } 474 }
469 kobj->state = &drv->states[i]; 475 kobj->state = &drv->states[i];
470 kobj->state_usage = &device->states_usage[i]; 476 kobj->state_usage = &device->states_usage[i];
477 kobj->device = device;
471 init_completion(&kobj->kobj_unregister); 478 init_completion(&kobj->kobj_unregister);
472 479
473 ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, 480 ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle,