Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1445758rdg; Sat, 12 Aug 2023 01:16:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOM8mdZEy9+0GbbrziQBKcd2MF7v5COI5vCGUeTAg5Jo1T0mlun1l4GV/uujjuxOES+Erc X-Received: by 2002:a17:906:3055:b0:99b:d178:f051 with SMTP id d21-20020a170906305500b0099bd178f051mr3454836ejd.64.1691828168587; Sat, 12 Aug 2023 01:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691828168; cv=none; d=google.com; s=arc-20160816; b=dIe9Y7naMxt2fT1anTXCW4OZrIs6MxECvB/9Ky7nW7/EDVWxlM0RFF16AN+oTRPqbE FHJ/phTaBHMJch8FDyuRtt1Xl/KcR/CEhRmRXR690BIJ4RVPZGVzlKIStiuwjz2+jNnh 6h03x6yh2pb1ETChxVUppG82KTsE3AVZFfLFRoKmnU3nR1HiaCcFDnuZLzirGqXR5mW8 7qkFTaIS3mwlj9F0FMjzNsrDVsU8mJ5gUNv2/fJ+fQirWNWMpbKDPZOY52p7YJeXuJXJ OZirylwEllz4gekjVhG6ljq87uyY12GcT3QBeUyB1qF9aTAXs27/KKHpvtYv7fEmsseO thKA== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=+215Il27mQYswidWrXF8ZJOra890MbaHVFw5nsJQ/Sg=; fh=YxLDSbKA4qDxeu7XSDxkeIUR6Aw0wrTXk4vt8RSpWjU=; b=kwegRV5fTRlwQtxHkWlpRUst57JNPgIqxagK8YW1d/B+Lw8yolerdm4PVIEcIqYIWW eQUdFst3fGxzmIxYQp7bwBsP0jG4lXyTM4HPn7AjZvBqotEpF/7xms20nAoEql3uul8s 815Y89tgah+SUpuE0ZGj/zQR5FQ5HhyCB2+i3hTpP19o6IwbFNJVaJrrMAgmRY4EIW9c bu1yYjKwGpt2T1SMHobUY4EH5euj2XcHSk2PBk1XfTzC36wrSSypa/PCOvJ5GSK72inW AekLGEgFt6kHRSouM3FUkW7aWAayQUjwNv6+znt3yzvxqSxT/T5oSJGrah+Oy25Y9etG rxDw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qu7-20020a170907110700b0099cd371dd90si4811646ejb.928.2023.08.12.01.15.43; Sat, 12 Aug 2023 01:16:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234786AbjHLHxs (ORCPT + 99 others); Sat, 12 Aug 2023 03:53:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjHLHxr (ORCPT ); Sat, 12 Aug 2023 03:53:47 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7A51BE6; Sat, 12 Aug 2023 00:53:49 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RNCbG0ZyFz4f3pC2; Sat, 12 Aug 2023 15:53:46 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgBH1qiIOtdkIy0XAg--.34377S3; Sat, 12 Aug 2023 15:53:46 +0800 (CST) Subject: Re: [PATCH 1/1] blk-throttle: fix throttle configuring not effective To: zhuxiaohui , tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, zhuxiaohui , "yukuai (C)" References: <20230812072116.42321-1-zhuxiaohui.400@bytedance.com> From: Yu Kuai Message-ID: <5ba76f5e-9b02-13c8-c2a3-b15fe016261d@huaweicloud.com> Date: Sat, 12 Aug 2023 15:53:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20230812072116.42321-1-zhuxiaohui.400@bytedance.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBH1qiIOtdkIy0XAg--.34377S3 X-Coremail-Antispam: 1UD129KBjvJXoWxCF4rGrW5tw4kCw1Duw1kuFg_yoW5XFW3pF yjkrs5Cw4qqFnxG3ZxZ3ZxAay5Xw48JrW8JrZFyry5AF13C3sxGFyUJr1Fkay0kF97Wr4k tw1jqr9rGa17uFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyEb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I 0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0E wIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04 k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY 1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU1zuWJUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,NICE_REPLY_A,SPF_HELO_NONE,SPF_NONE 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 Hi, ?? 2023/08/12 15:21, zhuxiaohui ะด??: > when updating block throttle limit with persistence and stable io > pressure, especially a relative high io pressure, fio test e.g., > there may never be a change to start a new slice, and carryover_ios & > carryover_bytes will not be cleared. > > As a result, when reconfiguring block throttle limit, we can notice that > the actual iops and throughput is a random value far away from what is > set > > So we need to update carryover value when dispatching bio I don't understand, not clear carryover_bytes/ios is what expected, and how can they affect actual bandwith/iops. Can you give a example how you tested and why current calculation is not correct? Thanks, Kuai > > Signed-off-by: zhuxiaohui > --- > block/blk-throttle.c | 26 ++++++++++++++++++++++++++ > block/blk-throttle.h | 4 ++-- > 2 files changed, 28 insertions(+), 2 deletions(-) > > diff --git a/block/blk-throttle.c b/block/blk-throttle.c > index 7397ff199d66..13c9d87a7201 100644 > --- a/block/blk-throttle.c > +++ b/block/blk-throttle.c > @@ -821,6 +821,30 @@ static void tg_update_carryover(struct throtl_grp *tg) > tg->carryover_ios[READ], tg->carryover_ios[WRITE]); > } > > +static void tg_charge_carryover(struct throtl_grp *tg, struct bio *bio) > +{ > + bool rw = bio_data_dir(bio); > + > + if (unlikely(tg->carryover_bytes[rw])) { > + unsigned int bio_size = throtl_bio_data_size(bio); > + unsigned int carryout_size = abs(tg->carryover_bytes[rw]); > + > + carryout_size = min(carryout_size, bio_size); > + > + if (tg->carryover_bytes[rw] < 0) > + tg->carryover_bytes[rw] += carryout_size; > + else > + tg->carryover_bytes[rw] -= carryout_size; > + } > + > + if (unlikely(tg->carryover_ios[rw])) { > + if (tg->carryover_ios[rw] < 0) > + tg->carryover_ios[rw] += 1; > + else > + tg->carryover_ios[rw] -= 1; > + } > +} > + > static unsigned long tg_within_iops_limit(struct throtl_grp *tg, struct bio *bio, > u32 iops_limit) > { > @@ -965,6 +989,8 @@ static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio) > > tg->io_disp[rw]++; > tg->last_io_disp[rw]++; > + > + tg_charge_carryover(tg, bio); > } > > /** > diff --git a/block/blk-throttle.h b/block/blk-throttle.h > index d1ccbfe9f797..8f1642becb23 100644 > --- a/block/blk-throttle.h > +++ b/block/blk-throttle.h > @@ -127,8 +127,8 @@ struct throtl_grp { > * bytes/ios are waited already in previous configuration, and they will > * be used to calculate wait time under new configuration. > */ > - uint64_t carryover_bytes[2]; > - unsigned int carryover_ios[2]; > + int64_t carryover_bytes[2]; > + int carryover_ios[2]; > > unsigned long last_check_time; > >