From patchwork Tue Jan 31 03:49:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 6458 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 2A45D249C6 for ; Tue, 31 Jan 2012 03:49:55 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 1AA25A182BE for ; Tue, 31 Jan 2012 03:49:55 +0000 (UTC) Received: by mail-bk0-f52.google.com with SMTP id r19so5134385bka.11 for ; Mon, 30 Jan 2012 19:49:55 -0800 (PST) Received: by 10.205.134.129 with SMTP id ic1mr9648475bkc.92.1327981794938; Mon, 30 Jan 2012 19:49:54 -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.204.130.220 with SMTP id u28cs170406bks; Mon, 30 Jan 2012 19:49:54 -0800 (PST) Received: by 10.236.124.2 with SMTP id w2mr17474550yhh.83.1327981793254; Mon, 30 Jan 2012 19:49:53 -0800 (PST) Received: from e7.ny.us.ibm.com (e7.ny.us.ibm.com. [32.97.182.137]) by mx.google.com with ESMTPS id i8si21393150yhe.82.2012.01.30.19.49.52 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jan 2012 19:49:53 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.137 as permitted sender) client-ip=32.97.182.137; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.137 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 30 Jan 2012 22:49:52 -0500 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 30 Jan 2012 22:49:48 -0500 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 1D32838C805C; Mon, 30 Jan 2012 22:49:48 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0V3nlhf418708; Mon, 30 Jan 2012 22:49:47 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0V3nlgO028114; Mon, 30 Jan 2012 22:49:47 -0500 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q0V3nk8P028104; Mon, 30 Jan 2012 22:49:47 -0500 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 937A7BFE61; Mon, 30 Jan 2012 19:49:45 -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 08/11] android-alarm: Update hrtimer if alarm at the head of the queue is reprogrammed Date: Mon, 30 Jan 2012 19:49:29 -0800 Message-Id: <1327981772-12329-9-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1327981772-12329-1-git-send-email-john.stultz@linaro.org> References: <1327981772-12329-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12013103-5806-0000-0000-000011E201D3 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 29135ed..b8cc843 100644 --- a/drivers/staging/android/alarm.c +++ b/drivers/staging/android/alarm.c @@ -120,12 +120,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); @@ -145,10 +148,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);