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>
Subject: [patch 2/2] hrtimer
Date: Sat, 25 Mar 2006 12:46:02 -0000	[thread overview]
Message-ID: <20060325121223.966390000@localhost.localdomain> (raw)
In-Reply-To: 20060325121219.172731000@localhost.localdomain

[-- Attachment #1: hrtimer-nanosleep-use-generic-sleeper.patch --]
[-- Type: text/plain, Size: 2197 bytes --]


Replace the nanosleep private sleeper functionality by the generic
hrtimer sleeper.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


 kernel/hrtimer.c |   34 +++++++---------------------------
 1 file changed, 7 insertions(+), 27 deletions(-)

Index: linux-2.6.16/kernel/hrtimer.c
===================================================================
--- linux-2.6.16.orig/kernel/hrtimer.c
+++ linux-2.6.16/kernel/hrtimer.c
@@ -655,7 +655,6 @@ void hrtimer_run_queues(void)
 /*
  * Sleep related functions:
  */
-
 static int hrtimer_wakeup(struct hrtimer *timer)
 {
 	struct hrtimer_sleeper *t =
@@ -675,28 +674,9 @@ void hrtimer_init_sleeper(struct hrtimer
 	sl->task = task;
 }
 
-struct sleep_hrtimer {
-	struct hrtimer timer;
-	struct task_struct *task;
-	int expired;
-};
-
-static int nanosleep_wakeup(struct hrtimer *timer)
-{
-	struct sleep_hrtimer *t =
-		container_of(timer, struct sleep_hrtimer, timer);
-
-	t->expired = 1;
-	wake_up_process(t->task);
-
-	return HRTIMER_NORESTART;
-}
-
-static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
+static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode)
 {
-	t->timer.function = nanosleep_wakeup;
-	t->task = current;
-	t->expired = 0;
+	hrtimer_init_sleeper(t, current);
 
 	do {
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -704,18 +684,18 @@ static int __sched do_nanosleep(struct s
 
 		schedule();
 
-		if (unlikely(!t->expired)) {
+		if (unlikely(t->task)) {
 			hrtimer_cancel(&t->timer);
 			mode = HRTIMER_ABS;
 		}
-	} while (!t->expired && !signal_pending(current));
+	} while (t->task && !signal_pending(current));
 
-	return t->expired;
+	return t->task == NULL;
 }
 
 static long __sched nanosleep_restart(struct restart_block *restart)
 {
-	struct sleep_hrtimer t;
+	struct hrtimer_sleeper t;
 	struct timespec __user *rmtp;
 	struct timespec tu;
 	ktime_t time;
@@ -748,7 +728,7 @@ long hrtimer_nanosleep(struct timespec *
 		       const enum hrtimer_mode mode, const clockid_t clockid)
 {
 	struct restart_block *restart;
-	struct sleep_hrtimer t;
+	struct hrtimer_sleeper t;
 	struct timespec tu;
 	ktime_t rem;
 

--


  parent reply	other threads:[~2006-03-25 12:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-25 12:46 [patch 0/2] hrtimer: generic sleeper infrastructure Thomas Gleixner
2006-03-25 12:46 ` [patch 1/2] hrtimer Thomas Gleixner
2006-03-25 12:46 ` Thomas Gleixner [this message]
2006-03-26  2:32   ` [patch 2/2] hrtimer Andrew Morton
2006-03-26 22:10     ` Thomas Gleixner
2006-03-27 23:55       ` Oleg Nesterov
2006-03-28  0:03         ` Roman Zippel
2006-03-28  8:29         ` 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=20060325121223.966390000@localhost.localdomain \
    --to=tglx@linutronix.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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