Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp328213rwb; Wed, 9 Nov 2022 03:07:31 -0800 (PST) X-Google-Smtp-Source: AMsMyM64xZNPlT9Wm4GAwl0VQH8cZawSyZOkhFZ4pBMcyUeBDXS15RiPsZ2lYbhAbUPbX35kamif X-Received: by 2002:a62:874f:0:b0:56c:45eb:1ffa with SMTP id i76-20020a62874f000000b0056c45eb1ffamr61299730pfe.58.1667992051203; Wed, 09 Nov 2022 03:07:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667992051; cv=none; d=google.com; s=arc-20160816; b=wK5juocSwzb6pd58PeZFc9YF/v+fOUKi+mrWkSXmhcpQuULR2K0A1cY1apygRgTsip NFIUpkXCjTiTztdAHDtIZtJxHqJYxoQsi1kYX83geVM2D5fkiPeUsgxLdXEhbPK7bRuv Erhu+Ts+5bwxPPVaZ8iQ41/Nmfk/UFn9fDh1DryzYI3VDlGipM+0cwRgxqgvd9ba8w8Z K40YM8P4nBaB0PeHaqk3hS7VSUK3oLKGEHCmmMRc3Q9hAdI6kAUd3dh/fHMmUQOuxu12 utZPUewZegxrHO0bwm61VbV9PB4uGLEUVZOWz1HwoYv4bykDc/CefPafnHNvD51MZG0x L/sw== 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=5wZNFiRC1sQ/JlHIoNsJSMQFUz3ovhzcGCN45JTZPEg=; b=hAnF18ufWf875KXGnRkKPQma9R66A/FwD1dHOzQxmizUtmV5nwCVWpOSFdNim8q68d wzR2SmsQqAz2PKpYFgkURkDPibVYDQjNDz5DyZ88gEDCmbq/Nge8JtIiJ/E9esVt62Np SHmX0QbIkGgzLMUbpM4R8JbqhH1/jsMPjOfFFtPSolgPIl0iNCrcacfBqUTDP1eTE3e9 5wlf5iZP+xexwBndHp3/arLLfo22u9jrEbBr1i2pfW7Pwz0X5M6RSrsefpJjO1jedzZH 5KAecGYneKxez5bd5FgqBoHy8lI8W9pDt0qQ5hTZMIZnHigcM8Y+sO1vVx6lQLbjinbp fWkg== 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=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a63f241000000b0046ef23ae9a6si16746332pgk.848.2022.11.09.03.07.19; Wed, 09 Nov 2022 03:07:31 -0800 (PST) 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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbiKIKdV (ORCPT + 93 others); Wed, 9 Nov 2022 05:33:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiKIKdU (ORCPT ); Wed, 9 Nov 2022 05:33:20 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D8B6263F for ; Wed, 9 Nov 2022 02:33:19 -0800 (PST) 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 F1B231FB; Wed, 9 Nov 2022 02:33:24 -0800 (PST) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3FB4C3F534; Wed, 9 Nov 2022 02:33:17 -0800 (PST) Message-ID: <33fcfe74-f6c7-f85c-5a8d-51efdecfa0ab@arm.com> Date: Wed, 9 Nov 2022 11:33:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 1/9] sched/uclamp: Fix relationship between uclamp and migration margin Content-Language: en-US To: Qais Yousef , Ingo Molnar , "Peter Zijlstra (Intel)" , Vincent Guittot Cc: linux-kernel@vger.kernel.org, Xuewen Yan , Lukasz Luba , Wei Wang , Jonathan JMChen , Hank References: <20220804143609.515789-1-qais.yousef@arm.com> <20220804143609.515789-2-qais.yousef@arm.com> From: Dietmar Eggemann In-Reply-To: <20220804143609.515789-2-qais.yousef@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 On 04/08/2022 16:36, Qais Yousef wrote: [...] > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 52dc9d6f811e..00c2de800685 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -4254,6 +4254,129 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, > trace_sched_util_est_se_tp(&p->se); > } > > +static inline int util_fits_cpu(unsigned long util, > + unsigned long uclamp_min, > + unsigned long uclamp_max, > + int cpu) > +{ > + unsigned long capacity_orig, capacity_orig_thermal; > + unsigned long capacity = capacity_of(cpu); > + bool fits, uclamp_max_fits; > + > + /* > + * Check if the real util fits without any uclamp boost/cap applied. > + */ > + fits = fits_capacity(util, capacity); > + > + if (!uclamp_is_used()) > + return fits; > + > + /* > + * We must use capacity_orig_of() for comparing against uclamp_min and > + * uclamp_max. We only care about capacity pressure (by using > + * capacity_of()) for comparing against the real util. > + * > + * If a task is boosted to 1024 for example, we don't want a tiny > + * pressure to skew the check whether it fits a CPU or not. > + * > + * Similarly if a task is capped to capacity_orig_of(little_cpu), it > + * should fit a little cpu even if there's some pressure. > + * > + * Only exception is for thermal pressure since it has a direct impact > + * on available OPP of the system. > + * > + * We honour it for uclamp_min only as a drop in performance level > + * could result in not getting the requested minimum performance level. > + * > + * For uclamp_max, we can tolerate a drop in performance level as the > + * goal is to cap the task. So it's okay if it's getting less. > + * > + * In case of capacity inversion, which is not handled yet, we should > + * honour the inverted capacity for both uclamp_min and uclamp_max all > + * the time. > + */ > + capacity_orig = capacity_orig_of(cpu); > + capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure(cpu); Did you and Vincent agreed at the end to use `cap_orig - _instantaneous_ thermal pressure` (1) here? Last email in v1 from Vincent on this one was https://lkml.kernel.org/r/20220722151300.GA30193@vingu-book : "Using capacity_orig_of(cpu) - thermal_load_avg(rq_of(cpu)) seems like a simple solution to cover thermal mitigation". And there is no Acked-By/Reviewed-By so far. We use (1) in feec() to cater for the thermal throttling (thermal restricting policy->max) schedutil takes into account immediately when asking for frequency (performance). EAS and schedutil should see the same thing. Do you want to use the same in util_fits_cpu() since it's used in feec()? [...]