Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp198241lqt; Thu, 6 Jun 2024 00:21:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUe60vnF+Sgmy5P+kc0DtFT6QOA0Br1ycM4Sa+7sR/aFE75MAlkrxDQREcKHVE8GD0gsjzYn5jdN6Ag+KY7ZCMJC0bMnCd1aQaYzxfIYQ== X-Google-Smtp-Source: AGHT+IH9o6C/0IaN4I2BwNFT0jHWgV/nOfyIcFoOoBbcHUXneibu7lm3vqY+dvstCrQiRe0jXK80 X-Received: by 2002:a05:6358:88b:b0:199:2e73:b3b8 with SMTP id e5c5f4694b2df-19c6c8fa6dfmr534172055d.26.1717658500712; Thu, 06 Jun 2024 00:21:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717658500; cv=pass; d=google.com; s=arc-20160816; b=0mtD89aqaKFcD41yFFAp+1uMnbFSLFQolw4NRUWHCZfrzaT6S43vPgD+btMhsGbfiy RqWosOXXLwyVTGWU8JZ4MJOEpjiIAp4VwfsWI6/Peuv6tPnI9ett4ELrxykNbP6R9PTW qFzYL0uH9S/BhxI82iryBxgaHukqtyEsllB5yFwsdB1GfXNS09+YKwf8YQgi9gVX7BZe WsonLqh6zbSocK1yumJPy0vBV1K+UjhiKACuNA7q1lNGXuzRJjfph2T8BEBQN2q2ka0K aNSUPEuWSScmvYslJ5WYLTnxIq3pxbTU4X0VIQVRpWoAPtYdP9U8WnEoO/OFy9l22gy7 sCjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MFC1pyOlym/b5PhJaLl2pSzHoJdyGjWFMkMHwggkOGg=; fh=C20ZdT7nsbJ+oKbrTBJB8HrZcfA7CckdPTrkr7Lis7k=; b=hw6rC1WMFbkFa2kkoQAE7sfpMO9+MedNSIL3IxAkM05/2k09v79jMQ1cTFDFG4GvZ7 4kLnSZa9MFOdlHQtCsoa7sO3UcaQkwCPbrpMXBrd0EdunVipxee0M1lKK5jPNy5GOwlZ MonDm65bmmh3SYW5vKA0fZ2X4ipDYYzdluHdecAlfv5cTTOCWWWKwGjsU11Gw+dmv0Ys 243suTsG1EyBQkvtYbqeEgWuotKLFuIG4IVORAsAJd9H+nJzbAm1PR/5wwSNE0Dmtfem g7FLWU9zuo4nAPJ8++exxTURIOU2/LvjLWyGsuA9Hd1kOuSJzAXz4pOThGlHdDCITu8w OvQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HHWp8mxF; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-203722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203722-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2073c872si694546a12.31.2024.06.06.00.21.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 00:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HHWp8mxF; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-203722-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203722-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7229BB22E68 for ; Thu, 6 Jun 2024 07:21:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2E7713C692; Thu, 6 Jun 2024 07:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HHWp8mxF" Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B7DD13AA47 for ; Thu, 6 Jun 2024 07:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717658437; cv=none; b=PqNeQRiP5tB5TaNplq8q+HdxZpgsph4rBvJsGEWLzkSy+xDhUSuUmzgSe976o3jCwxIFz1RJRf94J8cShEIB8y7SdbVDjMXHxAtNJ9zp7R2kb9ox8y5biex12pKY2vkXygbJAHUR2dm2o6kQoOYMTaBvrafvSrMYEkJ8lxPNWtE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717658437; c=relaxed/simple; bh=E1UEL5t44rjWMroslFhKMMvwn7TQfKD6dRQVyrgGjGA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JUGAVnBnd2X5QJCdCU59p416FEE/3eNs49J6FzmpNHfrc68eA2vhPjfaGN1pqrifDAWqZsdpXM67bE21mbH1rFDD9drU4q9qF+J1mURxDBECEJFu2kJ9unKMJHyYh1Bx2DyOYW2e74ESRGlvryvWK3RyDhb5WRyRCtSl4AoAlWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=HHWp8mxF; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6f943a34a83so239563a34.0 for ; Thu, 06 Jun 2024 00:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717658434; x=1718263234; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MFC1pyOlym/b5PhJaLl2pSzHoJdyGjWFMkMHwggkOGg=; b=HHWp8mxFzCgxUbpUYDEVUziaQ0Dt6DpmRIe+kp+SsWABN8ICrJe/UGhGzmLMQYN2ZR vcWv25DEoQSqO/rY2FYBSaMfeZAsj4HM1iajfbAXHYj/z3gj9bb5tgxZPZPWIPnl/2Js oqFbJ33s8PyglO6X4xhmc5BtR7KZige/sWDOk+8X5AJDNMRBJR4VxroEjjVw2IcXayuH RDi+tamJ0rBf3VFaMIvhnu4CWFZIQfi5giZbcrUWC1FYsSMI7dQvtMkpj5Rp9mS+J1kw YuxrhucAt2ftWuC1oi41F2L650ZbaN0i51KxrRu6L68iXi54z+X9kBt2/KY4dV3utpIA X+oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717658434; x=1718263234; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MFC1pyOlym/b5PhJaLl2pSzHoJdyGjWFMkMHwggkOGg=; b=SNT89+hHy5s/Q+AgeipXGnIGICMkNVi2+uusYxzHD3/aJt+inp2FaSCe3h6w8mdA6G bnHx9124/FzNmM4zWG1BOj1QH7VHyefRdv9MRKyhpcxaSXIn5BRy3NXqPui8QzPCqTOt OmSpMpJ+hxuv69UcQ+sCTFk2q+MDR7F5LH1zU+WNIaWBO6R7p59h0GJ+yE7HXZk0aIxY TkZIYZ1FaGJGKoLegJzyKGI/DiWCXRjN+vYpkgDHkG91Je+l5wKVKBe+CepS0OFWfIEO NglphF1R2JYeEXPkmu8C2osihX09NRe20QDTNdQKd00jSkNw2/Zi3rvZv+nKO6hg3hJ0 7Gjg== X-Forwarded-Encrypted: i=1; AJvYcCVIwxisqkFDEtxPaVANH6a7ToynCgQZQYkJOk9PphWVwgqq1TMQ1ynpmHRlLsgkuXmlkflV7eH7elHHUWtEsre7v4mZyBrUGRhgG+h7 X-Gm-Message-State: AOJu0Yyu6uz0rBUGRAdsumdSbEtgiEI2UKmBg5wCCKnw4ytitg1Q741v icbTfrT21nmsNnMMrtwOE20XDS20x6Y8DcmqkSmehlalQeSEV4FcBIfVwd7Ed/49gFQo6NfWh3W p X-Received: by 2002:a05:6870:612c:b0:24f:ccbd:75e with SMTP id 586e51a60fabf-25122094c30mr5531086fac.43.1717658434284; Thu, 06 Jun 2024 00:20:34 -0700 (PDT) Received: from localhost ([122.172.82.13]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-703fd372a82sm557353b3a.27.2024.06.06.00.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 00:20:33 -0700 (PDT) Date: Thu, 6 Jun 2024 12:50:31 +0530 From: Viresh Kumar To: Ionela Voinescu Cc: "liwei (JK)" , Beata Michalska , Vanshidhar Konda , rafael@kernel.org, al.stone@linaro.org, ashwin.chaugule@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, liwei391@huawei.com, liaoyu15@huawei.com Subject: Re: [PATCH] cpufreq/cppc: changing highest_perf to nominal_perf in cppc_cpufreq_cpu_init() Message-ID: <20240606072031.lxr7tykl7sdgjwva@vireshk-i7> References: <20240428092852.1588188-1-liwei728@huawei.com> <20240429104945.esdukn6ayudgyumc@vireshk-i7> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 05-06-24, 15:26, Ionela Voinescu wrote: > > > > > cpufreq_start_governor() // governor: performance > > > > > new_freq = cpufreq_driver->get() // if new_freq == policy->max > > > > > if (policy->cur != new_freq) > > > > > cpufreq_out_of_sync(policy, new_freq) > > > > > ... > > > > > policy->cur = new_freq > > > I believe the problem is here ^^^^^^^^^^^^^^^^^^^^^^. > > > > > > cpufreq_verify_current_freq() should not update policy->cur unless a > > > request to change frequency has actually reached the driver. I believe > > > policy->cur should always reflect the request, not the actual current > > > frequency of the CPU. There are times when the core doesn't have any prior information about the frequency, for example at driver probe time and resume. And so needs to set policy->cur by reading it from the hardware. > > > Given that new_freq is the current (hardware) frequency of the CPU, > > > obtained via .get(), it can be the nominal frequency, as it is in your > > > case, or any frequency, if there is any firmware/hardware capping in > > > place. > > > > > > This causes the issue in your scenario, in which __cpufreq_driver_target() > > > filters the request from the governor as it finds it equal to policy->cur, > > > and it believes it's already set by hardware. I am still not sure why mismatch happens at boot time here. > > > This causes another issue in which scaling_cur_freq, which for some > > > systems returns policy->cur, ends up returning the hardware frequency of > > > the CPUs, and not the last frequency request, as it should: > > > > > > "scaling_cur_freq > > > Current frequency of all of the CPUs belonging to this policy (in kHz). > > > > > > In the majority of cases, this is the frequency of the last P-state > > > requested by the scaling driver from the hardware using the scaling > > > interface provided by it, which may or may not reflect the frequency > > > the CPU is actually running at (due to hardware design and other > > > limitations)." [1] There is discussion going on about this in another thread [1] now. > > > Therefore policy->cur gets polluted with the hardware frequency of the > > > CPU sampled at that one time, and this affects governor decisions, as > > > in your case, and scaling_cur_freq feedback as well. This bad value will > > > not change until there's another .target() or cpufreq_out_of_sync() > > > call, which will never happen for fixed frequency governors like the > > > performance governor. -- viresh [1] https://lore.kernel.org/all/20240603081331.3829278-2-beata.michalska@arm.com/