All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Valdis.Kletnieks@vt.edu
Cc: Davide Libenzi <davidel@xmailserver.org>,
	Jeff Garzik <jgarzik@pobox.com>, Greg KH <greg@kroah.com>,
	Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org, Netdev <netdev@oss.sgi.com>
Subject: Re: MSEC_TO_JIFFIES is messed up...
Date: Wed, 12 May 2004 22:50:28 +0200	[thread overview]
Message-ID: <20040512205028.GA18806@elte.hu> (raw)
In-Reply-To: <20040512203500.GA17999@elte.hu>

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]


* Ingo Molnar <mingo@elte.hu> wrote:

> new patch attached - this adopts the overflow-safe variant from
> sctp.h, removes it from sctp.h and moves it into a generic include
> file and also does the HZ=1000 simplification.

yet another patch - this time it's: complete, covers irda, accelerates
HZ=100, unifies the slightly differing namespaces and compiles/boots as
well.

	Ingo

[-- Attachment #2: hz-cleanup-2.6.6-A2 --]
[-- Type: text/plain, Size: 2548 bytes --]

--- 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
+
 /*
  * The TICK_NSEC - 1 rounds up the value to the next resolution.  Note
  * that a remainder subtract here would not do the right thing as the
--- linux/include/net/irda/irda.h.orig	
+++ linux/include/net/irda/irda.h	
@@ -83,8 +83,6 @@ if(!(expr)) do { \
 #define MESSAGE(args...) printk(KERN_INFO args)
 #define ERROR(args...)   printk(KERN_ERR args)
 
-#define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
-
 /*
  *  Magic numbers used by Linux-IrDA. Random numbers which must be unique to 
  *  give the best protection
--- linux/include/net/sctp/sctp.h.orig	
+++ linux/include/net/sctp/sctp.h	
@@ -116,11 +116,6 @@
 #define SCTP_STATIC static
 #endif
 
-#define MSECS_TO_JIFFIES(msec) \
-	(((msec / 1000) * HZ) + ((msec % 1000) * HZ) / 1000)
-#define JIFFIES_TO_MSECS(jiff) \
-	(((jiff / HZ) * 1000) + ((jiff % HZ) * 1000) / HZ)
-
 /*
  * Function declarations.
  */
--- linux/include/asm-i386/param.h.orig	
+++ linux/include/asm-i386/param.h	
@@ -5,8 +5,6 @@
 # define HZ		1000		/* Internal kernel timer frequency */
 # define USER_HZ	100		/* .. some user interfaces are in "ticks" */
 # define CLOCKS_PER_SEC		(USER_HZ)	/* like times() */
-# define JIFFIES_TO_MSEC(x)	(x)
-# define MSEC_TO_JIFFIES(x)	(x)
 #endif
 
 #ifndef HZ
--- linux/kernel/sched.c.orig	
+++ linux/kernel/sched.c	
@@ -75,13 +75,6 @@
 #define NS_TO_JIFFIES(TIME)	((TIME) / (1000000000 / HZ))
 #define JIFFIES_TO_NS(TIME)	((TIME) * (1000000000 / HZ))
 
-#ifndef JIFFIES_TO_MSEC
-# define JIFFIES_TO_MSEC(x) ((x) * 1000 / HZ)
-#endif
-#ifndef MSEC_TO_JIFFIES
-# define MSEC_TO_JIFFIES(x) ((x) * HZ / 1000)
-#endif
-
 /*
  * These are the 'tuning knobs' of the scheduler:
  *
@@ -1880,7 +1873,7 @@ static void rebalance_tick(int this_cpu,
 			interval *= sd->busy_factor;
 
 		/* scale ms to jiffies */
-		interval = MSEC_TO_JIFFIES(interval);
+		interval = MSECS_TO_JIFFIES(interval);
 		if (unlikely(!interval))
 			interval = 1;
 

  reply	other threads:[~2004-05-12 21:01 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040512020700.6f6aa61f.akpm@osdl.org>
2004-05-12 18:19 ` MSEC_TO_JIFFIES is messed up Greg KH
2004-05-12 18:42   ` Jeff Garzik
2004-05-12 19:33     ` Ingo Molnar
2004-05-12 19:47       ` Valdis.Kletnieks
2004-05-12 19:56         ` Davide Libenzi
2004-05-12 20:07           ` Valdis.Kletnieks
2004-05-12 20:28             ` Ingo Molnar
2004-05-12 20:35               ` Ingo Molnar
2004-05-12 20:50                 ` Ingo Molnar [this message]
2004-05-12 21:03                   ` Valdis.Kletnieks
2004-05-12 21:33                     ` Davide Libenzi
2004-05-12 21:07                   ` Andrew Morton
2004-05-12 21:17                     ` Ingo Molnar
2004-05-12 22:18                       ` William Lee Irwin III
2004-05-13 17:38                         ` Paul Wagland
2004-05-13 19:11                           ` Andrew Morton
2004-05-13 19:19                             ` Jeff Garzik
2004-05-13 22:40                               ` Andrew Morton
2004-05-13 22:40                                 ` Andrew Morton
2004-05-13 22:41                                   ` Andrew Morton
2004-05-13 23:02                                     ` Jeff Garzik
2004-05-13 19:50                             ` Paul Wagland
2004-05-12 23:33           ` Peter Williams
2004-05-12 19:49       ` Davide Libenzi
2004-05-12 20:03         ` Ingo Molnar
2004-05-12 20:18           ` Valdis.Kletnieks
2004-05-12 20:20           ` Andrew Morton
2004-05-12 20:24             ` Jeff Garzik
2004-05-12 20:35               ` Andrew Morton
2004-05-12 20:44                 ` Jeff Garzik
2004-05-12 21:03                 ` Sridhar Samudrala
2004-05-12 20:32             ` Greg KH
2004-05-12 20:38             ` William Lee Irwin III
2004-05-12 20:47               ` Andrew Morton
2004-05-12 20:58                 ` Jeff Garzik
2004-05-12 20:59                 ` William Lee Irwin III
2004-05-12 20:55             ` Ingo Molnar
2004-05-12 21:01           ` Davide Libenzi
2004-05-12 21:12             ` Ingo Molnar
2004-05-12 21:40               ` Davide Libenzi
2004-05-12 21:49               ` Zan Lynx
2004-05-12 22:05                 ` Roland Dreier
2004-05-12 21:56               ` Zan Lynx
2004-05-12 21:39             ` J. Bruce Fields
2004-05-12 21:55               ` Andreas Schwab
2004-05-12 22:07                 ` J. Bruce Fields
2004-05-16  3:48                 ` Chris Wedgwood
2004-05-16 12:10                   ` Paul Wagland
2004-05-12 20:17       ` Jeff Garzik
2004-05-12 20:54     ` Bill Rugolsky Jr.
2004-05-12 22:44       ` Bill Rugolsky Jr.
2004-05-12 20:40 Jan Olderdissen
2004-05-12 20:46 ` Jeff Garzik
2004-05-12 20:49 ` Andreas Schwab

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=20040512205028.GA18806@elte.hu \
    --to=mingo@elte.hu \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@osdl.org \
    --cc=davidel@xmailserver.org \
    --cc=greg@kroah.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.