[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131104201204.GA27733@kmo>
Date: Mon, 4 Nov 2013 12:12:04 -0800
From: Kent Overstreet <kmo@...erainc.com>
To: Mikulas Patocka <mpatocka@...hat.com>
Cc: Jens Axboe <axboe@...nel.dk>, Mike Snitzer <snitzer@...hat.com>,
dm-devel@...hat.com, linux-kernel@...r.kernel.org,
Alasdair Kergon <agk@...hat.com>
Subject: Re: [PATCH for-next] dm: fix missing bi_remaining accounting
On Mon, Nov 04, 2013 at 10:06:00AM -0500, Mikulas Patocka wrote:
>
>
> On Fri, 1 Nov 2013, Jens Axboe wrote:
>
> > On 11/01/2013 07:59 AM, Mike Snitzer wrote:
> > > Add the missing bi_remaining increment, required by the block layer's
> > > new bio-chaining code, to both the verity and old snapshot DM targets.
> > >
> > > Otherwise users will hit the bi_remaining <= 0 BUG_ON in bio_endio().
> >
> > Thanks Mike, added to the mix.
> >
> > --
> > Jens Axboe
>
> Hi
>
> This improves a little bit on the previous patch, by replacing costly
> atomic_inc with cheap atomic_set.
IMO, this is a bad idea; the behaviour with this patch does _not_ match the
naming of bio_endio_nodec(), and the performance difference should be well in
the noise anyways because we're touching a cacheline we already have in cache
and won't be contended.
The fact that it's currently safe is accidental, I could see this easily
tripping people up and being a pain in the ass to debug in the future.
>
>
> From: Mikulas Patocka <mpatocka@...hat.com>
>
> dm: change atomic_inc to atomic_set(1)
>
> There are places in dm where we save bi_endio and bi_private, set them to
> target's routine, submit the bio, from the target's bi_endio routine we
> restore bi_endio and bi_private and end the bio with bi_endio.
>
> This causes underflow of bi_remaining, so we must restore bi_remaining
> before ending the bio from the target bi_endio routine.
>
> The code uses atomic_inc for restoration of bi_remaining. This patch
> changes it to atomic_set(1) to avoid an interlocked instruction. In the
> target's bi_endio routine we are sure that bi_remaining is zero
> (otherwise, the bi_endio routine wouldn't be called) and there are no
> concurrent users of the bio, so we can replace atomic_inc with
> atomic_set(1).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists