From: William Lee Irwin III <wli@holomorphy.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [sched.h 3/8] privatize CALC_LOAD()
Date: Fri, 24 Sep 2004 20:08:02 -0700 [thread overview]
Message-ID: <20040925030802.GO9106@holomorphy.com> (raw)
In-Reply-To: <20040925025304.GN9106@holomorphy.com>
On Fri, Sep 24, 2004 at 07:53:04PM -0700, William Lee Irwin III wrote:
> CT_TO_SECS() and CT_TO_USECS() are used where jiffies_to_timeval()
> should be; this patch teaches their sole caller to use that instead and
> by so doing removes them from the kernel entirely.
CALC_LOAD() is used nowhere but kernel/timer.c; this patch moves it
there.
Index: mm3-2.6.9-rc2/include/linux/sched.h
===================================================================
--- mm3-2.6.9-rc2.orig/include/linux/sched.h 2004-09-24 18:45:29.052287408 -0700
+++ mm3-2.6.9-rc2/include/linux/sched.h 2004-09-24 18:58:09.944614192 -0700
@@ -75,15 +75,6 @@
#define FSHIFT 11 /* nr of bits of precision */
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
-#define LOAD_FREQ (5*HZ) /* 5 sec intervals */
-#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
-#define EXP_5 2014 /* 1/exp(5sec/5min) */
-#define EXP_15 2037 /* 1/exp(5sec/15min) */
-
-#define CALC_LOAD(load,exp,n) \
- load *= exp; \
- load += n*(FIXED_1-exp); \
- load >>= FSHIFT;
extern int nr_threads;
extern int last_pid;
Index: mm3-2.6.9-rc2/kernel/timer.c
===================================================================
--- mm3-2.6.9-rc2.orig/kernel/timer.c 2004-09-24 17:37:17.000000000 -0700
+++ mm3-2.6.9-rc2/kernel/timer.c 2004-09-24 18:58:21.931791864 -0700
@@ -884,6 +884,16 @@
*/
unsigned long avenrun[3];
+#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
+#define EXP_5 2014 /* 1/exp(5sec/5min) */
+#define EXP_15 2037 /* 1/exp(5sec/15min) */
+
+static inline unsigned long
+__calc_load(unsigned long prev, unsigned long decay, unsigned long new)
+{
+ return (decay*prev + (FIXED_1 - decay)*new) >> FSHIFT;
+}
+
/*
* calc_load - given tick count, update the avenrun load estimates.
* This is called while holding a write_lock on xtime_lock.
@@ -891,15 +901,15 @@
static inline void calc_load(unsigned long ticks)
{
unsigned long active_tasks; /* fixed-point */
- static int count = LOAD_FREQ;
+ static int count = 5*HZ;
count -= ticks;
if (count < 0) {
- count += LOAD_FREQ;
+ count += 5*HZ;
active_tasks = count_active_tasks();
- CALC_LOAD(avenrun[0], EXP_1, active_tasks);
- CALC_LOAD(avenrun[1], EXP_5, active_tasks);
- CALC_LOAD(avenrun[2], EXP_15, active_tasks);
+ avenrun[0] = __calc_load(avenrun[0], EXP_1, active_tasks);
+ avenrun[1] = __calc_load(avenrun[1], EXP_5, active_tasks);
+ avenrun[2] = __calc_load(avenrun[2], EXP_15, active_tasks);
}
}
next prev parent reply other threads:[~2004-09-25 3:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-25 2:45 [sched.h 0/8] sched.h header cleanups vs. 2.6.9-rc2-mm3 William Lee Irwin III
2004-09-25 2:49 ` [sched.h 1/8] nuke itimer_ticks and itimer_next William Lee Irwin III
2004-09-25 2:53 ` [sched.h 2/8] nuke CT_TO_SECS() and CT_TO_USECS() William Lee Irwin III
2004-09-25 3:08 ` William Lee Irwin III [this message]
2004-09-25 3:19 ` [sched.h 4/8] move struct k_itimer to posix-timers.h William Lee Irwin III
2004-09-25 3:24 ` [sched.h 5/8] move struct mm_struct to mm.h William Lee Irwin III
2004-09-25 3:26 ` [sched.h 6/8] move aio include " William Lee Irwin III
2004-09-25 3:27 ` [sched.h 7/8] remove rbtree.h inclusion from sched.h William Lee Irwin III
2004-09-25 3:29 ` [sched.h 8/8] move exec_domain declarations to personality.h William Lee Irwin III
2004-09-26 1:56 ` [sched.h 6/8] move aio include to mm.h Arnd Bergmann
2004-09-26 2:06 ` William Lee Irwin III
2004-09-26 2:15 ` Lee Revell
2004-09-26 2:17 ` William Lee Irwin III
2004-09-26 3:03 ` Arnd Bergmann
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=20040925030802.GO9106@holomorphy.com \
--to=wli@holomorphy.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.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