From: Andrew Morton <akpm@osdl.org>
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: clameter@engr.sgi.com, linux-kernel@vger.kernel.org,
ralf@linux-mips.org, john stultz <johnstul@us.ibm.com>,
Andi Kleen <ak@muc.de>
Subject: Re: [PATCH] simplify update_times (avoid jiffies/jiffies_64 aliasing problem)
Date: Thu, 2 Mar 2006 19:04:08 -0800 [thread overview]
Message-ID: <20060302190408.1e754f12.akpm@osdl.org> (raw)
In-Reply-To: <20060303.114406.64806237.nemoto@toshiba-tops.co.jp>
Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
>
> ...
>
> In kernel 2.6, update_times() is called directly in timer interrupt,
> so there is no point calculating ticks here. Then update_wall_time()
> and calc_load() can also be optimized. This also get rid of
> difference of jiffies and jiffies_64 due to compiler's optimization
> (which was reported previously with subject "jiffies_64 vs. jiffies").
>
> Also adjust x86_64 timer interrupt handler with this change.
>
> diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
> index 3080f84..7a1d790 100644
> --- a/arch/x86_64/kernel/time.c
> +++ b/arch/x86_64/kernel/time.c
> @@ -423,7 +423,8 @@ void main_timer_handler(struct pt_regs *
>
> if (lost > 0) {
> handle_lost_ticks(lost, regs);
> - jiffies += lost;
> + while (lost--)
> + do_timer(regs);
> }
>
> /*
> diff --git a/kernel/timer.c b/kernel/timer.c
> index fc6646f..54544a7 100644
> --- a/kernel/timer.c
> +++ b/kernel/timer.c
> @@ -787,24 +787,14 @@ u64 current_tick_length(void)
> return ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj;
> }
>
> -/*
> - * Using a loop looks inefficient, but "ticks" is
> - * usually just one (we shouldn't be losing ticks,
> - * we're doing this this way mainly for interrupt
> - * latency reasons, not because we think we'll
> - * have lots of lost timer ticks
> - */
> -static void update_wall_time(unsigned long ticks)
> +static void update_wall_time(void)
> {
> - do {
> - ticks--;
> - update_wall_time_one_tick();
> - if (xtime.tv_nsec >= 1000000000) {
> - xtime.tv_nsec -= 1000000000;
> - xtime.tv_sec++;
> - second_overflow();
> - }
> - } while (ticks);
> + update_wall_time_one_tick();
> + if (xtime.tv_nsec >= 1000000000) {
> + xtime.tv_nsec -= 1000000000;
> + xtime.tv_sec++;
> + second_overflow();
> + }
> }
>
> /*
> @@ -849,15 +839,15 @@ unsigned long avenrun[3];
> EXPORT_SYMBOL(avenrun);
>
> /*
> - * calc_load - given tick count, update the avenrun load estimates.
> + * calc_load - 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 inline void calc_load(void)
> {
> unsigned long active_tasks; /* fixed-point */
> static int count = LOAD_FREQ;
>
> - count -= ticks;
> + count--;
> if (count < 0) {
> count += LOAD_FREQ;
> active_tasks = count_active_tasks();
> @@ -906,14 +896,9 @@ void run_local_timers(void)
> */
> static inline void update_times(void)
> {
> - unsigned long ticks;
> -
> - ticks = jiffies - wall_jiffies;
> - if (ticks) {
> - wall_jiffies += ticks;
> - update_wall_time(ticks);
> - }
> - calc_load(ticks);
> + wall_jiffies++;
> + update_wall_time();
> + calc_load();
> }
>
> /*
I'm actually creaking under the load of timer patches over here. A lot of
the above code has been heavily redone in John's time patches. I guess the
above optimisation is still relevant after John's work (?) but we need to
decide what to do. Now is as good a time as any.
John, that timer stuff is so fundamental and hits on code which has
historically been so fragile that I'm not sure it's even 2.6.17 material.
In which case we should sneak patches like the above underneath it all.
Or we decide to take your work into 2.6.17, in which case the above needs
to be redone for that context.
I'm not sure how to resolve this, really. Worried. Have you socialised
those changes with architecture maintainers? If so, what was the feedback?
Andi, have you had time to think about it all?
Thanks.
next prev parent reply other threads:[~2006-03-03 3:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-02 14:02 Atsushi Nemoto
2006-03-02 15:51 ` Atsushi Nemoto
2006-03-02 19:09 ` Christoph Lameter
2006-03-03 2:44 ` Atsushi Nemoto
2006-03-03 3:04 ` Andrew Morton [this message]
2006-03-03 3:20 ` Andi Kleen
2006-03-03 4:31 ` Atsushi Nemoto
2006-03-03 5:45 ` David S. Miller
2006-03-03 16:26 ` Atsushi Nemoto
2006-03-03 16:31 ` Atsushi Nemoto
2006-03-04 8:18 ` Andrew Morton
2006-03-04 11:20 ` Andi Kleen
2006-03-04 11:40 ` Andrew Morton
2006-03-04 5:21 ` Andi Kleen
2006-03-04 23:13 ` Paul Mackerras
2006-03-06 2:32 ` Atsushi Nemoto
2006-03-04 11:42 ` Paul Mackerras
2006-03-04 11:44 ` Andrew Morton
2006-03-04 12:33 ` Paul Mackerras
2006-03-04 16:43 ` Atsushi Nemoto
2006-03-03 20:17 ` john stultz
2006-03-03 21:15 ` Andrew Morton
2006-03-04 17:15 ` Atsushi Nemoto
2006-07-30 14:54 ` Atsushi Nemoto
2006-07-31 10:36 ` Martin Schwidefsky
2006-08-01 14:44 ` Atsushi Nemoto
2006-08-02 12:50 ` Martin Schwidefsky
2006-08-03 15:53 ` Atsushi Nemoto
2006-08-04 14:02 ` Martin Schwidefsky
2006-08-06 16:13 ` Atsushi Nemoto
2006-08-07 11:28 ` Martin Schwidefsky
2006-08-07 19:58 ` Andrew Morton
2006-08-08 8:11 ` Martin Schwidefsky
2006-08-09 15:07 ` Atsushi Nemoto
2006-03-03 18:13 ` john stultz
2006-03-04 2:34 ` Ralf Baechle
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=20060302190408.1e754f12.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=ak@muc.de \
--cc=anemo@mba.ocn.ne.jp \
--cc=clameter@engr.sgi.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ralf@linux-mips.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
Powered by JetHome