Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp48673rdb; Fri, 5 Jan 2024 02:13:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfbaU7FNYVJ2zb85j7gPNtkkZIlcOyQyxelm6MJqyeZITIlSIAwOh2GCK1fNLlRrpG7vKz X-Received: by 2002:a05:620a:25c7:b0:781:1bf7:4620 with SMTP id y7-20020a05620a25c700b007811bf74620mr2300265qko.99.1704449637718; Fri, 05 Jan 2024 02:13:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704449637; cv=none; d=google.com; s=arc-20160816; b=oGsEtlO3LRSVot4lgNHPH+QtCgtN4ZWeOXLFiRnZvcTjGpn7Vmxibz2JZ4WiAGienx 2jbQFyQxXvcMpUlJzuGs5kqrdFJiam8ByeKfLlk07dL5ppHHrvvy+PCOhEksNJ7K/9J5 UDJ6waxUga5fUHEwbQvnN7ApCQQNHOO33JnvpaR1kfFNbTcLfnDOfdDsehuK+QmOoV0u n1LKJhu+TbwX8Ob2v08+Brhoj07w7Svwq6ILLKRjJ5Zi0HCtNMicszO9+5JyDgWdHxU1 +Cu5lmuEspU34dVkSet601UuvBUovo3CKZYtZFtIKrW6GIv3Qro0D7zJZfnm0jACCXPd lPSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=gZ3tR1YpwchJkbBAH3oD7XDBNzaDpoTc77OTLHxKewM=; fh=4/TCkxbPHEgY7vYWc2/iqkaSAbklIgY7+ZP+6peb84A=; b=kEZEyHuXK7Lbe8n3vXhJXybw+woPfzeqr+9FwPYiyeYBqUt6vd6gfmczsN+KSTO+ud hbu05+bRgEpeu9+nW5kFO+6XZRpHqQUTSDToScJnrB0x/ine1X3F/6mQu9XMVIHQtadK rR8RCG+Eg1Ak3VMTCNlYntB+jH3lAfbVWpk8alyS60Neha4bIiBE/Nd+fBJ2OVWCYIFz Mbt2Y1r68atFbS71N8F0tOTw7j/jJBGnuIi2uy5COIIfMKbLmR8tpy9on8kgXCuSwIoc rqBmGC/VN1myWS9/Wigcd/C051wrC/6Uw9ofXkxhTJEIl5pSJhjufxrjkgfLQ36s8u7U 0uyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17718-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z22-20020a05620a261600b00781d517df64si1074685qko.429.2024.01.05.02.13.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 02:13:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17718-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17718-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5C6D31C22D2A for ; Fri, 5 Jan 2024 10:13:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B69392C85B; Fri, 5 Jan 2024 10:13:27 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C8D82C69D; Fri, 5 Jan 2024 10:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4T5zmt5sT4z4f3jpr; Fri, 5 Jan 2024 18:13:18 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9DEFE1A0AD2; Fri, 5 Jan 2024 18:13:20 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgDXJg0_1pdliqpcFg--.48265S3; Fri, 05 Jan 2024 18:13:20 +0800 (CST) Subject: Re: [PATCH for-6.8/block RFC v2] block: support to account io_ticks precisely To: Ming Lei , Yu Kuai Cc: hch@lst.de, bvanassche@acm.org, axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20240103071515.2477311-1-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: <0a7aa14b-2ceb-2551-3600-cac7f9370360@huaweicloud.com> Date: Fri, 5 Jan 2024 18:13:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgDXJg0_1pdliqpcFg--.48265S3 X-Coremail-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SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Hi, Ming! ?? 2024/01/05 10:49, Ming Lei ะด??: > On Wed, Jan 03, 2024 at 03:15:15PM +0800, Yu Kuai wrote: >> From: Yu Kuai >> >> Currently, io_ticks is accounted based on sampling, specifically >> update_io_ticks() will always account io_ticks by 1 jiffies from >> bdev_start_io_acct()/blk_account_io_start(), and the result can be >> inaccurate, for example(HZ is 250): >> >> Test script: >> fio -filename=/dev/sda -bs=4k -rw=write -direct=1 -name=test -thinktime=4ms >> >> Test result: util is about 90%, while the disk is really idle. >> >> In order to account io_ticks precisely, update_io_ticks() must know if >> there are IO inflight already, and this requires overhead slightly, >> hence precise io accounting is disabled by default, and user can enable >> it through sysfs entry. >> >> Noted that for rq-based devcie, part_stat_local_inc/dec() and >> part_in_flight() is used to track inflight instead of iterating tags, >> which is not supposed to be used in fast path because 'tags->lock' is >> grabbed in blk_mq_find_and_get_req(). >> >> Signed-off-by: Yu Kuai >> --- >> Changes in v2: >> - remove the new parameter for update_io_ticks(); >> - simplify update_io_ticks(); >> - use swith in queue_iostats_store(); >> - add missing part_stat_local_dec() in blk_account_io_merge_request() > > Looks fine, > > Reviewed-by: Ming Lei Thanks for the review, however, I made a mistake while "simplify update_io_ticks()" that first IO will still account by 1 jiffies even if precise iostat is enabled: + if (unlikely(time_after(now, stamp)) && + likely(try_cmpxchg(&part->bd_stamp, &stamp, now))) { + if (end || (blk_queue_precise_io_stat(part->bd_queue) && + part_in_flight(part))) + __part_stat_add(part, io_ticks, now - stamp); + else -> here, should be else if (!blk_queue_precise_io_stat(part->bd_queue)) + __part_stat_add(part, io_ticks, 1); Alough this is RFC, my apologize for sending this version without fully test the functionally. I'll send a formal version soon. Thanks, Kuai > > > thanks, > Ming > > . >