Zach Brown 1ebb1101c5 [PATCH] Fix lock inversion aio_kick_handler()
lockdep found a AB BC CA lock inversion in retry-based AIO:

1) The task struct's alloc_lock (A) is acquired in process context with
   interrupts enabled.  An interrupt might arrive and call wake_up() which
   grabs the wait queue's q->lock (B).

2) When performing retry-based AIO the AIO core registers
   aio_wake_function() as the wake funtion for iocb->ki_wait.  It is called
   with the wait queue's q->lock (B) held and then tries to add the iocb to
   the run list after acquiring the ctx_lock (C).

3) aio_kick_handler() holds the ctx_lock (C) while acquiring the
   alloc_lock (A) via lock_task() and unuse_mm().  Lockdep emits a warning
   saying that we're trying to connect the irq-safe q->lock to the
   irq-unsafe alloc_lock via ctx_lock.

This fixes the inversion by calling unuse_mm() in the AIO kick handing path
after we've released the ctx_lock.  As Ben LaHaise pointed out __put_ioctx
could set ctx->mm to NULL, so we must only access ctx->mm while we have the
lock.

Signed-off-by: Zach Brown <zach.brown@oracle.com>
Signed-off-by: Suparna Bhattacharya <suparna@in.ibm.com>
Acked-by: Benjamin LaHaise <bcrl@kvack.org>
Cc: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-30 10:55:54 -08:00
..
2006-12-08 08:28:43 -08:00
2006-12-08 08:28:44 -08:00
2006-12-15 12:51:22 -05:00
2006-12-08 08:28:45 -08:00
2006-12-15 12:51:51 -05:00
2006-12-08 08:28:45 -08:00
2006-12-08 08:28:45 -08:00
2006-12-08 08:28:45 -08:00
2006-12-08 08:28:46 -08:00
2006-12-08 08:28:47 -08:00
2006-11-16 11:43:38 -08:00
2006-12-08 08:28:48 -08:00
2006-12-08 08:28:49 -08:00
2006-12-08 08:28:49 -08:00
2006-12-08 08:28:50 -08:00
2006-12-08 08:28:50 -08:00
2006-11-16 11:43:38 -08:00
2006-10-04 06:51:26 -06:00
2006-12-07 08:39:25 -08:00
2006-12-13 09:05:50 -08:00
2006-12-07 08:39:25 -08:00
2006-12-13 09:05:50 -08:00
2006-10-01 00:39:19 -07:00
2006-12-13 09:05:47 -08:00
2006-12-22 08:55:48 -08:00