2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-19 18:53:52 +08:00
linux-next/arch/um
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
..
drivers missed kmalloc() in pcap_user.c 2008-05-21 16:55:57 -07:00
include uml: track and make up lost ticks 2008-05-13 08:02:22 -07:00
kernel nohz: prevent tick stop outside of the idle loop 2008-07-18 18:10:28 +02:00
os-Linux fix include order in sys-i386/registers.c 2008-05-21 16:55:58 -07:00
scripts uml: throw out CONFIG_MODE_TT 2007-10-16 09:43:05 -07:00
sys-i386 uml: tidy ptrace interface 2008-05-13 08:02:21 -07:00
sys-ia64 Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sys-ppc Generic semaphore implementation 2008-04-17 10:42:34 -04:00
sys-x86_64 missing export of csum_partial() on uml/amd64 2008-05-21 16:55:58 -07:00
defconfig UML: update defconfig 2008-02-23 17:12:13 -08:00
Kconfig thanks to net/mac80211 we need to pull drivers/leds/Kconfig on uml 2008-05-21 16:55:58 -07:00
Kconfig.char uml: fix CONFIG_RAW dependencies 2008-05-13 08:02:22 -07:00
Kconfig.debug uml: GPROF needs to depend on FRAME_POINTER 2008-02-05 09:44:25 -08:00
Kconfig.i386 x86, bitops: select the generic bitmap search functions 2008-04-26 19:21:17 +02:00
Kconfig.net uml: fix URLs in Kconfig and help strings 2008-02-05 09:44:25 -08:00
Kconfig.x86_64 x86, bitops: select the generic bitmap search functions 2008-04-26 19:21:17 +02:00
Makefile Revert "uml: fix gcc problem" 2008-05-06 17:09:27 -07:00
Makefile-i386 no need to mess with KBUILD_CFLAGS on uml-i386 anymore 2007-12-05 09:25:20 -08:00
Makefile-ia64 Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
Makefile-os-Linux kbuild: enable 'make CFLAGS=...' to add additional options to CC 2007-10-14 22:21:35 +02:00
Makefile-ppc Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
Makefile-skas [PATCH] uml makefiles sanitized 2005-09-29 08:46:26 -07:00
Makefile-x86_64 x86 merge fallout: uml 2007-10-29 07:41:32 -07:00