Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 97429
b: refs/heads/master
c: a381759
h: refs/heads/master
i:
  97427: 99a5cbe
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 29, 2008
1 parent 2f21886 commit b5c9d15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6363ca57c76b7b83639ca8c83fc285fa26a7880e
refs/heads/master: a381759d6ad5c5dea5a981918e0b4493e9b66ac7
18 changes: 14 additions & 4 deletions trunk/kernel/sched_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,26 @@ static inline struct sched_clock_data *cpu_sdc(int cpu)
return &per_cpu(sched_clock_data, cpu);
}

static __read_mostly int sched_clock_running;

void sched_clock_init(void)
{
u64 ktime_now = ktime_to_ns(ktime_get());
u64 now = 0;
unsigned long now_jiffies = jiffies;
int cpu;

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->prev_jiffies = now_jiffies;
scd->prev_raw = 0;
scd->tick_raw = 0;
scd->tick_gtod = ktime_now;
scd->clock = ktime_now;
}

sched_clock_running = 1;
}

/*
Expand Down Expand Up @@ -136,6 +140,9 @@ u64 sched_clock_cpu(int cpu)
struct sched_clock_data *scd = cpu_sdc(cpu);
u64 now, clock;

if (unlikely(!sched_clock_running))
return 0ull;

WARN_ON_ONCE(!irqs_disabled());
now = sched_clock();

Expand Down Expand Up @@ -174,6 +181,9 @@ void sched_clock_tick(void)
struct sched_clock_data *scd = this_scd();
u64 now, now_gtod;

if (unlikely(!sched_clock_running))
return;

WARN_ON_ONCE(!irqs_disabled());

now = sched_clock();
Expand Down

0 comments on commit b5c9d15

Please sign in to comment.