diff options
author | John Hawkes <hawkes@sgi.com> | 2005-12-16 10:00:24 -0800 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2005-12-16 10:00:24 -0800 |
commit | f5899b5d4fa806403f547dc41312d017d94ec273 (patch) | |
tree | 4cbc38474b5ab6dfe8591f0b490686315a6aaa26 /arch | |
parent | 7b6666530e2736f190a2629c8abe34275054449f (diff) | |
download | linux-3.10-f5899b5d4fa806403f547dc41312d017d94ec273.tar.gz linux-3.10-f5899b5d4fa806403f547dc41312d017d94ec273.tar.bz2 linux-3.10-f5899b5d4fa806403f547dc41312d017d94ec273.zip |
[IA64] disable preemption in udelay()
The udelay() inline for ia64 uses the ITC. If CONFIG_PREEMPT is enabled
and the platform has unsynchronized ITCs and the calling task migrates
to another CPU while doing the udelay loop, then the effective delay may
be too short or very, very long.
This patch disables preemption around 100 usec chunks of the overall
desired udelay time. This minimizes preemption-holdoffs.
udelay() is now too big to be inline, move it out of line and export it.
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ia64/kernel/time.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 5b7e736f3b4..028a2b95936 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c @@ -249,3 +249,32 @@ time_init (void) */ set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec); } + +#define SMALLUSECS 100 + +void +udelay (unsigned long usecs) +{ + unsigned long start; + unsigned long cycles; + unsigned long smallusecs; + + /* + * Execute the non-preemptible delay loop (because the ITC might + * not be synchronized between CPUS) in relatively short time + * chunks, allowing preemption between the chunks. + */ + while (usecs > 0) { + smallusecs = (usecs > SMALLUSECS) ? SMALLUSECS : usecs; + preempt_disable(); + cycles = smallusecs*local_cpu_data->cyc_per_usec; + start = ia64_get_itc(); + + while (ia64_get_itc() - start < cycles) + cpu_relax(); + + preempt_enable(); + usecs -= smallusecs; + } +} +EXPORT_SYMBOL(udelay); |