Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp136142rdh; Wed, 25 Oct 2023 19:36:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHV3vbzLlMU3nICStYuCLp5qz+vrdWcFjdcic9GNKouTu2nEXt+gCUzr5aA411fZS9Dobjy X-Received: by 2002:ae9:e912:0:b0:774:3235:4e6d with SMTP id x18-20020ae9e912000000b0077432354e6dmr15700648qkf.21.1698287791736; Wed, 25 Oct 2023 19:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698287791; cv=none; d=google.com; s=arc-20160816; b=pn2N24KtpUWEx7+O/JbkE6TmpHzHzBFmP+PtqN6muYP1xd2LXgDlvfZWDg8m+zeYs0 MapROnTWyM2Zmd7wLiylr7+cuo26yJ33uzIhl4Ply1cDu7CXzEi6kRPkFIXbht2iECJB j1Jk6IBunXPosgwfaucu9zQ5ASPNt4uBjE9Yp6aQVyoCHVrgFbyxXQdW2SBOpZgKUlXU +mxPu6Y9A+Q1Mkk2dQ/6mvj+WMndYIekxqKxqgn4+qh60584gvwDoPAl7bkcMpy0myw0 URu2Y4YQnbDh3rG2BgZ4DxhMR3s15OEvXLpra/J0Co+ArQNBmHEx8toHFlAvVPYVwvRt XFag== 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=PUWWJmzAhBbw67VWF8RUvXpmfdEk6g9eTz9r9eh9jn4=; fh=PSA9alnGL/AcTb/cu1N0aqZkOgGbrvpaaSI8/tkwr1E=; b=sPub16U57IAVqt/j0bHoAyeU8H/I5UzmEsIHaOEd0ypzwvF5QI2TkyE610IstDxMlO l2QoaPXww/FwDcQeiWgL4Rw0++RtlV8Vk8OiYAySyTFIjQ7iZHZKau33gBQX9khP7UDN Dl6gJda0pjFgfn9lAM3ennDmOBXEKp2PhbS5Yv94A94sZ4zMJWEIQ8Ps764Nazk5+Wzr 3+rFC+7oC/JkOZwdD1pPnJ/a+bqdPLNpS9tLejuJyyuNPv2MlFexz41cFtZ/KighVoRR 56toUKqegycIz0R8A+i5ZPlAhciJvWTucPw5XwnD/rOkyeZQcIP3T4i3wIzH7Khs//dX rS3A== 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:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id f133-20020a256a8b000000b00d7bad264374si11856418ybc.132.2023.10.25.19.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 19:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3FEEF80F4E1F; Wed, 25 Oct 2023 19:36:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbjJZCgV (ORCPT + 99 others); Wed, 25 Oct 2023 22:36:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjJZCgV (ORCPT ); Wed, 25 Oct 2023 22:36:21 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D164910A; Wed, 25 Oct 2023 19:36:18 -0700 (PDT) Received: from kwepemi500024.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SG8vd5cJbzNpW6; Thu, 26 Oct 2023 10:32:13 +0800 (CST) Received: from [10.174.179.163] (10.174.179.163) by kwepemi500024.china.huawei.com (7.221.188.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 26 Oct 2023 10:36:16 +0800 Message-ID: <1369cedf-e66b-82eb-4501-a6976bb8c558@huawei.com> Date: Thu, 26 Oct 2023 10:36:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH -next] cpufreq: userspace: Keep the current frequency when set userspace policy Content-Language: en-US To: Viresh Kumar CC: , , , , , References: <20231025080910.3245690-1-zengheng4@huawei.com> <20231025111821.pp3hdpilddbx4yzr@vireshk-i7> From: Zeng Heng In-Reply-To: <20231025111821.pp3hdpilddbx4yzr@vireshk-i7> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.163] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500024.china.huawei.com (7.221.188.100) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.1 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 howler.vger.email 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 (howler.vger.email [0.0.0.0]); Wed, 25 Oct 2023 19:36:29 -0700 (PDT) 在 2023/10/25 19:18, Viresh Kumar 写道: > On 25-10-23, 16:09, Zeng Heng wrote: >> When switching to the userspace policy, if the current frequency is within >> the range of policy's min and max values, the current frequency value >> should be remained. The .limit() function is called when changing governor >> or updating governor limits, so in both cases, there is no need to update >> frequency if the current frequency does not exceed the threshold. >> >> Additionally, when changing to userspace governor, the default value of >> set_speed is set by reading the current frequency of the CPU, but there >> is inevitable error between the frequency coming from .get_rate() interface >> and the actual working frequency. Consequently, when switching to userspace >> policy, keeping the current frequency can avoid unexpected changes. >> >> Signed-off-by: Zeng Heng >> --- >> drivers/cpufreq/cpufreq_userspace.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c >> index 2c42fee76daa..fe55a7bb663c 100644 >> --- a/drivers/cpufreq/cpufreq_userspace.c >> +++ b/drivers/cpufreq/cpufreq_userspace.c >> @@ -117,9 +117,7 @@ static void cpufreq_userspace_policy_limits(struct cpufreq_policy *policy) >> else if (policy->min > userspace->setspeed) >> __cpufreq_driver_target(policy, policy->min, >> CPUFREQ_RELATION_L); >> - else >> - __cpufreq_driver_target(policy, userspace->setspeed, >> - CPUFREQ_RELATION_L); >> + /* Otherwise, keep the current frequency. */ >> >> mutex_unlock(&userspace->mutex); >> } > Here is some reasoning why it should be done the way it is: > > commit e43e94c1eda7 ("cpufreq: Fix GOV_LIMITS handling for the userspace governor") Get it, thanks for the response. Zeng Heng