Re: CONFIG_PRINTK_TIME broken on git HEAD ?

From: Peter Zijlstra
Date: Fri May 09 2008 - 05:39:45 EST


On Thu, 2008-05-08 at 13:21 +0200, Gabriel C wrote:

> > Ok, so the issue is that the clock doesn't start at 0, but at:
> > 4294014.506571 ?
>
> At least on my box , yes.
>

Does this work for you?

---

Subject: sched: fixup sched-clock offset
From: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>

It could happen that ktime doesn't start at 0.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/sched_clock.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

Index: linux-2.6-2/kernel/sched_clock.c
===================================================================
--- linux-2.6-2.orig/kernel/sched_clock.c
+++ linux-2.6-2/kernel/sched_clock.c
@@ -59,21 +59,23 @@ static inline struct sched_clock_data *c
return &per_cpu(sched_clock_data, cpu);
}

+static __read_mostly u64 ktime_offset;
+
void sched_clock_init(void)
{
- u64 ktime_now = ktime_to_ns(ktime_get());
- u64 now = 0;
int cpu;

+ ktime_offset = ktime_to_ns(ktime_get());
+
for_each_possible_cpu(cpu) {
struct sched_clock_data *scd = cpu_sdc(cpu);

scd->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
scd->prev_jiffies = jiffies;
- scd->prev_raw = now;
- scd->tick_raw = now;
- scd->tick_gtod = ktime_now;
- scd->clock = ktime_now;
+ scd->prev_raw = 0;
+ scd->tick_raw = 0;
+ scd->tick_gtod = 0;
+ scd->clock = 0;
}
}

@@ -177,7 +179,7 @@ void sched_clock_tick(void)
WARN_ON_ONCE(!irqs_disabled());

now = sched_clock();
- now_gtod = ktime_to_ns(ktime_get());
+ now_gtod = ktime_to_ns(ktime_get()) - ktime_offset;

__raw_spin_lock(&scd->lock);
__update_sched_clock(scd, now);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/