lkml.org 
[lkml]   [2008]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: CONFIG_PRINTK_TIME broken on git HEAD ?
From
Date
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@chello.nl>

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

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
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);



\
 
 \ /
  Last update: 2008-05-09 11:41    [W:1.300 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site