From 8e37e1a2a3295f5d99e6dbe99eca24eca7a034ef Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Thu, 12 Jan 2017 21:27:02 +0800 Subject: cpuidle/menu: stop seeking deeper idle if current state is deep enough Obsolete commit 71abbbf856a0 (cpuidle: extend cpuidle and menu governor to handle dynamic states) wanted to introduce dynamic C-states, but that idea was dropped long ago. The nonsense deeper C-state checking remained, though. Since both target_residency and exit_latency are longer for deeper idle state, there's no need to waste CPU time on useless checks. Signed-off-by: Alex Shi Acked-by: Rik van Riel [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki --- drivers/cpuidle/governors/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index d9b5b9398a0f..07e36bb54006 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -357,9 +357,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) if (s->disabled || su->disable) continue; if (s->target_residency > data->predicted_us) - continue; + break; if (s->exit_latency > latency_req) - continue; + break; data->last_state_idx = i; } -- cgit v1.2.3-59-g8ed1b From 9908859acaa95640d4a07991a93f7cd5bfc18e02 Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Thu, 12 Jan 2017 21:27:04 +0800 Subject: cpuidle/menu: add per CPU PM QoS resume latency consideration There may be special requirements on CPU response time, like if a interrupt is pinned to a CPU, that CPU should not go into excessively deep idle states. For this reason, add a mechanism for adding PM QoS resume latency constraints for individual CPUs and modify the menu governor to take them into account. To that end, extend the device PM QoS pm_qos_resume_latency attribute to CPUs, which is possible, because the exit latency for CPUs is effectively equivalent to the resume latency for devices. Signed-off-by: Alex Shi Acked-by: Rik van Riel [ rjw : Subject & changelog ] Signed-off-by: Rafael J. Wysocki --- drivers/cpuidle/governors/menu.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index 07e36bb54006..8d6d25c38c02 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -19,6 +19,7 @@ #include #include #include +#include /* * Please note when changing the tuning values: @@ -280,17 +281,23 @@ again: static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) { struct menu_device *data = this_cpu_ptr(&menu_devices); + struct device *device = get_cpu_device(dev->cpu); int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); int i; unsigned int interactivity_req; unsigned int expected_interval; unsigned long nr_iowaiters, cpu_load; + int resume_latency = dev_pm_qos_read_value(device); if (data->needs_update) { menu_update(drv, dev); data->needs_update = 0; } + /* resume_latency is 0 means no restriction */ + if (resume_latency && resume_latency < latency_req) + latency_req = resume_latency; + /* Special case when user has set very strict latency requirement */ if (unlikely(latency_req == 0)) return 0; -- cgit v1.2.3-59-g8ed1b From 37efa4b41ffb31dcdfc3beb97d47992bb2a083e5 Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Thu, 12 Jan 2017 21:27:03 +0800 Subject: CPU / PM: expose pm_qos_resume_latency for CPUs The cpu-dma PM QoS constraint impacts all the cpus in the system. There is no way to let the user to choose a PM QoS constraint per cpu. The following patch exposes to the userspace a per cpu based sysfs file in order to let the userspace to change the value of the PM QoS latency constraint. This change is inoperative in its form and the cpuidle governors have to take into account the per cpu latency constraint in addition to the global cpu-dma latency constraint in order to operate properly. BTW The pm_qos_resume_latency usage defined in Documentation/ABI/testing/sysfs-devices-power The /sys/devices/.../power/pm_qos_resume_latency_us attribute contains the PM QoS resume latency limit for the given device, which is the maximum allowed time it can take to resume the device, after it has been suspended at run time, from a resume request to the moment the device will be ready to process I/O, in microseconds. If it is equal to 0, however, this means that the PM QoS resume latency may be arbitrary. Signed-off-by: Alex Shi Signed-off-by: Rafael J. Wysocki --- drivers/base/cpu.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 4c28e1a09786..2c3b359b3536 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "base.h" @@ -376,6 +377,7 @@ int register_cpu(struct cpu *cpu, int num) per_cpu(cpu_sys_devices, num) = &cpu->dev; register_cpu_under_node(num, cpu_to_node(num)); + dev_pm_qos_expose_latency_limit(&cpu->dev, 0); return 0; } -- cgit v1.2.3-59-g8ed1b