Message ID | 20231215013931.3329455-3-linan666@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-320-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8977208dys; Thu, 14 Dec 2023 17:42:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8qTWp3PmUfCldhQQDOF0TfSb5JGEtMLTXn/ctIcbf9D2HRQNbNM3kcNfXIp3pTkRwFWfa X-Received: by 2002:a17:906:3f06:b0:a0e:1f04:e659 with SMTP id c6-20020a1709063f0600b00a0e1f04e659mr5467318ejj.9.1702604547088; Thu, 14 Dec 2023 17:42:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702604547; cv=none; d=google.com; s=arc-20160816; b=pCwkJMsq7GOk4+4iudNZGeu18GKb4XevmfU2ELTnVpoqRUlslFcDjjDI5yQdKnQn6I WcmtTSn/LT+ev85Nc7QjujIw2v4POxK8deYH7GFOgPCsFozbWp4fdrXN1Fi6dVyY/eBS VsthT7/Psa5UCC2qUUPtFN72cZEBoBFaDmySaXHIMAAeap647gEyjenrdYuDUtJmXcXM MpCNYQC7rlV3C1pemgoabcD7QQZuk9tGYeeFooSTp6iV7sbAeyInfqVSNgVXR5AGofjH 3ib9FTr1yMz5mo00MO8gDD4dKzPo/E5F7AsGuPCx/6q7tEP+REowfCm0Az0cc8T574/N g3/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Ec17P4EKH5CYQ3+UnGMGy7ISBi9/YmGl7kHjrclNAPQ=; fh=KzMu/56/cZ/XdN+BRAd8A7ip70iszopujqpzmcppc/E=; b=ql8PH50DgpaNcZVZu5l6B0c560ruksMEGdT2Xk9vxl24WxvVbeHpVK8b4+d6qwb4hX xSHyjdixDsjYZJO3Zj7LFyZkTwiDxd0PQLsQxoIbyZRqlckgXScIKF1I9VSs0Wu+brsY va812pYSEj0rtizAgfe1ftBGBg1kljsitJJ3SQpq2WAPiB1OqEyUPCIvyXnjCh9Py34h 83+nP774EpBqME8uC4LGEbqUehCV6UpVwEYFTLgUPeh2yFgHuxvQmzFzM7GiG/pc8VUl zAv+WOsj9+ja6SIxSe5egyvu8SWy/XJnFTgiTGrYCTpwRwbH+pAl1JRXWidlqyEtpvt8 Tqlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-320-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bl25-20020a170906c25900b00a1d1f6bb280si7080971ejb.317.2023.12.14.17.42.26 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 17:42:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-320-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-320-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id AEC501F229B9 for <ouuuleilei@gmail.com>; Fri, 15 Dec 2023 01:42:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 585D55663; Fri, 15 Dec 2023 01:41:22 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 D1144650; Fri, 15 Dec 2023 01:41:17 +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.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SrsPX0QrRz4f3lVV; Fri, 15 Dec 2023 09:41:04 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 16F811A0554; Fri, 15 Dec 2023 09:41:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgD3Rg2yrntlPtG0Dg--.46759S6; Fri, 15 Dec 2023 09:41:08 +0800 (CST) From: linan666@huaweicloud.com To: song@kernel.org, axboe@kernel.dk Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linan666@huaweicloud.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH v2 2/2] md: don't account sync_io if iostats of the disk is disabled Date: Fri, 15 Dec 2023 09:39:31 +0800 Message-Id: <20231215013931.3329455-3-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231215013931.3329455-1-linan666@huaweicloud.com> References: <20231215013931.3329455-1-linan666@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgD3Rg2yrntlPtG0Dg--.46759S6 X-Coremail-Antispam: 1UD129KBjvJXoW7KFWxKF4kKr1xuF18try7Jrb_yoW8Gw1fpa ykAFyayryjqrW5u3WUX34Dua4rW3srKFW7ArW3A393ZFy3Jr9xKryrXayqqryDWFyrWFWa va4DGFZ8ua10yr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmK14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAa c4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzV Aqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S 6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxw ACI402YVCY1x02628vn2kIc2xKxwAKzVCY07xG64k0F24l42xK82IYc2Ij64vIr41l4I8I 3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxV WUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAF wI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcI k0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j 6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU1xhLUUUUU X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785310265859553454 X-GMAIL-MSGID: 1785310265859553454 |
Series |
md: fix is_mddev_idle()
|
|
Commit Message
Li Nan
Dec. 15, 2023, 1:39 a.m. UTC
From: Li Nan <linan122@huawei.com> If iostats is disabled, disk_stats will not be updated and part_stat_read_accum() only returns a constant value. In this case, continuing to count sync_io and to check is_mddev_idle() is no longer meaningful. Signed-off-by: Li Nan <linan122@huawei.com> --- drivers/md/md.h | 3 ++- drivers/md/md.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-)
Comments
On Thu, Dec 14, 2023 at 5:41 PM <linan666@huaweicloud.com> wrote: > > From: Li Nan <linan122@huawei.com> > > If iostats is disabled, disk_stats will not be updated and > part_stat_read_accum() only returns a constant value. In this case, > continuing to count sync_io and to check is_mddev_idle() is no longer > meaningful. > > Signed-off-by: Li Nan <linan122@huawei.com> > --- > drivers/md/md.h | 3 ++- > drivers/md/md.c | 4 ++++ > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/md.h b/drivers/md/md.h > index 1a4f976951c1..75f5c5d04e71 100644 > --- a/drivers/md/md.h > +++ b/drivers/md/md.h > @@ -589,7 +589,8 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect > > static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors) > { > - md_sync_acct(bio->bi_bdev, nr_sectors); > + if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue)) > + md_sync_acct(bio->bi_bdev, nr_sectors); Do we need the same check for md_sync_acct()? > } > > struct md_personality > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 1d71b2a9af03..18bbceb0ffd6 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -8502,6 +8502,10 @@ static int is_mddev_idle(struct mddev *mddev, int init) > rcu_read_lock(); > rdev_for_each_rcu(rdev, mddev) { > struct gendisk *disk = rdev->bdev->bd_disk; > + > + if (blk_queue_io_stat(mddev->queue)) > + continue; This looks weird. Do you mean if (!blk_queue_io_stat(disk->queue)) Note that I changed two things here: 1) add "!"; 2) check disk, not mddev. Did I miss something? Thanks, Song > + > curr_events = > (long long)part_stat_read_accum(disk->part0, sectors) - > atomic64_read(&disk->sync_io); > -- > 2.39.2 >
在 2023/12/15 17:08, Song Liu 写道: > On Thu, Dec 14, 2023 at 5:41 PM <linan666@huaweicloud.com> wrote: >> >> From: Li Nan <linan122@huawei.com> >> >> If iostats is disabled, disk_stats will not be updated and >> part_stat_read_accum() only returns a constant value. In this case, >> continuing to count sync_io and to check is_mddev_idle() is no longer >> meaningful. >> >> Signed-off-by: Li Nan <linan122@huawei.com> >> --- >> drivers/md/md.h | 3 ++- >> drivers/md/md.c | 4 ++++ >> 2 files changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/md/md.h b/drivers/md/md.h >> index 1a4f976951c1..75f5c5d04e71 100644 >> --- a/drivers/md/md.h >> +++ b/drivers/md/md.h >> @@ -589,7 +589,8 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect >> >> static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors) >> { >> - md_sync_acct(bio->bi_bdev, nr_sectors); >> + if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue)) >> + md_sync_acct(bio->bi_bdev, nr_sectors); > > Do we need the same check for md_sync_acct()? > >> } >> >> struct md_personality >> diff --git a/drivers/md/md.c b/drivers/md/md.c >> index 1d71b2a9af03..18bbceb0ffd6 100644 >> --- a/drivers/md/md.c >> +++ b/drivers/md/md.c >> @@ -8502,6 +8502,10 @@ static int is_mddev_idle(struct mddev *mddev, int init) >> rcu_read_lock(); >> rdev_for_each_rcu(rdev, mddev) { >> struct gendisk *disk = rdev->bdev->bd_disk; >> + >> + if (blk_queue_io_stat(mddev->queue)) >> + continue; > > This looks weird. Do you mean > > if (!blk_queue_io_stat(disk->queue)) > > Note that I changed two things here: 1) add "!"; 2) check disk, not mddev. > > Did I miss something? > > Thanks, > Song > Yeah... It's my bad. I will fix it in v3. >> + >> curr_events = >> (long long)part_stat_read_accum(disk->part0, sectors) - >> atomic64_read(&disk->sync_io); >> -- >> 2.39.2 >> > > .
diff --git a/drivers/md/md.h b/drivers/md/md.h index 1a4f976951c1..75f5c5d04e71 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -589,7 +589,8 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors) { - md_sync_acct(bio->bi_bdev, nr_sectors); + if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue)) + md_sync_acct(bio->bi_bdev, nr_sectors); } struct md_personality diff --git a/drivers/md/md.c b/drivers/md/md.c index 1d71b2a9af03..18bbceb0ffd6 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8502,6 +8502,10 @@ static int is_mddev_idle(struct mddev *mddev, int init) rcu_read_lock(); rdev_for_each_rcu(rdev, mddev) { struct gendisk *disk = rdev->bdev->bd_disk; + + if (blk_queue_io_stat(mddev->queue)) + continue; + curr_events = (long long)part_stat_read_accum(disk->part0, sectors) - atomic64_read(&disk->sync_io);