Re: [PATCH v2] cpuidle: Fix last_residency division

From
Arnd Bergmann <arnd@arndb.de>
Date
2016-06-24 19:41:08
Also in
linux-pm
Reply to
Shreyas B Prabhu, 2016-06-24
On Friday, June 24, 2016 9:31:35 PM CEST Shreyas B Prabhu wrote:
quoted
If those functions are called less often than cpuidle_enter_state(),
we could just move the division there. Since the divisor is constant,
do_div() can convert it into a multiply and shift, or we could use
your the code you suggest above, or use a 32-bit division most of
the time:

      if (diff <= UINT_MAX)
              diff_32 = (u32)diff / NSECS_PER_USEC;
      else
              diff_32 = div_u64(diff, NSECS_PER_USEC;

which gcc itself will turn into a multiplication or series of
shifts on CPUs on which that is faster.
I'm not sure which division method of the three suggested here to use.
Does anyone have a strong preference?
It depends on how accurate we want it and how long we expect
the times to be. The optimization for the 4.2 second cutoff
for doing a 32-bit division only makes sense if the majority
of the sleep times are below that.

	Arnd
Thread (11 messages) 11 messages, 5 authors, last reply 2016-06-29
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help