Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp703401lqp; Fri, 5 Apr 2024 06:34:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1j8DUETl4QdMSlvLqUyNF98tRYXozeHrQmsPsoJZBj1ChcyCnXu7/UNNmp6mGHEP6x6RChLKQQ5Gs62upqiU/zv3ZwnntAGlZV+5ciQ== X-Google-Smtp-Source: AGHT+IFjxsZ20QQVIM05UG/bHnf/uuN7L1jGvsq470BVMGPldTU/xwbYdStXaqwH/XN0L1eWVqnV X-Received: by 2002:a05:6870:a1a0:b0:22a:551c:3170 with SMTP id a32-20020a056870a1a000b0022a551c3170mr1620402oaf.23.1712324081135; Fri, 05 Apr 2024 06:34:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712324081; cv=pass; d=google.com; s=arc-20160816; b=Lc9dNV/3iXLr1pC5enZQ/FARG0EksJ2xvHcRS94g2fYF8lTVas0WKHIBeJNVhRLMR3 tsSt4a1PhpdKAeONh1Q2HS+aDFWy68fUGN4rDumYdS4N6W4Ghf5iwHbZ25EjHy6EcC2i tzoObDgXMBPDSpBK/n8B2exkEh+l4glTE4Cz+jUTxRuq2fjeRHcJBV/SLHnRcupg0lr2 y1uTH/Wc7WxACuJcA/vcxRWhAlhnQduIIPQoTLQTMu1/uT2TbyPDCgMSD3sUtB2Hr/NT E+7PzYaP9b4Y23NyB0Er0m8ScU4AY+Vb6DReMC/GhpIHt0hyI9Kj5/cNL3SETVy1hQ1K fuOw== 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=qJ8vSPeAbjmllIAMaYPZYrIlm5gVlM2EewYOBZaMyFw=; fh=cyDp+t11qGExQGVvcee9BaXo/5kV7bnnsUJA2sJhI3s=; b=DN8wF7FwLvUSG1civI43ymMaf608iKcM6RSvnN2+qzKbxOEfrVV50VluKF1XqhYZ4a CpxjE8fuXy4ibcej5W78WMc2/hLlgkkOWkTEkq6TeOb7JpxsOOAm9G/RgyKBDG5jE1y/ mcViJQXOB1klspgnQB/i/YXv5CFRefjGWCf9MNgMyMRRtfex8eCfdq2Lebr6vdKAhXEi Y2cG3dd1283vYI25r1bf+TkE022ktd7TtCev3orZ0v7S/uOz1WYDz3SeOIdBwZKgNsAi Zg4jUN3v8q2CNfXO+s8AGwMO2PRu6pX3Lyaqfn79v8IZ7msx9YGafNkg/4nEEFSFQ7Tt 8Gbw==; 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-133071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s19-20020a05622a019300b004318268cc1dsi1764618qtw.397.2024.04.05.06.34.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 06:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-133071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133071-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D53461C21DC0 for ; Fri, 5 Apr 2024 13:34:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 807EF16DECC; Fri, 5 Apr 2024 13:33:48 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB10216D9DD for ; Fri, 5 Apr 2024 13:33:46 +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=1712324028; cv=none; b=rJqScwRBm3moj+t5JNYfckQ25/i3mJc9awqabgovTiqgj1g8kXbhJf4QYxLXG3yJOTm/QE36JhILlnzM9q54l/+WcnTPB2xIml5jLVL0WHM1bRh62f269ENwWHqbv7EnXjmCjQfeBGnJEsA6C4UIO+cOmSP2uF7xgYgwt4N4Puk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712324028; c=relaxed/simple; bh=rbd3jknnd/pc9mbUuV7BSlIpgk6c+O5l7EkIsKegyLQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mG55DTb+MR/iN89h3b0R2KZX0COMZ5xZRQIoK99tiDJ+rJGzb7EWbW3mjKXCAYevJ/d2R/pZNhTrM0qW+0QbK0veiQPIcWB4YX0OWzcSUTqt5PAFLdIo/udvP3r4DxePlDFsZdX0jIF8j57kJJYTKDCevwRwAybFC0zqloaB7Eo= 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 BAAE916A3; Fri, 5 Apr 2024 06:34:16 -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 A65843F7B4; Fri, 5 Apr 2024 06:33:44 -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 Subject: [PATCH v4 4/4] cpufreq: Use arch specific feedback for cpuinfo_cur_freq Date: Fri, 5 Apr 2024 14:33:19 +0100 Message-Id: <20240405133319.859813-5-beata.michalska@arm.com> In-Reply-To: <20240405133319.859813-1-beata.michalska@arm.com> References: <20240405133319.859813-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 66e10a19d76a..603533b2608f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -795,8 +795,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