From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8724FC4167B for ; Tue, 5 Dec 2023 11:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JVsZgnUKradkSOC38+NohgG9Fx7qECN1+7FhtFQHM+8=; b=x7JBauwqK30Gcm Qmgh0sjD3pgaCn89zxgYvPd0nlyuWIHQkOTvctGuNxyuma2TaxIzK/7y7/q/m4lRoicC6ei4nrjKg npwnUPdh2HgQt5wjn1GPZaVW8o4EsmGPPCRhgarOphX+/mWDpIhMMSDWmOCh8c4Gh6jlw9Qlr90as Q3tC+COt04zm6RiWVo2m1UfOD0PKm5ohCMXRZH+omtQM60D6CtyVjiVLbQoPuQ7vGgvsn6ve6FcTp ST0gcZjEDfHYL8wD+2z8Zdig7DUFc1A7GjkwoSbnb/Gi7PcJbqlthZQKiBL2uvKikcsr/IbHqtyui MS2PoFeDN5VEiOFfd/EQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rATEr-0073bL-2g; Tue, 05 Dec 2023 11:05:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rATEo-0073ZS-0q for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 11:05:15 +0000 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 A48AE139F; Tue, 5 Dec 2023 03:05:57 -0800 (PST) Received: from localhost (ionvoi01-desktop.cambridge.arm.com [10.2.78.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACC663F5A1; Tue, 5 Dec 2023 03:05:10 -0800 (PST) Date: Tue, 5 Dec 2023 11:05:09 +0000 From: Ionela Voinescu To: Sumit Gupta Cc: Beata Michalska , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, sudeep.holla@arm.covm, will@kernel.org, catalin.marinas@arm.com, viresh.kumar@linaro.org, rafael@kernel.org, yang@os.amperecomputing.com, linux-tegra@vger.kernel.org Subject: Re: [PATCH v2 2/2] cpufreq: Wire-up arch-flavored freq info into cpufreq_verify_current_freq Message-ID: References: <20231127160838.1403404-1-beata.michalska@arm.com> <20231127160838.1403404-3-beata.michalska@arm.com> <3e6077bb-907c-057f-0896-d0a5814a4229@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3e6077bb-907c-057f-0896-d0a5814a4229@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_030514_413200_700D2D56 X-CRM114-Status: GOOD ( 29.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Sumit, On Friday 01 Dec 2023 at 18:32:10 (+0530), Sumit Gupta wrote: > Hi Ionela, > > > > --- a/drivers/cpufreq/cpufreq.c > > > +++ b/drivers/cpufreq/cpufreq.c > > > @@ -1756,7 +1756,8 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b > > > { > > > unsigned int new_freq; > > > > > > - new_freq = cpufreq_driver->get(policy->cpu); > > > + new_freq = arch_freq_get_on_cpu(policy->cpu); > > > + new_freq = new_freq ?: cpufreq_driver->get(policy->cpu); > > > > Given that arch_freq_get_on_cpu() is an average frequency, it does not > > seem right to me to trigger the sync & update process of > > cpufreq_verify_current_freq() based on it. > > > > cpufreq_verify_current_freq() will at least modify the internal state of > > the policy and send PRE and POST notifications, if not do a full frequency > > update, based on this average frequency, which is likely different from > > the current frequency, even beyond the 1MHz threshold. > > > > While I believe it's okay to return this average frequency in > > cpuinfo_cur_freq, I don't think it should be used as an indication of > > an accurate current frequency, which is what > > cpufreq_verify_current_freq() expects. > > > > Sumit, can you give more details on the issue at [1] and why this change > > fixes it? > > > > [1] https://lore.kernel.org/lkml/6a5710f6-bfbb-5dfd-11cd-0cd02220cee7@nvidia.com/ > > > > Thank you, > > Ionela. > > > cpufreq_verify_current_freq() also updates 'policy->cur' in POST > notification if the frequency from hardware has more delta (out of sync). > > As the value from 'cpufreq_driver->get()' is not reliable due to [1], > calling the 'get' hook can update the 'policy->cur' with a wrong value when > governor starts in cpufreq_start_governor(). > And if the frequency is never changed after the governor starts during > boot e.g. when performance governor is set as default, then > 'scaling_cur_freq' always returns wrong value. > > Instead, the arch_freq_get_on_cpu() API updates 'policy->cur' with a more > stable freq value. > > [1] https://lore.kernel.org/lkml/20230418113459.12860-7-sumitg@nvidia.com/ Got it, many thanks! As the code is right now in v2, arch_freq_get_on_cpu() is called on show_scaling_cur_freq(), so the problem you describe would not show up. policy->cur would still be incorrect, but 'scaling_cur_freq' would return the value from arch_freq_get_on_cpu(). Would it be enough if arch_freq_get_on_cpu() gets also called from show_cpuinfo_cur_freq() instead of cpufreq_verify_current_freq()? Thanks, Ionela. > > Best regards, > Sumit Gupta > > > > if (!new_freq) > > > return 0; > > > > > > -- > > > 2.25.1 > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel