From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752184AbcBOUGy (ORCPT ); Mon, 15 Feb 2016 15:06:54 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38270 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbcBOUGw (ORCPT ); Mon, 15 Feb 2016 15:06:52 -0500 Subject: Re: [PATCH 1/4] block: bio: introduce helpers to get the 1st and last bvec To: Ming Lei References: <1455519687-23873-1-git-send-email-ming.lei@canonical.com> <1455519687-23873-2-git-send-email-ming.lei@canonical.com> <56C18A25.50803@dev.mellanox.co.il> <20160215174212.648098b0@tom-T450> Cc: Jens Axboe , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig , stable@vger.kernel.org, tom.leiming@gmail.com, Keith Busch , Kent Overstreet From: Sagi Grimberg Message-ID: <56C22FD7.4020005@dev.mellanox.co.il> Date: Mon, 15 Feb 2016 22:06:47 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160215174212.648098b0@tom-T450> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Cc Kent and Keith. > > Follows another version which should be more efficient. > Kent and Keith, I appreciate much if you may give a review on it. > > diff --git a/include/linux/bio.h b/include/linux/bio.h > index 56d2db8..ef45fec 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -278,11 +278,21 @@ static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv) > */ > static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) > { > - struct bvec_iter iter; > + struct bvec_iter iter = bio->bi_iter; > + int idx; > + > + bio_advance_iter(bio, &iter, iter.bi_size); > + > + WARN_ON(!iter.bi_idx && !iter.bi_bvec_done); > + > + if (!iter.bi_bvec_done) > + idx = iter.bi_idx - 1; > + else /* in the middle of bvec */ > + idx = iter.bi_idx; > > - bio_for_each_segment(*bv, bio, iter) > - if (bv->bv_len == iter.bi_size) > - break; > + *bv = bio->bi_io_vec[idx]; > + if (iter.bi_bvec_done) > + bv->bv_len = iter.bi_bvec_done; > } > > /* > This looks good too. > >> >> However, given that it's a regression bug fix I'm not sure it's the best >> idea to add logic here. > > But the issue is obviously in bio_will_gap(), isn't it? > > Simply reverting 52cc6eead9095(block: blk-merge: fast-clone bio when splitting rw bios) > still might cause performance regression too. That's correct. I assume that the bio splitting code affects specific I/O pattern (gappy), however bio_will_gap is also tested for bio merges (even if the bios won't merge eventually). This means that each merge check will invoke bio_advance_iter() which is something I'd like to avoid...