From: Huang Rui <ray.huang@amd.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: "Borislav Petkov" <bp@suse.de>,
"Peter Zijlstra" <peterz@infradead.org>,
"Andy Lutomirski" <luto@amacapital.net>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Robert Richter" <rric@kernel.org>,
"Jacob Shin" <jacob.w.shin@gmail.com>,
"John Stultz" <john.stultz@linaro.org>,
"Fr�d�ric Weisbecker" <fweisbec@gmail.com>,
linux-kernel@vger.kernel.org, spg_linux_kernel@amd.com,
x86@kernel.org, "Guenter Roeck" <linux@roeck-us.net>,
"Andreas Herrmann" <herrmann.der.user@googlemail.com>,
"Suravee Suthikulpanit" <suravee.suthikulpanit@amd.com>,
"Aravind Gopalakrishnan" <Aravind.Gopalakrishnan@amd.com>,
"Borislav Petkov" <bp@alien8.de>,
"Fengguang Wu" <fengguang.wu@intel.com>,
"Aaron Lu" <aaron.lu@intel.com>
Subject: Re: [PATCH v3] perf/x86/amd/power: Add AMD accumulated power reporting mechanism
Date: Tue, 26 Jan 2016 21:47:09 +0800 [thread overview]
Message-ID: <20160126134708.GE23394@hr-amur2> (raw)
In-Reply-To: <20160126082823.GA8729@gmail.com>
On Tue, Jan 26, 2016 at 09:28:23AM +0100, Ingo Molnar wrote:
>
> * Huang Rui <ray.huang@amd.com> wrote:
>
> > +/*
> > + * Acc power status counters
> > + */
> > +#define AMD_POWER_PKG_ID 0
> > +#define AMD_POWER_EVENTSEL_PKG 1
>
> > +/*
> > + * the ratio of compute unit power accumulator sample period to the
> > + * PTSC period
> > + */
>
> > +/*
> > + * Accumulated power is to measure the sum of each compute unit's
> > + * power consumption. So it picks only one core from each compute unit
> > + * to get the power with MSR_F15H_CU_PWR_ACCUMULATOR. The cpu_mask
> > + * represents CPU bit map of all cores which are picked to measure the
> > + * power for the compute units that they belong to.
> > + */
> > +static cpumask_t cpu_mask;
>
> > + /*
> > + * calculate the power comsumption for each compute unit over
> > + * a time period, the unit of final value (delta) is
> > + * micro-Watts. Then add it into event count.
> > + */
>
> Please capitalize sentences consistently - half of the comments you added start
> lower-case.
>
Some of lower-case starting cases are not complete sentences such as:
/*
* the ratio of compute unit power accumulator sample period to the
* PTSC period
*/
/* maximum accumulated power of a compute unit */
So can I check again and capitalize comment if it is complete
sentence?
>
> > + if (cfg == AMD_POWER_EVENTSEL_PKG)
> > + bit = AMD_POWER_PKG_ID;
> > + else
> > + return -EINVAL;
> > +
> > + event->hw.event_base = MSR_F15H_CU_PWR_ACCUMULATOR;
> > + event->hw.config = cfg;
> > + event->hw.idx = bit;
> > +
> > + return ret;
>
> so this control flow looks pretty weird. Why not:
>
> > + if (cfg != AMD_POWER_EVENTSEL_PKG)
> > + return -EINVAL;
> > +
> > + event->hw.event_base = MSR_F15H_CU_PWR_ACCUMULATOR;
> > + event->hw.config = cfg;
> > + event->hw.idx = AMD_POWER_PKG_ID;
> > +
> > + return ret;
>
> ?
>
Looks better.
> > +static int power_cpu_init(int cpu)
> > +{
> > + struct power_pmu *pmu = per_cpu(amd_power_pmu, cpu);
> > +
> > + if (pmu)
> > + return 0;
> > +
> > + if (!cpumask_and(pmu->mask, topology_sibling_cpumask(cpu),
> > + &cpu_mask))
> > + cpumask_set_cpu(cpu, &cpu_mask);
> > +
> > + return 0;
> > +}
>
> Hm, has this function ever been runtime tested? This function either does nothing
> (contrary to the clear intention of twiddling the cpu_mask), or crashes on a NULL
> pointer.
>
> ( Also, the code has an annoying line-break. Don't pacify checkpatch by making the
> code harder to read. )
>
OK, that should be "if (!pmu)", thanks to check so carefully. I tested
to make the core offline and check the event context migration with
power_cpu_exit, but might miss this scenario. I will do more testing
on runtime case. Will fix it on next version.
Thanks,
Rui
prev parent reply other threads:[~2016-01-26 13:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-25 8:32 Huang Rui
2016-01-25 11:13 ` Peter Zijlstra
2016-01-25 15:43 ` Huang Rui
2016-01-26 8:28 ` Ingo Molnar
2016-01-26 13:47 ` Huang Rui [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=20160126134708.GE23394@hr-amur2 \
--to=ray.huang@amd.com \
--cc=Aravind.Gopalakrishnan@amd.com \
--cc=aaron.lu@intel.com \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=fengguang.wu@intel.com \
--cc=fweisbec@gmail.com \
--cc=herrmann.der.user@googlemail.com \
--cc=jacob.w.shin@gmail.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rric@kernel.org \
--cc=spg_linux_kernel@amd.com \
--cc=suravee.suthikulpanit@amd.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
all inboxes | Powered by JetHome®