From nobody Sun May 24 18:43:54 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8B2B3A1A41 for ; Fri, 22 May 2026 12:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779453286; cv=none; b=Cu6OffZOuleY3UKlvT3aLrG4uKevQgJiPO0y/lb9H9RQbU6xcmOo53Pd6oCxN8vOxW7Mtr/sqK8iBVsKkH4sWDQtDqQ3LKQceeg/dc5Yu82/VKg93XIwxMoH3vowHlr/56gML2oNDR/qtVol6pJZIs3zdw9T5v+jdULNWcwX794= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779453286; c=relaxed/simple; bh=CZe2Th/Kz3g0cBOC7HmIuidtzfohRB7G6m4QxL1cUd0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=S3D5lAlJ4L0O23XDwcVynfjGtPwcGevUB4GcRlV7llk6IPypEamqqYbXu3rhnGma8weSu/4+VMaxEAYyB9LYfwFO7Olo6l8gH2E0Z3j1jAX/uMrQniOdsManzNg7aU8G94G1Ml9EQOD0XJL71f427FAMLnmr0bSMCG7USpMD9xQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=lXw4EiK7; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="lXw4EiK7" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-36a3dd2e66eso1409917a91.0 for ; Fri, 22 May 2026 05:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1779453284; x=1780058084; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=i8NDhTcBxupujmsLnW4nemiXS1D1a+QTzbnmjzpK93I=; b=lXw4EiK7F8j38PQWddfX6qnKgKay/vO4JKr0M9t++kXE/XngdNPr8/JypsjM/Hr+yS b/8CQdAZ32uHBVkGJXgEc+qv1b8nssnNeI9sAWpLb3Y6up0GcwSeLqJ/ZsXNSvAaK4JW MPLJyk/ViXwD0IYtqJlBB55P5RuggXDWtXsaQC+Ojejr6WXFNw8ky9Az+5xJV+fAk9K/ vqVdMkInZQ/WwYngNTuaJl7kSIoL3XyKgDXm30s+e63xR9EtpQdPSrjmklUNp12Xn6I+ 0nMJnSRnxrMZHbaMIs3+QijKAmKPeI2T0xDdFp0l3BACB+EzpCpjwrLJU1vyXKt4CCWD H0vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779453284; x=1780058084; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=i8NDhTcBxupujmsLnW4nemiXS1D1a+QTzbnmjzpK93I=; b=a7NZsHcQz1rdaldhy72zsm0id5f67m3ISADzq9hlAfNPFBOzUCzx/YhkuQio2NekIt 9oJ1cZJouKHCUMGDbGB7vDwJpRLCOuL/OxsrdxKkxlt4fFYhUYjySEGi35ebzsFcUl+4 Dea/2oVj0AemZXheNJUhEwj3TCeBoks78O5cdkjayED5EK2AdPe5DUGCGVprw6ZNKVtQ WfhwP/P6HGhOZGNa4xXcZu8F4r3Xp5NaMiQF71Ht4BLm55NeRvb+tst8oGDAPXkmEYB4 vLaYBzUG45CLyF+uN9JISyvVwmcJKSrz4wkVSKSrM+8V0fPYSZi0sn3Y26Q2pGYryjGP K6DQ== X-Forwarded-Encrypted: i=1; AFNElJ8xQr+FLbvsDaYwWziStTYxTNsSKxFMPYxHz9UX3oL1VmElcrSIcdu159UlDBE9bJt/xHv3I8R0MqBMIjQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwdVyWJUAzihBNH4826kj8GQuA4Xjpeoc3lUjUMnDSDliEj0EGr jUyTIIHq1GyGUNEB6gIgGTA7Hzpmn33QGwq192BJByPespv8SkQBCBvN2+tjwIJl8DI= X-Gm-Gg: Acq92OH5W+7I+koVGmN6Y1/2UexOz6UqGdkiTo2BRn5SLQFoWhP0uMg8D+fgjiiqkbQ EZi5bpZyucjA3Kf7/HwtqhCFTQGJK1/YGiRb/wi+7AxAdp5/11ao44tlSuBe7yNnmm6BpWQ/phM FZgFYL7UJl1sAnXc9TuJFNuuQd89cYtnfDNGFKVZQcFT3X0tu3MTfNjeQEp+7WHOzHXaTCvq7DS X27nqb3dJjGf+g1EDDLqb40xeuY0PMB3DlNZ1qHBiQMO/W0nFYUWHpE0NkFTRei5rDAM88LBBGv r57iDY0BZQraiMJmFZHJ3wdlEwIeUn++lm1Alifbeq7Syo2rrw2xgHoOTkAGXWrpFaezYyqGizC /ZGVdWWY1veroR8xOFjSgiXTUOYMyFIP/TEC85DRIVsWOJmYuMmPKGsaVfIUepO5G3M35PeiTRk nXAhcpeZt3 X-Received: by 2002:a05:6a21:4d8d:b0:3a2:d79c:4159 with SMTP id adf61e73a8af0-3b3293404c6mr3695201637.32.1779453284125; Fri, 22 May 2026 05:34:44 -0700 (PDT) Received: from localhost.localdomain ([147.136.157.2]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85202b3867sm1496576a12.11.2026.05.22.05.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 05:34:43 -0700 (PDT) From: Tang Yizhou X-Google-Original-From: Tang Yizhou To: axboe@kernel.dk, hch@lst.de Cc: yukuai@fnnas.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Tang Yizhou , Leon Hwang Subject: [PATCH v2] block: propagate in_flight to whole disk on partition I/O Date: Fri, 22 May 2026 20:34:37 +0800 Message-ID: <20260522123437.214058-1-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Tang Yizhou Now when I/O is submitted to a partition, the per-CPU in_flight[] counter is incremented only on the partition's block_device, not on the underlying whole disk. This leads to a problem which can be shown by a fio test: lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS mydev 252:1 0 20G 0 disk =E2=94=94=E2=94=80mydev1 259:0 0 10G 0 part iostat -xp 1 Device r/s rkB/s ... aqu-sz %util mydev 128153.00 512612.00 ... 13.22 72.20 mydev1 128154.00 512616.00 ... 13.22 100.00 %util is different between mydev and mydev1, which is unexpected. This is the cumulative effect of a series of patches. The root cause is commit e016b78201a2 ("block: return just one value from part_in_flight"), which deleted the branch in part_in_flight() that aggregated the whole-disk in_flight count on top of the partition's. Then the second commit is commit 10ec5e86f9b8 ("block: merge part_{inc,dev}_in_flight into their only callers"), which folded the whole-disk in_flight accounting into generic_start_io_acct() and generic_end_io_acct(). Those two helpers were then removed by commit e722fff238bb ("block: remove generic_{start,end}_io_acct"), and from that point on the whole disk's in_flight is no longer accounted at all. In update_io_ticks(), if calling bdev_count_inflight() finds that the inflight value of the whole device is 0, the accumulation of io_ticks will be skipped, causing the reported util% value to be underestimated. Fix it by restoring the whole-disk in_flight accounting. Fixes: e016b78201a2 ("block: return just one value from part_in_flight") Suggested-by: Leon Hwang Signed-off-by: Tang Yizhou --- v2: Update commit message. block/blk-core.c | 4 ++++ block/blk-mq.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index 17450058ea6d..03f4b7015e69 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1043,6 +1043,8 @@ unsigned long bdev_start_io_acct(struct block_device = *bdev, enum req_op op, part_stat_lock(); update_io_ticks(bdev, start_time, false); part_stat_local_inc(bdev, in_flight[op_is_write(op)]); + if (bdev_is_partition(bdev)) + part_stat_local_inc(bdev_whole(bdev), in_flight[op_is_write(op)]); part_stat_unlock(); =20 return start_time; @@ -1074,6 +1076,8 @@ void bdev_end_io_acct(struct block_device *bdev, enum= req_op op, part_stat_add(bdev, sectors[sgrp], sectors); part_stat_add(bdev, nsecs[sgrp], jiffies_to_nsecs(duration)); part_stat_local_dec(bdev, in_flight[op_is_write(op)]); + if (bdev_is_partition(bdev)) + part_stat_local_dec(bdev_whole(bdev), in_flight[op_is_write(op)]); part_stat_unlock(); } EXPORT_SYMBOL(bdev_end_io_acct); diff --git a/block/blk-mq.c b/block/blk-mq.c index d0c37daf568f..60ead16f1496 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1084,6 +1084,9 @@ static inline void blk_account_io_done(struct request= *req, u64 now) part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns); part_stat_local_dec(req->part, in_flight[op_is_write(req_op(req))]); + if (bdev_is_partition(req->part)) + part_stat_local_dec(bdev_whole(req->part), + in_flight[op_is_write(req_op(req))]); part_stat_unlock(); } } @@ -1144,6 +1147,9 @@ static inline void blk_account_io_start(struct reques= t *req) part_stat_lock(); update_io_ticks(req->part, jiffies, false); part_stat_local_inc(req->part, in_flight[op_is_write(req_op(req))]); + if (bdev_is_partition(req->part)) + part_stat_local_inc(bdev_whole(req->part), + in_flight[op_is_write(req_op(req))]); part_stat_unlock(); } =20 --=20 2.43.0