From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ross Lagerwall Subject: [PATCH] timers: Set the deadline more accurately Date: Wed, 21 May 2014 11:45:06 +0100 Message-ID: <1400669106-28864-1-git-send-email-ross.lagerwall@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wn41L-0005Mk-BJ for xen-devel@lists.xenproject.org; Wed, 21 May 2014 10:45:15 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Keir Fraser , Ian Jackson , Ian Campbell , Jan Beulich , Tim Deegan List-Id: xen-devel@lists.xenproject.org Program the timer to the deadline of the closest timer if it is further than 50us ahead, otherwise set it 50us ahead. This way a single event fires on time rather than 50us late (as it would have previously) while still preventing too many timer wakeups in the case of having many timers scheduled close together. (where 50us is the timer_slop) Signed-off-by: Ross Lagerwall --- xen/common/timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/common/timer.c b/xen/common/timer.c index 1895a78..f36aebc 100644 --- a/xen/common/timer.c +++ b/xen/common/timer.c @@ -492,8 +492,9 @@ static void timer_softirq_action(void) deadline = heap[1]->expires; if ( (ts->list != NULL) && (ts->list->expires < deadline) ) deadline = ts->list->expires; + now = NOW(); this_cpu(timer_deadline) = - (deadline == STIME_MAX) ? 0 : deadline + timer_slop; + (deadline == STIME_MAX) ? 0 : MAX(deadline, now + timer_slop); if ( !reprogram_timer(this_cpu(timer_deadline)) ) raise_softirq(TIMER_SOFTIRQ); -- 1.9.0