From patchwork Thu Feb 9 22:24:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 6738 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EBD1C23E01 for ; Thu, 9 Feb 2012 22:25:28 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id B5354A18167 for ; Thu, 9 Feb 2012 22:25:28 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id z7so4255939iab.11 for ; Thu, 09 Feb 2012 14:25:28 -0800 (PST) Received: by 10.42.57.148 with SMTP id d20mr5472397ich.33.1328826328040; Thu, 09 Feb 2012 14:25:28 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.12.131 with SMTP id x3cs56323ibx; Thu, 9 Feb 2012 14:25:27 -0800 (PST) Received: by 10.236.183.198 with SMTP id q46mr5642127yhm.0.1328826326811; Thu, 09 Feb 2012 14:25:26 -0800 (PST) Received: from e32.co.us.ibm.com (e32.co.us.ibm.com. [32.97.110.150]) by mx.google.com with ESMTPS id v42si4085501yhl.92.2012.02.09.14.25.26 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Feb 2012 14:25:26 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.150 as permitted sender) client-ip=32.97.110.150; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.150 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Feb 2012 15:25:24 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Feb 2012 15:24:51 -0700 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 78A4F19D8052; Thu, 9 Feb 2012 15:24:47 -0700 (MST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q19MOojQ141674; Thu, 9 Feb 2012 15:24:50 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q19MOojB001601; Thu, 9 Feb 2012 15:24:50 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q19MOnLq001495; Thu, 9 Feb 2012 15:24:49 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 4F774BFEC9; Thu, 9 Feb 2012 14:24:48 -0800 (PST) From: John Stultz To: Greg KH Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Greg KH , Android Kernel Team , John Stultz Subject: [PATCH 09/12] android-alarm: Update hrtimer if alarm at the head of the queue is reprogrammed Date: Thu, 9 Feb 2012 14:24:38 -0800 Message-Id: <1328826281-27148-10-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1328826281-27148-1-git-send-email-john.stultz@linaro.org> References: <1328826281-27148-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12020922-3270-0000-0000-000003E0D36D X-Gm-Message-State: ALoCoQlAckOBxxmpltWO6il3r8Up4gJ4NQ3bGaDq0Q8o6Q0Sw5EFSGKDj2z+YOz0JTvKCXI2uLAz From: Arve Hjønnevåg If an alarm was restarted with a value that moved it away from the head of a queue, the hrtimer would not be updated. This would cause unnecessary wakeups. CC: Arve Hjønnevåg CC: Greg KH CC: Android Kernel Team Change-Id: If379f8dd92b0bdb3173bd8d057adfe0dc1d15259 Signed-off-by: Arve Hjønnevåg Signed-off-by: John Stultz --- drivers/staging/android/alarm.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/alarm.c b/drivers/staging/android/alarm.c index 5370fdc..445c0b1 100644 --- a/drivers/staging/android/alarm.c +++ b/drivers/staging/android/alarm.c @@ -119,12 +119,15 @@ static void alarm_enqueue_locked(struct android_alarm *alarm) struct rb_node *parent = NULL; struct android_alarm *entry; int leftmost = 1; + bool was_first = false; pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n", alarm->type, alarm->function, ktime_to_ns(alarm->expires)); - if (base->first == &alarm->node) + if (base->first == &alarm->node) { base->first = rb_next(&alarm->node); + was_first = true; + } if (!RB_EMPTY_NODE(&alarm->node)) { rb_erase(&alarm->node, &base->alarms); RB_CLEAR_NODE(&alarm->node); @@ -144,10 +147,10 @@ static void alarm_enqueue_locked(struct android_alarm *alarm) leftmost = 0; } } - if (leftmost) { + if (leftmost) base->first = &alarm->node; - update_timer_locked(base, false); - } + if (leftmost || was_first) + update_timer_locked(base, was_first); rb_link_node(&alarm->node, parent, link); rb_insert_color(&alarm->node, &base->alarms);