Thread (2 messages) flat view 2 messages, 2 authors, 2004-05-12

Re: MSEC_TO_JIFFIES is messed up...

From: <hidden>
Date: 2004-05-12 21:10:02
Also in: lkml

On Wed, 12 May 2004 22:50:28 +0200, Ingo Molnar said:
quoted hunk
Content-Disposition: attachment; filename="hz-cleanup-2.6.6-A2"
--- linux/include/linux/time.h.orig	
+++ linux/include/linux/time.h	
@@ -177,6 +177,24 @@ struct timezone {
 	(SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 
1) - 1)
 
 #endif
+
+/*
+ * Convert jiffies to milliseconds and back.
+ *
+ * Avoid unnecessary multiplications/divisions in the
+ * two most common HZ cases:
+ */
+#if HZ == 1000
+# define JIFFIES_TO_MSECS(x)	(x)
+# define MSECS_TO_JIFFIES(x)	(x)
+#elif HZ == 100
+# define JIFFIES_TO_MSECS(x)	((x) * 10)
+# define MSECS_TO_JIFFIES(x)	((x) / 10)
+#else
+# define JIFFIES_TO_MSECS(x)	((x) * 1000 / HZ)
+# define MSECS_TO_JIFFIES(x)	((x) * HZ / 1000)
+#endif
+
Looks good to me.. :)

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help