cpuidle: Pass exit latency limit to cpuidle_use_deepest_state()
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Sat, 16 Nov 2019 13:16:13 +0000 (14:16 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 20 Nov 2019 10:46:18 +0000 (11:46 +0100)
Modify cpuidle_use_deepest_state() to take an additional exit latency
limit argument to be passed to find_deepest_idle_state() and make
cpuidle_idle_call() pass dev->forced_idle_latency_limit_ns to it for
forced idle.

Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
[ rjw: Rebase and rearrange code, subject & changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpuidle/cpuidle.c
include/linux/cpuidle.h
kernel/sched/idle.c

index 12077db1158e466928023cfd51ca1bb76c93590d..569dbac443bd6e23d758f475cd95a619cea64ee2 100644 (file)
@@ -123,9 +123,10 @@ void cpuidle_use_deepest_state(u64 latency_limit_ns)
  * @dev: cpuidle device for the given CPU.
  */
 int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
-                              struct cpuidle_device *dev)
+                              struct cpuidle_device *dev,
+                              u64 latency_limit_ns)
 {
-       return find_deepest_state(drv, dev, U64_MAX, 0, false);
+       return find_deepest_state(drv, dev, latency_limit_ns, 0, false);
 }
 
 #ifdef CONFIG_SUSPEND
index 72b26ff1de4ba5ed8590d62ccce01d002bce73e6..2dbe46b7c21382db0a2e4c97deeb7483b8a84f6d 100644 (file)
@@ -213,13 +213,15 @@ static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; }
 
 #ifdef CONFIG_CPU_IDLE
 extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
-                                     struct cpuidle_device *dev);
+                                     struct cpuidle_device *dev,
+                                     u64 latency_limit_ns);
 extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
                                struct cpuidle_device *dev);
 extern void cpuidle_use_deepest_state(u64 latency_limit_ns);
 #else
 static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
-                                            struct cpuidle_device *dev)
+                                            struct cpuidle_device *dev,
+                                            u64 latency_limit_ns)
 {return -ENODEV; }
 static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
                                       struct cpuidle_device *dev)
index cd05ffa0abfe8409131bbd9825caa8529ab7ec3e..fc9604ddd80284909d590f98ac3855848f8aea17 100644 (file)
@@ -166,6 +166,8 @@ static void cpuidle_idle_call(void)
         */
 
        if (idle_should_enter_s2idle() || dev->forced_idle_latency_limit_ns) {
+               u64 max_latency_ns;
+
                if (idle_should_enter_s2idle()) {
                        rcu_idle_enter();
 
@@ -176,12 +178,16 @@ static void cpuidle_idle_call(void)
                        }
 
                        rcu_idle_exit();
+
+                       max_latency_ns = U64_MAX;
+               } else {
+                       max_latency_ns = dev->forced_idle_latency_limit_ns;
                }
 
                tick_nohz_idle_stop_tick();
                rcu_idle_enter();
 
-               next_state = cpuidle_find_deepest_state(drv, dev);
+               next_state = cpuidle_find_deepest_state(drv, dev, max_latency_ns);
                call_cpuidle(drv, dev, next_state);
        } else {
                bool stop_tick = true;