diff mbox

[RESEND,v2,2/2] power/idle: enhance the precision of sleep_length

Message ID 1466154816-17900-2-git-send-email-zhaoyang.huang@spreadtrum.com
State Superseded
Headers show

Commit Message

Zhaoyang Huang June 17, 2016, 9:13 a.m. UTC
There should be a gap between tick_nohz_idle_enter and
tick_nohz_get_sleep_length when idle, which will cause the
sleep_length is not very precised. Change it in this patch.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@spreadtrum.com>

---
 kernel/time/tick-sched.c |    5 +++++
 1 file changed, 5 insertions(+)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Zhaoyang Huang June 20, 2016, 1:14 a.m. UTC | #1
On 17 June 2016 at 19:50, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Fri, 17 Jun 2016, Zhaoyang Huang wrote:

>> On 17 June 2016 at 17:27, Thomas Gleixner <tglx@linutronix.de> wrote:

>> > On Fri, 17 Jun 2016, Zhaoyang Huang wrote:

>> >> There should be a gap between tick_nohz_idle_enter and

>> >> tick_nohz_get_sleep_length when idle, which will cause the

>> >> sleep_length is not very precised. Change it in this patch.

>> >

>> > What kind of imprecision are we talking about? Seconds, nanoseconds or

>> > lightyears?

>> >

>> > Your changelog lacks any form of useful information.

>> >

>> sorry for the confusion. The imprecision can be caused by, for

>> example, the callback function registered for CPU_PM_ENTER, which may

>> consume a period of time within the 'idle' time. Besides, I also

>> wonder why not calc the 'sleep_length' in the

>> tick_nohz_get_sleep_length?  This value is calculated at very

>> beginning of the idle in current approach.

>

> You still are not explaining the amount of imprecision. What are you talking

> about and is it really relevant in any way or are you just trying to solve an

> acedemic issue?

>

> Thanks,

>

>         tglx

>

Indeed, it is depends on how deep the idle state is. For example, the
lightest level for my current platform is 1100us, which sums up the
entry,exit and min time. However, there is a callback which do memory
management(merge the same page) in CPU_PM_ENTER will consume at least
500us. In current approach, it cause 50% imprecision for this level of
idle state.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhaoyang Huang June 23, 2016, 8:34 a.m. UTC | #2
On 23 June 2016 at 16:18, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Thu, 23 Jun 2016, Zhaoyang Huang wrote:

>> On 23 June 2016 at 15:01, Thomas Gleixner <tglx@linutronix.de> wrote:

>> Thomas, I agree with you, I have discussed the modification with the

>> call back owner. However, I wonder if we can make the idle's framework

>> to be more precised without the assumption of short CPU_PM_ENTER

>> callbacks. Thank you!

>

> What's the point? To help people who put insanities into the idle code path?

>

> Thanks,

>

>         tglx

>

Hi, Thomas. If the entry,exit,min time of one idle state sums up to
500us in some platform, the 100us callback which should be common as
caused by cache miss would also generate 20% imprecision. Don't you
think it is a case we should deal with?
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhaoyang Huang June 23, 2016, 8:45 a.m. UTC | #3
On 23 June 2016 at 16:35, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Thu, 23 Jun 2016, Zhaoyang Huang wrote:

>> On 23 June 2016 at 16:18, Thomas Gleixner <tglx@linutronix.de> wrote:

>> > On Thu, 23 Jun 2016, Zhaoyang Huang wrote:

>> >> On 23 June 2016 at 15:01, Thomas Gleixner <tglx@linutronix.de> wrote:

>> >> Thomas, I agree with you, I have discussed the modification with the

>> >> call back owner. However, I wonder if we can make the idle's framework

>> >> to be more precised without the assumption of short CPU_PM_ENTER

>> >> callbacks. Thank you!

>> >

>> > What's the point? To help people who put insanities into the idle code path?

>> >

>> > Thanks,

>> >

>> >         tglx

>> >

>> Hi, Thomas. If the entry,exit,min time of one idle state sums up to

>> 500us in some platform, the 100us callback which should be common as

>> caused by cache miss would also generate 20% imprecision. Don't you

>

> A cache miss is causing a 100us callback? What are you talking about?

>

> Thanks,

>

>         tglx

By a serials of memory access which maybe missed on cache all. Anyway,
we can require the callback not to introduce schedule etc, but can not
ask them to ensure their own executing time, which they can not
control.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 536ada8..ee3be3d 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -975,6 +975,11 @@  void tick_nohz_irq_exit(void)
 ktime_t tick_nohz_get_sleep_length(void)
 {
 	struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
+	struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev);
+	ktime_t now;
+
+	now = ktime_get();
+	ts->sleep_length = ktime_sub(dev->next_event, now);
 
 	return ts->sleep_length;
 }