Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 97610
b: refs/heads/master
c: 5c1ea08
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Thomas Gleixner committed Jun 4, 2008
1 parent c8a180b commit 64b73f9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 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: deef325086c3897393b8f7d6bccd03405244fe18
refs/heads/master: 5c1ea08215f1f830dfaf4819a5f22efca41c3832
31 changes: 27 additions & 4 deletions trunk/arch/x86/lib/delay_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,36 @@ static void delay_loop(unsigned long loops)
static void delay_tsc(unsigned long loops)
{
unsigned long bclock, now;
int cpu;

preempt_disable(); /* TSC's are per-cpu */
preempt_disable();
cpu = smp_processor_id();
rdtscl(bclock);
do {
rep_nop();
for (;;) {
rdtscl(now);
} while ((now-bclock) < loops);
if ((now - bclock) >= loops)
break;

/* Allow RT tasks to run */
preempt_enable();
rep_nop();
preempt_disable();

/*
* It is possible that we moved to another CPU, and
* since TSC's are per-cpu we need to calculate
* that. The delay must guarantee that we wait "at
* least" the amount of time. Being moved to another
* CPU could make the wait longer but we just need to
* make sure we waited long enough. Rebalance the
* counter for this CPU.
*/
if (unlikely(cpu != smp_processor_id())) {
loops -= (now - bclock);
cpu = smp_processor_id();
rdtscl(bclock);
}
}
preempt_enable();
}

Expand Down
30 changes: 26 additions & 4 deletions trunk/arch/x86/lib/delay_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,36 @@ int __devinit read_current_timer(unsigned long *timer_value)
void __delay(unsigned long loops)
{
unsigned bclock, now;
int cpu;

preempt_disable(); /* TSC's are pre-cpu */
preempt_disable();
cpu = smp_processor_id();
rdtscl(bclock);
do {
rep_nop();
for (;;) {
rdtscl(now);
if ((now - bclock) >= loops)
break;

/* Allow RT tasks to run */
preempt_enable();
rep_nop();
preempt_disable();

/*
* It is possible that we moved to another CPU, and
* since TSC's are per-cpu we need to calculate
* that. The delay must guarantee that we wait "at
* least" the amount of time. Being moved to another
* CPU could make the wait longer but we just need to
* make sure we waited long enough. Rebalance the
* counter for this CPU.
*/
if (unlikely(cpu != smp_processor_id())) {
loops -= (now - bclock);
cpu = smp_processor_id();
rdtscl(bclock);
}
}
while ((now-bclock) < loops);
preempt_enable();
}
EXPORT_SYMBOL(__delay);
Expand Down

0 comments on commit 64b73f9

Please sign in to comment.