android_kernel_xiaomi_sm8350/arch/mips
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
..
au1000 [MIPS] Pb1000: bury the remnants of the PCI code 2008-05-12 16:46:56 +01:00
basler/excite proc: switch /proc/excite/unit_id to seq_file interface 2008-04-29 08:06:19 -07:00
bcm47xx [MIPS] BCM47XX: Use new SSB SPROM data structure 2008-02-19 17:01:34 +00:00
boot
cobalt [MIPS] add cpu_wait() to machine_halt() 2008-01-29 10:15:00 +00:00
configs [MIPS] Allow setting of the cache attribute at run time. 2008-04-28 17:14:25 +01:00
dec [MIPS] DS1287: Add clockevent driver 2008-04-28 17:14:32 +01:00
emma2rh [MIPS] markeins: build fix 2008-05-12 16:46:56 +01:00
fw
gt64120/wrppmc
jazz
jmr3927 [MIPS] jmr3927: use generic txx9 gpio 2008-04-28 17:14:31 +01:00
kernel nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
lasat [MIPS] Lasat: Convert pvc_sem semaphore to mutex 2008-01-29 10:15:01 +00:00
lemote/lm2e
lib iomap: fix 64 bits resources on 32 bits 2008-04-29 08:06:02 -07:00
math-emu [MIPS] replace __inline with inline 2008-04-28 17:14:26 +01:00
mips-boards [MIPS] malta_int.c: make 4 variables static 2008-04-28 17:14:28 +01:00
mipssim [MIPS] Remove TLB sanitation code 2008-04-28 17:14:25 +01:00
mm [MIPS] unexport __kmap_atomic_to_page 2008-05-12 16:46:51 +01:00
nxp/pnx8550 [MIPS] Move arch/mips/philips to arch/mips/nxp 2008-04-28 17:14:26 +01:00
oprofile [MIPS] Fix build failure in mips oprofile code 2008-05-12 16:46:56 +01:00
pci [MIPS] Alchemy PCI code style cleanup 2008-05-12 16:46:52 +01:00
pmc-sierra [MIPS] msp_hwbutton.c: minor irq handler cleanups 2008-05-12 16:46:52 +01:00
sgi-ip22
sgi-ip27 [MIPS] ip27-timer: fix unsigned irq < 0 2008-05-12 16:46:51 +01:00
sgi-ip32 [MIPS] replace remaining __FUNCTION__ occurrences 2008-04-28 17:14:27 +01:00
sibyte [MIPS] BCM1480: Remove stray function call resulting in infinite recursion 2008-02-19 17:01:31 +00:00
sni
tx4927 [MIPS] replace remaining __FUNCTION__ occurrences 2008-04-28 17:14:27 +01:00
tx4938 [MIPS] rbtx4938: minor cleanup 2008-04-28 17:14:32 +01:00
vr41xx serial: add VR41xx SIU setup for serial console 2008-04-28 08:58:30 -07:00
Kconfig [MIPS] DS1287: Add clockevent driver 2008-04-28 17:14:32 +01:00
Kconfig.debug [MIPS] Allow setting of the cache attribute at run time. 2008-04-28 17:14:25 +01:00
Makefile [MIPS] Move arch/mips/philips to arch/mips/nxp 2008-04-28 17:14:26 +01:00