Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp869622pxb; Tue, 1 Feb 2022 12:06:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnXKKfN9ADS4ssmD7KyudM9LonDDZRjUxkkH0BGtoYrj43Bl64Cap8DvKo0UO/XWZka1zG X-Received: by 2002:a17:907:2da3:: with SMTP id gt35mr14240428ejc.262.1643746005629; Tue, 01 Feb 2022 12:06:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643746005; cv=none; d=google.com; s=arc-20160816; b=GEuVLeG+JEyZFn4e6ykBi9RZ+jO22NzhaZdsga+xlYhzS7A9XzjVjlS5/kV7mBiyV5 ReultLnaHRYzsCxcbGV3g97sfuHDD5zObj/3amx7l1X1CQRQabct1/4GGU6QsKNX9hBP siBg7rbNfyWQYbC45u/dcbfX8xHORk56YjC4SOznt/j290GCdV8BxsUkzwX4Wex28U8J etbOWCNSaPDjv0I2XbbvRZ/W4iRV67brKMCOaoiQWn3yXhr8zQYgiErucq3PhCH7CH5a uV4CaAjZMHpIkcVnJC0gc6idwUsiuvFstvJsAdwoCy6paGLem9+nvcmB+VXBtLoiHYli LkvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rV3qQ4qFT971ebGWA0XLzmUkkdWvzEIjl+vXZZVNUcA=; b=N6F6IifWvRri7TOMSObbcPKUAehbTIaH909BNzR7d9ghBkB1sWtXOmLwN53f4nLNMI Q1sgl6FV6e7lHZpK77uhRQ/tuRXTJneaqC3dOLblPVELvUFag6Wu5I+UvKK/tLmg1phx Uizdd4EsWQsh3UKihyTVDh7nYyof5OSVmd1JqelBG/ZfknoN7klDW1zaqndlalfuD3ae /vwvlmVy5++NdZ5dqEJFNVAzTlqos2dgTFHx0SbQKu9ftZf7FxjlOZc2b6vKFCjBW978 xGDN6201hzoWLt2HQ9cXaAGD1VayWpoJSLvTLTMive3Vcx9LjMVhRK7FuXMPkFboR5AM Kl8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tcM1cp7t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb34si10405582ejc.932.2022.02.01.12.06.19; Tue, 01 Feb 2022 12:06:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tcM1cp7t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377525AbiAaLSX (ORCPT + 99 others); Mon, 31 Jan 2022 06:18:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377559AbiAaLKM (ORCPT ); Mon, 31 Jan 2022 06:10:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90CF9C061788; Mon, 31 Jan 2022 03:08:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2FFBD60B28; Mon, 31 Jan 2022 11:08:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C1B1C340E8; Mon, 31 Jan 2022 11:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627316; bh=Ezrjp41BQos58bLBn/gP88p9AnpGvwixoOcJrn2JmEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcM1cp7tKNHQsF+eSRT54nmtWd8BGJ8aKot7pv2xn5n8VDcn2Seq3SRv/IUv8dM42 FqaabrkhzsSeJVBKp5ygEsze4VyWVcudUTtOoGzFt6+tknTXRlfK6126zYhrk+B2Fz LUphbRMfuPEo/sQOfBrRwftoaoxboN3sJcsystYA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Mike Snitzer , Jens Axboe Subject: [PATCH 5.15 044/171] block: add bio_start_io_acct_time() to control start_time Date: Mon, 31 Jan 2022 11:55:09 +0100 Message-Id: <20220131105231.515669552@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105229.959216821@linuxfoundation.org> References: <20220131105229.959216821@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Snitzer commit e45c47d1f94e0cc7b6b079fdb4bcce2995e2adc4 upstream. 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 Link: https://lore.kernel.org/r/20220128155841.39644-2-snitzer@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-core.c | 25 +++++++++++++++++++------ include/linux/blkdev.h | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1293,22 +1293,34 @@ void blk_account_io_start(struct request } 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 * @bio: bio to start account for * @@ -1316,14 +1328,15 @@ static unsigned long __part_start_io_acc */ 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); --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1947,6 +1947,7 @@ unsigned long disk_start_io_acct(struct 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);