public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Andrew Morton <akpm@osdl.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Roman Zippel <zippel@linux-m68k.org>
Subject: [patch 5/8] hrtimer remove state field
Date: Sun, 12 Mar 2006 10:37:18 -0000	[thread overview]
Message-ID: <20060312080332.274315000@localhost.localdomain> (raw)
In-Reply-To: 20060312080316.826824000@localhost.localdomain

[-- Attachment #1: hrtimers-remove-state-field.patch --]
[-- Type: text/plain, Size: 3162 bytes --]


From: Roman Zippel <zippel@linux-m68k.org>

Remove the state field and encode this information in the rb_node
similiar to normal timer.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Thomas Gleixner <tglx@linutronix.de>

 include/linux/hrtimer.h |   11 ++---------
 kernel/hrtimer.c        |   13 ++++---------
 2 files changed, 6 insertions(+), 18 deletions(-)

Index: linux-2.6.16-updates/include/linux/hrtimer.h
===================================================================
--- linux-2.6.16-updates.orig/include/linux/hrtimer.h
+++ linux-2.6.16-updates/include/linux/hrtimer.h
@@ -34,13 +34,7 @@ enum hrtimer_restart {
 	HRTIMER_RESTART,
 };
 
-/*
- * Timer states:
- */
-enum hrtimer_state {
-	HRTIMER_INACTIVE,		/* Timer is inactive */
-	HRTIMER_PENDING,		/* Timer is pending */
-};
+#define HRTIMER_INACTIVE	((void *)1UL)
 
 struct hrtimer_base;
 
@@ -61,7 +55,6 @@ struct hrtimer_base;
 struct hrtimer {
 	struct rb_node		node;
 	ktime_t			expires;
-	enum hrtimer_state	state;
 	int			(*function)(void *);
 	void			*data;
 	struct hrtimer_base	*base;
@@ -124,7 +117,7 @@ extern ktime_t hrtimer_get_next_event(vo
 
 static inline int hrtimer_active(const struct hrtimer *timer)
 {
-	return timer->state == HRTIMER_PENDING;
+	return timer->node.rb_parent != HRTIMER_INACTIVE;
 }
 
 /* Forward a hrtimer so it expires after now: */
Index: linux-2.6.16-updates/kernel/hrtimer.c
===================================================================
--- linux-2.6.16-updates.orig/kernel/hrtimer.c
+++ linux-2.6.16-updates/kernel/hrtimer.c
@@ -374,8 +374,6 @@ static void enqueue_hrtimer(struct hrtim
 	rb_link_node(&timer->node, parent, link);
 	rb_insert_color(&timer->node, &base->active);
 
-	timer->state = HRTIMER_PENDING;
-
 	if (!base->first || timer->expires.tv64 <
 	    rb_entry(base->first, struct hrtimer, node)->expires.tv64)
 		base->first = &timer->node;
@@ -395,6 +393,7 @@ static void __remove_hrtimer(struct hrti
 	if (base->first == &timer->node)
 		base->first = rb_next(&timer->node);
 	rb_erase(&timer->node, &base->active);
+	timer->node.rb_parent = HRTIMER_INACTIVE;
 }
 
 /*
@@ -405,7 +404,6 @@ remove_hrtimer(struct hrtimer *timer, st
 {
 	if (hrtimer_active(timer)) {
 		__remove_hrtimer(timer, base);
-		timer->state = HRTIMER_INACTIVE;
 		return 1;
 	}
 	return 0;
@@ -579,6 +577,7 @@ void hrtimer_init(struct hrtimer *timer,
 		clock_id = CLOCK_MONOTONIC;
 
 	timer->base = &bases[clock_id];
+	timer->node.rb_parent = HRTIMER_INACTIVE;
 }
 
 /**
@@ -625,7 +624,6 @@ static inline void run_hrtimer_queue(str
 		fn = timer->function;
 		data = timer->data;
 		set_curr_timer(base, timer);
-		timer->state = HRTIMER_INACTIVE;
 		__remove_hrtimer(timer, base);
 		spin_unlock_irq(&base->lock);
 
@@ -633,11 +631,8 @@ static inline void run_hrtimer_queue(str
 
 		spin_lock_irq(&base->lock);
 
-		/* Another CPU has added back the timer */
-		if (timer->state != HRTIMER_INACTIVE)
-			continue;
-
-		if (restart != HRTIMER_NORESTART)
+		if (restart != HRTIMER_NORESTART &&
+		    !hrtimer_active(timer))
 			enqueue_hrtimer(timer, base);
 	}
 	set_curr_timer(base, NULL);

--


  parent reply	other threads:[~2006-03-12 10:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-12 10:37 [patch 0/8] hrtimer updates Thomas Gleixner
2006-03-12 10:37 ` [patch 1/8] hrtimer optimize softirq runqueues Thomas Gleixner
2006-03-12 10:37 ` [patch 2/8] Pass current time to hrtimer_forward() Thomas Gleixner
2006-03-12 10:37 ` [patch 3/8] posix-timer cleanup common_timer_get() Thomas Gleixner
2006-03-12 10:37 ` [patch 4/8] hrtimer simplify nanosleep Thomas Gleixner
2006-03-12 10:37 ` Thomas Gleixner [this message]
2006-03-12 12:13   ` [patch 5/8] hrtimer remove state field Roman Zippel
2006-03-12 13:10     ` Thomas Gleixner
2006-03-12 13:26       ` Roman Zippel
2006-03-12 13:35         ` Thomas Gleixner
2006-03-12 13:55           ` Roman Zippel
2006-03-12 14:15             ` Thomas Gleixner
2006-03-12 14:30               ` Roman Zippel
2006-03-12 14:54                 ` Thomas Gleixner
2006-03-12 15:17                   ` Roman Zippel
2006-03-12 15:41                     ` Thomas Gleixner
2006-03-12 16:00                       ` Roman Zippel
2006-03-12 16:26                         ` Thomas Gleixner
2006-03-12 16:57                           ` [patch] hrtimer remove replace state check by BUG_ON Thomas Gleixner
2006-03-16  1:05                           ` [patch 5/8] hrtimer remove state field Roman Zippel
2006-03-16  9:01                             ` Thomas Gleixner
2006-03-17 22:07                               ` Roman Zippel
2006-03-18  8:46                                 ` Thomas Gleixner
2006-03-12 10:37 ` [patch 6/8] Remove it_real_value calculation from proc/*/stat Thomas Gleixner
2006-03-12 10:37 ` [patch 7/8] Remove DEFINE_KTIME and ktime_to_clock_t() Thomas Gleixner
2006-03-12 10:37 ` [patch 8/8] Remove nsec_t typedef Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060312080332.274315000@localhost.localdomain \
    --to=tglx@linutronix.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox