From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934430AbbDVTJE (ORCPT ); Wed, 22 Apr 2015 15:09:04 -0400 Received: from terminus.zytor.com ([198.137.202.10]:41331 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965702AbbDVTIp (ORCPT ); Wed, 22 Apr 2015 15:08:45 -0400 Date: Wed, 22 Apr 2015 12:08:10 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: linux-kernel@vger.kernel.org, mtosatti@redhat.com, hpa@zytor.com, viresh.kumar@linaro.org, preeti@linux.vnet.ibm.com, john.stultz@linaro.org, fweisbec@gmail.com, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org Reply-To: john.stultz@linaro.org, preeti@linux.vnet.ibm.com, tglx@linutronix.de, fweisbec@gmail.com, mingo@kernel.org, peterz@infradead.org, hpa@zytor.com, viresh.kumar@linaro.org, mtosatti@redhat.com, linux-kernel@vger.kernel.org In-Reply-To: <20150414203501.579063647@linutronix.de> References: <20150414203501.579063647@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/core] timerqueue: Let timerqueue_add/ del return information Git-Commit-ID: c320642e1ced3b81592610e374894fea995f475b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c320642e1ced3b81592610e374894fea995f475b Gitweb: http://git.kernel.org/tip/c320642e1ced3b81592610e374894fea995f475b Author: Thomas Gleixner AuthorDate: Tue, 14 Apr 2015 21:08:46 +0000 Committer: Thomas Gleixner CommitDate: Wed, 22 Apr 2015 17:06:49 +0200 timerqueue: Let timerqueue_add/del return information The hrtimer code is interested whether the added timer is the first one to expire and whether the removed timer was the last one in the tree. The add/del routines have that information already. So we can return it right away instead of reevaluating it at the call site. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra Cc: Preeti U Murthy Cc: Viresh Kumar Cc: Marcelo Tosatti Cc: Frederic Weisbecker Cc: John Stultz Link: http://lkml.kernel.org/r/20150414203501.579063647@linutronix.de Signed-off-by: Thomas Gleixner --- include/linux/timerqueue.h | 8 ++++---- lib/timerqueue.c | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/linux/timerqueue.h b/include/linux/timerqueue.h index a520fd7..7eec17a 100644 --- a/include/linux/timerqueue.h +++ b/include/linux/timerqueue.h @@ -16,10 +16,10 @@ struct timerqueue_head { }; -extern void timerqueue_add(struct timerqueue_head *head, - struct timerqueue_node *node); -extern void timerqueue_del(struct timerqueue_head *head, - struct timerqueue_node *node); +extern bool timerqueue_add(struct timerqueue_head *head, + struct timerqueue_node *node); +extern bool timerqueue_del(struct timerqueue_head *head, + struct timerqueue_node *node); extern struct timerqueue_node *timerqueue_iterate_next( struct timerqueue_node *node); diff --git a/lib/timerqueue.c b/lib/timerqueue.c index a382e4a..782ae8c 100644 --- a/lib/timerqueue.c +++ b/lib/timerqueue.c @@ -36,7 +36,7 @@ * Adds the timer node to the timerqueue, sorted by the * node's expires value. */ -void timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node) +bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node) { struct rb_node **p = &head->head.rb_node; struct rb_node *parent = NULL; @@ -56,8 +56,11 @@ void timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node) rb_link_node(&node->node, parent, p); rb_insert_color(&node->node, &head->head); - if (!head->next || node->expires.tv64 < head->next->expires.tv64) + if (!head->next || node->expires.tv64 < head->next->expires.tv64) { head->next = node; + return true; + } + return false; } EXPORT_SYMBOL_GPL(timerqueue_add); @@ -69,7 +72,7 @@ EXPORT_SYMBOL_GPL(timerqueue_add); * * Removes the timer node from the timerqueue. */ -void timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node) +bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node) { WARN_ON_ONCE(RB_EMPTY_NODE(&node->node)); @@ -82,6 +85,7 @@ void timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node) } rb_erase(&node->node, &head->head); RB_CLEAR_NODE(&node->node); + return head->next != NULL; } EXPORT_SYMBOL_GPL(timerqueue_del);