Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3051639rdb; Tue, 12 Sep 2023 23:43:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFEWnZ56BijAdbtYATZ86ylLE0mqZh2ChTb55pk1ple7RXuYA0Pp2sFSvodmx+1/bmUKEAl X-Received: by 2002:a17:90a:51c4:b0:26d:40ec:3cf3 with SMTP id u62-20020a17090a51c400b0026d40ec3cf3mr1325280pjh.0.1694587395808; Tue, 12 Sep 2023 23:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694587395; cv=none; d=google.com; s=arc-20160816; b=cUDzWpVsjL6YIsZOAFQC4l5SKVVDuWEDm+3ONdSnvo++CDFv8UqCclBQesGOyAUcAi LQOBNAuwvUzOqz0WOieGhm/s27rpGWps5lulUVZJ94lRSzYxiQhnOI3Y03qov1+4A47b sFobMvl+9/iKERbC03IcpsYr+AUqhhgE/2XT4t7fnl8rmuD8WQlQ0qqFQWqSLo5RZgVt cd4onJsEi8fCln8G87R+HPnePVLgTBjnSeQ+cD8RFFnu149HNAKK8dWd2icLA4zLiKKK XAppDx2IXhBoHOitZBOWzSQ5oBajKCgKlzytWKc/3YhV6vh5KzZc/crgcCY4Nvm2zBxW FsEg== 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=6sqkb4fftNykjUMd0fM4YQzHF09Fa0ybdk0F/of74S4=; fh=Pz4btxTJjpRruWqdFW1dGibdGKub9X9kSIOMrlafA2Q=; b=PUpYwrAqYce8wGGX94Tla02YZxzWfpu/VytkHWia1t5FMzvxxMkUoQx6QD7Tax7BpL ImRLKx1xsvBUnbgr5EEXKqYDT92KYrXZdM8Kx/Yil5gFllA/OwDN/To3m7BDMlHzze+X iXGezxhjUUNSihcrGK3gFXOaTqiCajsBquBGcke3yDjtyn+9bsNWM8JCStKijTpMdcvR Dvn7JrnVXbvdJYcRbpybVXCux9wOL+ENuwPOHj0ptgY+fA7qmrN+O7fKKmnkXix0IWkL GUMrYxPXaORPL88fxeB9WNja7HeWW5YCKreEGxXeEYdyin5+yK/TnZRZlR82vMesChwq KbEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u7-20020a17090a2b8700b0025bb4a1c12esi929288pjd.148.2023.09.12.23.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 23:43:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 6054E807C652; Tue, 12 Sep 2023 07:34:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236029AbjILOer (ORCPT + 99 others); Tue, 12 Sep 2023 10:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236028AbjILOeo (ORCPT ); Tue, 12 Sep 2023 10:34:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 52F1F12E; Tue, 12 Sep 2023 07:34:40 -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 42403C15; Tue, 12 Sep 2023 07:35:17 -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 B1EF33F5A1; Tue, 12 Sep 2023 07:34:38 -0700 (PDT) Message-ID: Date: Tue, 12 Sep 2023 16:34:27 +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 Cc: "Rafael J. Wysocki" , Viresh Kumar , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Vincent Guittot , Lukasz Luba References: <20230820210640.585311-1-qyousef@layalina.io> <20230820210640.585311-3-qyousef@layalina.io> <7839dd5f-e7fd-7065-934d-436d012ac9d6@arm.com> <20230826200829.gnha7xcrjbyipjr2@airbuntu> From: Dietmar Eggemann In-Reply-To: <20230826200829.gnha7xcrjbyipjr2@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 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:34:51 -0700 (PDT) On 26/08/2023 22:08, Qais Yousef wrote: > On 08/21/23 18:39, Dietmar Eggemann wrote: >> On 20/08/2023 23:06, Qais Yousef wrote: >>> DVFS headroom is applied after we calculate the effective_cpu_util() >>> which is where we honour uclamp constraints. It makes more sense to >>> apply the headroom there once and let all users naturally get the right >>> thing without having to sprinkle the call around in various places. >> >> uclamp is applied in effective_cpu_util(..., FREQUENCY_UTIL, ...) which >> IMHO currently has 2 power callers: (1) schedutil: sugov_get_util() and >> (2) EAS: eenv_pd_max_util() >> >>> Before this fix running >>> >>> uclampset -M 800 cat /dev/zero > /dev/null >>> >>> Will cause the test system to run at max freq of 2.8GHz. After the fix >>> it runs at 2.2GHz instead which is the correct value that matches the >>> capacity of 800. >> >> IMHO, a system at util = 800 (w/o uclamp) would also run at 2.8Ghz since >> we would call map_util_to_perf() on 800, no matter from where we call it. > > Sorry, I would very strongly disagree here. What you're saying the effective > range of uclamp_max is 800 and anything above that will always go to max. How > can this be acceptable? No that's not what I wanted to say here. I wanted to highlight the different treatment of `(1) a task with (natural) util = 800` and `(2) a task with uclamp_max = 800`. (1) util = 800 util = (1.25 * 800 * (1024 - irq) / 1024 + ... <- -> uclamped(cfs+rt+headroom(cfs+rt)) (2) uclamp_max = 800 util = (800 * (1024 - irq) / 1024 + ... <-> uclamped(cfs+rt+headroom(cfs+rt)) So for (1) the scheduler would ask for more than in (2). That's essentially the same question which was raised here: https://lkml.kernel.org/r/CAKfTPtDY48jpO+b-2KXawzxh-ty+FMKX6YUXioNR7kpgO=ua6Q@mail.gmail.com >>> Note that similar problem exist for uclamp_min. If util was 50, and >>> uclamp_min is 100. Since we apply_dvfs_headroom() after apply uclamp >>> constraints, we'll end up with util of 125 instead of 100. IOW, we get >>> boosted twice, first time by uclamp_min, and second time by dvfs >>> headroom. >> >> I see what you want to change here but: >> >> So far we have `util -> uclamp -> map_util_to_perf()` > > :-O > > So when I set the system uclamp_max to 800 it will still run at max; and this > is normal?!! No that's an issue (A) as well. But the diff between (1) and (2) is IMHO a new issue introduced by this patch-set. >> which is fine when we see uclamp as an entity which constrains util, not >> the util after being mapped to a capacity constraint. > > -ENOPARSE. What I meant is 'clamping the util' before scheduler hands over to 'cpufreq' is fine: util -> uclamp -> map_util_to_perf() scheduler -->|<-- cpufreq I do understand that you guys are already discussing a new cpufreq_give_me_freq_for_this_utilization_ctx() between EM and CPUfreq in the other thread of this patch to maybe sort out (A). [...]