2009-07-21 19:21:53

by Martin Schwidefsky

[permalink] [raw]
Subject: [RFC][patch 3/5] remove clocksource inline functions

From: Martin Schwidefsky <[email protected]>

Remove clocksource_read, clocksource_enable and clocksource_disable
inline functions. No functional change.

Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: john stultz <[email protected]>
Signed-off-by: Martin Schwidefsky <[email protected]>
---
kernel/time/clocksource.c | 18 ++++++++++++------
kernel/time/timekeeping.c | 13 ++++++-------
2 files changed, 18 insertions(+), 13 deletions(-)

Index: linux-2.6/kernel/time/clocksource.c
===================================================================
--- linux-2.6.orig/kernel/time/clocksource.c
+++ linux-2.6/kernel/time/clocksource.c
@@ -517,7 +517,7 @@ void clocksource_forward_now(void)
cycle_t cycle_now, cycle_delta;
s64 nsec;

- cycle_now = clocksource_read(clock);
+ cycle_now = clock->read(clock);
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
clock->cycle_last = cycle_now;

@@ -567,16 +567,19 @@ void change_clocksource(void)

clocksource_forward_now();

- if (clocksource_enable(new))
+ if (new->enable && !new->enable(new))
return;

+ /* save mult_orig after successful enable */
+ new->mult_orig = new->mult;
+
new->raw_time = clock->raw_time;
old = clock;
clock = new;
- clocksource_disable(old);
+ if (old->disable)
+ old->disable(old);

- clock->cycle_last = 0;
- clock->cycle_last = clocksource_read(clock);
+ clock->cycle_last = clock->read(clock);
clock->error = 0;
clock->xtime_nsec = 0;
clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
@@ -655,7 +658,10 @@ void clocksource_unregister(struct clock
void __init clocksource_init(void)
{
clock = clocksource_get_next();
- clocksource_enable(clock);
+ if (clock->enable)
+ clock->enable(clock);
+ /* save mult_orig on enable */
+ clock->mult_orig = clock->mult;
clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
clock->cycle_last = clock->read(clock);
}
Index: linux-2.6/kernel/time/timekeeping.c
===================================================================
--- linux-2.6.orig/kernel/time/timekeeping.c
+++ linux-2.6/kernel/time/timekeeping.c
@@ -78,7 +78,7 @@ void getnstimeofday(struct timespec *ts)
*ts = xtime;

/* read clocksource: */
- cycle_now = clocksource_read(clock);
+ cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
@@ -110,7 +110,7 @@ ktime_t ktime_get(void)
nsecs = xtime.tv_nsec + wall_to_monotonic.tv_nsec;

/* read clocksource: */
- cycle_now = clocksource_read(clock);
+ cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
@@ -150,7 +150,7 @@ void ktime_get_ts(struct timespec *ts)
tomono = wall_to_monotonic;

/* read clocksource: */
- cycle_now = clocksource_read(clock);
+ cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
@@ -296,7 +296,7 @@ void getrawmonotonic(struct timespec *ts
seq = read_seqbegin(&xtime_lock);

/* read clocksource: */
- cycle_now = clocksource_read(clock);
+ cycle_now = clock->read(clock);

/* calculate the delta since the last update_wall_time: */
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
@@ -396,8 +396,7 @@ static int timekeeping_resume(struct sys
}
update_xtime_cache(0);
/* re-base the last cycle value */
- clock->cycle_last = 0;
- clock->cycle_last = clocksource_read(clock);
+ clock->cycle_last = clock->read(clock);
clock->error = 0;
timekeeping_suspended = 0;
write_sequnlock_irqrestore(&xtime_lock, flags);
@@ -464,7 +463,7 @@ void update_wall_time(void)
return;

#ifdef CONFIG_GENERIC_TIME
- offset = (clocksource_read(clock) - clock->cycle_last) & clock->mask;
+ offset = (clock->read(clock) - clock->cycle_last) & clock->mask;
#else
offset = clock->cycle_interval;
#endif

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.


2009-07-21 19:48:23

by Daniel Walker

[permalink] [raw]
Subject: Re: [RFC][patch 3/5] remove clocksource inline functions

On Tue, 2009-07-21 at 21:17 +0200, Martin Schwidefsky wrote:
> plain text document attachment (clocksource-inline.diff)
> From: Martin Schwidefsky <[email protected]>
>
> Remove clocksource_read, clocksource_enable and clocksource_disable
> inline functions. No functional change.
>
> Cc: Ingo Molnar <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: john stultz <[email protected]>
> Signed-off-by: Martin Schwidefsky <[email protected]>
> ---
> kernel/time/clocksource.c | 18 ++++++++++++------
> kernel/time/timekeeping.c | 13 ++++++-------
> 2 files changed, 18 insertions(+), 13 deletions(-)
>
> Index: linux-2.6/kernel/time/clocksource.c
> ===================================================================
> --- linux-2.6.orig/kernel/time/clocksource.c
> +++ linux-2.6/kernel/time/clocksource.c
> @@ -517,7 +517,7 @@ void clocksource_forward_now(void)
> cycle_t cycle_now, cycle_delta;
> s64 nsec;
>
> - cycle_now = clocksource_read(clock);
> + cycle_now = clock->read(clock);

What the benefit of this? You get the same result either way. I think
it's actually less error prone (less confusing) using the inlines ..

Daniel

2009-07-21 22:04:08

by john stultz

[permalink] [raw]
Subject: Re: [RFC][patch 3/5] remove clocksource inline functions

On Tue, 2009-07-21 at 21:17 +0200, Martin Schwidefsky wrote:
> plain text document attachment (clocksource-inline.diff)
> From: Martin Schwidefsky <[email protected]>
>
> Remove clocksource_read, clocksource_enable and clocksource_disable
> inline functions. No functional change.
>
> Cc: Ingo Molnar <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: john stultz <[email protected]>
> Signed-off-by: Martin Schwidefsky <[email protected]>
> ---
> kernel/time/clocksource.c | 18 ++++++++++++------
> kernel/time/timekeeping.c | 13 ++++++-------
> 2 files changed, 18 insertions(+), 13 deletions(-)


There's a patch Magnus has that (should be) queued for 2.6.31 that makes
unbreaks the mult_orig manipulations enable/disable does. I suspect this
will cause this inline function removing to not be that much of a
benefit.

thanks
-john



> Index: linux-2.6/kernel/time/clocksource.c
> ===================================================================
> --- linux-2.6.orig/kernel/time/clocksource.c
> +++ linux-2.6/kernel/time/clocksource.c
> @@ -517,7 +517,7 @@ void clocksource_forward_now(void)
> cycle_t cycle_now, cycle_delta;
> s64 nsec;
>
> - cycle_now = clocksource_read(clock);
> + cycle_now = clock->read(clock);
> cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
> clock->cycle_last = cycle_now;
>
> @@ -567,16 +567,19 @@ void change_clocksource(void)
>
> clocksource_forward_now();
>
> - if (clocksource_enable(new))
> + if (new->enable && !new->enable(new))
> return;
>
> + /* save mult_orig after successful enable */
> + new->mult_orig = new->mult;
> +
> new->raw_time = clock->raw_time;
> old = clock;
> clock = new;
> - clocksource_disable(old);
> + if (old->disable)
> + old->disable(old);

mult_orig needs to be saved to mult at this point.

> - clock->cycle_last = 0;
> - clock->cycle_last = clocksource_read(clock);
> + clock->cycle_last = clock->read(clock);
> clock->error = 0;
> clock->xtime_nsec = 0;
> clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
> @@ -655,7 +658,10 @@ void clocksource_unregister(struct clock
> void __init clocksource_init(void)
> {
> clock = clocksource_get_next();
> - clocksource_enable(clock);
> + if (clock->enable)
> + clock->enable(clock);
> + /* save mult_orig on enable */
> + clock->mult_orig = clock->mult;
> clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
> clock->cycle_last = clock->read(clock);
> }
> Index: linux-2.6/kernel/time/timekeeping.c
> ===================================================================
> --- linux-2.6.orig/kernel/time/timekeeping.c
> +++ linux-2.6/kernel/time/timekeeping.c
> @@ -78,7 +78,7 @@ void getnstimeofday(struct timespec *ts)
> *ts = xtime;
>
> /* read clocksource: */
> - cycle_now = clocksource_read(clock);
> + cycle_now = clock->read(clock);
>
> /* calculate the delta since the last update_wall_time: */
> cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
> @@ -110,7 +110,7 @@ ktime_t ktime_get(void)
> nsecs = xtime.tv_nsec + wall_to_monotonic.tv_nsec;
>
> /* read clocksource: */
> - cycle_now = clocksource_read(clock);
> + cycle_now = clock->read(clock);
>
> /* calculate the delta since the last update_wall_time: */
> cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
> @@ -150,7 +150,7 @@ void ktime_get_ts(struct timespec *ts)
> tomono = wall_to_monotonic;
>
> /* read clocksource: */
> - cycle_now = clocksource_read(clock);
> + cycle_now = clock->read(clock);
>
> /* calculate the delta since the last update_wall_time: */
> cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
> @@ -296,7 +296,7 @@ void getrawmonotonic(struct timespec *ts
> seq = read_seqbegin(&xtime_lock);
>
> /* read clocksource: */
> - cycle_now = clocksource_read(clock);
> + cycle_now = clock->read(clock);
>
> /* calculate the delta since the last update_wall_time: */
> cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
> @@ -396,8 +396,7 @@ static int timekeeping_resume(struct sys
> }
> update_xtime_cache(0);
> /* re-base the last cycle value */
> - clock->cycle_last = 0;
> - clock->cycle_last = clocksource_read(clock);
> + clock->cycle_last = clock->read(clock);
> clock->error = 0;
> timekeeping_suspended = 0;
> write_sequnlock_irqrestore(&xtime_lock, flags);
> @@ -464,7 +463,7 @@ void update_wall_time(void)
> return;
>
> #ifdef CONFIG_GENERIC_TIME
> - offset = (clocksource_read(clock) - clock->cycle_last) & clock->mask;
> + offset = (clock->read(clock) - clock->cycle_last) & clock->mask;
> #else
> offset = clock->cycle_interval;
> #endif
>
> --
> blue skies,
> Martin.
>
> "Reality continues to ruin my life." - Calvin.
>

2009-07-22 07:33:17

by Martin Schwidefsky

[permalink] [raw]
Subject: Re: [RFC][patch 3/5] remove clocksource inline functions

On Tue, 21 Jul 2009 15:03:55 -0700
john stultz <[email protected]> wrote:

> On Tue, 2009-07-21 at 21:17 +0200, Martin Schwidefsky wrote:
> > plain text document attachment (clocksource-inline.diff)
> > From: Martin Schwidefsky <[email protected]>
> >
> > Remove clocksource_read, clocksource_enable and clocksource_disable
> > inline functions. No functional change.
> >
> > Cc: Ingo Molnar <[email protected]>
> > Cc: Thomas Gleixner <[email protected]>
> > Cc: john stultz <[email protected]>
> > Signed-off-by: Martin Schwidefsky <[email protected]>
> > ---
> > kernel/time/clocksource.c | 18 ++++++++++++------
> > kernel/time/timekeeping.c | 13 ++++++-------
> > 2 files changed, 18 insertions(+), 13 deletions(-)
>
>
> There's a patch Magnus has that (should be) queued for 2.6.31 that makes
> unbreaks the mult_orig manipulations enable/disable does. I suspect this
> will cause this inline function removing to not be that much of a
> benefit.

After moving the enable/disable code over to clocksource.c there is no
reason for the inline function anymore, no?

> > Index: linux-2.6/kernel/time/clocksource.c
> > ===================================================================
> > --- linux-2.6.orig/kernel/time/clocksource.c
> > +++ linux-2.6/kernel/time/clocksource.c
> > @@ -517,7 +517,7 @@ void clocksource_forward_now(void)
> > cycle_t cycle_now, cycle_delta;
> > s64 nsec;
> >
> > - cycle_now = clocksource_read(clock);
> > + cycle_now = clock->read(clock);
> > cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
> > clock->cycle_last = cycle_now;
> >
> > @@ -567,16 +567,19 @@ void change_clocksource(void)
> >
> > clocksource_forward_now();
> >
> > - if (clocksource_enable(new))
> > + if (new->enable && !new->enable(new))
> > return;
> >
> > + /* save mult_orig after successful enable */
> > + new->mult_orig = new->mult;
> > +
> > new->raw_time = clock->raw_time;
> > old = clock;
> > clock = new;
> > - clocksource_disable(old);
> > + if (old->disable)
> > + old->disable(old);
>
> mult_orig needs to be saved to mult at this point.

Yes, it would make sense to do that. The old code doesn't so I did not
want to add it in a cleanup patch. That should be a patch on its own.

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.