Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp419527rwi; Mon, 10 Oct 2022 02:14:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46zGc8XeDhUyiLKIiEN3FOL30qoTlw5BHJqe24z6/ow6Oru3ktHoi2EFO9GZ80eQvQrRSL X-Received: by 2002:a17:906:9b94:b0:78d:b8a5:7493 with SMTP id dd20-20020a1709069b9400b0078db8a57493mr2256325ejc.530.1665393288561; Mon, 10 Oct 2022 02:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665393288; cv=none; d=google.com; s=arc-20160816; b=i2fWalwMwqiGOGEBWwQv2fWGXHBAUL2Sc6tVF3mVwD4dmy9HgUI2ipEbvQ8kDxDfaq m9lwD6/5XWJS2DvMV8ghzIYcD2xmHOowp4OfHAfS8A0WRusRlF5hqoWjniGJ0C/h3Dvy fayhZrwIfi9dQrmejCydwkJ4Ub1VwFFE2N4kDXL40U7KXnyzcdYHJPXRCeEZe0sK4yVF DuMXlqBLyOyPt+wlMQUqnHCmzUv9JCsoyZeZfVMTBnvJ87nw8pfs7erT2QFTEIWbCcqU gv31UuelKetuDOWb8RJSDwyz8T9QCZn7CrmarUBDwJVuC73RFHOh9710Ehox7l9gUiqc mp/Q== 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=+GNj1cLZa1w4op3rAU7oLUfhgn4jzsFnnye7BQoaUKg=; b=uEf0P5t+qJZzJzwptjkAZ6guyCxwsjObw6/gUbeYNBE3n8lJ/H2qbdhzQnvF7Fo5Qc 8dc4t4gtcfBroKTAOJ9eMsQNe7Zq/DoJDbdz78+A1dqUMLz85lpbExDvQkBeBXtrYgZf 4B0Kppnc2ywy8we/2nlwDsmmwxWhdEadGgtJmqkVwOqrpA/Bk1SgLLww65t509cw6joc kE4N3PyQ7bOWQUs+KNr41e9KD1trb/NOG0WoXmi4e6RcUa2Ayvp73P5FXBE9eIVh0oCp Yvs1yo9OxFRbSAywpE2yCGQ0goc2FdP/JJFveqneDSnTDjMe0ARUOGwPV9I7AhjoOuwe V3ew== 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 du18-20020a17090772d200b00787c0e9818csi9361669ejc.568.2022.10.10.02.14.18; Mon, 10 Oct 2022 02:14:48 -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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231590AbiJJJCc (ORCPT + 99 others); Mon, 10 Oct 2022 05:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiJJJCb (ORCPT ); Mon, 10 Oct 2022 05:02:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64FE81127; Mon, 10 Oct 2022 02:02:30 -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 5B1041480; Mon, 10 Oct 2022 02:02:36 -0700 (PDT) Received: from [10.57.5.39] (unknown [10.57.5.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DFA6D3F792; Mon, 10 Oct 2022 02:02:28 -0700 (PDT) Message-ID: <3f9a4123-171b-5fa7-f506-341355f71483@arm.com> Date: Mon, 10 Oct 2022 10:02:27 +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 2/2] cpufreq: Update CPU capacity reduction in store_scaling_max_freq() Content-Language: en-US To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, rafael@kernel.org, linux-pm@vger.kernel.org, Dietmar.Eggemann@arm.com, peterz@infradead.org, Vincent Guittot References: <20220930094821.31665-1-lukasz.luba@arm.com> <20220930094821.31665-2-lukasz.luba@arm.com> <20221010053902.5rofnpzvyynumw3e@vireshk-i7> From: Lukasz Luba In-Reply-To: <20221010053902.5rofnpzvyynumw3e@vireshk-i7> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,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 10/10/22 06:39, Viresh Kumar wrote: > Would be good to always CC Scheduler maintainers for such a patch. Agree, I'll do that. > > On 30-09-22, 10:48, Lukasz Luba wrote: >> When the new max frequency value is stored, the task scheduler must >> know about it. The scheduler uses the CPUs capacity information in the >> task placement. Use the existing mechanism which provides information >> about reduced CPU capacity to the scheduler due to thermal capping. >> >> Signed-off-by: Lukasz Luba >> --- >> drivers/cpufreq/cpufreq.c | 18 +++++++++++++++++- >> 1 file changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c >> index 1f8b93f42c76..205d9ea9c023 100644 >> --- a/drivers/cpufreq/cpufreq.c >> +++ b/drivers/cpufreq/cpufreq.c >> @@ -27,6 +27,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -718,6 +719,8 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf) >> static ssize_t store_scaling_max_freq >> (struct cpufreq_policy *policy, const char *buf, size_t count) >> { >> + unsigned int frequency; >> + struct cpumask *cpus; >> unsigned long val; >> int ret; >> >> @@ -726,7 +729,20 @@ static ssize_t store_scaling_max_freq >> return -EINVAL; >> >> ret = freq_qos_update_request(policy->max_freq_req, val); >> - return ret >= 0 ? count : ret; >> + if (ret >= 0) { >> + /* >> + * Make sure that the task scheduler sees these CPUs >> + * capacity reduction. Use the thermal pressure mechanism >> + * to propagate this information to the scheduler. >> + */ >> + cpus = policy->related_cpus; > > No need of this, just use related_cpus directly. > >> + frequency = __resolve_freq(policy, val, CPUFREQ_RELATION_HE); >> + arch_update_thermal_pressure(cpus, frequency); > > I wonder if using the thermal-pressure API here is the right thing to > do. It is a change coming from User, which may or may not be > thermal-related. Yes, I thought the same. Thermal-pressure name might be not the best for covering this use case. I have been thinking about this thermal pressure mechanism for a while, since there are other use cases like PowerCap DTPM which also reduces CPU capacity because of power policy from user-space. We don't notify the scheduler about it. There might be also an issue with virtual guest OS and how that kernel 'sees' the capacity of CPUs. We might try to use this 'thermal-pressure' in the guest kernel to notify about available CPU capacity (just a proposal, not even an RFC, since we are missing requirements, but issues where discussed on LPC 2022 on ChromeOS+Android_guest) Android middleware has 'powerhits' (IIRC since ~4-5 versions now) but our capacity in task scheduler is not aware of those reductions. IMO thermal-pressure mechanism is good, but the naming convention just might be a bit more 'generic' to cover those two users. Some proposals of better naming: 1. Performance capping 2. Capacity capping 3. Performance reduction What do you think about changing the name of this and cover those two users: PowerCap DTPM and this user-space cpufreq?