2011-06-01 07:33:12

by John Stultz

[permalink] [raw]
Subject: [PATCH 0/6] clocksource_register_hz/khz cleanups

Here's the next batch of clocksource_register_hz/khz cleanups.

It would be really great if maintainers could pick these up,
otherwise I'll likely push these through Thomas for 3.1.

thanks
-john

CC: Jeff Dike <[email protected]>
CC: Nikolaus Voss <[email protected]>
CC: Kyle McMartin <[email protected]>
CC: Chris Zankel <[email protected]>
CC: Mikael Starvik <[email protected]>
CC: Jesper Nilsson <[email protected]>
CC: Chris Metcalf <[email protected]>
CC: Thomas Gleixner <[email protected]>

John Stultz (6):
clocksource: Convert tcb_clksrc to use clocksource_register_hz/khz
clocksource: parisc: convert to clocksource_register_hz/khz
clocksource: um: convert to clocksource_register_hz/khz
clocksource: xtensa: convert to clocksource_register_hz/khz
clocksource: cris: convert to clocksource_register_khz
clocksource: tile: convert to use clocksource_register_hz

arch/cris/arch-v32/kernel/time.c | 4 +---
arch/parisc/kernel/time.c | 6 +-----
arch/tile/kernel/time.c | 5 +----
arch/um/kernel/time.c | 6 ++----
arch/xtensa/kernel/time.c | 13 +------------
drivers/clocksource/tcb_clksrc.c | 4 +---
6 files changed, 7 insertions(+), 31 deletions(-)

--
1.7.3.2.146.gca209


2011-06-01 07:32:58

by John Stultz

[permalink] [raw]
Subject: [PATCH 1/6] clocksource: Convert tcb_clksrc to use clocksource_register_hz/khz

Convert tcb_clksrc to use clocksource_register_hz.

Untested. Help from maintainers would be appreciated.

CC: Nikolaus Voss <[email protected]>
CC: Thomas Gleixner <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
drivers/clocksource/tcb_clksrc.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
index 79c47e8..55d0f95 100644
--- a/drivers/clocksource/tcb_clksrc.c
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -59,7 +59,6 @@ static struct clocksource clksrc = {
.rating = 200,
.read = tc_get_cycles,
.mask = CLOCKSOURCE_MASK(32),
- .shift = 18,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

@@ -256,7 +255,6 @@ static int __init tcb_clksrc_init(void)
best_divisor_idx = i;
}

- clksrc.mult = clocksource_hz2mult(divided_rate, clksrc.shift);

printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
divided_rate / 1000000,
@@ -292,7 +290,7 @@ static int __init tcb_clksrc_init(void)
__raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);

/* and away we go! */
- clocksource_register(&clksrc);
+ clocksource_register_hz(&clksrc, divided_rate);

/* channel 2: periodic and oneshot timer support */
setup_clkevents(tc, clk32k_divisor_idx);
--
1.7.3.2.146.gca209

2011-06-01 07:33:51

by John Stultz

[permalink] [raw]
Subject: [PATCH 2/6] clocksource: parisc: convert to clocksource_register_hz/khz

From: John Stultz <[email protected]>

This converts the parisc clocksources to use clocksource_register_hz/khz

This is untested, so any assistance in testing would be appreciated!

CC: Kyle McMartin <[email protected]>
CC: Thomas Gleixner <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
arch/parisc/kernel/time.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 45b7389..7c07743 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -198,8 +198,6 @@ static struct clocksource clocksource_cr16 = {
.rating = 300,
.read = read_cr16,
.mask = CLOCKSOURCE_MASK(BITS_PER_LONG),
- .mult = 0, /* to be set */
- .shift = 22,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

@@ -270,7 +268,5 @@ void __init time_init(void)

/* register at clocksource framework */
current_cr16_khz = PAGE0->mem_10msec/10; /* kHz */
- clocksource_cr16.mult = clocksource_khz2mult(current_cr16_khz,
- clocksource_cr16.shift);
- clocksource_register(&clocksource_cr16);
+ clocksource_register_khz(&clocksource_cr16, current_cr16_khz);
}
--
1.7.3.2.146.gca209

2011-06-01 07:33:03

by John Stultz

[permalink] [raw]
Subject: [PATCH 3/6] clocksource: um: convert to clocksource_register_hz/khz

From: John Stultz <[email protected]>

This converts the um clocksource to use clocksource_register_hz/khz

This is untested, so any assistance in testing would be appreciated!

CC: Jeff Dike <[email protected]>
CC: Thomas Gleixner <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
arch/um/kernel/time.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index a08d9fa..82a6e22 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -75,8 +75,6 @@ static struct clocksource itimer_clocksource = {
.rating = 300,
.read = itimer_read,
.mask = CLOCKSOURCE_MASK(64),
- .mult = 1000,
- .shift = 0,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

@@ -94,9 +92,9 @@ static void __init setup_itimer(void)
clockevent_delta2ns(60 * HZ, &itimer_clockevent);
itimer_clockevent.min_delta_ns =
clockevent_delta2ns(1, &itimer_clockevent);
- err = clocksource_register(&itimer_clocksource);
+ err = clocksource_register_hz(&itimer_clocksource, USEC_PER_SEC);
if (err) {
- printk(KERN_ERR "clocksource_register returned %d\n", err);
+ printk(KERN_ERR "clocksource_register_hz returned %d\n", err);
return;
}
clockevents_register_device(&itimer_clockevent);
--
1.7.3.2.146.gca209

2011-06-01 07:33:48

by John Stultz

[permalink] [raw]
Subject: [PATCH 4/6] clocksource: xtensa: convert to clocksource_register_hz/khz

From: John Stultz <[email protected]>

This converts the xtensa clocksource to use clocksource_register_hz/khz

This is untested, so any assistance in testing would be appreciated!

CC: Chris Zankel <[email protected]>
CC: Thomas Gleixner <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
arch/xtensa/kernel/time.c | 13 +------------
1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index f3e5eb4..ac62f9c 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -41,14 +41,6 @@ static struct clocksource ccount_clocksource = {
.rating = 200,
.read = ccount_read,
.mask = CLOCKSOURCE_MASK(32),
- /*
- * With a shift of 22 the lower limit of the cpu clock is
- * 1MHz, where NSEC_PER_CCOUNT is 1000 or a bit less than
- * 2^10: Since we have 32 bits and the multiplicator can
- * already take up as much as 10 bits, this leaves us with
- * remaining upper 22 bits.
- */
- .shift = 22,
};

static irqreturn_t timer_interrupt(int irq, void *dev_id);
@@ -66,10 +58,7 @@ void __init time_init(void)
printk("%d.%02d MHz\n", (int)ccount_per_jiffy/(1000000/HZ),
(int)(ccount_per_jiffy/(10000/HZ))%100);
#endif
- ccount_clocksource.mult =
- clocksource_hz2mult(CCOUNT_PER_JIFFY * HZ,
- ccount_clocksource.shift);
- clocksource_register(&ccount_clocksource);
+ clocksource_register_hz(&ccount_clocksource, CCOUNT_PER_JIFFY * HZ);

/* Initialize the linux timer interrupt. */

--
1.7.3.2.146.gca209

2011-06-01 07:33:33

by John Stultz

[permalink] [raw]
Subject: [PATCH 5/6] clocksource: cris: convert to clocksource_register_khz

From: John Stultz <[email protected]>

This converts the cris architecture to use clocksource_register_khz

This is untested, so any help from maintainers would be appreciated.

CC: Mikael Starvik <[email protected]>
CC: Jesper Nilsson <[email protected]>
CC: Thomas Gleixner <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
arch/cris/arch-v32/kernel/time.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/cris/arch-v32/kernel/time.c b/arch/cris/arch-v32/kernel/time.c
index bb978ed..6773fc8 100644
--- a/arch/cris/arch-v32/kernel/time.c
+++ b/arch/cris/arch-v32/kernel/time.c
@@ -47,14 +47,12 @@ static struct clocksource cont_rotime = {
.rating = 300,
.read = read_cont_rotime,
.mask = CLOCKSOURCE_MASK(32),
- .shift = 10,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

static int __init etrax_init_cont_rotime(void)
{
- cont_rotime.mult = clocksource_khz2mult(100000, cont_rotime.shift);
- clocksource_register(&cont_rotime);
+ clocksource_register_khz(&cont_rotime, 100000);
return 0;
}
arch_initcall(etrax_init_cont_rotime);
--
1.7.3.2.146.gca209

2011-06-01 07:33:47

by John Stultz

[permalink] [raw]
Subject: [PATCH 6/6] clocksource: tile: convert to use clocksource_register_hz

From: John Stultz <[email protected]>

Convert tile to use clocksource_register_hz.

Untested. Help from maintainers would be appreciated.

CC: Chris Metcalf <[email protected]>
CC: Thomas Gleixner <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
arch/tile/kernel/time.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
index c4be58c..f6f50f2a 100644
--- a/arch/tile/kernel/time.c
+++ b/arch/tile/kernel/time.c
@@ -78,7 +78,6 @@ static struct clocksource cycle_counter_cs = {
.rating = 300,
.read = clocksource_get_cycles,
.mask = CLOCKSOURCE_MASK(64),
- .shift = 22, /* typical value, e.g. x86 tsc uses this */
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

@@ -91,8 +90,6 @@ void __init setup_clock(void)
cycles_per_sec = hv_sysconf(HV_SYSCONF_CPU_SPEED);
sched_clock_mult =
clocksource_hz2mult(cycles_per_sec, SCHED_CLOCK_SHIFT);
- cycle_counter_cs.mult =
- clocksource_hz2mult(cycles_per_sec, cycle_counter_cs.shift);
}

void __init calibrate_delay(void)
@@ -107,7 +104,7 @@ void __init calibrate_delay(void)
void __init time_init(void)
{
/* Initialize and register the clock source. */
- clocksource_register(&cycle_counter_cs);
+ clocksource_register_hz(&cycle_counter_cs, cycles_per_sec);

/* Start up the tile-timer interrupt source on the boot cpu. */
setup_tile_timer();
--
1.7.3.2.146.gca209

2011-06-01 16:18:19

by Chris Metcalf

[permalink] [raw]
Subject: Re: [PATCH 6/6] clocksource: tile: convert to use clocksource_register_hz

On 6/1/2011 3:32 AM, John Stultz wrote:
> From: John Stultz <[email protected]>
>
> Convert tile to use clocksource_register_hz.
>
> Untested. Help from maintainers would be appreciated.
>
> CC: Chris Metcalf <[email protected]>

This patch boots up fine on tile. It provides a shift count of 31, with a
mult value in the billions. This does mean that clocksource_cyc2ns() will
only be able to give correct timer conversions for up to about 9 seconds.
Is this believed to be adequate for all the uses the cycle counter is put
to? I can run our normal regression tests, but I'd like to get a
high-level sanity check from the clocksource folks.

The original shift of 22 was put in by commit
749dc6f252b57d5cb9c1f4c1c4aafe4c92a28207 back in August.

> CC: Thomas Gleixner <[email protected]>
> Signed-off-by: John Stultz <[email protected]>
> ---
> arch/tile/kernel/time.c | 5 +----
> 1 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
> index c4be58c..f6f50f2a 100644
> --- a/arch/tile/kernel/time.c
> +++ b/arch/tile/kernel/time.c
> @@ -78,7 +78,6 @@ static struct clocksource cycle_counter_cs = {
> .rating = 300,
> .read = clocksource_get_cycles,
> .mask = CLOCKSOURCE_MASK(64),
> - .shift = 22, /* typical value, e.g. x86 tsc uses this */
> .flags = CLOCK_SOURCE_IS_CONTINUOUS,
> };
>
> @@ -91,8 +90,6 @@ void __init setup_clock(void)
> cycles_per_sec = hv_sysconf(HV_SYSCONF_CPU_SPEED);
> sched_clock_mult =
> clocksource_hz2mult(cycles_per_sec, SCHED_CLOCK_SHIFT);
> - cycle_counter_cs.mult =
> - clocksource_hz2mult(cycles_per_sec, cycle_counter_cs.shift);
> }
>
> void __init calibrate_delay(void)
> @@ -107,7 +104,7 @@ void __init calibrate_delay(void)
> void __init time_init(void)
> {
> /* Initialize and register the clock source. */
> - clocksource_register(&cycle_counter_cs);
> + clocksource_register_hz(&cycle_counter_cs, cycles_per_sec);
>
> /* Start up the tile-timer interrupt source on the boot cpu. */
> setup_tile_timer();

--
Chris Metcalf, Tilera Corp.
http://www.tilera.com

2011-06-01 17:55:50

by john stultz

[permalink] [raw]
Subject: Re: [PATCH 6/6] clocksource: tile: convert to use clocksource_register_hz

On Wed, 2011-06-01 at 12:18 -0400, Chris Metcalf wrote:
> On 6/1/2011 3:32 AM, John Stultz wrote:
> > From: John Stultz <[email protected]>
> >
> > Convert tile to use clocksource_register_hz.
> >
> > Untested. Help from maintainers would be appreciated.
> >
> > CC: Chris Metcalf <[email protected]>
>
> This patch boots up fine on tile. It provides a shift count of 31, with a
> mult value in the billions. This does mean that clocksource_cyc2ns() will
> only be able to give correct timer conversions for up to about 9 seconds.
> Is this believed to be adequate for all the uses the cycle counter is put
> to? I can run our normal regression tests, but I'd like to get a
> high-level sanity check from the clocksource folks.

I believe 9 seconds should be plenty for timekeeping, so I suspect it
should be fine. Although I've not closely checked in this case if the
tile clocksource is used for other purposes, so do let me know if you
see any issues in your testing.

Additionally Thomas has a patch (which I thought already landed in
3.0-rc, but maybe not) which should pick a shift value that gets us
close to 600 second intervals (hardware allowing), allowing for much
longer NOHZ periods.

The important part is that we're centralizing this logic so it can be
properly adjusted without having to tune 30-some clocksources
individually.

Thanks for the testing and review!
-john


2011-06-03 21:27:20

by Chris Metcalf

[permalink] [raw]
Subject: Re: [PATCH 6/6] clocksource: tile: convert to use clocksource_register_hz

On 6/1/2011 3:32 AM, John Stultz wrote:
> From: John Stultz <[email protected]>
>
> Convert tile to use clocksource_register_hz.
>
> Untested. Help from maintainers would be appreciated.
>
> CC: Chris Metcalf <[email protected]>
> CC: Thomas Gleixner <[email protected]>
> Signed-off-by: John Stultz <[email protected]>
> ---
> arch/tile/kernel/time.c | 5 +----
> 1 files changed, 1 insertions(+), 4 deletions(-)

Applied, thanks!

--
Chris Metcalf, Tilera Corp.
http://www.tilera.com