Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4484797pxj; Tue, 22 Jun 2021 01:01:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdRpbxj5fJX/Cm2fSQCRpHvAV24nJV13xEXKfQtAOv/U8QqoPckHaJZRrnUy+O026yN6h5 X-Received: by 2002:a05:6402:748:: with SMTP id p8mr3178437edy.91.1624348871644; Tue, 22 Jun 2021 01:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624348871; cv=none; d=google.com; s=arc-20160816; b=dk42ooiEntQo2ksyffOaIUL2FAZufqpSpwUJ1wW6Kh1JuwZVtXw8PS7lenVcm/IOMQ BO/P/6zLJ3Rn3kJJ37qztg7WYQaPHXsBDXUxqChFd1H4DYf0CZs5b5XqKZxVnFYzxD1Z vcB+wJ5Inhtk5kkm1A+2AyQ8z+hUm+WE9wExFdVCkXI4e8k0ujAiAcEdwFSzq1r3bclO PJ/QSdZrY9I/5Yj5H8icHQsdioGeVwktvjk4Sdvu8SZ5s570xFht6jkt8kLjM8mMLFOW IUkpZZHcyGIQC2WImdbGnhCqZE+YuOLqmXs8bna/mwBnuqjNcd+zFtYdJH4CSQLThC3z /Hzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=nnEjsf36S7hHOilinKkcN7bVTt7QfRFBY408mjN0pDE=; b=CpLhY+y62E+M14HN7WAcVuGXhFVmwHaL9aXCMIQePza+2zr0sYhahD1qCqhOJYQqKE dI8R1DAM8rO/bm1Xne/bQRc0lHK7oMVJfGV9e9K5NC6RH7TSw2cZJrzeT+057kztfAHx Zbajtx2VHcH2Wv0huDubdNUdlQqYfCkWDk94kIc5gaqgzk6RbcXNI1HS3UI4SqkO6Oe0 38DNBuJUJmUgzbwRGQdxWiX2/0eQ//gZ3I9sLvps3KE/S7HAWE79AOiIS8HCO819nDr/ lxeBGu4N4d4D+n0PNWtJB6xCAqNzqunusfYbCG0rLk5m7XnvC0DrKxTliARO0JuilqvT zq8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 23si13892380ejg.480.2021.06.22.01.00.48; Tue, 22 Jun 2021 01:01:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbhFVIB4 (ORCPT + 99 others); Tue, 22 Jun 2021 04:01:56 -0400 Received: from foss.arm.com ([217.140.110.172]:44076 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbhFVIBy (ORCPT ); Tue, 22 Jun 2021 04:01:54 -0400 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 83B0CD6E; Tue, 22 Jun 2021 00:59:36 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.9.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 55A323F718; Tue, 22 Jun 2021 00:59:34 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, amitk@kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com, dietmar.eggemann@arm.com, Chris.Redpath@arm.com, Beata.Michalska@arm.com, viresh.kumar@linaro.org, rjw@rjwysocki.net, amit.kachhap@gmail.com Subject: [RFC PATCH 0/4] Introduce Active Stats framework with CPU performance statistics Date: Tue, 22 Jun 2021 08:59:21 +0100 Message-Id: <20210622075925.16189-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, This patch set introduces a new mechanism: Active Stats framework (ASF), which gathers and maintains statistics of CPU performance - time residency at each performance state. The ASF tracks all the frequency transitions as well as CPU idle entry/exit events for all CPUs. Based on that it accounts the active (non-idle) residency time for each CPU at each frequency. This information can be used by some other subsystems (like thermal governor) to enhance their estimations about CPU usage at a given period. Does it fix something in mainline? Yes, there is thermal governor Intelligent Power Allocation (IPA), which estimates the CPUs power used in the past. IPA is sampling the CPU utilization and frequency and relies on the info available at the time of sampling and this imposes the estimation errors. The use of ASF solve the issue and enables IPA to make better estimates. Why it couldn't be done using existing frameworks? The CPUFreq and CPUIdle statistics are not combined, so it is not possible to derive the information on how long exactly the CPU was running with a given frequency. This new framework combines that information and provides it in a handy way. IMHO it has to be implemented as a new framework, next to CPUFreq and CPUIdle, due to a clean design and not just hooks from thermal governor into the frequency change and idle code paths. The patch set contains also a patch 4/4 which adds the new power model based on ASF into the cpufreq cooling (used by thermal governor IPA). It is added as ifdef option, since Active Stats might be not compiled in. The ASF is a compile time option, but that might be changed and IPA could select it, which would allow to remove some redundant code from cpufreq_cooling.c. Comments and suggestions are very welcome. Regards, Lukasz Luba Lukasz Luba (4): PM: Introduce Active Stats framework cpuidle: Add Active Stats calls tracking idle entry/exit cpufreq: Add Active Stats calls tracking frequency changes thermal: cpufreq_cooling: Improve power estimation based on Active Stats framework Documentation/power/active_stats.rst | 128 +++++ Documentation/power/index.rst | 1 + MAINTAINERS | 8 + drivers/cpufreq/cpufreq.c | 5 + drivers/cpuidle/cpuidle.c | 5 + drivers/thermal/cpufreq_cooling.c | 120 ++++- include/linux/active_stats.h | 119 +++++ kernel/power/Kconfig | 9 + kernel/power/Makefile | 1 + kernel/power/active_stats.c | 751 +++++++++++++++++++++++++++ 10 files changed, 1146 insertions(+), 1 deletion(-) create mode 100644 Documentation/power/active_stats.rst create mode 100644 include/linux/active_stats.h create mode 100644 kernel/power/active_stats.c -- 2.17.1