Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp967136rwr; Fri, 5 May 2023 07:26:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Psv1ubYs4slyGW4LuyCgstWDhuWLrMMaimlaCRr6eN9jycouCDMAObCj+fxMhrIs745Z4 X-Received: by 2002:a17:90a:2f85:b0:24c:5e6:7035 with SMTP id t5-20020a17090a2f8500b0024c05e67035mr1693465pjd.30.1683296779762; Fri, 05 May 2023 07:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683296779; cv=none; d=google.com; s=arc-20160816; b=Wg8RcO2d0K6wAYFywPrmpDhis0dKLDHeo1gWkh3R96J1MRmqonWFqaQaTOdvGORMB9 pZDJLG/CGHXCEUk0dgqUKBG0HFiXoRulm/Xy+EylHy38Ih3njQsj00t1Hg8oZaiBcNG9 JmgBOLBVGHcsd63zCL2/IcRpMhUY+kXC+uQq2ho1d5PX2EoN8fUSCGR6OjOa5RK2rhLz LnpvKU3qULHBsYMjNO89at2szFHtIrowvIz2rVlvo5L8zDYBG0nrgj9UfNPw8NnyLzof Qbdf5iZhtZOFewMSdlkA3HibNWvqR6kUG1v1SrkIR0rcAJd1hUCXmiOxxa1rzR6Dshaa AEgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=g3RvOc3E8ZFO1x/9akr2bpEbHeCFqf25nGHeEQGUAU0=; b=fatApjDpgG85UenvjQR45TN/fITdybtq8aTg64MyllUFcilTZo5ODbDA+TCrPnAvYz wB+9CrtqUs4csqi8YHOzJukWQpFSsQV/4epQekGKxv+4nqUcSNQ5vCPWx16pqbcAqhAY VJMsC/KfIwOLkfYnNu5OXyc6eiG3Hn1bkLTnJ+XhotPQ5tKIkat1uyyM9NkJaKz4x65K NsvEichjtCZ/QtV4WKL1ls+SUSGVGfQZ/hg15NE8SVqfvYiFlH6TqnixorIQjAu44uMm k5vU/AVeikacnMVTgh8ZQkVH49lbk5uhcOx4QSeacnvhIidFLZk7l2Q/N6b452HkqGfC sHzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=C0II2oek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hi5-20020a17090b30c500b0024e11f7a011si10669857pjb.100.2023.05.05.07.26.04; Fri, 05 May 2023 07:26:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=C0II2oek; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232399AbjEENgA (ORCPT + 99 others); Fri, 5 May 2023 09:36:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232404AbjEENf6 (ORCPT ); Fri, 5 May 2023 09:35:58 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40302268F for ; Fri, 5 May 2023 06:35:27 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-643ac91c51fso234940b3a.1 for ; Fri, 05 May 2023 06:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1683293727; x=1685885727; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=g3RvOc3E8ZFO1x/9akr2bpEbHeCFqf25nGHeEQGUAU0=; b=C0II2oek0zykI2dzG8RkjOqVTRnziAg3YOlg88doaFXBlEhJiIQLAg034eFtxiz6vS g4J8GzDJnyaqmfq8f7Z0i//CSTfgoxZmlub414QeBnfVUF727nol+9PHR2yR/xbSMxlC o6lH+wAATQI69r76wyrPRw2nujuAx8X1wObPJk0sgB3Vz/JHn+/j7XfVEKvs6waccDv/ CdMFmqpzeiZ/fuPIhmQYLumv7uRuc7NYm7B7r0Pqre1WB3dgAeBFdvOU/ayOFBBfZ+tn VfmjJuCKHmz5I3ZOVgB6eu0R670bvCMWjW2HF8jSwPMJdkvUVsLONN0m2u73Yc+tOvpQ 7C9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683293727; x=1685885727; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=g3RvOc3E8ZFO1x/9akr2bpEbHeCFqf25nGHeEQGUAU0=; b=DpdrncsaMcbgtRyNsgWRQmK8hrnGMAyZv8ZG43qjSiBLNq/MZgKmEa0yJ1Ev2zLeQj t76svRP5TYvL8bQIe3v4dbUmISib5fB/ChAocWPYHeCqimvM9eylrU0UuY8BzWZFOF0S 05BMfwHR1qmhT2O49ZEkIyivQSsB1//Yb8XVXdVckhYnVH0i2uqwXFCAkIFrjJUTDrZC NrFH1snhVo4Nz7s2dxbS8xSzaRnjWrY9yu+2PEuOJrppKMp3n1Qp2Sdpn9JbSdjplbyL YYaMy06uZLsYeMepayI/6b/w1PFUFsndo3Qsip7Om/Q4D7OHzTQNBpivgaSmCYKKAJyr /0AQ== X-Gm-Message-State: AC+VfDxPccagruDByLnv/Zq4WOidnvaQYE5iozogpvEv9Uw7DMCUqz/7 wkWB124yjIa59lSJortLOcnoEA== X-Received: by 2002:a05:6a00:1ad0:b0:63b:5f78:d6db with SMTP id f16-20020a056a001ad000b0063b5f78d6dbmr2357743pfv.21.1683293727288; Fri, 05 May 2023 06:35:27 -0700 (PDT) Received: from [10.254.14.195] ([139.177.225.238]) by smtp.gmail.com with ESMTPSA id y17-20020aa78051000000b0062d859a33d1sm1650787pfm.84.2023.05.05.06.35.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 May 2023 06:35:26 -0700 (PDT) Message-ID: <6696100e-e838-d96a-2894-bbca9783d2a3@bytedance.com> Date: Fri, 5 May 2023 21:35:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [External] Re: [PATCH v2] blk-throttle: Fix io statistics for cgroup v1 To: Andrea Righi Cc: tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230401094708.77631-1-hanjinke.666@bytedance.com> From: hanjinke In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2023/5/5 上午5:13, Andrea Righi 写道: > On Thu, May 04, 2023 at 11:08:53PM +0800, hanjinke wrote: >> Hi >> >> Sorry for delay(Chinese Labor Day holiday). > > No problem, it was also Labor Day in Italy. :) > >> >> 在 2023/4/29 上午3:05, Andrea Righi 写道: >>> On Sat, Apr 01, 2023 at 05:47:08PM +0800, Jinke Han wrote: >>>> From: Jinke Han >>>> >>>> After commit f382fb0bcef4 ("block: remove legacy IO schedulers"), >>>> blkio.throttle.io_serviced and blkio.throttle.io_service_bytes become >>>> the only stable io stats interface of cgroup v1, and these statistics >>>> are done in the blk-throttle code. But the current code only counts the >>>> bios that are actually throttled. When the user does not add the throttle >>>> limit, the io stats for cgroup v1 has nothing. I fix it according to the >>>> statistical method of v2, and made it count all ios accurately. >>>> >>>> Fixes: a7b36ee6ba29 ("block: move blk-throtl fast path inline") >>>> Signed-off-by: Jinke Han >>> >>> Thanks for fixing this! >>> >>> The code looks correct to me, but this seems to report io statistics >>> only if at least one throttling limit is defined. IIRC with cgroup v1 it >>> was possible to see the io statistics inside a cgroup also with no >>> throttling limits configured. >>> >>> Basically to restore the old behavior we would need to drop the >>> cgroup_subsys_on_dfl() check, something like the following (on top of >>> your patch). >>> >>> But I'm not sure if we're breaking other behaviors in this way... >>> opinions? >>> >>> block/blk-cgroup.c | 3 --- >>> block/blk-throttle.h | 12 +++++------- >>> 2 files changed, 5 insertions(+), 10 deletions(-) >>> >>> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c >>> index 79138bfc6001..43af86db7cf3 100644 >>> --- a/block/blk-cgroup.c >>> +++ b/block/blk-cgroup.c >>> @@ -2045,9 +2045,6 @@ void blk_cgroup_bio_start(struct bio *bio) >>> struct blkg_iostat_set *bis; >>> unsigned long flags; >>> - if (!cgroup_subsys_on_dfl(io_cgrp_subsys)) >>> - return; >>> - >>> /* Root-level stats are sourced from system-wide IO stats */ >>> if (!cgroup_parent(blkcg->css.cgroup)) >>> return; >>> diff --git a/block/blk-throttle.h b/block/blk-throttle.h >>> index d1ccbfe9f797..bcb40ee2eeba 100644 >>> --- a/block/blk-throttle.h >>> +++ b/block/blk-throttle.h >>> @@ -185,14 +185,12 @@ static inline bool blk_should_throtl(struct bio *bio) >>> struct throtl_grp *tg = blkg_to_tg(bio->bi_blkg); >>> int rw = bio_data_dir(bio); >>> - if (!cgroup_subsys_on_dfl(io_cgrp_subsys)) { >>> - if (!bio_flagged(bio, BIO_CGROUP_ACCT)) { >>> - bio_set_flag(bio, BIO_CGROUP_ACCT); >>> - blkg_rwstat_add(&tg->stat_bytes, bio->bi_opf, >>> - bio->bi_iter.bi_size); >>> - } >>> - blkg_rwstat_add(&tg->stat_ios, bio->bi_opf, 1); >>> + if (!bio_flagged(bio, BIO_CGROUP_ACCT)) { >>> + bio_set_flag(bio, BIO_CGROUP_ACCT); >>> + blkg_rwstat_add(&tg->stat_bytes, bio->bi_opf, >>> + bio->bi_iter.bi_size); >>> } >>> + blkg_rwstat_add(&tg->stat_ios, bio->bi_opf, 1); >> I checked the code again. If we remove cgroup_subsys_on_dfl check here, io statistics will still be performed in the case of v2, which I think is unnecessary, and this information will be counted to io_service_bytes/io_serviced, these two files are not visible in v2. Am I missing something? Thanks. Jinke