cpuidle: Use nanoseconds as the unit of time
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 7 Nov 2019 14:25:12 +0000 (15:25 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 11 Nov 2019 20:56:07 +0000 (21:56 +0100)
commitc1d51f684c72b5eb2aecbbd47be3a2977a2dc903
tree4e929d24f9033246e46d08ebf2157d0d438941a1
parent99e98d3fb1008ef7416e16a1fd355cb73a253502
cpuidle: Use nanoseconds as the unit of time

Currently, the cpuidle subsystem uses microseconds as the unit of
time which (among other things) causes the idle loop to incur some
integer division overhead for no clear benefit.

In order to allow cpuidle to measure time in nanoseconds, add two
new fields, exit_latency_ns and target_residency_ns, to represent the
exit latency and target residency of an idle state in nanoseconds,
respectively, to struct cpuidle_state and initialize them with the
help of the corresponding values in microseconds provided by drivers.
Additionally, change cpuidle_governor_latency_req() to return the
idle state exit latency constraint in nanoseconds.

Also meeasure idle state residency (last_residency_ns in struct
cpuidle_device and time_ns in struct cpuidle_driver) in nanoseconds
and update the cpuidle core and governors accordingly.

However, the menu governor still computes typical intervals in
microseconds to avoid integer overflows.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Doug Smythies <dsmythies@telus.net>
Tested-by: Doug Smythies <dsmythies@telus.net>
drivers/cpuidle/cpuidle.c
drivers/cpuidle/driver.c
drivers/cpuidle/governor.c
drivers/cpuidle/governors/haltpoll.c
drivers/cpuidle/governors/ladder.c
drivers/cpuidle/governors/menu.c
drivers/cpuidle/governors/teo.c
drivers/cpuidle/poll_state.c
drivers/cpuidle/sysfs.c
include/linux/cpuidle.h
kernel/sched/idle.c