Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269183
b: refs/heads/master
c: dce75a8
h: refs/heads/master
i:
  269181: 2168f33
  269179: 9d694bb
  269175: 3d13668
  269167: 1b1695b
  269151: d0679a7
  269119: b1bb011
  269055: 1a7b06a
v: v3
  • Loading branch information
John Stultz committed Aug 10, 2011
1 parent b29cd02 commit cb6f994
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 54da23b720d5d612f8f1669f9ed3744008fb7382
refs/heads/master: dce75a8c71819ed4c7efdcd53c9b6f6356dc8cb5
2 changes: 2 additions & 0 deletions trunk/include/linux/alarmtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
void alarm_cancel(struct alarm *alarm);

u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);

#endif
37 changes: 36 additions & 1 deletion trunk/kernel/time/alarmtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,41 @@ void alarm_cancel(struct alarm *alarm)
}



u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval)
{
u64 overrun = 1;
ktime_t delta;

delta = ktime_sub(now, alarm->node.expires);

if (delta.tv64 < 0)
return 0;

if (unlikely(delta.tv64 >= interval.tv64)) {
s64 incr = ktime_to_ns(interval);

overrun = ktime_divns(delta, incr);

alarm->node.expires = ktime_add_ns(alarm->node.expires,
incr*overrun);

if (alarm->node.expires.tv64 > now.tv64)
return overrun;
/*
* This (and the ktime_add() below) is the
* correction for exact:
*/
overrun++;
}

alarm->node.expires = ktime_add(alarm->node.expires, interval);
return overrun;
}




/**
* clock2alarm - helper that converts from clockid to alarmtypes
* @clockid: clockid.
Expand Down Expand Up @@ -376,7 +411,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,

/* Re-add periodic timers */
if (alarm->period.tv64) {
alarm->node.expires = ktime_add(now, alarm->period);
ptr->it_overrun += alarm_forward(alarm, now, alarm->period);
return ALARMTIMER_RESTART;
}
return ALARMTIMER_NORESTART;
Expand Down

0 comments on commit cb6f994

Please sign in to comment.