Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Tejun Heo
Hello, Dave. On Wed, Sep 05, 2012 at 01:57:59PM +1000, Dave Chinner wrote: > > But, yeah, this can't be solved by enlarging the stack size. The > > upper limit is unbound. > > Sure, but recursion issue is isolated to the block layer. > > If we can still submit IO directly through the block laye

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Dave Chinner
On Tue, Sep 04, 2012 at 11:26:33AM -0700, Tejun Heo wrote: > Hello, > > On Tue, Sep 04, 2012 at 09:54:23AM -0400, Vivek Goyal wrote: > > > Given that we are working around stack depth issues in the > > > filesystems already in several places, and now it seems like there's > > > a reason to work ar

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Tejun Heo
Hello, On Tue, Sep 04, 2012 at 12:42:37PM -0700, Kent Overstreet wrote: > You want to point me at the relevant workqueue code? I'd really like to > see what you did there, it's entirely possible you're aware of some > issue I'm not but if not I'd like to take a stab at it. I was mistaken. The is

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Kent Overstreet
On Tue, Sep 04, 2012 at 12:01:19PM -0700, Tejun Heo wrote: > On Tue, Sep 04, 2012 at 11:55:40AM -0700, Tejun Heo wrote: > > Actually, if the timer approach can reduce the frequency of rescuer > > involvement, I think it could actually be better. > > Ooh, it wouldn't. It's kicking in only after al

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Kent Overstreet
On Tue, Sep 04, 2012 at 11:55:40AM -0700, Tejun Heo wrote: > Hello, Mikulas, Kent. > > On Mon, Sep 03, 2012 at 08:41:00PM -0700, Kent Overstreet wrote: > > On Mon, Sep 03, 2012 at 04:41:37PM -0400, Mikulas Patocka wrote: > > > ... or another possibility - start a timer when something is put to >

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Vivek Goyal
On Tue, Sep 04, 2012 at 03:26:19PM -0400, Mikulas Patocka wrote: [..] > BTW. can these new-style timerless plugs introduce deadlocks too? What > happens when some bios are indefinitely delayed because their requests are > held in a plug and a mempool runs out? I think they will not deadlock bec

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Mikulas Patocka
On Mon, 3 Sep 2012, Kent Overstreet wrote: > On Mon, Sep 03, 2012 at 04:41:37PM -0400, Mikulas Patocka wrote: > > ... or another possibility - start a timer when something is put to > > current->bio_list and use that timer to pop entries off current->bio_list > > and submit them to a workqueue

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Tejun Heo
On Tue, Sep 04, 2012 at 11:55:40AM -0700, Tejun Heo wrote: > Actually, if the timer approach can reduce the frequency of rescuer > involvement, I think it could actually be better. Ooh, it wouldn't. It's kicking in only after alloc failure. I don't know. I think conditioning it on alloc failure

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Tejun Heo
Hello, Mikulas, Kent. On Mon, Sep 03, 2012 at 08:41:00PM -0700, Kent Overstreet wrote: > On Mon, Sep 03, 2012 at 04:41:37PM -0400, Mikulas Patocka wrote: > > ... or another possibility - start a timer when something is put to > > current->bio_list and use that timer to pop entries off current->bi

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Tejun Heo
Hello, On Tue, Sep 04, 2012 at 09:54:23AM -0400, Vivek Goyal wrote: > > Given that we are working around stack depth issues in the > > filesystems already in several places, and now it seems like there's > > a reason to work around it in the block layers as well, shouldn't we > > simply increase t

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Vivek Goyal
On Fri, Aug 31, 2012 at 07:13:48PM -0700, Tejun Heo wrote: > Hello, Vivek. > > On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > > Here is one quick and dirty proof of concept patch. It checks for stack > > depth and if remaining space is less than 20% of stack size, then it > > defer

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-04 Thread Vivek Goyal
On Mon, Sep 03, 2012 at 10:49:27AM +1000, Dave Chinner wrote: > On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > > On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > > > > [..] > > > > Performance aside, punting submission to per device worker in case of > > > > deep

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-03 Thread Kent Overstreet
On Mon, Sep 03, 2012 at 04:41:37PM -0400, Mikulas Patocka wrote: > ... or another possibility - start a timer when something is put to > current->bio_list and use that timer to pop entries off current->bio_list > and submit them to a workqueue. The timer can be cpu-local so only > interrupt mask

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-03 Thread Mikulas Patocka
On Thu, 30 Aug 2012, Kent Overstreet wrote: > On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > > On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > > > > [..] > > > > Performance aside, punting submission to per device worker in case of > > > > deep > > > > stack

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-02 Thread Kent Overstreet
On Fri, Aug 31, 2012 at 11:01:59AM -0400, Vivek Goyal wrote: > On Thu, Aug 30, 2012 at 06:43:59PM -0700, Kent Overstreet wrote: > > On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > > > On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > > > > > > [..] > > > > > Perform

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-02 Thread Kent Overstreet
On Mon, Sep 03, 2012 at 10:49:27AM +1000, Dave Chinner wrote: > Given that we are working around stack depth issues in the > filesystems already in several places, and now it seems like there's > a reason to work around it in the block layers as well, shouldn't we > simply increase the default stac

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-09-02 Thread Dave Chinner
On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > > [..] > > > Performance aside, punting submission to per device worker in case of deep > > > stack usage sounds cleaner solution to me. > > > > Agreed, but performanc

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-31 Thread Tejun Heo
Hello, Vivek. On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > Here is one quick and dirty proof of concept patch. It checks for stack > depth and if remaining space is less than 20% of stack size, then it > defers the bio submission to per queue worker. So, it removes breadth-first

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-31 Thread Vivek Goyal
On Thu, Aug 30, 2012 at 06:43:59PM -0700, Kent Overstreet wrote: > On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > > On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > > > > [..] > > > > Performance aside, punting submission to per device worker in case of > > > > d

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-30 Thread Kent Overstreet
On Thu, Aug 30, 2012 at 6:43 PM, Kent Overstreet wrote: > On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: >> On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: >> >> [..] >> > > Performance aside, punting submission to per device worker in case of >> > > deep >> > > sta

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-30 Thread Kent Overstreet
On Thu, Aug 30, 2012 at 06:07:45PM -0400, Vivek Goyal wrote: > On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > > [..] > > > Performance aside, punting submission to per device worker in case of deep > > > stack usage sounds cleaner solution to me. > > > > Agreed, but performanc

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-30 Thread Vivek Goyal
On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: [..] > > Performance aside, punting submission to per device worker in case of deep > > stack usage sounds cleaner solution to me. > > Agreed, but performance tends to matter in the real world. And either > way the tricky bits are g

Re: [dm-devel] [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread John Stoffel
> "Kent" == Kent Overstreet writes: Kent> On Wed, Aug 29, 2012 at 03:39:14PM +0100, Alasdair G Kergon wrote: >> It's also instructive to remember why the code is the way it is: it used >> to process bios for underlying devices immediately, but this sometimes >> meant too much recursive stack

Re: [dm-devel] [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Kent Overstreet
On Wed, Aug 29, 2012 at 05:01:09PM -0400, John Stoffel wrote: > > "Kent" == Kent Overstreet writes: > > Kent> On Wed, Aug 29, 2012 at 03:39:14PM +0100, Alasdair G Kergon wrote: > >> It's also instructive to remember why the code is the way it is: it used > >> to process bios for underlying de

Re: [dm-devel] [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Kent Overstreet
On Wed, Aug 29, 2012 at 06:23:36PM +0100, Alasdair G Kergon wrote: > On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > > Only on allocation failure. > > Which as you already said assumes wrapping together the other mempools in the > submission path first... Yes? I'm not sure wha

Re: [dm-devel] [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Alasdair G Kergon
On Wed, Aug 29, 2012 at 10:13:45AM -0700, Kent Overstreet wrote: > Only on allocation failure. Which as you already said assumes wrapping together the other mempools in the submission path first... Alasdair -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body o

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Kent Overstreet
On Wed, Aug 29, 2012 at 01:07:11PM -0400, Vivek Goyal wrote: > On Wed, Aug 29, 2012 at 09:50:06AM -0700, Kent Overstreet wrote: > > [..] > > > The problem is that majority of device mapper code assumes that if we > > > submit a bio, that bio will be finished in a finite time. The commit > > > d8

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Vivek Goyal
On Wed, Aug 29, 2012 at 09:50:06AM -0700, Kent Overstreet wrote: [..] > > The problem is that majority of device mapper code assumes that if we > > submit a bio, that bio will be finished in a finite time. The commit > > d89d87965dcbe6fe4f96a2a7e8421b3a75f634d1 in 2.6.22 broke this assumption. >

Re: [dm-devel] [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Alasdair G Kergon
On Wed, Aug 29, 2012 at 09:50:06AM -0700, Kent Overstreet wrote: > The other thing we could do is make the rescuer thread per block device > (which arguably makes more sense than per bio_set anyways), then > associate bio_sets with specific block devices/rescuers. For dm, it's equivalent - alread

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Kent Overstreet
On Wed, Aug 29, 2012 at 12:24:43PM -0400, Mikulas Patocka wrote: > Hi > > This fixes the bio allocation problems, but doesn't fix a similar deadlock > in device mapper when allocating from md->io_pool or other mempools in > the target driver. Ick. That is a problem. There are a bunch of mempoo

Re: [dm-devel] [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Kent Overstreet
On Wed, Aug 29, 2012 at 03:39:14PM +0100, Alasdair G Kergon wrote: > It's also instructive to remember why the code is the way it is: it used > to process bios for underlying devices immediately, but this sometimes > meant too much recursive stack growth. If a per-device rescuer thread > is to be

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Mikulas Patocka
Hi This fixes the bio allocation problems, but doesn't fix a similar deadlock in device mapper when allocating from md->io_pool or other mempools in the target driver. The problem is that majority of device mapper code assumes that if we submit a bio, that bio will be finished in a finite time

Re: [dm-devel] [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Alasdair G Kergon
On Wed, Aug 29, 2012 at 08:57:59AM -0400, Vivek Goyal wrote: > I would say keep all the bio splitting patches and any fixes w.r.t > deadlocks in a seprate series. As this is little complicated and a lot > of is just theoritical corner cases. If you limit this series to just > bio_set related cleanu

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-29 Thread Vivek Goyal
On Tue, Aug 28, 2012 at 08:25:58PM -0700, Kent Overstreet wrote: [..] > Except that when thread a goes to punt those blocked bios to its > rescuer, it punts _all_ the bios on current->bio_list. Even those > generated by/belonging to other bio_sets. > > So thread 1 in device b punts bios to its re

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Kent Overstreet
On Tue, Aug 28, 2012 at 09:31:50PM -0400, Vivek Goyal wrote: > On Tue, Aug 28, 2012 at 04:01:08PM -0700, Kent Overstreet wrote: > > On Tue, Aug 28, 2012 at 03:28:00PM -0700, Kent Overstreet wrote: > > > On Tue, Aug 28, 2012 at 01:49:10PM -0700, Tejun Heo wrote: > > > > Overall, I *think* this is co

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Vivek Goyal
On Tue, Aug 28, 2012 at 04:01:08PM -0700, Kent Overstreet wrote: > On Tue, Aug 28, 2012 at 03:28:00PM -0700, Kent Overstreet wrote: > > On Tue, Aug 28, 2012 at 01:49:10PM -0700, Tejun Heo wrote: > > > Overall, I *think* this is correct but need to think more about it to > > > be sure. > > > > Plea

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Kent Overstreet
On Tue, Aug 28, 2012 at 03:28:00PM -0700, Kent Overstreet wrote: > On Tue, Aug 28, 2012 at 01:49:10PM -0700, Tejun Heo wrote: > > Overall, I *think* this is correct but need to think more about it to > > be sure. > > Please do. As much time as I've spent staring at this kind of stuff, > I'm pretty

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Kent Overstreet
On Tue, Aug 28, 2012 at 01:49:10PM -0700, Tejun Heo wrote: > Hello, > > On Tue, Aug 28, 2012 at 10:37:36AM -0700, Kent Overstreet wrote: > > @@ -324,13 +342,37 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int > > nr_iovecs, struct bio_set *bs) > > front_pad = 0; > > inl

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Kent Overstreet
On Tue, Aug 28, 2012 at 06:06:10PM -0400, Vivek Goyal wrote: > On Tue, Aug 28, 2012 at 10:37:36AM -0700, Kent Overstreet wrote: > > Previously, if we ever try to allocate more than once from the same bio > > set while running under generic_make_request() (i.e. a stacking block > > driver), we risk

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Vivek Goyal
On Tue, Aug 28, 2012 at 10:37:36AM -0700, Kent Overstreet wrote: > Previously, if we ever try to allocate more than once from the same bio > set while running under generic_make_request() (i.e. a stacking block > driver), we risk deadlock. > > This is because of the code in generic_make_request()

Re: [PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Tejun Heo
Hello, On Tue, Aug 28, 2012 at 10:37:36AM -0700, Kent Overstreet wrote: > @@ -324,13 +342,37 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int > nr_iovecs, struct bio_set *bs) > front_pad = 0; > inline_vecs = nr_iovecs; > } else { > + /* > +

[PATCH v7 9/9] block: Avoid deadlocks with bio allocation by stacking drivers

2012-08-28 Thread Kent Overstreet
Previously, if we ever try to allocate more than once from the same bio set while running under generic_make_request() (i.e. a stacking block driver), we risk deadlock. This is because of the code in generic_make_request() that converts recursion to iteration; any bios we submit won't actually be