Skip to content

Commit 490ba17

Browse files
cfd-36Linus Torvalds
authored andcommitted
[PATCH] uml: make time data per-cpu
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>
1 parent c0961c1 commit 490ba17

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎arch/um/kernel/time.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,31 @@ unsigned long long sched_clock(void)
3535
return (unsigned long long)jiffies_64 * (1000000000 / HZ);
3636
}
3737

38-
static unsigned long long prev_nsecs;
38+
static unsigned long long prev_nsecs[NR_CPUS];
3939
#ifdef CONFIG_UML_REAL_TIME_CLOCK
40-
static long long delta; /* Deviation per interval */
40+
static long long delta[NR_CPUS]; /* Deviation per interval */
4141
#endif
4242

4343
void timer_irq(union uml_pt_regs *regs)
4444
{
4545
unsigned long long ticks = 0;
46-
4746
#ifdef CONFIG_UML_REAL_TIME_CLOCK
48-
if(prev_nsecs){
47+
int c = cpu();
48+
if(prev_nsecs[c]){
4949
/* We've had 1 tick */
5050
unsigned long long nsecs = os_nsecs();
5151

52-
delta += nsecs - prev_nsecs;
53-
prev_nsecs = nsecs;
52+
delta[c] += nsecs - prev_nsecs[c];
53+
prev_nsecs[c] = nsecs;
5454

5555
/* Protect against the host clock being set backwards */
56-
if(delta < 0)
57-
delta = 0;
56+
if(delta[c] < 0)
57+
delta[c] = 0;
5858

59-
ticks += (delta * HZ) / BILLION;
60-
delta -= (ticks * BILLION) / HZ;
59+
ticks += (delta[c] * HZ) / BILLION;
60+
delta[c] -= (ticks * BILLION) / HZ;
6161
}
62-
else prev_nsecs = os_nsecs();
62+
else prev_nsecs[c] = os_nsecs();
6363
#else
6464
ticks = 1;
6565
#endif
@@ -69,8 +69,8 @@ void timer_irq(union uml_pt_regs *regs)
6969
}
7070
}
7171

72+
/* Protects local_offset */
7273
static DEFINE_SPINLOCK(timer_spinlock);
73-
7474
static unsigned long long local_offset = 0;
7575

7676
static inline unsigned long long get_time(void)

0 commit comments

Comments
 (0)