kernel-ark/arch/arm/kernel
Thomas Gleixner b8f8c3cf0a nohz: prevent tick stop outside of the idle loop
Jack Ren and Eric Miao tracked down the following long standing
problem in the NOHZ code:

	scheduler switch to idle task
	enable interrupts

Window starts here

	----> interrupt happens (does not set NEED_RESCHED)
	      	irq_exit() stops the tick

	----> interrupt happens (does set NEED_RESCHED)

	return from schedule()
	
	cpu_idle(): preempt_disable();

Window ends here

The interrupts can happen at any point inside the race window. The
first interrupt stops the tick, the second one causes the scheduler to
rerun and switch away from idle again and we end up with the tick
disabled.

The fact that it needs two interrupts where the first one does not set
NEED_RESCHED and the second one does made the bug obscure and extremly
hard to reproduce and analyse. Kudos to Jack and Eric.

Solution: Limit the NOHZ functionality to the idle loop to make sure
that we can not run into such a situation ever again.

cpu_idle()
{
	preempt_disable();

	while(1) {
		 tick_nohz_stop_sched_tick(1); <- tell NOHZ code that we
		 			          are in the idle loop

		 while (!need_resched())
		       halt();

		 tick_nohz_restart_sched_tick(); <- disables NOHZ mode
		 preempt_enable_no_resched();
		 schedule();
		 preempt_disable();
	}
}

In hindsight we should have done this forever, but ... 

/me grabs a large brown paperbag.

Debugged-by: Jack Ren <jack.ren@marvell.com>, 
Debugged-by: eric miao <eric.y.miao@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-07-18 18:10:28 +02:00
..
armksyms.c [ARM] export copy_page 2008-05-17 22:55:12 +01:00
arthur.c [ARM] arm/kernel/arthur.c: add MODULE_LICENSE 2008-05-17 22:55:16 +01:00
asm-offsets.c arm: use kbuild.h instead of macros in asm-offsets.c 2008-04-29 08:06:29 -07:00
atags.c proc: remove proc_root from drivers 2008-04-29 08:06:18 -07:00
atags.h [ARM] 4736/1: Export atags to userspace and allow kexec to use customised atags 2008-02-04 13:21:03 +00:00
bios32.c
calls.S Merge branch 'omap2-upstream' into devel 2008-04-19 17:17:29 +01:00
compat.c
compat.h
crunch-bits.S
crunch.c
debug.S
dma-isa.c
dma.c
ecard.c proc: switch /proc/bus/ecard/devices to seq_file interface 2008-04-29 08:06:19 -07:00
ecard.h
entry-armv.S Merge branches 'arm', 'at91', 'ep93xx', 'iop', 'ks8695', 'misc', 'mxc', 'ns9x', 'orion', 'pxa', 'sa1100', 's3c' and 'sparsemem' into devel 2008-04-19 17:17:25 +01:00
entry-common.S Add a prefetch abort handler 2008-04-18 22:43:07 +01:00
entry-header.S
fiq.c
head-common.S [ARM] 4881/1: print unrecognised processor ID as part of failure message 2008-04-19 11:28:08 +01:00
head-nommu.S
head.S [ARM] 4849/1: move ATAGS asm definitions 2008-03-06 12:18:18 +00:00
init_task.c [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
io.c
irq.c
isa.c
iwmmxt.S
kprobes-decode.c kprobes/arm: fix decoding of arithmetic immediate instructions 2008-04-28 15:54:55 -04:00
kprobes.c kprobes/arm: fix cache flush address for instruction stub 2008-04-28 15:54:37 -04:00
machine_kexec.c [ARM] 4736/1: Export atags to userspace and allow kexec to use customised atags 2008-02-04 13:21:03 +00:00
Makefile Merge branch 'merge-fixes' into devel 2008-04-19 17:17:34 +01:00
module.c
process.c nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
ptrace.c
ptrace.h
relocate_kernel.S [ARM] 4736/1: Export atags to userspace and allow kexec to use customised atags 2008-02-04 13:21:03 +00:00
setup.c [ARM] constify function pointer tables 2008-02-09 22:46:44 +00:00
signal.c [ARM] 4870/1: fix signal return code when enable CONFIG_OABI_COMPAT 2008-03-20 15:59:31 +00:00
signal.h
smp.c add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
stacktrace.c
stacktrace.h
sys_arm.c unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
sys_oabi-compat.c [ARM] 4878/1: Add oabi shim for fstatat64 2008-03-28 15:00:46 +00:00
thumbee.c ARMv7: Add support for the ThumbEE state saving/restoring 2008-04-18 22:43:06 +01:00
time.c
traps.c
vmlinux.lds.S all archs: consolidate init and exit sections in vmlinux.lds.h 2008-01-28 23:21:17 +01:00
xscale-cp0.c