linux-stable/arch/sh
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
..
boards sh: use sm501 8250 mfd support on r2d boards 2008-05-23 11:53:24 +09:00
boot sh: remove -traditional. 2008-05-08 19:51:46 +09:00
cchips sh: Kill off more dead symbols. 2008-02-14 14:22:12 +09:00
configs sh: update Migo-R defconfig 2008-05-23 11:53:27 +09:00
drivers MODULE_LICENSE expects "GPL v2", not "GPLv2" 2008-05-21 16:56:00 -07:00
kernel nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
lib sh: Fix up optimized SH-4 memcpy on big endian. 2008-05-16 14:55:07 +09:00
lib64 sh64: Fix up compile warning in event tracer. 2008-05-08 19:51:37 +09:00
math-emu sh: Fix up the math-emu build. 2007-06-11 15:57:42 +09:00
mm sh: add memory resources to /proc/iomem 2008-05-08 19:51:51 +09:00
oprofile sh: Add -Werror for clean directories. 2007-11-07 11:13:55 +09:00
tools sh: remove the broken SH_MPC1211 support 2008-05-08 19:51:39 +09:00
Kconfig sh: Drop broken URAM support on SH7723. 2008-05-26 11:45:45 +09:00
Kconfig.cpu sh: Disable big endian for SH-5. 2008-02-14 14:22:10 +09:00
Kconfig.debug sh: sh-bios depends on SUPERH32. 2008-05-08 19:51:35 +09:00
Makefile sh: remove the broken SH_MPC1211 support 2008-05-08 19:51:39 +09:00