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 5B216C433F5 for ; Fri, 28 Jan 2022 04:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643343490; 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=LPWr3ykwkO/t93MmEQqErnSDVP8tnNk02jNvCVJlyMY=; b=Z3Ry6TTYRkM2jcYRtvTUwHKJBKLym36QSdAsZsdHpbacOysxmPXl1KF7KGwlJPbBMOqq1/ 4bGuDuO2qc7Lnfp0St90fLdFCNX2lUJAtfr/69JcqMhvHqNvq3Pj/TmhVogP8HdcXdhUGG 6fbmsKwyFtVSJfHN/3T/ZjnXD6AGvr4= 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-62-HfPao5fSPs6aJLypVktE_g-1; Thu, 27 Jan 2022 23:18:06 -0500 X-MC-Unique: HfPao5fSPs6aJLypVktE_g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07037814264; Fri, 28 Jan 2022 04:18:02 +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 E09DC4DC17; Fri, 28 Jan 2022 04:18:01 +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 055944A7C9; Fri, 28 Jan 2022 04:18:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20S4HvZu009722 for ; Thu, 27 Jan 2022 23:17:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 99521141DEE2; Fri, 28 Jan 2022 04:17:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 95B9A141DEE1 for ; Fri, 28 Jan 2022 04:17:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 7A00329AB44F for ; Fri, 28 Jan 2022 04:17:57 +0000 (UTC) Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-qTBJ8PJ3NRCe6-Di-sVZKQ-1; Thu, 27 Jan 2022 23:17:56 -0500 X-MC-Unique: qTBJ8PJ3NRCe6-Di-sVZKQ-1 Received: by mail-qk1-f199.google.com with SMTP id l23-20020a37f517000000b0049b8b31c76cso4008132qkk.4 for ; Thu, 27 Jan 2022 20:17:56 -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=LPT/xXbA8dMnjNDPrd3foEhpTUzqW1ZlXYJLQcHQMDc=; b=hTrO937neo47Sjm//gmAe5hMwk3kopalkL+Bpd0V6XY3AGgLjHpfisQ2hLoced2Cb2 QlwlOQoE8mLKeffXVen6cwaJRX3HuMXAXWXWxyh95QeoMlYAz70EQrVEvczkpWPWJh9i /6TRz12X3IFFzrN50AV2jlk/3OGT+WFYl/xo+D/vBU9LFBMQ5j58uN4r5nQluKVk5nk/ 5Yt8/hYg/3b1CrVlXGE0QmmLTZWZ1/Zyls4Y+ki6jeDARRGwpTXyIh4SotJjhJCwKqJ3 iymEQKc5izRAZQdRrA1Cy2KwNJAxnuaqpvfUfSLVnvfY2TL7bxHSkxL79l/ElW7UIdSQ ViSw== X-Gm-Message-State: AOAM533ZfzpnqCcIZcBHH3hV9G5XFQclsLgMfykgbpb0eLpzYf/SBgoL mEKAjI4j7DLZOyV/mTiDQjxE4EyscpkuDPlJb6daSqWQ7/KWjvJcAr/ufl5T9lRDhwvhKCMTU58 LzaO6V6InKj6QMg== X-Received: by 2002:a05:622a:2ca:: with SMTP id a10mr2856215qtx.298.1643343475935; Thu, 27 Jan 2022 20:17:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5RF7BzncHiFMVWiTMxZmqy6R9FtGtyMp3kV52MUk+7hmiCaTdZrq/spDha5BE/Q8LIfYHBA== X-Received: by 2002:a05:622a:2ca:: with SMTP id a10mr2856214qtx.298.1643343475751; Thu, 27 Jan 2022 20:17:55 -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 d13sm2318189qtx.35.2022.01.27.20.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 20:17:55 -0800 (PST) From: Mike Snitzer To: axboe@kernel.dk Date: Thu, 27 Jan 2022 23:17:51 -0500 Message-Id: <20220128041753.32195-2-snitzer@redhat.com> In-Reply-To: <20220128041753.32195-1-snitzer@redhat.com> References: <20220128041753.32195-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org, dm-devel@redhat.com, hch@lst.de Subject: [dm-devel] [PATCH v3 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.15 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). 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 B3BF9C433FE for ; Fri, 28 Jan 2022 04:17:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345964AbiA1ER6 (ORCPT ); Thu, 27 Jan 2022 23:17:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42121 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236875AbiA1ER6 (ORCPT ); Thu, 27 Jan 2022 23:17:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643343477; 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=LPT/xXbA8dMnjNDPrd3foEhpTUzqW1ZlXYJLQcHQMDc=; b=IWw27skig7vTTsjsuyw07AtIx+PfRVzbIs8XXmObRMqgNE0tV5hPMXnQ0CpjPC8ynUH+Z6 Gas4EEked27Nh9T344WqIanyc/zXHyFNZ+ufELx72QU5eOXC+B2WR607C76GtYZQl2RoNC iiKL86vFfb07hbaXSQC+vJn63nzdNes= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-347-PQGmj2gNOXi3vL-ZsY_BCg-1; Thu, 27 Jan 2022 23:17:56 -0500 X-MC-Unique: PQGmj2gNOXi3vL-ZsY_BCg-1 Received: by mail-qv1-f70.google.com with SMTP id u15-20020a0cec8f000000b00425d89d8be0so2586640qvo.20 for ; Thu, 27 Jan 2022 20:17:56 -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=LPT/xXbA8dMnjNDPrd3foEhpTUzqW1ZlXYJLQcHQMDc=; b=x9/YsV6c/1Z+2a4XM4Tl/Di9lRCKr7/NWqY90tWlUUx4N4TtmORNDA6UvYQ0ICHnQE OIqXcmp/1lmERbhorUTCDpEfw6I/v/dTTh5Zkx+odli/XRNfoN2BiVpZiP0jYx3phNfP KPLI8WCGpBQ+ngu+tqiepdzMXipEqqak6upAR6IJmLaYNgfap7V5Ho89sQGryaGkgjc3 xYr4tILWfTeTVj0jha3YQrdx78p0OuLoB/vvikoPPnT73ClfXS5f8Y5mEabY+AZvOBHe FRBdkVLFmnVAOw6701bGS+t1NRoJIJ2fPVWvphEPyS7VPz0Bkw+5Ys34SQ8q0oqHyhc4 irEA== X-Gm-Message-State: AOAM5338JadSw9R8KXmurEM1jsDw+ZXRzeN9Eb1PXjkMmmtp2/oo+zia mxrh8vG4IuaTeY5VS3C9fZrIIcv9YEMZjoN5TFKYP1QAcigdv17y8khrvJcp1MzA2Tmzuf6ZfpL U1TXIbs+GcLUqdgYJgZITJw== X-Received: by 2002:a05:622a:2ca:: with SMTP id a10mr2856217qtx.298.1643343475936; Thu, 27 Jan 2022 20:17:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5RF7BzncHiFMVWiTMxZmqy6R9FtGtyMp3kV52MUk+7hmiCaTdZrq/spDha5BE/Q8LIfYHBA== X-Received: by 2002:a05:622a:2ca:: with SMTP id a10mr2856214qtx.298.1643343475751; Thu, 27 Jan 2022 20:17:55 -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 d13sm2318189qtx.35.2022.01.27.20.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 20:17:55 -0800 (PST) From: Mike Snitzer To: axboe@kernel.dk Cc: hch@lst.de, dm-devel@redhat.com, linux-block@vger.kernel.org Subject: [PATCH v3 1/3] block: add bio_start_io_acct_time() to control start_time Date: Thu, 27 Jan 2022 23:17:51 -0500 Message-Id: <20220128041753.32195-2-snitzer@redhat.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20220128041753.32195-1-snitzer@redhat.com> References: <20220128041753.32195-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). 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