From nobody Sun May 24 18:42:27 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 991853CBE6B for ; Fri, 22 May 2026 11:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779449880; cv=none; b=QI6NxxzGcLj6/OYO+8HyAo9Ap33udqxoInUZulgzE7uhDUOlrWP+BQmf32Gh5VTVJ7DzBU1BIEy4ihETtUFx25f/nUhPR/5+LyZ8yxQfR7Y62XStg21UJarzY8Bzkz2TkPXprvhhBS+38OadVQ0oku+pZcE6Ah2UOIHnAGHM/lc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779449880; c=relaxed/simple; bh=+6XTlrFaNMeuJy/nAA9K8IKD9L0qB+VwyTccxLkgEP4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=p+sJWAX/aRrAJQrEzQ8VYwT2zkFOB9bRvCxNoPV5Pd16Vht4oqNWhMjB7DviKJDHKod6dgL0pKStonP2ncV/pobnZvZ4FyAr95Dul7eZaDRu4RFN+QCAkMMAoiOOzFEPnd+hmtaT6KdsYxn0k31xB6nVa37CmCJ3n8DOHsgkodU= 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=dfyhb27Z; arc=none smtp.client-ip=209.85.216.41 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="dfyhb27Z" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-366375c4076so2915791a91.3 for ; Fri, 22 May 2026 04:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1779449879; x=1780054679; 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=O2dyv1Pdhzf1sUnv9J0e7+lVLWOmeeI6cw+f8Q9XDUs=; b=dfyhb27ZYDUTrR/wh079736nH96f553DfLABLAKz05Fyk8hMbEkfEVymHiR0Eq7nhC zvFpuJ2lF6Oam5FE37komrFWILRVZTTtMOQGbiZjCJS0tuu82H8zXLEXIo0nE+GSwaPT niAgCK2xWg2k87BOCoh8BAIy1EDTEYOuMZOC7Vk6ROdhk5JnhvoVMOhxdpCNXYLP3rKN ssBMc8idMCFcO5Zw2A/kKnDqgmaNbti9rm9/iRi4bZ217Id3lDCp3RUSXAlqfegaewW3 RkilYgVAcnx97FvEtkZmL+XQjhgCIceFeHZUMgWnT/qSvkWNl1plbxcy6Qu52l4r8EHx x9bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779449879; x=1780054679; 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=O2dyv1Pdhzf1sUnv9J0e7+lVLWOmeeI6cw+f8Q9XDUs=; b=s62GZNvetR/tRh6nZkUxNjlU1o5X6osjyRqCCQjYg8fuW4CHR6vwPasJqAj+UZTMnK xN5VZiW/0vY97oGhPjhIcNtQl58eM9NQd52vBjMepRrF9fKcKbM2z4kj0YH1VMmjyKFC 1leYCN0wNQsxlxXVzmNNctxBgTZPfZ6pqPEAxepID3IY/GfZLMoXlJnLf2hKdmlyhJtl gkejPdQHWGy+Itx6vRO4Dss1EWjQ4upcnEPRQbANkDPUL/PwrFUZoDWAZm6G/HDXPCDR Iuy+57IoAkPOWErw501c89sH1IkeZlRrBX/YBSf4imkONIxDKbsIc4v3StG7RxInjtM1 nx9A== X-Forwarded-Encrypted: i=1; AFNElJ9UD3euZOxRO+OHzX+tp21cV9oPXxXfy06iZL/b9TCbyXkBi1H/4ZDa6wqrw0nuyTNvD/dp7y4t/tcD9Lo=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8L+/hbP8qXz13oKeoRz5lWiledFSy4XrhEha0lIWnOUF5godX mXJ7Lrj3rw59vbPNAHcGZl49e8gBXoB6fMEKskXHTgO1ZCNsnKIK/2un2DIPJilq8s8= X-Gm-Gg: Acq92OFV6YrLKhQ6fGP90RvgI2PH/gf5MjcDixMY0oY5g4KTqGNupOy+6+tQdI9H9L2 ffIkssbNuwAkK27VWH0PJ4BanU6xH2Z3CG7uv0V223XVvP2PfpZZf1nSRZOyrF8qV+i4lUefbvQ ctN4dCiEKEmtdG+bEDr1QR/CvVIdJ3tmD87vPbbP23PvkRz9AgKG38qS7TYmZCAepBev/5MK/2I dUWQOFGOFGrgfYmf+//6MXY6mgXIRl6g4QSfGB1wUT1/q1fFsdv7EhmtNXNFXwBpxw2Ro65j80K zkGmwN06GJXu42SkFrpp9e5YMSwDJ2XbyNqv6740mkl4sz1FLsKCJdKfUPq/BSl4KqQUVN7mnhD yw5/xVOnCbyFGMbPYPPjnEvpX4e4WggDvPorALYG5jBuUn4huZNu8PGRSNyosDRiCnJrs8PYtLv +/ab2br3FuJ0+rovE6vMA= X-Received: by 2002:a17:90b:564f:b0:35c:30a8:32a with SMTP id 98e67ed59e1d1-36a674d88edmr3074090a91.9.1779449878838; Fri, 22 May 2026 04:37:58 -0700 (PDT) Received: from localhost.localdomain ([147.136.157.3]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a72c913a1sm1619107a91.15.2026.05.22.04.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 04:37:57 -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] block: propagate in_flight to whole disk on partition I/O Date: Fri, 22 May 2026 19:37:51 +0800 Message-ID: <20260522113751.171630-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 key step 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. Fix it by restoring the whole-disk in_flight accounting. Fixes: e722fff238bb ("block: remove generic_{start,end}_io_acct") Suggested-by: Leon Hwang Signed-off-by: Tang Yizhou --- 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