Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4731490pxj; Tue, 22 Jun 2021 06:53:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhUSib5nPdk6q/aB5CCRDy0MgBom8nox8rQGYeWSW1dsKmp1spYNJJHrOyi9pD3DkbMDd7 X-Received: by 2002:a05:6602:2d12:: with SMTP id c18mr3009234iow.170.1624370029901; Tue, 22 Jun 2021 06:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624370029; cv=none; d=google.com; s=arc-20160816; b=f6IEw/IEqviYpNM5UDITHt4rqQPwz1EtldNate1rnS2JR3pGPiBdxJuzhI0hmqgcKf zAtSm62Mkz5Dr7537shnoceCpV4H2xZxjrtIABNnyrVE++wT5VmwDsQ60imGNbR9H9nl qIiktlhoXMnUbkSLfV9g/ficB1nyq++LNTC1z4oBlAQTHS0YK32yjYZuW7JdR6rhAFmj Zctv7hjSU5PBNeQgnMhV4tVLYKratuuiZF6nFDTS9BghYGA3T25Vh15jXAVI+Ps80qND pNbgZSyY+MJ5TrNt7+LHodxlg1yXa+yqAkyUcIVeMC+vEJagkB9NRRfDMzTG1NxNEyMe MESQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=OE2Mk9QdTDme3m1WozqakgyokZ60Oww1ipgpJqvrp3c=; b=dVOc5IUTunNtyczjJVb2eSVG5GBwKZ29gHI8yJgZW2wNV25rCy6Gt9SwjG4D58EXI9 cRBA90bLGdPweQnvf15msHuT2VzX4NCcStZ9Us5F+N/UJVCiWhQEOcOHPMfRbV8/3hvD O4uA8Sq0zYUkovs2uHyRio659v/rUQ9hQzKPX/+Vvg6nFdCaOF42qch3BbMNEIfTk0ET m5dgpR5G9rbO8ueXPiMulZjrSDXpQZCeU4r6JoclWoYsbOmcnAxqJDdCdCqtDlvnNRzX a0J1/HXIbrnO5biKJ+L/K6eGoBmw/BwobUVMdqNLcW2ibbByGOTdZnnSsZR+v09ns4NP q+RQ== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si23787643iov.2.2021.06.22.06.53.37; Tue, 22 Jun 2021 06:53:49 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbhFVNy1 (ORCPT + 99 others); Tue, 22 Jun 2021 09:54:27 -0400 Received: from mail-ot1-f44.google.com ([209.85.210.44]:43876 "EHLO mail-ot1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbhFVNy0 (ORCPT ); Tue, 22 Jun 2021 09:54:26 -0400 Received: by mail-ot1-f44.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso21248164otu.10; Tue, 22 Jun 2021 06:52:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OE2Mk9QdTDme3m1WozqakgyokZ60Oww1ipgpJqvrp3c=; b=qwp14xglvFmTj+3RWJbaj2jXN3u8nPFSWUy6zGAQ6H+p83oNP2lzZZL4RTuRz1mCe6 yBHsUAtGwuT78D818xb5NSriHZh8zcKBzLQ97nComMJsU/qt4/NQwoIxV+6eKExbRCJK 4qguz9QHDEtONeh4xSSc0Iw690EZj6XQ57z1vOjhEJQMEijbZIoKbarPlTvIjZGNGAR9 +86H2JTjOHlv0ewhiRutARZNeT63LgBC6kJp7ca/4f8FLoITYy+uwg8jOmTgWksYLSRj ZrWU7nDSn74tH/gBJ15RbyKJmYLV3hWQexeV6r2GmLiMB37+QYJNZnr8ZR8cTMAmU1dU 5LDg== X-Gm-Message-State: AOAM532KDn9KFz8y70mNkAbjQ7gfKn031ffojvaBqBLqM91D0mtYhzSr 8dFbtb0btwEwPOsnyuhwfRwTPV6exJfaSaF9HYdSelvJ X-Received: by 2002:a9d:674b:: with SMTP id w11mr3220982otm.260.1624369929664; Tue, 22 Jun 2021 06:52:09 -0700 (PDT) MIME-Version: 1.0 References: <20210622075925.16189-1-lukasz.luba@arm.com> <20210622075925.16189-4-lukasz.luba@arm.com> <4e5476a6-fa9f-a9ef-ff26-8fa1b4bb90c0@arm.com> In-Reply-To: <4e5476a6-fa9f-a9ef-ff26-8fa1b4bb90c0@arm.com> From: "Rafael J. Wysocki" Date: Tue, 22 Jun 2021 15:51:58 +0200 Message-ID: Subject: Re: [RFC PATCH 3/4] cpufreq: Add Active Stats calls tracking frequency changes To: Lukasz Luba Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , Daniel Lezcano , Linux PM , Amit Kucheria , "Zhang, Rui" , Dietmar Eggemann , Chris Redpath , Beata.Michalska@arm.com, Viresh Kumar , "Rafael J. Wysocki" , Amit Kachhap Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 3:42 PM Lukasz Luba wrote: > > > > On 6/22/21 1:28 PM, Rafael J. Wysocki wrote: > > On Tue, Jun 22, 2021 at 9:59 AM Lukasz Luba wrote: > >> > >> The Active Stats framework tracks and accounts the activity of the CPU > >> for each performance level. It accounts the real residency, when the CPU > >> was not idle, at a given performance level. This patch adds needed calls > >> which provide the CPU frequency transition events to the Active Stats > >> framework. > >> > >> Signed-off-by: Lukasz Luba > >> --- > >> drivers/cpufreq/cpufreq.c | 5 +++++ > >> 1 file changed, 5 insertions(+) > >> > >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > >> index 802abc925b2a..d79cb9310572 100644 > >> --- a/drivers/cpufreq/cpufreq.c > >> +++ b/drivers/cpufreq/cpufreq.c > >> @@ -14,6 +14,7 @@ > >> > >> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > >> > >> +#include > >> #include > >> #include > >> #include > >> @@ -387,6 +388,8 @@ static void cpufreq_notify_transition(struct cpufreq_policy *policy, > >> > >> cpufreq_stats_record_transition(policy, freqs->new); > >> policy->cur = freqs->new; > >> + > >> + active_stats_cpu_freq_change(policy->cpu, freqs->new); > >> } > >> } > >> > >> @@ -2085,6 +2088,8 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, > >> policy->cpuinfo.max_freq); > >> cpufreq_stats_record_transition(policy, freq); > >> > >> + active_stats_cpu_freq_fast_change(policy->cpu, freq); > >> + > > > > This is quite a bit of overhead and so why is it needed in addition to > > the code below? > > The code below is tracing, which is good for post-processing. We use in > our tool LISA, when we analyze the EAS decision, based on captured > trace data. > > This new code is present at run time, so subsystems like our thermal > governor IPA can use it and get better estimation about CPU used power > for any arbitrary period, e.g. 50ms, 100ms, 300ms, ... So can it be made not run when the IPA is not using it? > > > > And pretty much the same goes for the idle loop change. There is > > quite a bit of instrumentation in that code already and it avoids > > adding new locking for a reason. Why is it a good idea to add more > > locking to that code? > > This active_stats_cpu_freq_fast_change() doesn't use the locking, it > relies on schedutil lock in [1]. Ah, OK. But it still adds overhead AFAICS. > > > >> if (trace_cpu_frequency_enabled()) { > >> for_each_cpu(cpu, policy->cpus) > >> trace_cpu_frequency(freq, cpu); > >> -- > > > [1] > https://elixir.bootlin.com/linux/latest/source/kernel/sched/cpufreq_schedutil.c#L447