Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1383330 > unrolled thread
| Started by | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| First post | 2016-04-20 14:20 +0200 |
| Last post | 2016-04-20 18:50 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] cpuidle: Change ktime_get() with local_clock() Peter Zijlstra <peterz@infradead.org> - 2016-04-20 14:20 +0200
Re: [PATCH] cpuidle: Change ktime_get() with local_clock() Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-04-20 14:40 +0200
Re: [PATCH] cpuidle: Change ktime_get() with local_clock() Peter Zijlstra <peterz@infradead.org> - 2016-04-20 15:00 +0200
Re: [PATCH] cpuidle: Change ktime_get() with local_clock() Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-04-20 18:50 +0200
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-04-20 14:20 +0200 |
| Subject | Re: [PATCH] cpuidle: Change ktime_get() with local_clock() |
| Message-ID | <rpZgR-7JT-3@gated-at.bofh.it> |
On Thu, Apr 14, 2016 at 09:23:54PM +0200, Daniel Lezcano wrote: > @@ -217,7 +217,11 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, > if (!cpuidle_state_is_coupled(drv, entered_state)) > local_irq_enable(); > > - diff = ktime_to_us(ktime_sub(time_end, time_start)); > + /* > + * local_clock() returns the time in nanosecond, let's shift > + * by 10 (divide by 1024) to have microsecond based time. > + */ > + diff = (time_end - time_start) >> 10; Changelog fails to explain the ramifications of this change...
[toc] | [next] | [standalone]
| From | Daniel Lezcano <daniel.lezcano@linaro.org> |
|---|---|
| Date | 2016-04-20 14:40 +0200 |
| Message-ID | <rpZAe-7Uv-21@gated-at.bofh.it> |
| In reply to | #1383330 |
On Wed, Apr 20, 2016 at 02:13:15PM +0200, Peter Zijlstra wrote: > On Thu, Apr 14, 2016 at 09:23:54PM +0200, Daniel Lezcano wrote: > > @@ -217,7 +217,11 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, > > if (!cpuidle_state_is_coupled(drv, entered_state)) > > local_irq_enable(); > > > > - diff = ktime_to_us(ktime_sub(time_end, time_start)); > > + /* > > + * local_clock() returns the time in nanosecond, let's shift > > + * by 10 (divide by 1024) to have microsecond based time. > > + */ > > + diff = (time_end - time_start) >> 10; > > Changelog fails to explain the ramifications of this change... Sorry, I don't get the point of your comment. Do you mean I should elaborate the comment above in the changelog?
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-04-20 15:00 +0200 |
| Message-ID | <rpZTz-834-5@gated-at.bofh.it> |
| In reply to | #1383344 |
On Wed, Apr 20, 2016 at 02:30:11PM +0200, Daniel Lezcano wrote: > On Wed, Apr 20, 2016 at 02:13:15PM +0200, Peter Zijlstra wrote: > > On Thu, Apr 14, 2016 at 09:23:54PM +0200, Daniel Lezcano wrote: > > > @@ -217,7 +217,11 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, > > > if (!cpuidle_state_is_coupled(drv, entered_state)) > > > local_irq_enable(); > > > > > > - diff = ktime_to_us(ktime_sub(time_end, time_start)); > > > + /* > > > + * local_clock() returns the time in nanosecond, let's shift > > > + * by 10 (divide by 1024) to have microsecond based time. > > > + */ > > > + diff = (time_end - time_start) >> 10; > > > > Changelog fails to explain the ramifications of this change... > > Sorry, I don't get the point of your comment. Do you mean I should elaborate > the comment above in the changelog? Yeah, why is /1024 good enough?
[toc] | [prev] | [next] | [standalone]
| From | Daniel Lezcano <daniel.lezcano@linaro.org> |
|---|---|
| Date | 2016-04-20 18:50 +0200 |
| Message-ID | <rq3uc-2ta-31@gated-at.bofh.it> |
| In reply to | #1383353 |
On Wed, Apr 20, 2016 at 02:58:37PM +0200, Peter Zijlstra wrote: > On Wed, Apr 20, 2016 at 02:30:11PM +0200, Daniel Lezcano wrote: > > On Wed, Apr 20, 2016 at 02:13:15PM +0200, Peter Zijlstra wrote: > > > On Thu, Apr 14, 2016 at 09:23:54PM +0200, Daniel Lezcano wrote: > > > > @@ -217,7 +217,11 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, > > > > if (!cpuidle_state_is_coupled(drv, entered_state)) > > > > local_irq_enable(); > > > > > > > > - diff = ktime_to_us(ktime_sub(time_end, time_start)); > > > > + /* > > > > + * local_clock() returns the time in nanosecond, let's shift > > > > + * by 10 (divide by 1024) to have microsecond based time. > > > > + */ > > > > + diff = (time_end - time_start) >> 10; > > > > > > Changelog fails to explain the ramifications of this change... > > > > Sorry, I don't get the point of your comment. Do you mean I should elaborate > > the comment above in the changelog? > > Yeah, why is /1024 good enough? Ok. The conversion between nanosec to microsec could be done with integer division (div 1000) or by 10 bits shifting (div 1024). The following table gives some results at the limits. ------------------------------------------ | nsec | div(1000) | div(1024) | ------------------------------------------ | 1e3 | 1 usec | 976 nsec | ------------------------------------------ | 1e6 | 1000 usec | 976 usec | ------------------------------------------ | 1e9 | 1000000 usec | 976562 usec | ------------------------------------------ There is a linear deviation of 2.34%. This loss of precision is acceptable in the context of the resulting diff which is used for statistics. These ones are processed to guess estimate an approximation of the duration of the next idle period which ends up into an idle state selection. The selection criteria takes into account the next duration based on large intervals, represented by the idle state's target residency. The 2^10 division is enough because the approximation regarding the 1e3 division is lost in all the approximations done for the next idle duration computation. Would be this explanation sufficient ?
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web