From patchwork Sat Oct 29 08:08:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9403333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6065460587 for ; Sat, 29 Oct 2016 08:23:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C6902A13D for ; Sat, 29 Oct 2016 08:23:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40F692A60D; Sat, 29 Oct 2016 08:23:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA58C2A13D for ; Sat, 29 Oct 2016 08:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936399AbcJ2IXE (ORCPT ); Sat, 29 Oct 2016 04:23:04 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35252 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754305AbcJ2IPF (ORCPT ); Sat, 29 Oct 2016 04:15:05 -0400 Received: by mail-pf0-f194.google.com with SMTP id s8so3383131pfj.2; Sat, 29 Oct 2016 01:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gfZep6VSjG8D0lMonZt4bc6dbTDwZL+ST7ZBkJpATc4=; b=f4MwRPU2dI06foKdVnwRBEEoH37l+UHL1ROjk4dibqcG6j96+dn1swQQJX5mJAAcI0 gOw5YWZiMGqbzgRCQH1mZtBCproYHr9CKVDgZzWGyK4uxbaU4sZEx7r9+aZx6+wNKdof n9BUhN17RrFk6JJj8rLSgZ6qc1HO8lhJUZ385wSQD2CvhCnc1jDvUYAsgU90WdkK0M92 qKbakKjzlZGSEtZm0fy+RefhlGUNcV/htxS0OQ2471hftbOOXUmxUzKjhh7PZgFqJFHh PXSEvPYfCH+4xK7annG0g3jGuFXMRg7RDOGQBaz3RXKiYl8e97HdylIVqFC/ggs3o8f+ nJew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gfZep6VSjG8D0lMonZt4bc6dbTDwZL+ST7ZBkJpATc4=; b=MbaVwYL88jx97LpBvgoSzv1GLxcLwIVrdw3BjGjUCO3Wzeht1RyImL2L04TK1G17Ru S5F2/c3lNcVR19e5/ezFIyHEhxY6//+u1zZYZBRerp/ADGdqOtvsBxs/JQLz/TtZS1mY uvou0WmOcI0VBRhuJXDsTa/kz72VIouOgSiBshl5F/deiqFgSEGaQj5ujRp0pgb6/3FK dW1Epqh+oXqQFRs+jkYIRiIuyC2BNhhz+6D18tUTr+32v+4VH8pL8gGfU5Pb/Yvm5WXA iuPYjzI2oQWuuZFIdWKCXSSIP4Wh1FxfYuBFtwGm1iMIFjQJPiMWjYqRUxz8heKlhaSq 2GVQ== X-Gm-Message-State: ABUngvcw2lGaUSveARYrDYjsi57mGVAoyHuEqD/6Wu1YwofjodocwrJ6nmceDaISoIu5+w== X-Received: by 10.98.22.23 with SMTP id 23mr31476395pfw.65.1477728904662; Sat, 29 Oct 2016 01:15:04 -0700 (PDT) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id fi6sm23574851pac.20.2016.10.29.01.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2016 01:15:04 -0700 (PDT) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , "Kirill A . Shutemov" , Ming Lei , Jens Axboe Subject: [PATCH 40/60] blk-merge: compute bio->bi_seg_front_size efficiently Date: Sat, 29 Oct 2016 16:08:39 +0800 Message-Id: <1477728600-12938-41-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> References: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is enough to check and compute bio->bi_seg_front_size just after the 1st segment is found, but current code checks that for each bvec, which is inefficient. This patch follows the way in __blk_recalc_rq_segments() for computing bio->bi_seg_front_size, and it is more efficient and code becomes more readable too. Signed-off-by: Ming Lei --- block/blk-merge.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 266c94d1d82f..465d9c65cb41 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -157,22 +157,21 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, bvprvp = &bvprv; sectors += bv.bv_len >> 9; - if (nsegs == 1 && seg_size > front_seg_size) - front_seg_size = seg_size; continue; } new_segment: if (nsegs == queue_max_segments(q)) goto split; + if (nsegs == 1 && seg_size > front_seg_size) + front_seg_size = seg_size; + nsegs++; bvprv = bv; bvprvp = &bvprv; seg_size = bv.bv_len; sectors += bv.bv_len >> 9; - if (nsegs == 1 && seg_size > front_seg_size) - front_seg_size = seg_size; } do_split = false; @@ -185,6 +184,8 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, bio = new; } + if (nsegs == 1 && seg_size > front_seg_size) + front_seg_size = seg_size; bio->bi_seg_front_size = front_seg_size; if (seg_size > bio->bi_seg_back_size) bio->bi_seg_back_size = seg_size;