linux-kernel-test/arch
Steven Rostedt 5c1ea08215 x86: enable preemption in delay
The RT team has been searching for a nasty latency. This latency shows
up out of the blue and has been seen to be as big as 5ms!

Using ftrace I found the cause of the latency.

   pcscd-2995  3dNh1 52360300us : irq_exit (smp_apic_timer_interrupt)
   pcscd-2995  3dN.2 52360301us : idle_cpu (irq_exit)
   pcscd-2995  3dN.2 52360301us : rcu_irq_exit (irq_exit)
   pcscd-2995  3dN.1 52360771us : smp_apic_timer_interrupt (apic_timer_interrupt
)
   pcscd-2995  3dN.1 52360771us : exit_idle (smp_apic_timer_interrupt)

Here's an example of a 400 us latency. pcscd took a timer interrupt and
returned with "need resched" enabled, but did not reschedule until after
the next interrupt came in at 52360771us 400us later!

At first I thought we somehow missed a preemption check in entry.S. But
I also noticed that this always seemed to happen during a __delay call.

   pcscd-2995  3dN.2 52360836us : rcu_irq_exit (irq_exit)
   pcscd-2995  3.N.. 52361265us : preempt_schedule (__delay)

Looking at the x86 delay, I found my problem.

In git commit 35d5d08a08, Andrew Morton
placed preempt_disable around the entire delay due to TSC's not working
nicely on SMP.  Unfortunately for those that care about latencies this
is devastating! Especially when we have callers to mdelay(8).

Here I enable preemption during the loop and account for anytime the task
migrates to a new CPU. The delay asked for may be extended a bit by
the migration, but delay only guarantees that it will delay for that minimum
time. Delaying longer should not be an issue.

[
  Thanks to Thomas Gleixner for spotting that cpu wasn't updated,
    and to place the rep_nop between preempt_enabled/disable.
]

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Cc: akpm@osdl.org
Cc: Clark Williams <clark.williams@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Luis Claudio R. Goncalves" <lclaudio@uudg.org>
Cc: Gregory Haskins <ghaskins@novell.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andi Kleen <andi-suse@firstfloor.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-06-04 13:11:46 +02:00
..
alpha [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
arm [ARM] integrator: fix build warnings and errors 2008-05-23 19:35:52 +01:00
avr32 avr32: Fix cpufreq oops when ondemand governor is default 2008-05-27 09:37:42 +02:00
blackfin Blackfin arch: Remove bad and usless code 2008-05-31 15:35:40 +08:00
cris [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
frv frv: export empty_zero_page 2008-05-24 09:56:13 -07:00
h8300 [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
ia64 [IA64] Workaround for RSE issue 2008-05-27 13:24:39 -07:00
m32r [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
m68k provide out-of-line strcat() for m68k 2008-05-21 16:56:00 -07:00
m68knommu [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
mips [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
mn10300 [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
parisc [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
powerpc [POWERPC] Fix DMA nodes in the MPC8610 HPCD device tree 2008-05-31 17:08:29 +10:00
ppc [POWERPC] Export empty_zero_page and copy_page in arch/ppc 2008-05-31 17:08:28 +10:00
s390 [S390] Update default configuration. 2008-05-30 10:03:36 +02:00
sh sh: Drop broken URAM support on SH7723. 2008-05-26 11:45:45 +09:00
sparc sparc: remove CVS keywords 2008-05-20 00:33:44 -07:00
sparc64 sparc64: Prevent stack backtrace false positives on trap frames. 2008-05-21 21:50:01 -07:00
um thanks to net/mac80211 we need to pull drivers/leds/Kconfig on uml 2008-05-21 16:55:58 -07:00
v850 [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
x86 x86: enable preemption in delay 2008-06-04 13:11:46 +02:00
xtensa [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
.gitignore
Kconfig dma: add dma_*map*_attrs() interfaces 2008-04-29 08:06:11 -07:00