All of lore.kernel.org
 help / color / mirror / Atom feed
* Deadlocks due to per-process plugging
@ 2012-07-11 13:37 Jan Kara
  2012-07-11 16:05 ` Jeff Moyer
  0 siblings, 1 reply; 33+ messages in thread
From: Jan Kara @ 2012-07-11 13:37 UTC (permalink / raw)
  To: LKML; +Cc: linux-fsdevel, Tejun Heo, Jens Axboe

  Hello,

  we've recently hit a deadlock in our QA runs which is caused by the
per-process plugging code. The problem is as follows:
  process A					process B (kjournald)
  generic_file_aio_write()
    blk_start_plug(&plug);
    ...
    somewhere in here we allocate memory and
    direct reclaim submits buffer X for IO
    ...
    ext3_write_begin()
      ext3_journal_start()
        we need more space in a journal
        so we want to checkpoint old transactions,
        we block waiting for kjournald to commit
        a currently running transaction.
						journal_commit_transaction()
						  wait for IO on buffer X
						  to complete as it is part
						  of the current transaction

  => deadlock since A waits for B and B waits for A to do unplug.
BTW: I don't think this is really ext3/ext4 specific. I think other
filesystems can get into problems as well when direct reclaim submits some
IO and the process subsequently blocks without submitting the IO.

Effectively the per process plugging introduces a lock dependency
buffer_lock -> any lock acquired after IO submission before the process'
queue is unplugged. This certainly creates lots of cycles in the lock
dependency graph...

I'm wondering how we should fix this best. Trivial fix would be to flush
the IO plug on every schedule, not just io_schedule(), but that can have
some peformance implications I guess (the effect of plugging would be very
limited). Better (although more tedious) solution would be to push the
plugs from higher levels down into the filesystems where they could be
managed to not create problematic lock dependencies (but e.g. for ext3/ext4
that means we have to unplug after writing each page so it is effectively
rather similar to unplugging on every schedule()).

Thoughts?

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2012-07-23  9:47 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11 13:37 Deadlocks due to per-process plugging Jan Kara
2012-07-11 16:05 ` Jeff Moyer
2012-07-11 20:16   ` Jan Kara
2012-07-11 22:12     ` Thomas Gleixner
2012-07-12  4:12       ` Mike Galbraith
2012-07-13 12:38       ` Jan Kara
2012-07-12  2:07     ` Mike Galbraith
2012-07-12 14:15     ` Thomas Gleixner
2012-07-13 12:33       ` Jan Kara
2012-07-13 14:25         ` Thomas Gleixner
2012-07-13 14:46           ` Jan Kara
2012-07-15  8:59             ` Thomas Gleixner
2012-07-15  9:14               ` Mike Galbraith
2012-07-15  9:51                 ` Thomas Gleixner
2012-07-16  2:22                 ` Mike Galbraith
2012-07-16  8:59                   ` Thomas Gleixner
2012-07-16  9:48                     ` Mike Galbraith
2012-07-16  9:59                       ` Thomas Gleixner
2012-07-16 10:13                         ` Mike Galbraith
2012-07-16 10:08                       ` Mike Galbraith
2012-07-16 10:19                         ` Thomas Gleixner
2012-07-16 10:30                           ` Mike Galbraith
2012-07-16 11:24                           ` Mike Galbraith
2012-07-16 14:35                             ` Mike Galbraith
2012-07-17 13:10                           ` Mike Galbraith
2012-07-18  4:44                             ` Mike Galbraith
2012-07-18  5:30                               ` Mike Galbraith
2012-07-21  7:47                                 ` Mike Galbraith
2012-07-22 18:43                                   ` Mike Galbraith
2012-07-23  9:46                                     ` Mike Galbraith
2012-07-14 11:00           ` Mike Galbraith
2012-07-14 11:06             ` Mike Galbraith
2012-07-15  7:14             ` Mike Galbraith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.