linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] add hrtimer_sleep_ns helper function
@ 2008-08-06 19:08 Josef Bacik
  2008-08-06 19:15 ` [PATCH 2/2] improve ext3 fsync batching Josef Bacik
  2008-08-19 19:15 ` [PATCH 1/2] add hrtimer_sleep_ns helper function Matthew Wilcox
  0 siblings, 2 replies; 19+ messages in thread
From: Josef Bacik @ 2008-08-06 19:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: rwheeler, tglx, linux-fsdevel, chris.mason, linux-ext4

Hello,

This patch adds a function so that things within the kernel can sleep for
nanoseconds.  This is needed for the next patch in the series.  Thank you,

Signed-off-by: Josef Bacik <jbacik@redhat.com>

Index: linux-2.6/include/linux/hrtimer.h
===================================================================
--- linux-2.6.orig/include/linux/hrtimer.h
+++ linux-2.6/include/linux/hrtimer.h
@@ -345,6 +345,7 @@ extern long hrtimer_nanosleep_restart(st
 
 extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
 				 struct task_struct *tsk);
+extern int hrtimer_sleep_ns(u64 ns, int interruptible);
 
 /* Soft interrupt function to run the hrtimer queues: */
 extern void hrtimer_run_queues(void);
Index: linux-2.6/kernel/hrtimer.c
===================================================================
--- linux-2.6.orig/kernel/hrtimer.c
+++ linux-2.6/kernel/hrtimer.c
@@ -1459,12 +1459,14 @@ void hrtimer_init_sleeper(struct hrtimer
 #endif
 }
 
-static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode)
+static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode,
+				int interruptible)
 {
 	hrtimer_init_sleeper(t, current);
 
 	do {
-		set_current_state(TASK_INTERRUPTIBLE);
+		set_current_state(interruptible ? TASK_INTERRUPTIBLE :
+				  TASK_UNINTERRUPTIBLE);
 		hrtimer_start(&t->timer, t->timer.expires, mode);
 		if (!hrtimer_active(&t->timer))
 			t->task = NULL;
@@ -1482,6 +1484,22 @@ static int __sched do_nanosleep(struct h
 	return t->task == NULL;
 }
 
+int hrtimer_sleep_ns(u64 ns, int interruptible)
+{
+	struct hrtimer_sleeper t;
+	int ret = 0;
+
+	hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
+	t.timer.expires = ktime_add_ns(ktime_get(), ns);
+
+	ret = do_nanosleep(&t, HRTIMER_MODE_ABS, interruptible);
+
+	destroy_hrtimer_on_stack(&t.timer);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(hrtimer_sleep_ns);
+
 static int update_rmtp(struct hrtimer *timer, struct timespec __user *rmtp)
 {
 	struct timespec rmt;
@@ -1508,7 +1526,7 @@ long __sched hrtimer_nanosleep_restart(s
 				HRTIMER_MODE_ABS);
 	t.timer.expires.tv64 = restart->nanosleep.expires;
 
-	if (do_nanosleep(&t, HRTIMER_MODE_ABS))
+	if (do_nanosleep(&t, HRTIMER_MODE_ABS, 1))
 		goto out;
 
 	rmtp = restart->nanosleep.rmtp;
@@ -1534,7 +1552,7 @@ long hrtimer_nanosleep(struct timespec *
 
 	hrtimer_init_on_stack(&t.timer, clockid, mode);
 	t.timer.expires = timespec_to_ktime(*rqtp);
-	if (do_nanosleep(&t, mode))
+	if (do_nanosleep(&t, mode, 1))
 		goto out;
 
 	/* Absolute timers do not update the rmtp value and restart: */

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2008-08-19 21:29 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-06 19:08 [PATCH 1/2] add hrtimer_sleep_ns helper function Josef Bacik
2008-08-06 19:15 ` [PATCH 2/2] improve ext3 fsync batching Josef Bacik
2008-08-06 19:23   ` Josef Bacik
2008-08-19  4:31   ` Andrew Morton
2008-08-19  5:44     ` Andreas Dilger
2008-08-19 11:01       ` Ric Wheeler
2008-08-19 17:56         ` Andrew Morton
2008-08-19 18:08           ` Ric Wheeler
2008-08-19 20:29             ` Andrew Morton
2008-08-19 20:55               ` Ric Wheeler
2008-08-19 21:18                 ` Andrew Morton
2008-08-19 21:29                   ` Ric Wheeler
2008-08-19 18:43           ` Ric Wheeler
2008-08-19 20:34             ` Andrew Morton
2008-08-19 19:18           ` Josef Bacik
2008-08-19 19:15 ` [PATCH 1/2] add hrtimer_sleep_ns helper function Matthew Wilcox
2008-08-19 19:22   ` Josef Bacik
2008-08-19 19:36     ` Matthew Wilcox
2008-08-19 19:39       ` Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).