From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>, Zhang Rui <rui.zhang@intel.com>
Cc: linux-x86 <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
mingo@redhat.com, acme@kernel.org,
alexander.shishkin@linux.intel.com, jolsa@redhat.com,
namhyung@kernel.org, tglx@linutronix.de, "Liang,
Kan" <kan.liang@intel.com>
Subject: Re: [PATCH] perf/rapl: restart perf rapl counter after resume
Date: Thu, 20 Jun 2019 10:33:48 -0400 [thread overview]
Message-ID: <d663757d-8395-bab8-cde3-e6b1ecab0cda@linux.intel.com> (raw)
In-Reply-To: <20190620125059.GZ3436@hirez.programming.kicks-ass.net>
On 6/20/2019 8:50 AM, Peter Zijlstra wrote:
> On Mon, Jun 17, 2019 at 09:41:37PM +0800, Zhang Rui wrote:
>
>> After S3 suspend/resume, "perf stat -I 1000 -e power/energy-pkg/ -a"
>> reports an insane value for the very first sampling period after resume
>> as shown below.
>>
>> 19.278989977 2.16 Joules power/energy-pkg/
>> 20.279373569 1.96 Joules power/energy-pkg/
>> 21.279765481 2.09 Joules power/energy-pkg/
>> 22.280305420 2.10 Joules power/energy-pkg/
>> 25.504782277 4,294,966,686.01 Joules power/energy-pkg/
>> 26.505114993 3.58 Joules power/energy-pkg/
>> 27.505471758 1.66 Joules power/energy-pkg/
>>
>> Fix this by resetting the counter right after resume.
>
> Cute...
>
>
>> +#ifdef CONFIG_PM
>> +
>> +static int perf_rapl_suspend(void)
>> +{
>> + int i;
>> +
>> + get_online_cpus();
>> + for (i = 0; i < rapl_pmus->maxpkg; i++)
>> + rapl_pmu_update_all(rapl_pmus->pmus[i]);
>> + put_online_cpus();
>> + return 0;
>> +}
>> +
>> +static void perf_rapl_resume(void)
>> +{
>> + int i;
>> +
>> + get_online_cpus();
>> + for (i = 0; i < rapl_pmus->maxpkg; i++)
>> + rapl_pmu_restart_all(rapl_pmus->pmus[i]);
>> + put_online_cpus();
>> +}
>
> What's the reason for that get/put_online_cpus() here ?
>
It looks like syscore_* functions are executed with one CPU on-line.
If so, they may not be the right place for the rapl callback.
Rapl is per socket. The driver manipulates the registers on the first
CPU of each socket. I think we need to update/restart the counters on
all sockets. That's the reason I add get/put_online_cpus() in the
original patch.
Besides, I think we also need to call rapl_pmu_restart/update_all() on
the target cpu.
Thanks,
Kan
prev parent reply other threads:[~2019-06-20 14:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 13:41 [PATCH] perf/rapl: restart perf rapl counter after resume Zhang Rui
2019-06-20 12:50 ` Peter Zijlstra
2019-06-20 14:33 ` Liang, Kan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d663757d-8395-bab8-cde3-e6b1ecab0cda@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rui.zhang@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox