From patchwork Tue Jan 17 21:57:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Moyer X-Patchwork-Id: 9521959 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 A01046020B for ; Tue, 17 Jan 2017 21:57:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DB1728615 for ; Tue, 17 Jan 2017 21:57:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81B4E28617; Tue, 17 Jan 2017 21:57:48 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 D834728615 for ; Tue, 17 Jan 2017 21:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750924AbdAQV5r (ORCPT ); Tue, 17 Jan 2017 16:57:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52868 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750863AbdAQV5q (ORCPT ); Tue, 17 Jan 2017 16:57:46 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEC6FBB1B; Tue, 17 Jan 2017 21:57:46 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCAE684D0F; Tue, 17 Jan 2017 21:57:45 +0000 (UTC) From: Jeff Moyer To: axboe@kernel.dk, linux-block@vger.kernel.org Cc: agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, shli@kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, hch@lst.de Subject: [patch] block: add blktrace C events for bio-based drivers X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Tue, 17 Jan 2017 16:57:45 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 17 Jan 2017 21:57:46 +0000 (UTC) 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 Only a few bio-based drivers actually generate blktrace completion (C) events. Instead of changing all bio-based drivers to call trace_block_bio_complete, move the tracing to bio_complete, and remove the explicit tracing from the few drivers that actually do it. After this patch, there is exactly one caller of trace_block_bio_complete and one caller of trace_block_rq_complete. More importantly, all bio-based drivers now generate C events, which is useful for performance analysis. Suggested-by: Christoph Hellwig Signed-off-by: Jeff Moyer --- Testing: I made sure that request-based drivers don't see duplicate completions, and that bio-based drivers show both Q and C events. I haven't tested all affected drivers or combinations, though. -- 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/block/bio.c b/block/bio.c index 2b37502..ba5daad 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1785,16 +1785,7 @@ static inline bool bio_remaining_done(struct bio *bio) return false; } -/** - * bio_endio - end I/O on a bio - * @bio: bio - * - * Description: - * bio_endio() will end I/O on the whole bio. bio_endio() is the preferred - * way to end I/O on a bio. No one should call bi_end_io() directly on a - * bio unless they own it and thus know that it has an end_io function. - **/ -void bio_endio(struct bio *bio) +void __bio_endio(struct bio *bio) { again: if (!bio_remaining_done(bio)) @@ -1816,6 +1807,22 @@ void bio_endio(struct bio *bio) if (bio->bi_end_io) bio->bi_end_io(bio); } + +/** + * bio_endio - end I/O on a bio + * @bio: bio + * + * Description: + * bio_endio() will end I/O on the whole bio. bio_endio() is the preferred + * way to end I/O on a bio. No one should call bi_end_io() directly on a + * bio unless they own it and thus know that it has an end_io function. + **/ +void bio_endio(struct bio *bio) +{ + trace_block_bio_complete(bdev_get_queue(bio->bi_bdev), + bio, bio->bi_error); + __bio_endio(bio); +} EXPORT_SYMBOL(bio_endio); /** diff --git a/block/blk-core.c b/block/blk-core.c index 61ba08c..f77f2d9 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -153,7 +153,7 @@ static void req_bio_endio(struct request *rq, struct bio *bio, /* don't actually finish bio if it's part of flush sequence */ if (bio->bi_iter.bi_size == 0 && !(rq->rq_flags & RQF_FLUSH_SEQ)) - bio_endio(bio); + __bio_endio(bio); } void blk_dump_rq_flags(struct request *rq, char *msg) @@ -1947,7 +1947,7 @@ generic_make_request_checks(struct bio *bio) err = -EOPNOTSUPP; end_io: bio->bi_error = err; - bio_endio(bio); + __bio_endio(bio); return false; } diff --git a/block/blk.h b/block/blk.h index 041185e..1c9b50a 100644 --- a/block/blk.h +++ b/block/blk.h @@ -57,6 +57,7 @@ int blk_init_rl(struct request_list *rl, struct request_queue *q, gfp_t gfp_mask); void blk_exit_rl(struct request_list *rl); void init_request_from_bio(struct request *req, struct bio *bio); +void __bio_endio(struct bio *bio); void blk_rq_bio_prep(struct request_queue *q, struct request *rq, struct bio *bio); void blk_queue_bypass_start(struct request_queue *q); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 3086da5..e151aef 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -807,7 +807,6 @@ static void dec_pending(struct dm_io *io, int error) queue_io(md, bio); } else { /* done with normal IO or empty flush */ - trace_block_bio_complete(md->queue, bio, io_error); bio->bi_error = io_error; bio_endio(bio); } diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 36c13e4..17b4e06 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -159,8 +159,6 @@ static void return_io(struct bio_list *return_bi) struct bio *bi; while ((bi = bio_list_pop(return_bi)) != NULL) { bi->bi_iter.bi_size = 0; - trace_block_bio_complete(bdev_get_queue(bi->bi_bdev), - bi, 0); bio_endio(bi); } } @@ -4902,8 +4900,6 @@ static void raid5_align_endio(struct bio *bi) rdev_dec_pending(rdev, conf->mddev); if (!error) { - trace_block_bio_complete(bdev_get_queue(raid_bi->bi_bdev), - raid_bi, 0); bio_endio(raid_bi); if (atomic_dec_and_test(&conf->active_aligned_reads)) wake_up(&conf->wait_for_quiescent); @@ -5470,8 +5466,6 @@ static void raid5_make_request(struct mddev *mddev, struct bio * bi) if ( rw == WRITE ) md_write_end(mddev); - trace_block_bio_complete(bdev_get_queue(bi->bi_bdev), - bi, 0); bio_endio(bi); } } @@ -5878,11 +5872,9 @@ static int retry_aligned_read(struct r5conf *conf, struct bio *raid_bio) handled++; } remaining = raid5_dec_bi_active_stripes(raid_bio); - if (remaining == 0) { - trace_block_bio_complete(bdev_get_queue(raid_bio->bi_bdev), - raid_bio, 0); + if (remaining == 0) bio_endio(raid_bio); - } + if (atomic_dec_and_test(&conf->active_aligned_reads)) wake_up(&conf->wait_for_quiescent); return handled;