summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_clocksource.c
diff options
context:
space:
mode:
authordavide <davide@FreeBSD.org>2013-02-28 10:46:54 +0000
committerdavide <davide@FreeBSD.org>2013-02-28 10:46:54 +0000
commit2bf12d0c7ceced74a813d6940dd07310a11d6a2a (patch)
tree33c7f3089361e0ab5379fdc8445540c6eeb03ed0 /sys/kern/kern_clocksource.c
parentf3c985cbe184c9d4c31d0e7140c146768a82833c (diff)
downloadFreeBSD-src-2bf12d0c7ceced74a813d6940dd07310a11d6a2a.zip
FreeBSD-src-2bf12d0c7ceced74a813d6940dd07310a11d6a2a.tar.gz
MFcalloutng:
When CPU becomes idle, cpu_idleclock() calculates time to the next timer event in order to reprogram hw timer. Return that time in sbintime_t to the caller and pass it to acpi_cpu_idle(), where it can be used as one more factor (quite precise) to extimate furter sleep time and choose optimal sleep state. This is a preparatory change for further callout improvements will be committed in the next days. The commmit is not targeted for MFC.
Diffstat (limited to 'sys/kern/kern_clocksource.c')
-rw-r--r--sys/kern/kern_clocksource.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c
index 33f21e9..ac7e2de 100644
--- a/sys/kern/kern_clocksource.c
+++ b/sys/kern/kern_clocksource.c
@@ -767,7 +767,7 @@ cpu_stopprofclock(void)
/*
* Switch to idle mode (all ticks handled).
*/
-void
+sbintime_t
cpu_idleclock(void)
{
struct bintime now, t;
@@ -779,7 +779,7 @@ cpu_idleclock(void)
|| curcpu == CPU_FIRST()
#endif
)
- return;
+ return (-1);
state = DPCPU_PTR(timerstate);
if (periodic)
now = state->now;
@@ -795,6 +795,8 @@ cpu_idleclock(void)
if (!periodic)
loadtimer(&now, 0);
ET_HW_UNLOCK(state);
+ bintime_sub(&t, &now);
+ return (MAX(bttosbt(t), 0));
}
/*
OpenPOWER on IntegriCloud