From: Dimitri Sivanich <sivanich@sgi.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [patch 1/3] timers: use function instead of macro for calc_load
Date: Thu, 7 May 2009 13:16:06 -0500 [thread overview]
Message-ID: <20090507181606.GA6549@sgi.com> (raw)
In-Reply-To: <20090502190545.410632127@linutronix.de>
On Sat, May 02, 2009 at 07:06:31PM -0000, Thomas Gleixner wrote:
> Replace the CALC_LOAD macro by a static function.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
> ---
> include/linux/sched.h | 5 -----
> kernel/timer.c | 29 ++++++++++++++---------------
> 2 files changed, 14 insertions(+), 20 deletions(-)
>
> Index: linux-2.6/include/linux/sched.h
> ===================================================================
> --- linux-2.6.orig/include/linux/sched.h
> +++ linux-2.6/include/linux/sched.h
> @@ -124,11 +124,6 @@ extern unsigned long avenrun[]; /* Load
> #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 unsigned long total_forks;
> extern int nr_threads;
> DECLARE_PER_CPU(unsigned long, process_counts);
> Index: linux-2.6/kernel/timer.c
> ===================================================================
> --- linux-2.6.orig/kernel/timer.c
> +++ linux-2.6/kernel/timer.c
> @@ -1123,14 +1123,6 @@ void update_process_times(int user_tick)
> }
>
> /*
> - * Nr of active tasks - counted in fixed-point numbers
> - */
> -static unsigned long count_active_tasks(void)
> -{
> - return nr_active() * FIXED_1;
> -}
> -
> -/*
> * Hmm.. Changed this, as the GNU make sources (load.c) seems to
> * imply that avenrun[] is the standard name for this kind of thing.
> * Nothing else seems to be standardized: the fractional size etc
> @@ -1139,25 +1131,32 @@ static unsigned long count_active_tasks(
> * Requires xtime_lock to access.
> */
> unsigned long avenrun[3];
> -
> EXPORT_SYMBOL(avenrun);
>
> +static unsigned long
> +calc_load(unsigned long load, unsigned long exp, unsigned long active)
> +{
> + load *= exp;
> + load += active * (FIXED_1 - exp);
> + return load >> FSHIFT;
> +}
> +
> /*
> * calc_load - given tick count, update the avenrun load estimates.
> * This is called while holding a write_lock on xtime_lock.
> */
> -static inline void calc_load(unsigned long ticks)
> +static void calc_global_load(unsigned long ticks)
> {
> unsigned long active_tasks; /* fixed-point */
> static int count = LOAD_FREQ;
>
> count -= ticks;
> if (unlikely(count < 0)) {
> - active_tasks = count_active_tasks();
> + active_tasks = nr_active() * FIXED_1;
> do {
> - 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);
> count += LOAD_FREQ;
> } while (count < 0);
> }
> @@ -1193,7 +1192,7 @@ void run_local_timers(void)
> static inline void update_times(unsigned long ticks)
> {
> update_wall_time();
> - calc_load(ticks);
> + calc_global_load(ticks);
> }
>
> /*
>
next prev parent reply other threads:[~2009-05-07 18:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-02 19:06 [patch 0/3] move calc_load to softirq Thomas Gleixner
2009-05-02 19:06 ` [patch 1/3] timers: use function instead of macro for calc_load Thomas Gleixner
2009-05-07 18:16 ` Dimitri Sivanich [this message]
2009-05-02 19:06 ` [patch 2/3] timer: move calc_load to softirq Thomas Gleixner
2009-05-02 19:24 ` Andrew Morton
2009-05-02 19:54 ` Thomas Gleixner
2009-05-07 18:18 ` Dimitri Sivanich
2009-05-02 19:06 ` [patch 3/3] tiemrs: cleanup avenrun users 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=20090507181606.GA6549@sgi.com \
--to=sivanich@sgi.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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.