From patchwork Mon Feb 15 09:42:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8312141 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5EAA1C02AA for ; Mon, 15 Feb 2016 09:42:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 75A512041B for ; Mon, 15 Feb 2016 09:42:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20D35203A5 for ; Mon, 15 Feb 2016 09:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752600AbcBOJmw (ORCPT ); Mon, 15 Feb 2016 04:42:52 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52630 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752241AbcBOJmb (ORCPT ); Mon, 15 Feb 2016 04:42:31 -0500 Received: from [116.251.208.106] (helo=tom-T450) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1aVFfn-0005MK-AL; Mon, 15 Feb 2016 09:42:27 +0000 Date: Mon, 15 Feb 2016 17:42:12 +0800 From: Ming Lei To: Sagi Grimberg 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 Subject: Re: [PATCH 1/4] block: bio: introduce helpers to get the 1st and last bvec Message-ID: <20160215174212.648098b0@tom-T450> In-Reply-To: <56C18A25.50803@dev.mellanox.co.il> 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> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Mon, 15 Feb 2016 10:19:49 +0200 Sagi Grimberg wrote: > > > +/* > > + * bio_get_last_bvec() is introduced to get the last bvec of one > > + * bio for bio_will_gap(). > > + * > > + * TODO: make it more efficient. > > + */ > > +static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) > > +{ > > + struct bvec_iter iter; > > + > > + bio_for_each_segment(*bv, bio, iter) > > + if (bv->bv_len == iter.bi_size) > > + break; > > +} > > This helper is used for each req/bio once or more. I'd say No, the helper is only used for the non-splitted BIO, and all splitted BIO is marked as non-merge. > it's critical to make it efficient and not settle for > a quick bail for drivers that don't have a virt_boundary > like you did in patch #2. 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. > > 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. > -- > To unsubscribe from this list: send the line "unsubscribe linux-block" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; } /*