linux/arch/um/include
Jeff Dike 53b173327d [PATCH] uml: fix I/O hang
Fix a UML hang in which everything would just stop until some I/O happened
- a ping, someone whacking the keyboard - at which point everything would
start up again as though nothing had happened.

The cause was gcc reordering some code which absolutely needed to be
executed in the order in the source.  When unblock_signals switches signals
from off to on, it needs to see if any interrupts had happened in the
critical section.  The interrupt handlers check signals_enabled - if it is
zero, then the handler adds a bit to the "pending" bitmask and returns.
unblock_signals checks this mask to see if any signals need to be
delivered.

The crucial part is this:
	signals_enabled = 1;
	save_pending = pending;
	if(save_pending == 0)
		return;
	pending = 0;

In order to avoid an interrupt arriving between reading pending and setting
it to zero, in which case, the record of the interrupt would be erased,
signals are enabled.

What happened was that gcc reordered this so that 'save_pending = pending'
came before 'signals_enabled = 1', creating a one-instruction window within
which an interrupt could arrive, set its bit in pending, and have it be
immediately erased.

When the I/O workload is purely disk-based, the loss of a block device
interrupt stops the entire I/O system because the next block request will
wait for the current one to finish.  Thus the system hangs until something
else causes some I/O to arrive, such as a network packet or console input.

The fix to this particular problem is a memory barrier between enabling
signals and reading the pending signal mask.  An xchg would also probably
work.

Looking over this code for similar problems led me to do a few more
things:

- make signals_enabled and pending volatile so that they don't get cached
  in registers

- add an mb() to the return paths of block_signals and unblock_signals so
  that the modification of signals_enabled doesn't get shuffled into the
  caller in the event that these are inlined in the future.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-11-03 12:27:58 -08:00
..
skas Remove all inclusions of <linux/config.h> 2006-10-04 03:38:54 -04:00
sysdep-i386 [PATCH] uml: fix I/O hang 2006-11-03 12:27:58 -08:00
sysdep-ia64 [PATCH] uml: S390 preparation, abstract host page fault data 2005-05-05 16:36:36 -07:00
sysdep-ppc Remove all inclusions of <linux/config.h> 2006-10-04 03:38:54 -04:00
sysdep-x86_64 [PATCH] uml: fix I/O hang 2006-11-03 12:27:58 -08:00
tt [PATCH] uml: fix static binary segfault 2006-07-10 13:24:23 -07:00
aio.h [PATCH] uml: revert block driver use of host AIO 2005-10-12 08:22:26 -07:00
chan_kern.h [PATCH] uml: const more data 2006-09-27 08:26:15 -07:00
chan_user.h [PATCH] uml: const more data 2006-09-27 08:26:15 -07:00
choose-mode.h [PATCH] uml: better diagnostics for broken configs 2006-01-06 08:33:47 -08:00
common-offsets.h [PATCH] uml: asm offsets duplication removal 2006-10-11 11:14:20 -07:00
elf_user.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
frame_kern.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
init.h [PATCH] uml: fix ((unused)) attribute 2006-02-24 14:31:37 -08:00
initrd.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
irq_kern.h IRQ: Use the new typedef for interrupt handler function pointers 2006-10-09 12:19:47 +01:00
irq_user.h [PATCH] uml: remove spinlock wrapper functions 2006-07-10 13:24:23 -07:00
kern_util.h [PATCH] make UML compile (FC6/x86-64) 2006-10-15 14:18:39 -07:00
kern.h [PATCH] uml: fix declaration of exit() 2006-03-27 08:44:37 -08:00
line.h [PATCH] const struct tty_operations 2006-10-02 07:57:14 -07:00
longjmp.h [PATCH] uml: make UML_SETJMP always safe 2006-10-11 11:14:20 -07:00
mconsole_kern.h [PATCH] uml ubd driver: various little changes 2006-10-31 08:07:00 -08:00
mconsole.h [PATCH] uml: mconsole fixes 2006-10-24 22:01:10 -07:00
mem_kern.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
mem_user.h [PATCH] UML: Hotplug memory, take 2 2006-03-31 12:18:50 -08:00
mem.h [PATCH] uml: inline mk_pte and various friends 2005-09-10 12:00:18 -07:00
misc_constants.h [PATCH] uml: move libc-dependent irq code to os-Linux 2006-03-27 08:44:37 -08:00
mode_kern.h Remove all inclusions of <linux/config.h> 2006-10-04 03:38:54 -04:00
mode.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
net_kern.h [PATCH] uml: mechanical tidying after random MACs change 2006-09-29 09:18:04 -07:00
net_user.h [PATCH] uml: don't roll my own random MAC generator 2006-09-29 09:18:04 -07:00
os.h [PATCH] uml: readd forgot prototype 2006-10-11 11:14:20 -07:00
process.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ptrace_user.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
registers.h [PATCH] uml: stack usage reduction 2006-09-26 08:49:09 -07:00
sigcontext.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sigio.h [PATCH] uml: move sigio_user.c to os-Linux/sigio.c 2006-03-27 08:44:38 -08:00
signal_kern.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
skas_ptrace.h [PATCH] uml: header and code cleanup 2005-05-05 16:36:39 -07:00
skas_ptregs.h [PATCH] uml makefiles sanitized 2005-09-29 08:46:26 -07:00
syscall.h [PATCH] uml: system call path cleanup 2005-09-05 00:06:23 -07:00
sysrq.h [PATCH] uml: stack dump fix 2005-05-28 16:46:13 -07:00
task.h [PATCH] uml makefiles sanitized 2005-09-29 08:46:26 -07:00
tempfile.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
tlb.h [PATCH] mm: uml kill unused 2005-10-29 21:40:42 -07:00
ubd_user.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
um_malloc.h [PATCH] uml: split memory allocation prototypes out of user.h 2006-10-20 10:26:36 -07:00
um_mmu.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
um_uaccess.h Remove all inclusions of <linux/config.h> 2006-10-04 03:38:54 -04:00
umid.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
uml_uaccess.h [PATCH] uml: separate libc-dependent uaccess code 2005-11-07 07:53:31 -08:00
user_util.h [PATCH] uml: split memory allocation prototypes out of user.h 2006-10-20 10:26:36 -07:00
user.h [PATCH] uml: split memory allocation prototypes out of user.h 2006-10-20 10:26:36 -07:00