Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp496888lqb; Wed, 17 Apr 2024 02:41:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQsnUrVCutFEN1vhIVJpUWrhXVWk8Mb+YfWnAgmRL6e3ogxkjzvDejrOAYwFUvAqVAgledJshj6H1QxTWP4uIwNjP1o8vvjqrCMyQocA== X-Google-Smtp-Source: AGHT+IFQg+kLLJSzyN7UTaKBi9q+OPqcRgzLsMzb+x4KxDppRujm2RGa/T9spELyjhAVfT4BXdL/ X-Received: by 2002:a17:906:134a:b0:a52:195:7090 with SMTP id x10-20020a170906134a00b00a5201957090mr9352309ejb.41.1713346862623; Wed, 17 Apr 2024 02:41:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713346862; cv=pass; d=google.com; s=arc-20160816; b=YrLvnVFofeMgE9NYwJaD+UwPGCZSV/YjtQaD9jKFRZ55mdULrkpMnDWF/K113hTMK/ /2OsVjXLzbsjY1zsOHQVsxWJIubVaWLUFqEoTYUF5skuZh1aQUj4i9QTEAIDEayxY7Ry Ld4lnYS/Fd9F3vJVuenWd/fsuxkxUZZnda36iTR2HMpMRbk2CdXi9g6snQV2bllmM/vE X8o+PJIu40SyQd/AcDjuG6oPLbdP51wEGoXd2UMTq1Xxv2x3qpzBo+kOF2J+akONcnSZ 8M1HqotId3Sv/gJnvP+TRVCaC3cD5mG236O4NrcsBLIwnRcGnuTmEnP6+Ct2yc5xT2P9 YiIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=LyWxrLjiaZ4vTN8siKsD7sQ1mM81a2oN66oz02K7Ir0=; fh=Q/fJBPnBnMinsWaL+/VHtwI3DR4foDV1ujXNM08oUFo=; b=Y/5pqFGNY0ON+DrJHaA0HjmF7oHqsmnj4AYeulodZLLOf9JCR4aQOc7Lrltlg+RE2a aqhZvgNC0ajQ8tnl5IhLtmdaPLVOXQtnpKlAyPKXzefQdT2Za+F5/qSKyEvm6YChkP3m ftlrjY7LTSQ1zHsN9e2LoA7oWhmpJEijOf6AKJykeEiOIyuWt9Mkt0Ou5YSH2e3BDv9c ZB1M2lWt33AcaxE3ttwskuvgA7GcUiaeviN0uyYKd5ad7rFdA+fbpbuRYWOHS/03u4XP 51MQVxP8EiumoR5oRS3y4HER1YoljYVeh7kett2fETGh/gSIIt79I/98AydVyl2CH7bF CskQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-148262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kf9-20020a17090776c900b00a4e9a14552asi6712712ejc.674.2024.04.17.02.41.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:41:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-148262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 589531F22891 for ; Wed, 17 Apr 2024 09:41:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B59C13C690; Wed, 17 Apr 2024 09:39:12 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DABB313C3FF for ; Wed, 17 Apr 2024 09:39:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346752; cv=none; b=Y5UqMilRpob1xrk6HvXjM+OAc7C9LvpTsrHKH5GoDcyF/jK2HPkGfyvOacC60bQ/hO0uk2pMuVXVyagLuwD62KtLg6yovBUfAMlnx0CPpC35/2MLcbhvXYXWcobfRRaawbdjrP48A+2Y6cMbTHo61y5RMwxeWKCU5OrHZjwvlDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346752; c=relaxed/simple; bh=zVISUDfH5Und8B2M0/FRkHymAWK9FfVIOHuACS05Y0w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iKCPXaLFTySGi5FPQ91TMSEw7Ual9ur04VY5+7+UaUKpauy++qmo1zMouDDyK6GgcQIKw5tW+lKBR2TZ5DVilNso9wQtK2IkZG6Q56cexAVdZpVw2SvJhO/kbTuovY/oPOIzXavapLs/sbyhH0Qy/O1YCJdfWkf3qVuABnRgi0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 6D3A21477; Wed, 17 Apr 2024 02:39:38 -0700 (PDT) Received: from e125905.cambridge.arm.com (e125905.cambridge.arm.com [10.1.194.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B5D333F64C; Wed, 17 Apr 2024 02:39:08 -0700 (PDT) From: Beata Michalska To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ionela.voinescu@arm.com, vanshikonda@os.amperecomputing.com Cc: sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, vincent.guittot@linaro.org, sumitg@nvidia.com, yang@os.amperecomputing.com, lihuisong@huawei.com, viresh.kumar@linaro.org Subject: [PATCH v5 5/5] cpufreq: Use arch specific feedback for cpuinfo_cur_freq Date: Wed, 17 Apr 2024 10:38:48 +0100 Message-Id: <20240417093848.1555462-6-beata.michalska@arm.com> In-Reply-To: <20240417093848.1555462-1-beata.michalska@arm.com> References: <20240417093848.1555462-1-beata.michalska@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some architectures provide a way to determine an average frequency over a certain period of time based on available performance monitors (AMU on ARM or APERF/MPERf on x86). With those at hand, enroll arch_freq_get_on_cpu into cpuinfo_cur_freq policy sysfs attribute handler, which is expected to represent the current frequency of a given CPU,as obtained by the hardware. This is the type of feedback that counters do provide. Signed-off-by: Beata Michalska --- drivers/cpufreq/cpufreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index f6f8d7f450e7..89118406ec68 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -793,8 +793,10 @@ store_one(scaling_max_freq, max); static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy, char *buf) { - unsigned int cur_freq = __cpufreq_get(policy); + unsigned int cur_freq = arch_freq_get_on_cpu(policy->cpu); + if (!cur_freq) + cur_freq = __cpufreq_get(policy); if (cur_freq) return sprintf(buf, "%u\n", cur_freq); -- 2.25.1