Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2597101rdb; Tue, 12 Sep 2023 06:52:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3WTTrp4rTGFnhfhJEH5nbOSmXC0oFypJAjyb+vvd6XmCN3E9yScSEr2nKeCARkprtHSTS X-Received: by 2002:a17:902:c404:b0:1bd:e5e7:4845 with SMTP id k4-20020a170902c40400b001bde5e74845mr13979527plk.26.1694526755012; Tue, 12 Sep 2023 06:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694526754; cv=none; d=google.com; s=arc-20160816; b=bqostRha6JIsXz+qpqPvmon91f8yWpPDkmFxQbZL0/9IH7vCa4LB1KkSMtIBseYZk9 eWh56tJBHL6RBSVj74Db3phHhOUe0dKKy49CyYhbyFkRvOWYfyf5kBUv8lwln38idx9R uXuBrA/ag0PaNFFod4aDKifrxNZY48vwmMSgbpCKIkOo3/oVFTRDPjiBajaD2t7mnW6b MVq38ziqMsQgV+aWd6YeDS5iqSUcbHTXbL1FeNr3Tsd7yiPMy5iF+ZIDluRFNEOj4ism 3aW8Bra+DG26s/NKBbUov7H2KfVSRrX4+xxU4d4we6doEPydKMDzBlPCoUUUIcKQzVpV Aycw== 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:content-language:subject:user-agent:mime-version :date:message-id; bh=NZrL+pf1xMXRO2wAiIwUt+dbhir8o+kLK99eAfnlX20=; fh=e8h5+AOTR8Auejprs7NNsg2x26tbLAlabl6PRk+uZdY=; b=w1XPK1PCoeYyec/Lj9oqaSZC1ry3wRvmVjhP+brQuAzUy672Lo+fC8IfZw/7fRhzl9 ly8AtY73fALAr9yK4ShwNhQCba3OgZu9iq23HFKw3nMHbaPIrhtKI6ITyhTvJBrHpCl5 fGxncUhi6ZcXGEpIiWBLuqFLppEXDnJQFZsDvZxWY6Id2sJKCCkk1Mm0wlXT38z5SJUp JJcfFiXu2OFjnSpOS32b42Zjzx0AQxBH0iJ8C0HnE2mPtJNMuH+oKaGpNGj83xs4posG nDeNocsI6lvQBVUJBj3gw0pBeAjnDmpCt0S78QbdVTqFQG62hzMYhvQRKzGrqqyTHG4u dRHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u10-20020a170902e80a00b001bf0cc53d2csi8262925plg.261.2023.09.12.06.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 06:52:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3FBF280787F3; Tue, 12 Sep 2023 06:40:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235531AbjILNkS (ORCPT + 99 others); Tue, 12 Sep 2023 09:40:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbjILNkP (ORCPT ); Tue, 12 Sep 2023 09:40:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E6E310CE; Tue, 12 Sep 2023 06:40:11 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CD0F0C15; Tue, 12 Sep 2023 06:40:47 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 42D103F5A1; Tue, 12 Sep 2023 06:40:09 -0700 (PDT) Message-ID: <979a9e2f-06a8-1936-b5cd-2949eca99b21@arm.com> Date: Tue, 12 Sep 2023 15:40:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 2/4] sched: cpufreq: Fix apply_dvfs_headroom() escaping uclamp constraints Content-Language: en-US To: Qais Yousef , Vincent Guittot Cc: "Rafael J. Wysocki" , Viresh Kumar , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Lukasz Luba References: <20230820210640.585311-1-qyousef@layalina.io> <20230820210640.585311-3-qyousef@layalina.io> <20230829163740.uadhv2jfjuumqk3w@airbuntu> <20230907215555.exjxho34ntkjmn6r@airbuntu> <20230910174638.qe7jqq6mq36brh6o@airbuntu> From: Dietmar Eggemann In-Reply-To: <20230910174638.qe7jqq6mq36brh6o@airbuntu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 06:40:20 -0700 (PDT) X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email On 10/09/2023 19:46, Qais Yousef wrote: > On 09/08/23 16:30, Vincent Guittot wrote: > [...] >>>> above 512 whatever the current (720) formula or your proposal (608). >>>> In the case of uclamp, it should be applied after having been scaled >>>> by irq time. >>> >>> I lost you a bit here. I'm not sure how you reached the 720 and 608 numbers. >> >> My bad, I finally decided to use an irq pressure of 128 in my >> calculation but forgot to change the value in my email >> >>> >>> So the way I'm proposing it here >>> >>> util = cfs + rt + dvfs_headroom(cfs+rt) = 800 + 0.25 * 800 = 1000 >>> util = uclamp_rq_util_with(rq, util, NULL) = 512 >>> util = scale_rq_capacity(512, 256, 1024) = 0.75 * 512 = 384 >>> util += dvfs_headroom(irq) = 384 + 256 + 0.25 * 256 = 704 >>> util += dvfs_headroom(dl_bw) = 704 >>> >>>> >>>> So we should have reported utilization of 720 with a bandwidth >>>> requirement of 512 and then cpufreq can applies its headroom if needed >>> >>> The key part I'm changing is this >>> >>> util = cfs + rt + dvfs_headroom(cfs+rt) = 800 + 0.25 * 800 = 1000 >>> util = uclamp_rq_util_with(rq, util, NULL) = 512 >>> >>> Before we had (assume irq, rt and dl are 0 for simplicity and a single task is >>> running) >>> >>> util = cfs = 800 >>> util = uclamp_rq_util_with(rq, util, NULL) = 512 >>> util = dvfs_headroom(util) = 512 * 0.25 * 512 = 640 >>> >>> So we are running higher than we are allowed to. So applying the headroom >>> after taking uclamp constraints into account is the problem. I'm not sure I understood all the example math in this thread correctly: Examples: irq = 128 or 256 util = 800 uclamp = 512 --- current code: ((util_cfs + util_rt) * ((max - irq) / max) + irq + dl_bw) * scale <- uclamped(cfs+rt) -> <-- scale_irq_capacity() -->|<-- map_util_perf() / (headroom()) irq = 128: (512 * (1024 - 128) / 1024 + 128 + 0) * 1.25 = 576 * 1.25 = 720 irq = 256: (512 * (1024 - 256) / 1024 + 256 + 0) * 1.25 = 640 * 1.25 = 800 --- new approach: irq = 128: (512 * (1024 - 128) / 1024 + 128 + 0.25 * 128) = 608 irq = 256: (512 * (1024 - 256) / 1024 + 256 + 0.25 * 256) = 704 <-> uclamped(cfs+rt+headroom(cfs+rt)) <- scale_irq_capacity() -> <-- headroom(irq) ? --> Is the correct? [...]