android_kernel_xiaomi_sm8350/arch/blackfin
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
..
boot [Blackfin] arch: add include/boot .gitignore files 2008-04-25 08:29:11 +08:00
configs Blackfin arch: update boards defconfig files 2008-05-19 14:56:33 +08:00
kernel nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
lib Blackfin arch: IO Port functions to read/write unalligned memory 2008-05-17 16:38:52 +08:00
mach-bf527 i2c: Clean up Blackfin BF527 I2C device declarations 2008-05-18 20:49:40 +02:00
mach-bf533 [Blackfin] arch: rename bf5xx-flash to bfin-async-flash 2008-05-13 12:31:32 +08:00
mach-bf537 [Blackfin] arch: protect linux/usb/isp1362.h include until the driver gets mainlined 2008-05-10 00:06:10 +08:00
mach-bf548 [Blackfin] arch: protect linux/usb/musb.h include until the driver gets mainlined 2008-05-10 00:08:12 +08:00
mach-bf561 [Blackfin] arch: protect linux/usb/isp1362.h include until the driver gets mainlined 2008-05-10 00:06:10 +08:00
mach-common [Blackfin] arch: fix gdb testing regression 2008-05-07 11:41:26 +08:00
mm [Blackfin] arch: fix bug - make sure we check the right L1 length 2008-04-23 08:55:26 +08:00
oprofile [Blackfin] arch: __FUNCTION__ is gcc-specific, use __func__ 2008-04-23 09:39:01 +08:00
Kconfig Blackfin arch: enable a choice to provide 4M DMA memory 2008-05-17 16:36:52 +08:00
Kconfig.debug [Blackfin] arch: add slightly better help text for CPLB_INFO 2008-02-02 15:32:40 +08:00
Makefile [Blackfin] arch: declare CHECKFLAGS to make sparse output more readable 2008-03-07 02:43:48 +08:00