Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3653026ioa; Tue, 26 Apr 2022 07:35:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/SrZ72l2Un2rfBdfO19NVoFuKY3bE7MywUziRKiVuxlvWXbrGFfKwA0XxJeMGHNMc3c72 X-Received: by 2002:a63:8549:0:b0:3ab:3197:3efc with SMTP id u70-20020a638549000000b003ab31973efcmr9542224pgd.137.1650983745327; Tue, 26 Apr 2022 07:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650983745; cv=none; d=google.com; s=arc-20160816; b=jbMpC6ExGHK+NGGfxk4AQ+0zoYUxsuWf3HxwWEXLL6jjC1Sv9byW3aW9KRSmw9x7bC APay16UvYMZ0/MZEFiHDfCkc0Xvjxag9l+slm6TSfqtJvt5r+qSRpzDJd8igqJGooPJJ 3IJcMausLeyjuDfL4Qg94h6qOoIGVB+BhyHKGLmAWbqomCCsQ8BShAZ/lGXuXRTyqZhI Q73nmPdB3un819QdBRAAAaftlrPjEXugkpcML5uHulU0RFg0EUxEImDj3vXFlj1cnUus nXVIeZar+KLzCfMTd7KIZ7JHRj633tM8lTaC0ec8p37skJsBbbTzhW/iBWA4kYtgVlnr qLsw== 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=tNkRuakyB29KO2Tdh410DxPJTdfG7T/N2M/k5W7EZ0U=; b=SPnoSooijwnJkVMaDt9DX6BXHYxKgEM0xckPwLdaAvRyKie8V6TVmcG0MHHEBTHHnt 94gcvE9P4wsj9YyrnaSJQIVEMy9obHR6LbkwLkKg+GSiIzJ/8hLrGXEnpRa6RoKqqIqT SQWbZw1Brp78isNpyQFv3nzv2LNJdViICd9hd1deuvvPQvoplMZ6MbAY7BdS85oDuZqc GvFigj6Jl/JwCbG40Ymu40uFoMy1t575k9phGoCa7xwe5+cIWkz6NYlYozEODvr6QJvD 6nvDLn3rPGeZZwEydc98IvbLX9YB+TqcIuI2v2XH501Yphq4nX5FzInr1FcNc7eyIWss 0Mnw== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a63f249000000b003820b4f8361si19395441pgk.182.2022.04.26.07.35.25; Tue, 26 Apr 2022 07:35:45 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349540AbiDZLan (ORCPT + 99 others); Tue, 26 Apr 2022 07:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349536AbiDZLag (ORCPT ); Tue, 26 Apr 2022 07:30:36 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8F0F6F4BD; Tue, 26 Apr 2022 04:27:27 -0700 (PDT) Received: from kwepemi100003.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Knfj46hcqzfbFj; Tue, 26 Apr 2022 19:26:32 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi100003.china.huawei.com (7.221.188.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Apr 2022 19:27:25 +0800 Received: from [10.174.176.73] (10.174.176.73) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Apr 2022 19:27:25 +0800 Subject: Re: [PATCH -next v2 2/5] block, bfq: add fake weight_counter for weight-raised queue To: Jan Kara CC: , , , , , , References: <20220416093753.3054696-1-yukuai3@huawei.com> <20220416093753.3054696-3-yukuai3@huawei.com> <20220425094856.qgkhba2klguduxot@quack3.lan> <20220425161650.xzyijgkb5yzviea3@quack3.lan> <4591d02d-1f14-c928-1c50-6e434dfbb7b2@huawei.com> <20220426074023.5y4gwvjsjzem3vgp@quack3.lan> <77b4c06c-f813-bcac-ea26-107e52f46d0a@huawei.com> <20220426091556.qzryd552gzo6dikf@quack3.lan> From: "yukuai (C)" Message-ID: <6a829b09-4546-990a-52b6-bbd398f864bb@huawei.com> Date: Tue, 26 Apr 2022 19:27:24 +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: <20220426091556.qzryd552gzo6dikf@quack3.lan> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 在 2022/04/26 17:15, Jan Kara 写道: > On Tue 26-04-22 16:27:46, yukuai (C) wrote: >> 在 2022/04/26 15:40, Jan Kara 写道: >>> On Tue 26-04-22 09:49:04, yukuai (C) wrote: >>>> 在 2022/04/26 0:16, Jan Kara 写道: >>>>> Hello! >>>>> >>>>> On Mon 25-04-22 21:34:16, yukuai (C) wrote: >>>>>> 在 2022/04/25 17:48, Jan Kara 写道: >>>>>>> On Sat 16-04-22 17:37:50, Yu Kuai wrote: >>>>>>>> Weight-raised queue is not inserted to weights_tree, which makes it >>>>>>>> impossible to track how many queues have pending requests through >>>>>>>> weights_tree insertion and removel. This patch add fake weight_counter >>>>>>>> for weight-raised queue to do that. >>>>>>>> >>>>>>>> Signed-off-by: Yu Kuai >>>>>>> >>>>>>> This is a bit hacky. I was looking into a better place where to hook to >>>>>>> count entities in a bfq_group with requests and I think bfq_add_bfqq_busy() >>>>>>> and bfq_del_bfqq_busy() are ideal for this. It also makes better sense >>>>>>> conceptually than hooking into weights tree handling. >>>>>> >>>>>> bfq_del_bfqq_busy() will be called when all the reqs in the bfqq are >>>>>> dispatched, however there might still some reqs are't completed yet. >>>>>> >>>>>> Here what we want to track is how many bfqqs have pending reqs, >>>>>> specifically if the bfqq have reqs are't complted. >>>>>> >>>>>> Thus I think bfq_del_bfqq_busy() is not the right place to do that. >>>>> >>>>> Yes, I'm aware there will be a difference. But note that bfqq can stay busy >>>>> with only dispatched requests because the logic in __bfq_bfqq_expire() will >>>>> not call bfq_del_bfqq_busy() if idling is needed for service guarantees. So >>>>> I think using bfq_add/del_bfqq_busy() would work OK. >>>> Hi, >>>> >>>> I didn't think of that before. If bfqq stay busy after dispathing all >>>> the requests, there are two other places that bfqq can clear busy: >>>> >>>> 1) bfq_remove_request(), bfqq has to insert a new req while it's not in >>>> service. >>> >>> Yes and the request then would have to be dispatched or merged. Which >>> generally means another bfqq from the same bfqg is currently active and >>> thus this should have no impact on service guarantees we are interested in. >>> >>>> 2) bfq_release_process_ref(), user thread is gone / moved, or old bfqq >>>> is gone due to merge / ioprio change. >>> >>> Yes, here there's no new IO for the bfqq so no point in maintaining any >>> service guarantees to it. >>> >>>> I wonder, will bfq_del_bfqq_busy() be called immediately when requests >>>> are completed? (It seems not to me...). For example, a user thread >>>> issue a sync io just once, and it keep running without issuing new io, >>>> then when does the bfqq clears the busy state? >>> >>> No, when bfqq is kept busy, it will get scheduled as in-service queue in >>> the future. Then what happens depends on whether it will get more requests >>> or not. But generally its busy state will get cleared once it is expired >>> for other reason than preemption. >> >> Thanks for your explanation. >> >> I think in normal case using bfq_add/del_bfqq_busy() if fine. >> >> There is one last situation that I'm worried: If some disk are very >> slow that the dispatched reqs are not completed when the bfqq is >> rescheduled as in-service queue, and thus busy state can be cleared >> while reqs are not completed. >> >> Using bfq_del_bfqq_busy() will change behaviour in this specail case, >> do you think service guarantees will be broken? > > Well, I don't think so. Because slow disks don't tend to do a lot of > internal scheduling (or have deep IO queues for that matter). Also note > that generally bfq_select_queue() will not even expire a queue (despite it > not having any requests to dispatch) when we should not dispatch other > requests to maintain service guarantees. So I think service guarantees will > be generally preserved. Obviously I could be wrong, we we will not know > until we try it :). Thanks a lot for your explanation, I'll do some tests. And i'll send a new version if tests look good.