Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1012022rdb; Fri, 1 Dec 2023 05:02:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEszrxotmneEzG2tDaf9Ie/jCMjPHvfL7Lusm+P2YIWitDSBn+7dEyXVirtxjlG15KKtpYu X-Received: by 2002:a05:6a00:9384:b0:6cd:dfae:1b44 with SMTP id ka4-20020a056a00938400b006cddfae1b44mr7446780pfb.34.1701435775006; Fri, 01 Dec 2023 05:02:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701435774; cv=pass; d=google.com; s=arc-20160816; b=ltoQ1SzLZWqOgTeGlRLRo735OXC5qP+eK42ekzsifnZ1uLIBkwBTZ+IFdpzAu0g48G MRiFx43wSZKXw8LwElN041oIziAVX+hrhieyJeACPzI7ICMzpd21UyzXSpEjmhqnb/cp G9gB/Vln9CSJ1ZST6DsH4tW52lsi4QQ57avs1tVpk+W0XyRuEH7dHPhlT7ypXOSlTade 7xJysEVuCCcDRNH40sAxNYEw2AXhqw8juBJT+Cf4nCUbvFOx2EDWBJSgHDNduK1Y/a0i wdpOZGTdB1TPopv2Ysx3AWihscu3iASiWihRbGbCJg50U4ePpoX7HjDQTs7TvTDdaZJn MRQQ== ARC-Message-Signature: i=2; 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:dkim-signature; bh=rrCfA8ufham5WJFVdTba5/o9lVBfvgzfJ6TyG6wGXIc=; fh=FBWonZ2/UKe2WeFioNV2zEheEPW5/+lOQPjWByQtmnk=; b=AXJ8zEusOaM8AM/unOZAhDUuSuv5ZFNMd4Cqdyc43f66RC2EmOna1Vdg2mkzOVRkWR fOp8kS6Y0NmUZ3LINSivpgcTkHOjTgaTtEf452dVnK+1/h8/NQDd32xujGQ5c+DW1y4C QrLT91s3K99ksZE+yz0auSYRG+Nxs+NPAGkqCaJ+JamEw7jAwdA4F3iN7ywiofFkr95B SgmSzLYVLzxKfu6C/ziPSbPsiS5vAFH1U3YSRftomxLjLA9kz/l+0Vd7GRMYvUlriRCd wk34o9ny8zne/qow0M0P3tTXQ/iGfjGVzjK2+dJrmPXnDxIGlOODl4u5sH68cmF8MavL eCkQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="R/pRRFAn"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id de12-20020a056a00468c00b006cddd0d9820si3084630pfb.72.2023.12.01.05.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 05:02:54 -0800 (PST) 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; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="R/pRRFAn"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C13AA810673C; Fri, 1 Dec 2023 05:02:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378913AbjLANCm (ORCPT + 99 others); Fri, 1 Dec 2023 08:02:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378858AbjLANCl (ORCPT ); Fri, 1 Dec 2023 08:02:41 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2087.outbound.protection.outlook.com [40.107.94.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB241B3; Fri, 1 Dec 2023 05:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gprZmvo1RGXBoStFSFuo5nBAAiZWbWf28uCsszDHpD3Y+aLUvps9gKCdLkiDX5znciss7+SE4cphaixVyOW6RdRGpHHqtjna3/kKPmBhrk+h6sQbOvvKbf50EKFWcQnsW20J2Q8dz2nc6kFdLvrSF3VhYSuLM5AMA1YpGe5uepzT424wAdWbQWYbW7prQTqxYjznFyWoOGVRPjGe9gxLKFxv3XJ2Egl0ORji8LGYdDZK7NDAwdxETgYV+4aRs2/qkrzbPj2pKaznGf3CjGtrjR+f2Efve0Zyx/lzGo+I7Q8LFNkEgtXvxKLomppXoUVYsy6JZcqYnrONUN6h0X726A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rrCfA8ufham5WJFVdTba5/o9lVBfvgzfJ6TyG6wGXIc=; b=DCqohLzgVr6WSrfimXn4zmG601Wpmr1oxaS09bfQouqD2VFzAFiuekgaF1JfwixrGseEwTyVX8RhU57WBmIJrDeYnJNn2c3ve6xNO1c3qeDAXb2zfm8gaU26xalSxMUeReiz8QKEpYdkb/9sdcDXPKgQFJfVWo7TqLZmyVhUWhnHCs4Tbr2dOmtFlubdeAchtUxmQZ+1WOJug8vLvJxpAvdBi+Tgg+19dfLXtV04RzwiRjtjiD2mtBwoBcqib9ugiOIrmgclf/7KkwgQWf+nHY0ZFPoYUXZxGVmuoNh19NJE4kcR2HK1j9iZUXw/eeiSEZw0bZabKC0N7z5UF8VU4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=arm.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rrCfA8ufham5WJFVdTba5/o9lVBfvgzfJ6TyG6wGXIc=; b=R/pRRFAnik1cjQ0RJqgzGQqS5KA+T22ik02js4Br476KbMls6nXZoVSGHFn6un5efM35XFFVznd2nKGNM77hC1efss2om9N1JLfYvEWxvuHUYCNJpe7/7A2AzSKrVg3bhhKouDv8JjQqf/BRipcxjdBAsIq09f1BqWmAyid30wlF3AiG6zsjNqatmk8u8uB4nRntQ+yPhQDW1mzwSXHCEjv1hpsLLGx61FGogq5BhBUbPHNnnTsv+VsFEPyCAFcI3O26VQP7tVadaHg2+LwxPG/PKanJD9fVbBBbfAUniZ4DNHHkToGeVT4wu1wq0fkQNwolO8q3D9b2WLdsXAr4pg== Received: from PH7PR17CA0021.namprd17.prod.outlook.com (2603:10b6:510:324::27) by DM4PR12MB6304.namprd12.prod.outlook.com (2603:10b6:8:a2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.24; Fri, 1 Dec 2023 13:02:43 +0000 Received: from SN1PEPF0002BA52.namprd03.prod.outlook.com (2603:10b6:510:324:cafe::2f) by PH7PR17CA0021.outlook.office365.com (2603:10b6:510:324::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.27 via Frontend Transport; Fri, 1 Dec 2023 13:02:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002BA52.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.17 via Frontend Transport; Fri, 1 Dec 2023 13:02:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 1 Dec 2023 05:02:16 -0800 Received: from [10.41.21.79] (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Fri, 1 Dec 2023 05:02:13 -0800 Message-ID: <3e6077bb-907c-057f-0896-d0a5814a4229@nvidia.com> Date: Fri, 1 Dec 2023 18:32:10 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2 2/2] cpufreq: Wire-up arch-flavored freq info into cpufreq_verify_current_freq Content-Language: en-US To: Ionela Voinescu , Beata Michalska CC: , , , , , , , , , , Sumit Gupta References: <20231127160838.1403404-1-beata.michalska@arm.com> <20231127160838.1403404-3-beata.michalska@arm.com> From: Sumit Gupta In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA52:EE_|DM4PR12MB6304:EE_ X-MS-Office365-Filtering-Correlation-Id: bccdf2db-2f0a-45a3-4f72-08dbf26dce71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ogXGgQNdb/rTEiCZeK5XvOd6c/Cebhs3wlyR678hynVc71RcMZrUtkNzEbZ2VVz2oC9oiRmEyiuSVPgNkyh46QjrdMqUf1y3IPGaQ8hhqLx8laKsWgPJu85qfAXGl+xB1ZAqTaSWzgce5PkMop2ch+jZ0o6s1TV0QbMfCsCkL1c6Zf90P5pg/Eag9RIGmIiHqldV6Uz1oj3dNOoJpUoCgDyGncYuQHqMPu2E4gCqgemTaS2a/H5srfknl1vurfsd9AYuTflzdKzSrRy1Yn/3z0VAMoZtU6We01R4FTFwQrLoa8Ju04KtsMeqtjxPODrbyvyQ1Lw7EnRWl3H6Vs45jM2EI+skldllnaTLD8fQ3/T9I7883PHI4XOhcPUOP9DJFkWeJ9TLjqqI27EaM1DC49cxsozU7xALaZfmJzYfj3n5RiIpUER6CxQjMOqXgfgoSUAbwXY4EjdX58NdEulNMyBeGkeoiRF/Aw8ALnQaZUrhaFY4BF+20Qx4DRs94JUOj8d8E0KaCDE+QgH7aqZrL9NQYkGomfkZF+KMn/LHzdfarUNvPt/3cWGJe7FNmywj4RwjpfQJmK3WCMJQ7jyOcGwfpJiVUqJ2IN9LoC3JhoxcDZ/rqESyLEvhMK99ItWt00Di8lt+rYfY+9fM2lMGHy6cV8QVnV4ZKsGgVii20KYzkW5JyAXeihGNHAmP63mF6fCIEEprT60J98A41bwiYugJ7TFrnH0SDgP6TVTe7LnWXi1xtUw1Jt1aCieLYnxCwV08OcrcMUDtWajTPI56+vSESZQO1PIUTmlejTCBSaYUIYTyvmnYwwdgXehwfBkOstzcgNoN3uCx4hySz8zqh5dNq7zU2l4pDPdYBH2NFk= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(230922051799003)(64100799003)(82310400011)(451199024)(186009)(1800799012)(40470700004)(36840700001)(46966006)(40480700001)(31686004)(86362001)(83380400001)(40460700003)(70586007)(70206006)(7636003)(356005)(82740400003)(36756003)(31696002)(54906003)(47076005)(36860700001)(426003)(26005)(2616005)(107886003)(110136005)(966005)(16526019)(2906002)(316002)(16576012)(4326008)(5660300002)(336012)(8936002)(7416002)(8676002)(478600001)(41300700001)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2023 13:02:43.0540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bccdf2db-2f0a-45a3-4f72-08dbf26dce71 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA52.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6304 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 01 Dec 2023 05:02:52 -0800 (PST) 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/ Best regards, Sumit Gupta >> if (!new_freq) >> return 0; >> >> -- >> 2.25.1 >>