Skip to content

Commit

Permalink
[PATCH] uml: make time data per-cpu
Browse files Browse the repository at this point in the history
prev_nsecs and delta need to be arrays, and indexed by CPU number.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed Feb 11, 2007
1 parent c0961c1 commit 490ba17
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions arch/um/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ unsigned long long sched_clock(void)
return (unsigned long long)jiffies_64 * (1000000000 / HZ);
}

static unsigned long long prev_nsecs;
static unsigned long long prev_nsecs[NR_CPUS];
#ifdef CONFIG_UML_REAL_TIME_CLOCK
static long long delta; /* Deviation per interval */
static long long delta[NR_CPUS]; /* Deviation per interval */
#endif

void timer_irq(union uml_pt_regs *regs)
{
unsigned long long ticks = 0;

#ifdef CONFIG_UML_REAL_TIME_CLOCK
if(prev_nsecs){
int c = cpu();
if(prev_nsecs[c]){
/* We've had 1 tick */
unsigned long long nsecs = os_nsecs();

delta += nsecs - prev_nsecs;
prev_nsecs = nsecs;
delta[c] += nsecs - prev_nsecs[c];
prev_nsecs[c] = nsecs;

/* Protect against the host clock being set backwards */
if(delta < 0)
delta = 0;
if(delta[c] < 0)
delta[c] = 0;

ticks += (delta * HZ) / BILLION;
delta -= (ticks * BILLION) / HZ;
ticks += (delta[c] * HZ) / BILLION;
delta[c] -= (ticks * BILLION) / HZ;
}
else prev_nsecs = os_nsecs();
else prev_nsecs[c] = os_nsecs();
#else
ticks = 1;
#endif
Expand All @@ -69,8 +69,8 @@ void timer_irq(union uml_pt_regs *regs)
}
}

/* Protects local_offset */
static DEFINE_SPINLOCK(timer_spinlock);

static unsigned long long local_offset = 0;

static inline unsigned long long get_time(void)
Expand Down

0 comments on commit 490ba17

Please sign in to comment.