From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 080B5C433EF for ; Fri, 28 Jan 2022 15:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643385539; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=App1zdW8z/WT9LGLW1c/7nysq2HlQmGqZTTF3W5QVoU=; b=doRjT1Zk9Xs6FhO+0eHRwFrP6V78s2cgv/2E6cuS+h9i3sT44Iq2rNLMEXK61/P27+skWt 2OIVX24U3nMY0t6MUPWiNLgvbbKzH4bwlxJPuy2bPAULFU4HEMq3oV7HbiMG1Unw/4btFw Eszgi0FmLiAW/dLFcpFBeXzqLJ9EBwE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-634-uLTUiDqFMcSnHZg23oYOeA-1; Fri, 28 Jan 2022 10:58:56 -0500 X-MC-Unique: uLTUiDqFMcSnHZg23oYOeA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 188771006AA5; Fri, 28 Jan 2022 15:58:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDAEF7B028; Fri, 28 Jan 2022 15:58:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B756D4CA9B; Fri, 28 Jan 2022 15:58:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20SFwmNr026005 for ; Fri, 28 Jan 2022 10:58:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76089200F463; Fri, 28 Jan 2022 15:58:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 717C72144B22 for ; Fri, 28 Jan 2022 15:58:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A80BC101A54C for ; Fri, 28 Jan 2022 15:58:46 +0000 (UTC) Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-153-u5Zmgn4qPXaIE0_uS9i1XQ-1; Fri, 28 Jan 2022 10:58:45 -0500 X-MC-Unique: u5Zmgn4qPXaIE0_uS9i1XQ-1 Received: by mail-qk1-f197.google.com with SMTP id t79-20020a37aa52000000b0047ebe27cb48so5083600qke.16 for ; Fri, 28 Jan 2022 07:58:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=feoZP+F8CU+MhuuvBnIaQ56CdERUV6n68Kc4W9BEtGU=; b=rD1zgugWVsjAI4wlauk8rLiLMIhLP98dQiNPE8FI8cQzFX6rhcYIpDJvziYdVfjH3A QRmntrTK0wcQSGS+GY2qdBW3ntbBHOb65Xxet4oYOhvNqC0UTR9CptbTeuHoVuQuJ6nE fBr0BEatXVOpkIBpLTEdDJEq6G9dGL9fHuv9DMjUrTiBoOYfi47FEyUL/CTv7J0yC83T z7Yzvmcx0ZOrHia+LA1b2uWtnrFQAE53liJqzMDyra/ofGJcgpPsk3ACl8e4FOHKyo8K 5dHzo626V7XhWLDbs0VZXBWCkSFziwHT4ypFNMY+3ub6ylJh2hxkpqBDOOV3ovgsrN/p G1jA== X-Gm-Message-State: AOAM5300SLnonHE6CTo70PuLyVzaQ9QaGikxqs4QEBvrTog5SEp8oMB9 SiOvSwa863ug0NMrAQQ2YraRRfm+YqubGqjJttAwF8k+lV4CEKb4hvXS63JYkgs8U+xrmIeCidq DiN+Z5BRVhZ/D0w== X-Received: by 2002:a37:454d:: with SMTP id s74mr5909292qka.405.1643385524656; Fri, 28 Jan 2022 07:58:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwuxz2dMV0PAXdD547KZ6/o97ih+oVUp28N/1DDUc/W/RNqad0W7Yx08YDHw8QRriC+il69ug== X-Received: by 2002:a37:454d:: with SMTP id s74mr5909286qka.405.1643385524475; Fri, 28 Jan 2022 07:58:44 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id w3sm3005092qta.13.2022.01.28.07.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 07:58:44 -0800 (PST) From: Mike Snitzer To: axboe@kernel.dk Date: Fri, 28 Jan 2022 10:58:39 -0500 Message-Id: <20220128155841.39644-2-snitzer@redhat.com> In-Reply-To: <20220128155841.39644-1-snitzer@redhat.com> References: <20220128155841.39644-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org, dm-devel@redhat.com, hch@lst.de Subject: [dm-devel] [PATCH v4 1/3] block: add bio_start_io_acct_time() to control start_time X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit bio_start_io_acct_time() interface is like bio_start_io_acct() that allows start_time to be passed in. This gives drivers the ability to defer starting accounting until after IO is issued (but possibily not entirely due to bio splitting). Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- block/blk-core.c | 25 +++++++++++++++++++------ include/linux/blkdev.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 97f8bc8d3a79..d93e3bb9a769 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1061,20 +1061,32 @@ void update_io_ticks(struct block_device *part, unsigned long now, bool end) } static unsigned long __part_start_io_acct(struct block_device *part, - unsigned int sectors, unsigned int op) + unsigned int sectors, unsigned int op, + unsigned long start_time) { const int sgrp = op_stat_group(op); - unsigned long now = READ_ONCE(jiffies); part_stat_lock(); - update_io_ticks(part, now, false); + update_io_ticks(part, start_time, false); part_stat_inc(part, ios[sgrp]); part_stat_add(part, sectors[sgrp], sectors); part_stat_local_inc(part, in_flight[op_is_write(op)]); part_stat_unlock(); - return now; + return start_time; +} + +/** + * bio_start_io_acct_time - start I/O accounting for bio based drivers + * @bio: bio to start account for + * @start_time: start time that should be passed back to bio_end_io_acct(). + */ +void bio_start_io_acct_time(struct bio *bio, unsigned long start_time) +{ + __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), + bio_op(bio), start_time); } +EXPORT_SYMBOL_GPL(bio_start_io_acct_time); /** * bio_start_io_acct - start I/O accounting for bio based drivers @@ -1084,14 +1096,15 @@ static unsigned long __part_start_io_acct(struct block_device *part, */ unsigned long bio_start_io_acct(struct bio *bio) { - return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), bio_op(bio)); + return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), + bio_op(bio), jiffies); } EXPORT_SYMBOL_GPL(bio_start_io_acct); unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors, unsigned int op) { - return __part_start_io_acct(disk->part0, sectors, op); + return __part_start_io_acct(disk->part0, sectors, op, jiffies); } EXPORT_SYMBOL(disk_start_io_acct); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 9c95df26fc26..f35aea98bc35 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1258,6 +1258,7 @@ unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors, void disk_end_io_acct(struct gendisk *disk, unsigned int op, unsigned long start_time); +void bio_start_io_acct_time(struct bio *bio, unsigned long start_time); unsigned long bio_start_io_acct(struct bio *bio); void bio_end_io_acct_remapped(struct bio *bio, unsigned long start_time, struct block_device *orig_bdev); -- 2.15.0 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89B4DC433FE for ; Fri, 28 Jan 2022 15:58:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349800AbiA1P6v (ORCPT ); Fri, 28 Jan 2022 10:58:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39627 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245032AbiA1P6r (ORCPT ); Fri, 28 Jan 2022 10:58:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643385526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=feoZP+F8CU+MhuuvBnIaQ56CdERUV6n68Kc4W9BEtGU=; b=g3F94lnge+RwRqyHrcfOsAtScS9MdiIRrsYPW3YyBvUt4Fxlvvomr22g+7gS+8bl+ZGCug Qo6UE8INXKdES0VuFvWIJaegxnQdGSUwIXFHYwmBcOIckXknbDGznwJrlSpARsKhC+yd7X MleYPzqVN9bCGpw8K/rlZnvWjtIgTUw= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-115-7ooOfIh7MIGv-QAUs3zOnQ-1; Fri, 28 Jan 2022 10:58:45 -0500 X-MC-Unique: 7ooOfIh7MIGv-QAUs3zOnQ-1 Received: by mail-qt1-f199.google.com with SMTP id c20-20020ac84e14000000b002d198444921so4784237qtw.23 for ; Fri, 28 Jan 2022 07:58:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=feoZP+F8CU+MhuuvBnIaQ56CdERUV6n68Kc4W9BEtGU=; b=kXjKymwQFfLANK6DuHMokK/U9/HfeXvYc+ICVT8gSbmG7hltqFBZ/IS1NtIPGIh1ED Fdm1RZZ+U1ZDai3086KyKOz9iaHLQycWOMwnkDhwzjeaL2tY2gcn2Ai+ckXUMTR+9gn7 bClPVO/6cg2RMICHB6p5OIPuFeQV2Pzbsm2Qq9uwAM0vLMI7EaOSUJmqMmVRBEiRSpwx QZjxC5WZNHzTsAnWLPAKqc7BZcbHMOikaZb9E2GwJKjzbM4y9PnjYn7iVw9KQlH3rfpR w9jZgw6lY2w4byTPuIsohFs6iQt18LIt02z0jbtmdCHtkeUafineV9ByLk15z9fsKphP rODA== X-Gm-Message-State: AOAM533auHgiLu9+2utC09a1OsWytcDL7e9jMir4rw01OhLhBELk96SJ U5CX5isqUy8j3qYmEW5ZEemQDVn8onGaelHILe8OhEmoFlXsRRy1O6t+AwIDNF8r4YOS4lMT3J5 o7K/LAWF5vRN6dqiPxT/vfw== X-Received: by 2002:a37:454d:: with SMTP id s74mr5909293qka.405.1643385524656; Fri, 28 Jan 2022 07:58:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwuxz2dMV0PAXdD547KZ6/o97ih+oVUp28N/1DDUc/W/RNqad0W7Yx08YDHw8QRriC+il69ug== X-Received: by 2002:a37:454d:: with SMTP id s74mr5909286qka.405.1643385524475; Fri, 28 Jan 2022 07:58:44 -0800 (PST) Received: from localhost (pool-68-160-176-52.bstnma.fios.verizon.net. [68.160.176.52]) by smtp.gmail.com with ESMTPSA id w3sm3005092qta.13.2022.01.28.07.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 07:58:44 -0800 (PST) From: Mike Snitzer To: axboe@kernel.dk Cc: hch@lst.de, dm-devel@redhat.com, linux-block@vger.kernel.org Subject: [PATCH v4 1/3] block: add bio_start_io_acct_time() to control start_time Date: Fri, 28 Jan 2022 10:58:39 -0500 Message-Id: <20220128155841.39644-2-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220128155841.39644-1-snitzer@redhat.com> References: <20220128155841.39644-1-snitzer@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bio_start_io_acct_time() interface is like bio_start_io_acct() that allows start_time to be passed in. This gives drivers the ability to defer starting accounting until after IO is issued (but possibily not entirely due to bio splitting). Reviewed-by: Christoph Hellwig Signed-off-by: Mike Snitzer --- block/blk-core.c | 25 +++++++++++++++++++------ include/linux/blkdev.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 97f8bc8d3a79..d93e3bb9a769 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1061,20 +1061,32 @@ void update_io_ticks(struct block_device *part, unsigned long now, bool end) } static unsigned long __part_start_io_acct(struct block_device *part, - unsigned int sectors, unsigned int op) + unsigned int sectors, unsigned int op, + unsigned long start_time) { const int sgrp = op_stat_group(op); - unsigned long now = READ_ONCE(jiffies); part_stat_lock(); - update_io_ticks(part, now, false); + update_io_ticks(part, start_time, false); part_stat_inc(part, ios[sgrp]); part_stat_add(part, sectors[sgrp], sectors); part_stat_local_inc(part, in_flight[op_is_write(op)]); part_stat_unlock(); - return now; + return start_time; +} + +/** + * bio_start_io_acct_time - start I/O accounting for bio based drivers + * @bio: bio to start account for + * @start_time: start time that should be passed back to bio_end_io_acct(). + */ +void bio_start_io_acct_time(struct bio *bio, unsigned long start_time) +{ + __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), + bio_op(bio), start_time); } +EXPORT_SYMBOL_GPL(bio_start_io_acct_time); /** * bio_start_io_acct - start I/O accounting for bio based drivers @@ -1084,14 +1096,15 @@ static unsigned long __part_start_io_acct(struct block_device *part, */ unsigned long bio_start_io_acct(struct bio *bio) { - return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), bio_op(bio)); + return __part_start_io_acct(bio->bi_bdev, bio_sectors(bio), + bio_op(bio), jiffies); } EXPORT_SYMBOL_GPL(bio_start_io_acct); unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors, unsigned int op) { - return __part_start_io_acct(disk->part0, sectors, op); + return __part_start_io_acct(disk->part0, sectors, op, jiffies); } EXPORT_SYMBOL(disk_start_io_acct); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 9c95df26fc26..f35aea98bc35 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1258,6 +1258,7 @@ unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors, void disk_end_io_acct(struct gendisk *disk, unsigned int op, unsigned long start_time); +void bio_start_io_acct_time(struct bio *bio, unsigned long start_time); unsigned long bio_start_io_acct(struct bio *bio); void bio_end_io_acct_remapped(struct bio *bio, unsigned long start_time, struct block_device *orig_bdev); -- 2.15.0