android_kernel_motorola_sm6225/arch
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
..
alpha [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
arm nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
avr32 nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
blackfin nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02: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 nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02: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 nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
ppc [POWERPC] ppc: More compile fixes 2008-05-12 22:57:51 +10:00
s390 [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
sh nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
sparc sparc: remove CVS keywords 2008-05-20 00:33:44 -07:00
sparc64 nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
um nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
v850 [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
x86 nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
xtensa [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
.gitignore arch: Ignore arch/i386 and arch/x86_64 2008-01-19 21:29:39 -08:00
Kconfig dma: add dma_*map*_attrs() interfaces 2008-04-29 08:06:11 -07:00