Skip to contentSkip to conversation

arm: Replace arm sched_clock by clocksource based sched_clock

PATCH New Thomas Gleixner 11 participants 51 messages Apr 23, 2011 – Jun 13, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

The core timekeeping code makes already sure that we don't wrap the timekeeper and we can base a sched_clock easily on that.

It uses the read function of the clocksource and keeps track of time independent of the timekeeping code as the ARM sched_clock implementation does. It also uses it's own sequence counter so sched_clock is not dependent on xtime_lock. The update sequence is just adding offsets once in a while and runs from do_timer() which also makes sure that only one core tries to update it.

Only lightly tested on orion. Please give it a go.

Another 650 lines gone :)

Thanks,

tglx

---
 arch/arm/include/asm/sched_clock.h                     |  120 ----------------
 arch/arm/kernel/sched_clock.c                          |   74 ----------
 arch/arm/plat-versatile/include/plat/sched_clock.h     |    6 
 arch/arm/plat-versatile/sched-clock.c                  |   58 -------
 linux-2.6-tip/arch/arm/Kconfig                         |   15 --
 linux-2.6-tip/arch/arm/common/timer-sp.c               |    4 
 linux-2.6-tip/arch/arm/kernel/Makefile                 |    1 
 linux-2.6-tip/arch/arm/kernel/time.c                   |    4 
 linux-2.6-tip/arch/arm/mach-davinci/time.c             |   30 ----
 linux-2.6-tip/arch/arm/mach-integrator/integrator_cp.c |    5 
 linux-2.6-tip/arch/arm/mach-ixp4xx/common.c            |   22 --
 linux-2.6-tip/arch/arm/mach-mmp/time.c                 |   19 --
 linux-2.6-tip/arch/arm/mach-omap1/time.c               |   62 --------
 linux-2.6-tip/arch/arm/mach-omap2/timer-gp.c           |   17 --
 linux-2.6-tip/arch/arm/mach-pxa/time.c                 |   31 ----
 linux-2.6-tip/arch/arm/mach-realview/core.c            |    3 
 linux-2.6-tip/arch/arm/mach-sa1100/time.c              |   35 ----
 linux-2.6-tip/arch/arm/mach-tegra/timer.c              |   29 ---
 linux-2.6-tip/arch/arm/mach-u300/timer.c               |   29 ---
 linux-2.6-tip/arch/arm/mach-versatile/core.c           |    3 
 linux-2.6-tip/arch/arm/mach-vexpress/v2m.c             |    3 
 linux-2.6-tip/arch/arm/plat-iop/time.c                 |   22 --
 linux-2.6-tip/arch/arm/plat-mxc/time.c                 |   28 ---
 linux-2.6-tip/arch/arm/plat-nomadik/Kconfig            |    1 
 linux-2.6-tip/arch/arm/plat-nomadik/timer.c            |   45 ------
 linux-2.6-tip/arch/arm/plat-omap/counter_32k.c         |   71 ---------
 linux-2.6-tip/arch/arm/plat-omap/dmtimer.c             |    4 
 linux-2.6-tip/arch/arm/plat-omap/include/plat/common.h |    1 
 linux-2.6-tip/arch/arm/plat-orion/time.c               |   37 -----
 linux-2.6-tip/arch/arm/plat-s5p/s5p-time.c             |   67 ---------
 linux-2.6-tip/arch/arm/plat-versatile/Kconfig          |    4 
 linux-2.6-tip/arch/arm/plat-versatile/Makefile         |    1 
 linux-2.6-tip/include/linux/clocksource.h              |    1 
 linux-2.6-tip/include/linux/sched.h                    |    1 
 linux-2.6-tip/kernel/sched_clock.c                     |   12 -
 linux-2.6-tip/kernel/time/Kconfig                      |    4 
 linux-2.6-tip/kernel/time/timekeeping.c                |  125 +++++++++++++++++
 37 files changed, 173 insertions(+), 821 deletions(-)
#2 lore raw

PATCH 1/16 time: Provide clocksource based sched_clock()

Quoted 12 lines · Thomas Gleixner

Index: linux-2.6-tip/kernel/time/Kconfig
===================================================================

kernel/time/Kconfig +4 -0
@@ -27,3 +27,7 @@ config GENERIC_CLOCKEVENTS_BUILD
 	default y
 	depends on GENERIC_CLOCKEVENTS || GENERIC_CLOCKEVENTS_MIGR
 
+# Selectable by architectures which want to reuse the clocksource as
+# sched_clock
+config HAVE_CLKSRC_SCHED_CLOCK
+       bool
#3 lore raw

PATCH 1/16 time: Provide clocksource based sched_clock()

Quoted 9 lines · Stephen Boyd
Quoted 8 lines · Thomas Gleixner

Index: linux-2.6-tip/kernel/time/Kconfig
===================================================================

kernel/time/Kconfig +0 -0
@@ -27,3 +27,7 @@ config GENERIC_CLOCKEVENTS_BUILD
 	default y
 	depends on GENERIC_CLOCKEVENTS || GENERIC_CLOCKEVENTS_MIGR
 
Quoted 6 lines
Quoted 6 lines
kernel/time/Kconfig +4 -0
+# Selectable by architectures which want to reuse the clocksource as
+# sched_clock
+config HAVE_CLKSRC_SCHED_CLOCK
+       bool

From what I can tell this isn't used so I'm guessing we can drop it?

Oops. Yes. Leftover from first version. I decided not to clutter the tree with another "select HAVE_...."

Thanks,

tglx

#4 lore raw

PATCH 1/16 time: Provide clocksource based sched_clock()

In reply to Thomas Gleixner
Quoted 8 lines · Thomas Gleixner

Many embedded platforms use the clocksource which is used for timekeeping as their sched_clock as well. Though they need to take care about the wraparounds as sched_clock() wants to be monotonic increasing nsescs. The timekeeping code and the NOHZ core take care of the timekeeping clocksource wraparound so we can simply use the timekeeping clocksource if possible.

Quoted 8 lines

clocksources which can be used by the clksrc sched_clock must have the flag CLOCK_SOURCE_SCHED_CLOCK set. This works with the default (weak) sched_clock implementation but the clksrc based function is also provided for architectures where multi platform kernels might override it. If there is no CLOCK_SOURCE_SCHED_CLOCK available, then the function returns the jiffies based sched clock.

Tested on Samsung stuff...

Quoted 8 lines
---
 include/linux/clocksource.h |    1
 include/linux/sched.h       |    1
 kernel/sched_clock.c        |   12 ----
 kernel/time/Kconfig         |    4 +
 kernel/time/timekeeping.c   |  125
++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 131 insertions(+), 12 deletions(-)

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#5 lore raw

PATCH 1/16 time: Provide clocksource based sched_clock()

In reply to Thomas Gleixner
Quoted 7 lines · Thomas Gleixner

Many embedded platforms use the clocksource which is used for timekeeping as their sched_clock as well. Though they need to take care about the wraparounds as sched_clock() wants to be monotonic increasing nsescs. The timekeeping code and the NOHZ core take care of the timekeeping clocksource wraparound so we can simply use the timekeeping clocksource if possible.

Quoted 8 lines

clocksources which can be used by the clksrc sched_clock must have the flag CLOCK_SOURCE_SCHED_CLOCK set. This works with the default (weak) sched_clock implementation but the clksrc based function is also provided for architectures where multi platform kernels might override it. If there is no CLOCK_SOURCE_SCHED_CLOCK available, then the function returns the jiffies based sched clock.

MSM doesn't have a sched_clock(), so I applied this patch on top. Care to pick it up?

8<-----

Subject: [PATCH] msm: timer: Support clocksource sched_clock()

With the clocksource sched_clock() implementation we can support sched_clock on MSM with little effort.

---
 arch/arm/mach-msm/timer.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-msm/timer.c +3 -2
index 38b95e9..c875f9a 100644
@@ -96,7 +96,7 @@ static irqreturn_t msm_timer_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static cycle_t msm_read_timer_count(struct clocksource *cs)
+static cycle_t notrace msm_read_timer_count(struct clocksource *cs)
 {
        struct msm_clock *clk = container_of(cs, struct msm_clock, clocksource);
 
@@ -186,7 +186,8 @@ static struct msm_clock msm_clocks[] = {
                        .rating         = 300,
                        .read           = msm_read_timer_count,
                        .mask           = CLOCKSOURCE_MASK((32 - MSM_DGT_SHIFT)),
-                       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
+                       .flags          = CLOCK_SOURCE_IS_CONTINUOUS |
+                                         CLOCK_SOURCE_SCHED_CLOCK,
                },
                .irq = {
                        .name    = "dg_timer",
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#8 lore raw

PATCH 3/16 arm: s5p: Use clocksource based sched_clock

Review

Quoted 7 lines · Thomas Gleixner

struct clocksource time_clocksource = {

(quoted diff) +1 -1
 	.name		= "s5p_clocksource_timer",
 	.rating		= 250,
 	.read		= s5p_timer_read,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS | CLOCKS_SOURCE_SCHED_CLOCK,

Drop the extra 'S'. CLOCK_SOURCE_SCHED_CLOCK.

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#9 lore raw

PATCH 3/16 arm: s5p: Use clocksource based sched_clock

Quoted 10 lines · Stephen Boyd

Review

Quoted 7 lines · Thomas Gleixner

struct clocksource time_clocksource = {

(quoted diff) +1 -1
 	.name		= "s5p_clocksource_timer",
 	.rating		= 250,
 	.read		= s5p_timer_read,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS | CLOCKS_SOURCE_SCHED_CLOCK,

Drop the extra 'S'. CLOCK_SOURCE_SCHED_CLOCK.

Indeed

#10 lore raw

PATCH 3/16 arm: s5p: Use clocksource based sched_clock

In reply to Thomas Gleixner
Quoted 2 lines · Thomas Gleixner

(snip)

Quoted 8 lines

struct clocksource time_clocksource = {

(quoted diff) +1 -1
 	.name		= "s5p_clocksource_timer",
 	.rating		= 250,
 	.read		= s5p_timer_read,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS |

CLOCKS_SOURCE_SCHED_CLOCK,

As Stephen Boyd said, with fixing CLOCK_SOURCE_SCHED_CLOCK :)

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#12 lore raw

PATCH 4/16 arm: davinci: Use clocksource based sched_clock

Quoted 12 lines · Thomas Gleixner
(quoted diff) +1 -5
-static cycle_t read_cycles(struct clocksource *cs)
+static cycle_t notrace read_cycles(struct clocksource *cs)
 {
 	struct timer_s *t = &timers[TID_CLOCKSOURCE];
 
 	return (cycles_t)timer32_read(t);
 }
 
-/*
- * Kernel assumes that sched_clock can be called early but may not have
- * things ready yet.
- */

Review

Quoted 10 lines
(quoted diff) +1 -7
-static cycle_t read_dummy(struct clocksource *cs)
-{
-	return 0;
-}
-
-
 static struct clocksource clocksource_davinci = {
 	.rating		= 300,
-	.read		= read_dummy,
+	.read		= read_,

This should be read_cycles, I guess.

With that fixed, boot tested on DM365 and DA850 EVMs.

Thanks,
Sekhar

maintainer
#16 lore raw

PATCH 7/16 arm: omap: Use clocksource based sched_clock

Quoted 8 lines · Thomas Gleixner
---
 arch/arm/mach-omap1/time.c               |   62 +--------------------------
 arch/arm/mach-omap2/timer-gp.c           |   17 -------
 arch/arm/plat-omap/counter_32k.c         |   71 ++-----------------------------
 arch/arm/plat-omap/dmtimer.c             |    4 -
 arch/arm/plat-omap/include/plat/common.h |    1 
 5 files changed, 13 insertions(+), 142 deletions(-)

This one needs the following patch to compile. Also, this fails with following, probably because the clocks are not set up at that point.

Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 80000005 [#1] SMP
last sysfs file: 
Modules linked in:
CPU: 0    Not tainted  (2.6.39-rc5-00081-gc3dec8c #166)
PC is at 0x0
LR is at read_persistent_clock+0x24/0xb4
pc : [<00000000>]    lr : [<c007f86c>]    psr: 600001d3

sp : c05a3fa8 ip : c05a2000 fp : 00000000
r10: 00000000 r9 : 411fc092 r8 : 80000000
r7 : c05bc144 r6 : c05a3fc0 r5 : c0624bf4 r4 : c05f9120 r3 : 00000000 r2 : 00000001 r1 : c009bb24 r0 : c05f9120
Flags: nZCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel
Control: 10c53c7f Table: 8000404a DAC: 00000017
Process swapper (pid: 0, stack limit = 0xc05a22f8)

Stack: (0xc05a3fa8 to 0xc05a4000)

3fa0: c0035d3c 00000001 c0623bc0 c001ce10 00000000 00000001
3fc0: 00000000 c0400a48 c0035d3c c0035d3c 00000001 c0008a04 c0008640 00000870 3fe0: 80000100 c0035d3c 10c53c7d c05b78dc c0035d0c 8000803c 00000000 00000000 [<c007f86c>] (read_persistent_clock+0x24/0xb4) from [<c001ce10>] (timekeeping_init+0x10/0x114) [<c001ce10>] (timekeeping_init+0x10/0x114) from [<c0008a04>] (start_kernel+0x188/0x2ec) [<c0008a04>] (start_kernel+0x188/0x2ec) from [<8000803c>] (0x8000803c)

Code: bad PC value
---[ end trace 1b75b31a2719ed1c ]---

The generic code should probably just return 0 until the clocks are initialized. Or do you have some other solution for that in mind?

Tony

arch/arm/plat-omap/counter_32k.c +0 -2
@@ -139,8 +139,6 @@ int __init omap_init_clocksource_32k(void)
 		if (!IS_ERR(sync_32k_ick))
 			clk_enable(sync_32k_ick);
 
-		offset_32k = clocksource_32k.read(&clocksource_32k);
-
 		if (clocksource_register_hz(&clocksource_32k, 32768))
 			printk(err, clocksource_32k.name);
 	}
#17 lore raw

PATCH 7/16 arm: omap: Use clocksource based sched_clock

Quoted 21 lines · Tony Lindgren
Quoted 8 lines · Thomas Gleixner
---
 arch/arm/mach-omap1/time.c               |   62 +--------------------------
 arch/arm/mach-omap2/timer-gp.c           |   17 -------
 arch/arm/plat-omap/counter_32k.c         |   71 ++-----------------------------
 arch/arm/plat-omap/dmtimer.c             |    4 -
 arch/arm/plat-omap/include/plat/common.h |    1 
 5 files changed, 13 insertions(+), 142 deletions(-)

This one needs the following patch to compile. Also, this fails with following, probably because the clocks are not set up at that point.

Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 80000005 [#1] SMP
last sysfs file: 
Modules linked in:
CPU: 0    Not tainted  (2.6.39-rc5-00081-gc3dec8c #166)
Quoted 5 lines

PC is at 0x0
LR is at read_persistent_clock+0x24/0xb4

The generic code should probably just return 0 until the clocks are initialized. Or do you have some other solution for that in mind?

The generic sched_clock implementation returns a jiffies based value as long as there is no clocksource registered. But the above does not fail in sched_clock() it fails in read_persistent_clock() which does

        last_cycles = cycles;
        cycles = clocksource_32k.read(&clocksource_32k);

So the following change causes this:

- .read = omap_32k_read_dummy,

Which leads to the question why you have a read_persistent_clock() at all if it always reads 0 via omap_32k_read_dummy ? Or is this meant just for the resume case? Then the above and the removal of omap_32k_read_dummy() needs to be undone.

Thanks,

tglx

maintainer
#18 lore raw

PATCH 7/16 arm: omap: Use clocksource based sched_clock

Quoted 11 lines · Thomas Gleixner

The generic sched_clock implementation returns a jiffies based value as long as there is no clocksource registered. But the above does not fail in sched_clock() it fails in read_persistent_clock() which does

        last_cycles = cycles;
        cycles = clocksource_32k.read(&clocksource_32k);

So the following change causes this:

- .read = omap_32k_read_dummy,

Ah right.

Quoted 4 lines

Which leads to the question why you have a read_persistent_clock() at all if it always reads 0 via omap_32k_read_dummy ? Or is this meant just for the resume case? Then the above and the removal of omap_32k_read_dummy() needs to be undone.

The omap_32k_read_dummy needs to return 0 until the clocks are enabled and the right read function is selected. The .read gets then set in omap_init_clocksource_32k.

It would be nice to handle that in a generic way though, I would assume the same issue exists for other platforms too.

Updated version of your patch below, it now boots on both omap1 and omap2+.

Regards,

Tony

From: Thomas Gleixner <[email protected]>
Subject: [PATCH] arm: omap: Use clocksource based sched_clock

arch/arm/mach-omap1/time.c +3 -59
@@ -49,7 +49,6 @@
 #include <mach/hardware.h>
 #include <asm/leds.h>
 #include <asm/irq.h>
-#include <asm/sched_clock.h>
 
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
@@ -203,7 +202,7 @@ static struct irqaction omap_mpu_timer2_irq = {
 	.handler	= omap_mpu_timer2_interrupt,
 };
 
-static cycle_t mpu_read(struct clocksource *cs)
+static cycle_t notrace mpu_read(struct clocksource *cs)
 {
 	return ~omap_mpu_timer_read(1);
 }
@@ -213,35 +212,9 @@ static struct clocksource clocksource_mpu = {
 	.rating		= 300,
 	.read		= mpu_read,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SCHED_CLOCK,
 };
 
-static DEFINE_CLOCK_DATA(cd);
-
-static inline unsigned long long notrace _omap_mpu_sched_clock(void)
-{
-	u32 cyc = mpu_read(&clocksource_mpu);
-	return cyc_to_sched_clock(&cd, cyc, (u32)~0);
-}
-
-#ifndef CONFIG_OMAP_32K_TIMER
-unsigned long long notrace sched_clock(void)
-{
-	return _omap_mpu_sched_clock();
-}
-#else
-static unsigned long long notrace omap_mpu_sched_clock(void)
-{
-	return _omap_mpu_sched_clock();
-}
-#endif
-
-static void notrace mpu_update_sched_clock(void)
-{
-	u32 cyc = mpu_read(&clocksource_mpu);
-	update_sched_clock(&cd, cyc, (u32)~0);
-}
-
 static void __init omap_init_clocksource(unsigned long rate)
 {
 	static char err[] __initdata = KERN_ERR
@@ -249,7 +222,6 @@ static void __init omap_init_clocksource(unsigned long rate)
 
 	setup_irq(INT_TIMER2, &omap_mpu_timer2_irq);
 	omap_mpu_timer_start(1, ~0, 1);
-	init_sched_clock(&cd, mpu_update_sched_clock, 32, rate);
 
 	if (clocksource_register_hz(&clocksource_mpu, rate))
 		printk(err, clocksource_mpu.name);
@@ -279,30 +251,6 @@ static inline void omap_mpu_timer_init(void)
 }
 #endif	/* CONFIG_OMAP_MPU_TIMER */
 
-#if defined(CONFIG_OMAP_MPU_TIMER) && defined(CONFIG_OMAP_32K_TIMER)
-static unsigned long long (*preferred_sched_clock)(void);
-
-unsigned long long notrace sched_clock(void)
-{
-	if (!preferred_sched_clock)
-		return 0;
-
-	return preferred_sched_clock();
-}
-
-static inline void preferred_sched_clock_init(bool use_32k_sched_clock)
-{
-	if (use_32k_sched_clock)
-		preferred_sched_clock = omap_32k_sched_clock;
-	else
-		preferred_sched_clock = omap_mpu_sched_clock;
-}
-#else
-static inline void preferred_sched_clock_init(bool use_32k_sched_clcok)
-{
-}
-#endif
-
 static inline int omap_32k_timer_usable(void)
 {
 	int res = false;
@@ -324,12 +272,8 @@ static inline int omap_32k_timer_usable(void)
  */
 static void __init omap_timer_init(void)
 {
-	if (omap_32k_timer_usable()) {
-		preferred_sched_clock_init(1);
-	} else {
+	if (!omap_32k_timer_usable())
 		omap_mpu_timer_init();
-		preferred_sched_clock_init(0);
-	}
 }
 
 struct sys_timer omap_timer = {
arch/arm/mach-omap2/timer-gp.c +2 -15
@@ -39,7 +39,6 @@
 #include <asm/mach/time.h>
 #include <plat/dmtimer.h>
 #include <asm/localtimer.h>
-#include <asm/sched_clock.h>
 #include <plat/common.h>
 #include <plat/omap_hwmod.h>
 
@@ -196,9 +195,8 @@ static void __init omap2_gp_clocksource_init(void)
 /*
  * clocksource
  */
-static DEFINE_CLOCK_DATA(cd);
 static struct omap_dm_timer *gpt_clocksource;
-static cycle_t clocksource_read_cycles(struct clocksource *cs)
+static cycle_t notrace clocksource_read_cycles(struct clocksource *cs)
 {
 	return (cycle_t)omap_dm_timer_read_counter(gpt_clocksource);
 }
@@ -208,18 +206,9 @@ static struct clocksource clocksource_gpt = {
 	.rating		= 300,
 	.read		= clocksource_read_cycles,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SCHED_CLOCK,
 };
 
-static void notrace dmtimer_update_sched_clock(void)
-{
-	u32 cyc;
-
-	cyc = omap_dm_timer_read_counter(gpt_clocksource);
-
-	update_sched_clock(&cd, cyc, (u32)~0);
-}
-
 /* Setup free-running counter for clocksource */
 static void __init omap2_gp_clocksource_init(void)
 {
@@ -240,8 +229,6 @@ static void __init omap2_gp_clocksource_init(void)
 
 	omap_dm_timer_set_load_start(gpt, 1, 0);
 
-	init_sched_clock(&cd, dmtimer_update_sched_clock, 32, tick_rate);
-
 	if (clocksource_register_hz(&clocksource_gpt, tick_rate))
 		printk(err2, clocksource_gpt.name);
 }
arch/arm/plat-omap/counter_32k.c +6 -57

118 lines not on this page · raw message

arch/arm/plat-omap/dmtimer.c +2 -2
@@ -289,7 +289,7 @@ static spinlock_t dm_timer_lock;
  * is encoded in reg. Note that in posted mode write pending bit must be
  * checked. Otherwise a read of a non completed write will produce an error.
  */
-static inline u32 omap_dm_timer_read_reg(struct omap_dm_timer *timer, u32 reg)
+static inline u32 notrace omap_dm_timer_read_reg(struct omap_dm_timer *timer, u32 reg)
 {
 	if (timer->posted)
 		while (readl(timer->io_base + (OMAP_TIMER_WRITE_PEND_REG & 0xff))
@@ -700,7 +700,7 @@ void omap_dm_timer_write_status(struct omap_dm_timer *timer, unsigned int value)
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_write_status);
 
-unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer)
+unsigned int notrace omap_dm_timer_read_counter(struct omap_dm_timer *timer)
 {
 	unsigned int l;
 
arch/arm/plat-omap/include/plat/common.h +0 -1
@@ -37,7 +37,6 @@ extern void omap_map_common_io(void);
 extern struct sys_timer omap_timer;
 extern bool omap_32k_timer_init(void);
 extern int __init omap_init_clocksource_32k(void);
-extern unsigned long long notrace omap_32k_sched_clock(void);
 
 extern void omap_reserve(void);
 
#19 lore raw

PATCH 7/16 arm: omap: Use clocksource based sched_clock

Quoted 20 lines · Tony Lindgren
Quoted 11 lines · Thomas Gleixner

The generic sched_clock implementation returns a jiffies based value as long as there is no clocksource registered. But the above does not fail in sched_clock() it fails in read_persistent_clock() which does

        last_cycles = cycles;
        cycles = clocksource_32k.read(&clocksource_32k);

So the following change causes this:

- .read = omap_32k_read_dummy,

Ah right.

Quoted 4 lines

Which leads to the question why you have a read_persistent_clock() at all if it always reads 0 via omap_32k_read_dummy ? Or is this meant just for the resume case? Then the above and the removal of omap_32k_read_dummy() needs to be undone.

Quoted 6 lines

The omap_32k_read_dummy needs to return 0 until the clocks are enabled and the right read function is selected. The .read gets then set in omap_init_clocksource_32k.

It would be nice to handle that in a generic way though, I would assume the same issue exists for other platforms too.

static inline cycles_t clocksource_read_safe(struct clocksource *c)

{
	return c->read ? c->read(c) : 0;
}

For the core timekeeping code that's a non issue as nothing should register a clocksource with an invalid read function pointer :)

Thanks,

tglx

maintainer
#20 lore raw

PATCH 7/16 arm: omap: Use clocksource based sched_clock

Quoted 25 lines · Thomas Gleixner
Quoted 24 lines · Tony Lindgren
Quoted 11 lines · Thomas Gleixner

The generic sched_clock implementation returns a jiffies based value as long as there is no clocksource registered. But the above does not fail in sched_clock() it fails in read_persistent_clock() which does

        last_cycles = cycles;
        cycles = clocksource_32k.read(&clocksource_32k);

So the following change causes this:

- .read = omap_32k_read_dummy,

Ah right.

Quoted 4 lines

Which leads to the question why you have a read_persistent_clock() at all if it always reads 0 via omap_32k_read_dummy ? Or is this meant just for the resume case? Then the above and the removal of omap_32k_read_dummy() needs to be undone.

The omap_32k_read_dummy needs to return 0 until the clocks are enabled and the right read function is selected. The .read gets then set in omap_init_clocksource_32k.

Quoted 7 lines
Quoted 2 lines

It would be nice to handle that in a generic way though, I would assume the same issue exists for other platforms too.

static inline cycles_t clocksource_read_safe(struct clocksource *c)

{
	return c->read ? c->read(c) : 0;
}

That adds testing for it for each read.. So the current setup is better.

Quoted 2 lines

For the core timekeeping code that's a non issue as nothing should register a clocksource with an invalid read function pointer :)

Looks like omap_device code calls read_persistent_clock before omap_init_clocksource_32k is run. I'll take a look and see if that is needed when I refresh other omap init_early patches.

Anyways, currently nothing prevents calling read_persistent_clock before it's initialized and a platform specific hack is needed. Maybe the default should be clocksource_read_safe that gets changed by the platform code when initializing?

Regards,

Tony

#22 lore raw

PATCH 8/16 arm: pxa: Use clocksource based sched_clock

Quoted 3 lines · Thomas Gleixner

---
arch/arm/mach-pxa/time.c | 31 +++----------------------------

I think we need to remove HAVE_SCHED_CLOCK from ARCH_PXA in arch/arm/Kconfig as well.

Didn't look into other sub-arch, but should be applicable to those selecting HAVE_SCHED_CLOCK.

Quoted 69 lines
1 file changed, 3 insertions(+), 28 deletions(-)

Index: linux-2.6-tip/arch/arm/mach-pxa/time.c
===================================================================

arch/arm/mach-pxa/time.c +3 -28
@@ -21,31 +21,8 @@
 #include <asm/div64.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
-#include <asm/sched_clock.h>
-#include <mach/regs-ost.h>
-
-/*
- * This is PXA's sched_clock implementation. This has a resolution
- * of at least 308 ns and a maximum value of 208 days.
- *
- * The return value is guaranteed to be monotonic in that range as
- * long as there is always less than 582 seconds between successive
- * calls to sched_clock() which should always be the case in practice.
- */
-static DEFINE_CLOCK_DATA(cd);
-
-unsigned long long notrace sched_clock(void)
-{
-	u32 cyc = OSCR;
-	return cyc_to_sched_clock(&cd, cyc, (u32)~0);
-}
-
-static void notrace pxa_update_sched_clock(void)
-{
-	u32 cyc = OSCR;
-	update_sched_clock(&cd, cyc, (u32)~0);
-}
 
+#include <mach/regs-ost.h>
 
 #define MIN_OSCR_DELTA 16
 
@@ -105,7 +82,7 @@ static struct clock_event_device ckevt_p
 	.set_mode	= pxa_osmr0_set_mode,
 };
 
-static cycle_t pxa_read_oscr(struct clocksource *cs)
+static cycle_t notrace pxa_read_oscr(struct clocksource *cs)
 {
 	return OSCR;
 }
@@ -115,7 +92,7 @@ static struct clocksource cksrc_pxa_oscr
 	.rating         = 200,
 	.read           = pxa_read_oscr,
 	.mask           = CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SCHED_CLOCK,
 };
 
 static struct irqaction pxa_ost0_irq = {
@@ -132,8 +109,6 @@ static void __init pxa_timer_init(void)
 	OIER = 0;
 	OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3;
 
-	init_sched_clock(&cd, pxa_update_sched_clock, 32, clock_tick_rate);
-
 	clocksource_calc_mult_shift(&cksrc_pxa_oscr0, clock_tick_rate, 4);
 	clockevents_calc_mult_shift(&ckevt_pxa_osmr0, clock_tick_rate, 4);
 	ckevt_pxa_osmr0.max_delta_ns =
#23 lore raw

PATCH 8/16 arm: pxa: Use clocksource based sched_clock

Eric,

Quoted 8 lines · Eric
Quoted 3 lines · Thomas Gleixner

---
arch/arm/mach-pxa/time.c | 31 +++----------------------------

Quoted 5 lines

I think we need to remove HAVE_SCHED_CLOCK from ARCH_PXA in arch/arm/Kconfig as well.

Didn't look into other sub-arch, but should be applicable to those selecting HAVE_SCHED_CLOCK.

Thomas already did this. See 16/16

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#24 lore raw

PATCH 8/16 arm: pxa: Use clocksource based sched_clock

Quoted 11 lines · Sascha Hauer

Eric,

Quoted 8 lines · Eric
Quoted 3 lines · Thomas Gleixner

---
arch/arm/mach-pxa/time.c | ? 31 +++----------------------------

Quoted 8 lines
Quoted 5 lines

I think we need to remove HAVE_SCHED_CLOCK from ARCH_PXA in arch/arm/Kconfig as well.

Didn't look into other sub-arch, but should be applicable to those selecting HAVE_SCHED_CLOCK.

Thomas already did this. See 16/16

Ah, I missed that. Then I'm completely fine with this patch series.

Quoted 8 lines

Sascha

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?|
Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |
#31 lore raw

PATCH 13/16 arm plat-mxc: Use clocksource based sched_clock

Quoted 4 lines · Thomas Gleixner
---
 arch/arm/plat-mxc/time.c |   28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)
Quoted 71 lines

Index: linux-2.6-tip/arch/arm/plat-mxc/time.c
===================================================================

arch/arm/plat-mxc/time.c +3 -25
@@ -27,7 +27,6 @@
 #include <linux/clk.h>
 
 #include <mach/hardware.h>
-#include <asm/sched_clock.h>
 #include <asm/mach/time.h>
 #include <mach/common.h>
 
@@ -106,17 +105,12 @@ static void gpt_irq_acknowledge(void)
 		__raw_writel(V2_TSTAT_OF1, timer_base + V2_TSTAT);
 }
 
-static cycle_t dummy_get_cycles(struct clocksource *cs)
-{
-	return 0;
-}
-
-static cycle_t mx1_2_get_cycles(struct clocksource *cs)
+static cycle_t notrace mx1_2_get_cycles(struct clocksource *cs)
 {
 	return __raw_readl(timer_base + MX1_2_TCN);
 }
 
-static cycle_t v2_get_cycles(struct clocksource *cs)
+static cycle_t notrace v2_get_cycles(struct clocksource *cs)
 {
 	return __raw_readl(timer_base + V2_TCN);
 }
@@ -124,25 +118,10 @@ static cycle_t v2_get_cycles(struct cloc
 static struct clocksource clocksource_mxc = {
 	.name 		= "mxc_timer1",
 	.rating		= 200,
-	.read		= dummy_get_cycles,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SCHED_CLOCK,
 };
 
-static DEFINE_CLOCK_DATA(cd);
-unsigned long long notrace sched_clock(void)
-{
-	cycle_t cyc = clocksource_mxc.read(&clocksource_mxc);
-
-	return cyc_to_sched_clock(&cd, cyc, (u32)~0);
-}
-
-static void notrace mxc_update_sched_clock(void)
-{
-	cycle_t cyc = clocksource_mxc.read(&clocksource_mxc);
-	update_sched_clock(&cd, cyc, (u32)~0);
-}
-
 static int __init mxc_clocksource_init(struct clk *timer_clk)
 {
 	unsigned int c = clk_get_rate(timer_clk);
@@ -152,7 +131,6 @@ static int __init mxc_clocksource_init(s
 	else
 		clocksource_mxc.read = mx1_2_get_cycles;
 
-	init_sched_clock(&cd, mxc_update_sched_clock, 32, c);
 	clocksource_register_hz(&clocksource_mxc, c);
 
 	return 0;
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#36 lore raw

PATCH 16/16 arm: Remove sched_clock code

Quoted 4 lines · Thomas Gleixner

All users converted to use the clocksource based sched_clock.

Tested on Samsung stuff...

Quoted 3 lines
---
 arch/arm/Kconfig                   |   15 ----
 arch/arm/include/asm/sched_clock.h |  120

----------------------------------

Quoted 6 lines
---
 arch/arm/kernel/Makefile           |    1
 arch/arm/kernel/sched_clock.c      |   74 ----------------------
 arch/arm/kernel/time.c             |    4 -
 5 files changed, 214 deletions(-)

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#37 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

In reply to Thomas Gleixner

2011/4/23 Thomas Gleixner <[email protected]>:

Quoted 3 lines

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

Excellent patch set!

Quoted 1 line

Another 650 lines gone :)

Any reason why we can't simply move *all* of these to drivers/clocksource/* and proceed with consolidation there?

It must be a pain having to grep through the tree to find all of these (even though I bet you know them all by heart now).

Yours,
Linus Walleij

#38 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Quoted 6 lines · Linus Walleij

2011/4/23 Thomas Gleixner <[email protected]>:

Quoted 3 lines

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

Quoted 6 lines

Excellent patch set!

Quoted 1 line

Another 650 lines gone :)

Any reason why we can't simply move *all* of these to drivers/clocksource/* and proceed with consolidation there?

This gives me some pause, as having the clocksources in the platform code makes it easier to know what platform needs to be tested when a change is made. The rule so far has been if more then one arch can make use of it, it should be moved to the drivers/clocksource dir. Otherwise, leave it close to any arch specific code that manages the hardware.

Quoted 2 lines

It must be a pain having to grep through the tree to find all of these (even though I bet you know them all by heart now).

Not sure if grepping backwards through config dependencies to see who actually uses a specific clocksource would be easier. But I'll admit that sharing code is likely more important.

thanks
-john

#39 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

2011/4/25 john stultz <[email protected]>:

Quoted 9 lines · Linus Walleij
Quoted 2 lines

Any reason why we can't simply move *all* of these to drivers/clocksource/* and proceed with consolidation there?

This gives me some pause, as having the clocksources in the platform code makes it easier to know what platform needs to be tested when a change is made. The rule so far has been if more then one arch can make use of it, it should be moved to the drivers/clocksource dir. Otherwise, leave it close to any arch specific code that manages the hardware.

That means that by definition anything in a plat-* directory, say e.g. plat-nomadik/timer.c and plat-omap/dmtimer.c should go into drivers/clocksource I believe?

Yours,
Linus Walleij

maintainer
#40 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Quoted 11 lines · Linus Walleij

2011/4/25 john stultz <[email protected]>:

Quoted 9 lines · Linus Walleij
Quoted 2 lines

Any reason why we can't simply move *all* of these to drivers/clocksource/* and proceed with consolidation there?

This gives me some pause, as having the clocksources in the platform code makes it easier to know what platform needs to be tested when a change is made. The rule so far has been if more then one arch can make use of it, it should be moved to the drivers/clocksource dir. Otherwise, leave it close to any arch specific code that manages the hardware.

Quoted 3 lines

That means that by definition anything in a plat-* directory, say e.g. plat-nomadik/timer.c and plat-omap/dmtimer.c should go into drivers/clocksource I believe?

Or drivers/timers as they may be generic hardware timers? They are not necessarily used for clocksource.

Regards,

Tony

#41 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

In reply to Linus Walleij
Quoted 8 lines · Linus Walleij

2011/4/23 Thomas Gleixner <[email protected]>:

Quoted 3 lines

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

Excellent patch set!

Quoted 7 lines
Quoted 1 line

Another 650 lines gone :)

Any reason why we can't simply move *all* of these to drivers/clocksource/* and proceed with consolidation there?

It must be a pain having to grep through the tree to find all of these (even though I bet you know them all by heart now).

Russell has a patch which creates clocksource_mmio. That will replace all the mmio (read some random register) based clocksources all over the place.

Thanks,

tglx

#42 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

In reply to Thomas Gleixner
Quoted 3 lines · Thomas Gleixner

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

sched_clock really needs to be setup earlier than clocksources are setup, before sched_init() is called in init/main.c. This is where the scheduler reads the initial value of sched_clock() to start its time measurements. This is well before clocksources are initialized, or even the irq subsystem.

So I don't believe bolting it directly into the clocksource code in this way is correct. As things are currently setup with my sched_clock() implementation, we can (and in any cases do) get the sched_clock() up and running really early which is what's required.

#43 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Quoted 10 lines · Russell King - ARM Linux
Quoted 3 lines · Thomas Gleixner

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

sched_clock really needs to be setup earlier than clocksources are setup, before sched_init() is called in init/main.c. This is where the scheduler reads the initial value of sched_clock() to start its time measurements. This is well before clocksources are initialized, or even the irq subsystem.

Quoted 4 lines

So I don't believe bolting it directly into the clocksource code in this way is correct. As things are currently setup with my sched_clock() implementation, we can (and in any cases do) get the sched_clock() up and running really early which is what's required.

Not really. There is no requirement to have a high resolution sched clock in the early boot process. The only requirement is that sched_clock is monotonic increasing nsecs. So the code utilizes jiffies up to the point where the clocksource is installed and then switches over keeping the clock monotonic. The scheduler does not care whether it gets coarse grained time information in the early boot stage and then fine grained information at some point later.

The only drawback is that you don't get precise timestamps for tracing up to the point where the clock source is installed. But that's really not a big deal to worry about.

Thanks,

tglx

maintainer
#44 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Quoted 25 lines · Thomas Gleixner
Quoted 10 lines · Russell King - ARM Linux
Quoted 3 lines · Thomas Gleixner

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

sched_clock really needs to be setup earlier than clocksources are setup, before sched_init() is called in init/main.c. This is where the scheduler reads the initial value of sched_clock() to start its time measurements. This is well before clocksources are initialized, or even the irq subsystem.

Quoted 4 lines

So I don't believe bolting it directly into the clocksource code in this way is correct. As things are currently setup with my sched_clock() implementation, we can (and in any cases do) get the sched_clock() up and running really early which is what's required.

Not really. There is no requirement to have a high resolution sched clock in the early boot process. The only requirement is that sched_clock is monotonic increasing nsecs. So the code utilizes jiffies up to the point where the clocksource is installed and then switches over keeping the clock monotonic. The scheduler does not care whether it gets coarse grained time information in the early boot stage and then fine grained information at some point later.

Quoted 3 lines

The only drawback is that you don't get precise timestamps for tracing up to the point where the clock source is installed. But that's really not a big deal to worry about.

What about PRINTK_TIME? I think that uses sched_clock right from the start.

Tony

#45 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Quoted 26 lines · Tony Lindgren
Quoted 25 lines · Thomas Gleixner
Quoted 10 lines · Russell King - ARM Linux
Quoted 3 lines · Thomas Gleixner

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

sched_clock really needs to be setup earlier than clocksources are setup, before sched_init() is called in init/main.c. This is where the scheduler reads the initial value of sched_clock() to start its time measurements. This is well before clocksources are initialized, or even the irq subsystem.

Quoted 4 lines

So I don't believe bolting it directly into the clocksource code in this way is correct. As things are currently setup with my sched_clock() implementation, we can (and in any cases do) get the sched_clock() up and running really early which is what's required.

Not really. There is no requirement to have a high resolution sched clock in the early boot process. The only requirement is that sched_clock is monotonic increasing nsecs. So the code utilizes jiffies up to the point where the clocksource is installed and then switches over keeping the clock monotonic. The scheduler does not care whether it gets coarse grained time information in the early boot stage and then fine grained information at some point later.

Quoted 6 lines
Quoted 3 lines

The only drawback is that you don't get precise timestamps for tracing up to the point where the clock source is installed. But that's really not a big deal to worry about.

What about PRINTK_TIME? I think that uses sched_clock right from the start.

Right, but where is the problem ? A few time stamps with jiffies resolution and then the finegrained ones.

Thanks,

tglx

#46 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

2011/4/29 Thomas Gleixner <[email protected]>:

Quoted 6 lines · Tony Lindgren
Quoted 2 lines

What about PRINTK_TIME? I think that uses sched_clock right from the start.

Right, but where is the problem ? A few time stamps with jiffies resolution and then the finegrained ones.

Jonas ?berg has this pending patch that we call "boot time recorder". What it does is basically start a free running timer before the kernel is booted, e.g. in U-boot or even in the ROM of your machine if you can.

If we need more finegrained sched_clock() before the clocksource is up, a good approach would be to utilize something like that for sched_clock up to that point, plus it has the upside that [0.000000] is as close to electrical power-on as possible.

Yours,
Linus Walleij

#47 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Quoted 13 lines · Linus Walleij

2011/4/29 Thomas Gleixner <[email protected]>:

Quoted 6 lines · Tony Lindgren
Quoted 2 lines

What about PRINTK_TIME? I think that uses sched_clock right from the start.

Right, but where is the problem ? A few time stamps with jiffies resolution and then the finegrained ones.

Jonas ?berg has this pending patch that we call "boot time recorder". What it does is basically start a free running timer before the kernel is booted, e.g. in U-boot or even in the ROM of your machine if you can.

Quoted 5 lines

If we need more finegrained sched_clock() before the clocksource is up, a good approach would be to utilize something like that for sched_clock up to that point, plus it has the upside that [0.000000] is as close to electrical power-on as possible.

Well, you can read out that value at the point the clocksource gets installed so you have the time spent up to that point without adding another facility, level of indirection ...

Thanks,

tglx

maintainer
#48 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

Quoted 21 lines · Thomas Gleixner
Quoted 13 lines · Linus Walleij

2011/4/29 Thomas Gleixner <[email protected]>:

Quoted 6 lines · Tony Lindgren
Quoted 2 lines

What about PRINTK_TIME? I think that uses sched_clock right from the start.

Right, but where is the problem ? A few time stamps with jiffies resolution and then the finegrained ones.

Jonas ?berg has this pending patch that we call "boot time recorder". What it does is basically start a free running timer before the kernel is booted, e.g. in U-boot or even in the ROM of your machine if you can.

Quoted 5 lines

If we need more finegrained sched_clock() before the clocksource is up, a good approach would be to utilize something like that for sched_clock up to that point, plus it has the upside that [0.000000] is as close to electrical power-on as possible.

Quoted 3 lines

Well, you can read out that value at the point the clocksource gets installed so you have the time spent up to that point without adding another facility, level of indirection ...

I think the problem here too is that we are calling read_persistent_clock and sched_clock before they're initialized. So we should default to jiffies based value before the platform code enables the hardware.

Tony

#49 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

In reply to Thomas Gleixner
Quoted 13 lines · Thomas Gleixner
Quoted 11 lines · Linus Walleij

Jonas ?berg has this pending patch that we call "boot time recorder". What it does is basically start a free running timer before the kernel is booted, e.g. in U-boot or even in the ROM of your machine if you can.

If we need more finegrained sched_clock() before the clocksource is up, a good approach would be to utilize something like that for sched_clock up to that point, plus it has the upside that [0.000000] is as close to electrical power-on as possible.

Quoted 3 lines

Well, you can read out that value at the point the clocksource gets installed so you have the time spent up to that point without adding another facility, level of indirection ...

That too (one does not exclude the other), what I was getting at is that systems may have something alredy running that is monotonic and trustable, and would likely go into some early_timer() or similar familiar kernel naming scheme. But no point in doing any of that sort now, let's have jiffies for now and get that to work.

Thanks,
Linus Walleij

#50 lore raw

cover arm: Replace arm sched_clock by clocksource based sched_clock

In reply to Thomas Gleixner

Thomas,

Quoted 14 lines · Thomas Gleixner

Most of ARM sched_clocks is using the timekeeping clocksource as the sched_clock. Only versatile uses a different clock for it, but there is no real reason why it can't use the clocksource as well.

The core timekeeping code makes already sure that we don't wrap the timekeeper and we can base a sched_clock easily on that.

It uses the read function of the clocksource and keeps track of time independent of the timekeeping code as the ARM sched_clock implementation does. It also uses it's own sequence counter so sched_clock is not dependent on xtime_lock. The update sequence is just adding offsets once in a while and runs from do_timer() which also makes sure that only one core tries to update it.

Quoted 4 lines

Only lightly tested on orion. Please give it a go.

Another 650 lines gone :)

What's happening with this patch series? Just wondering if I'll need to add yet another sched_clock implementation or not.

Rob